Search code examples
androidandroid-mediaplayerh.264rtsp

IP camera rtsp stream to Android fails


So I've got an RTSP stream I am trying to setup between a D-Link936L and a Samsung Galaxy Tab S. I have verified codecs (a/v) match and are compatible. I have verified ip camera connects to my desktop using VLC.

What I have done, that I have not seen others do is take a deeper look into the network packets for RTSP that are being shared between the tablet and the camera. I ended up finding something interesting.

Note: I am also receiving the error:

D/MediaPlayer: setDataSource IOException | SecurityException happend : 
                                                                            java.io.FileNotFoundException: No content provider: rtsp://

as well as the 0x8000000000 (or however many 0's) error somthing like

error (1, -2147483648)

which I am chalking up to a poorly handled timeout/miscommunication error.

How did I come to this conclusion? I recorded with wireshark a good connection (tablet running RTSP Player from google play store to ip camera EDIT) and a bad connection (tablet to ip camera). Below you can see what I found.

Good connection:

Good connection

And a bad connection:

Bad connection

You'll notice in the good connection there is a command followed by an ACK. However you'll also notice in the bad connection it takes about 2.2 seconds to receive the ACK for the DESCRIBE packet. This causes the android side to send a TEARDOWN, where shortly after that is sent a DESCRIBE_ACK is received. So, trying to be smart, the android device sends a SETUP...but its no match for the TEARDOWN_ACK it receives shortly act it receives shortly after.

Finally: So my question is what the heck(?!?!?!?!) is causing this 2 second delay...oh and I need to figure this out by 12/8/17....oh boy...

EDIT: One thing I forgot to mention, it works with rtsp://184.72.239.149/vod/mp4:BigBuckBunny_175k.mov but not with my IP camera.

Something I did just notice though is that when I run the software i was using to packet capture on the android device, the link above fails with the Error (1, -214#####) code as well.


Solution

  • I will answer this in case someone else comes across this.

    I was never able to find the root cause, as my development was rapid and I had no time for debugging issues.

    My first solution was to use the VXG api, but this only allowed me 3 streams per application run, 2 min cap on stream length, and a watermark on each video...GROSS!

    My second and final solution was to use the VLC api, which was a little quirky, but I was able to set it up in a work day and get it working for more than 3 streams, unlimited time, and no watermark...AWESOME!

    My suggestion is use the VLC api. My only issues with it were it was only able to work in a surface view, so that gave me some issues and that it seemed to use TCP because it was more latent than the VXG api (but i did not wireshark to check what communication was being used). So essentially be prepared for less than real-time video, maybe a 0.5-1 second of latency is what I experienced on a private WLAN.