开发者

Android Camera RTSP/RTP Stream?

开发者 https://www.devze.com 2023-03-05 12:23 出处:网络
How can I send Android camera video using RTP/RTSP and play it in PC(using vlc or any other player). I googled this and found two answers:

How can I send Android camera video using RTP/RTSP and play it in PC(using vlc or any other player).

I googled this and found two answers:

1) using mediarecorder (http://sipdroid.org/ using VideoCamera.java)

How to work with it i tried it but no result :(

2) using PreviewCallback() - onPreviewFrame(data, camera) method.

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.

But I am not able to play my packets in VLC :(

This is my 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开发者_如何学Go{                          
            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!!!

I am totally confused:( I am new to android development!! need help from experts!!!!


I think you might need to decode the stream via decodeYUV420SP since the byte[] data is in YUV format.

0

精彩评论

暂无评论...
验证码 换一张
取 消