您的位置:首页 > 理论基础 > 计算机网络

安卓与PC网络对接实现视频实时播放

2013-07-27 21:11 405 查看
研究安卓网络通信一段时间了, 由于最近公司催的比较紧, 硬着头皮弄出来了.
现在手机客户端终于能够连接流媒体服务器实时播放前端的视频流了.
其实通信方面主要还是命令包的解析, 以及分包组包.
比如要把以下的结构赋值, 就要进行以下函数的转化.
/*
*
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;
}




内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: