Android摄像头RTSP / RTP流? [英] Android Camera RTSP/RTP Stream?
问题描述
我如何发送使用RTP / RTSP Android摄像头的视频并播放它在PC(使用VLC或任何其他球员)。
How can I send Android camera video using RTP/RTSP and play it in PC(using vlc or any other player).
我GOOGLE了这一点,并发现了两个答案:
I googled this and found two answers:
1)使用mediarecorder( http://sipdroid.org/ 使用VideoCamera.java)
1) using mediarecorder (http://sipdroid.org/ using VideoCamera.java)
如何使用它,我尝试过,但工作没有结果:(
How to work with it i tried it but no result :(
2)使用previewCallback() - 在previewFrame(数据,摄像头)方法
2) using PreviewCallback() - onPreviewFrame(data, camera) method.
使用sipdroid的(Rtppacket,Rtpsocket,sipdroidsocket)我能够发送包含RTP包每帧数据,我能够通过Wireshark来抓住它。
by using sipdroid's (Rtppacket,Rtpsocket,sipdroidsocket) I am able to send Rtp Packets containing each frame as data and I am able to catch it via Wireshark.
但我不能够在VLC播放我的包:(
But I am not able to play my packets in VLC :(
这是我的code:
mCamera.setPreviewCallback(new PreviewCallback() {
public void onPreviewFrame(byte[] data, Camera camera) {
int width= 320;
int height=240;
eth=getInterfaces();
Log.v("Connected to ","Ethernet"+eth);
if(eth!=null){
try{
InetAddress serverAddr = InetAddress.getByName("IP Address of My PC");
Log.v("trying to ","connect with"+serverAddr);
SipdroidSocket soc = new SipdroidSocket(9954);
Log.v("trying to ","connect with Sipdroid Socket");
soc.connect(serverAddr, 9954);
Log.v("Socket ","Connected");
RtpPacket rtpp=new RtpPacket(data,height);
//rtpp.setPayloadType(125);
Log.v("RTPPacket","Created");
RtpSocket rtps= new RtpSocket(soc,serverAddr,9954);
Log.v("RTPSocket","Created");
rtps.send(rtpp);
Log.v("Packet","Sent");
}
catch(Exception e){e.printStackTrace();Log.v(TAG, "Socket");}
}
}
});
我怎么能玩包?请给一些建议!
How can I play the packets? Please give some suggestions!!!
我完全糊涂了:(我是新android开发!!需要专家的帮助!
I am totally confused:( I am new to android development!! need help from experts!!!!
推荐答案
我想你可能需要去$ C C通过去codeYUV420SP流$以来的byte []的数据为YUV格式。
I think you might need to decode the stream via decodeYUV420SP since the byte[] data is in YUV format.
这篇关于Android摄像头RTSP / RTP流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!