zoukankan      html  css  js  c++  java
  • 安卓与PC网络对接实现视频实时播放

    研究安卓网络通信一段时间了,  由于最近公司催的比较紧, 硬着头皮弄出来了.

    现在手机客户端终于能够连接流媒体服务器实时播放前端的视频流了.

    其实通信方面主要还是命令包的解析, 以及分包组包.

    比如要把以下的结构赋值, 就要进行以下函数的转化.

          /*
         *  

        TNetPackHead = record
          Flag: DWORD;  //0,1,2,3
          Level: TLevel;  //4,5,6,7
          cmd: Word;    //1633 8,9
          Size: Word;   // 10,11
          byChannel:   Byte;
          sServer: array[0..15] of char;
          sHost: array[0..15] of char;
          sMemo: array[0..15] of char;
          byStreamType: Byte;
        end;
         * */

        public byte[] OpenDvrInfo(String DvrIp,int iCmd, int ichan, int istream)
        {
        byte[] b = new byte[100];       
        byte[] temp;
        //分别将struct的成员格式为byte数组。       
        temp = toLH(1);
        System.arraycopy(temp, 0, b, 0, temp.length);
        temp = toLH(0);
        System.arraycopy(temp, 0, b, 4, temp.length);    
        temp = toLH2(iCmd);
        System.arraycopy(temp, 0, b, 6, temp.length); 
        temp = toLH2(10);
        System.arraycopy(temp, 0, b, 8, temp.length);
       
        b[12] = (byte)ichan;
        temp = DvrIp.getBytes();
        System.arraycopy(temp, 0, b, 13, DvrIp.length());
        System.arraycopy(temp, 0, b, 29, DvrIp.length());
        System.arraycopy(temp, 0, b, 45, DvrIp.length());
        b[61] = (byte)istream;
      
        return b;       
        }

  • 相关阅读:
    小程序支付
    小程序传参
    git
    学习过程遇到问题的解决方法
    进程创建注意事项:函数及对应包
    进程创建:函数及对应包
    mac解决eclipse 端口占用问题
    暴力
    doc2vec
    Java正则表达式的解释说明
  • 原文地址:https://www.cnblogs.com/doorsky/p/3218043.html
Copyright © 2011-2022 走看看