安卓与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;
}
现在手机客户端终于能够连接流媒体服务器实时播放前端的视频流了.
其实通信方面主要还是命令包的解析, 以及分包组包.
比如要把以下的结构赋值, 就要进行以下函数的转化.
/*
*
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;
}
相关文章推荐
- 安卓与PC网络对接实现视频实时播放
- 如何实现兼容 PC 和微信 H5 的全屏播放小视频
- QT5+opencv3.1实现视频播放加实时直方图
- 安卓使用MediaPlayer实现播放内存卡内的视频
- Android实现网络视频播放
- 海康IPC+NVR+EasyDarwin+EasyPusher+VLC实现Web实时播放RTSP视频
- ADSL拨号网络环境下实时视频广播的完美实现
- 海康IPC+NVR+EasyDarwin+EasyPusher+VLC实现Web实时播放RTSP视频
- android WebView实现播放网络视频以及全屏显示
- GStreamer实现视频本地播放并RTP上传到网络VLC播放
- 安卓实现实时视频传输
- Android ExoPlayer实现网络URL、本地视频播放
- [教程]手机通过网络(网上邻居)播放PC共享视频的方法
- 安卓视频播放器 一行代码快速实现在线视频播放,Android视频播放,AndroidMP3播放,安卓视频播放一行代码搞定
- Android提高之MediaPlayer播放网络视频的实现方法
- WebRTC 整理 (安卓IOS微信端实现实时视频通话)
- 很酷,酷播wordpress视频插件(支持PC/安卓/苹果跨平台播放)
- 安卓实现播放本地是视频
- Android之MediaPlayer播放网络视频的实现方法
- 视频播放网站CDN内容分发网络简单代码实现