安卓与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;       
    }


<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值