MediaPlayer and RTSP server on localhost

1,630 views
Skip to first unread message

inon

unread,
May 15, 2011, 11:52:48 AM5/15/11
to android-platform
Hi,
I am working on an application that streams video between android
devices using SIP/RTP.
since android's media player does not support RTP streams directly I
have come up with a solution
to run an RTSP server on the client and wrap the RTP stream with RTSP
stream, then set the media player's data source to
that RTSP server (i.e, rtsp://localhost:5544/video.3gpp).

The problem:
when the RTSP server runs on a different device than the media
player's device, everything works great, BUT
if the RTSP server runs on the same device (localhost) than after
media player do RTSP OPTIONS and DESCRIBE it fails.
that is, after DESCRIBE response (the same response that is returned
when it works on 2 devices) I get the following
error in logcat:

05-15 15:44:26.374: WARN/MediaPlayer(4243): info/warning (1, 26)
05-15 15:44:26.374: INFO/MediaPlayer(4243): Info (1,26)
05-15 15:44:26.374: ERROR/PlayerDriver(121): Command PLAYER_INIT
completed with an error or info PVMFFailure
05-15 15:44:26.374: ERROR/MediaPlayer(4243): error (1, -1)
05-15 15:44:26.384: ERROR/MediaPlayer(4243): Error (1,-1)
05-15 15:44:26.384: DEBUG/VideoView(4243): Error: 1,-1


I am really clueless on how to solve this one, so any help would be
great
Thanks

Paul Gardner-Stephen

unread,
May 17, 2011, 5:32:58 PM5/17/11
to android-platform
Hello,

On May 16, 12:52 am, inon <ini2...@gmail.com> wrote:
> Hi,
> I am working on an application that streams video between android
> devices using SIP/RTP.
> since android's media player does not support RTP streams directly I
> have come up with a solution
> to run an RTSP server on the client and wrap the RTP stream with RTSP
> stream, then set the media player's data source to
> that RTSP server (i.e, rtsp://localhost:5544/video.3gpp).

This is interesting. Are you streaming video from the camera to a
3gpp file, that you are then streaming via SIP/RTP?
If so, is this on a dual-camera device, or are you using the primary
camera.
If so, how are you dealing with the failure of most primary camera
hardware on Android to deliver a streamable video stream?

Indeed, it is possible that this is the source of the problem, if you
have the camera capture to SDcard, say, and then try to play that
stream live, it simply will not work on devices using the Qualcomm msm
chipset (most phones I have seen), because the 3gp file will be
missing the header (first 24 bytes all zero), and then the MDAT box
follows, but without the trak info boxes, which don't get written
until the stream is closed.

You can verify if this is the problem by streaming a pre-recorded 3gpp
file, instead of streaming one while it is still recording. If that
works, then you have probably hit this problem.

It is possible to re-container the MDAT box containing the raw H.263
stream in a friendlier format (AVI is probably the best if you can
play it on the phone), but if you are running at <29.97fps (H.263
native frame rate) you will have trouble because the trak info boxes
are needed to give the frame presentation times.

We currently have a hack solution for this, using a patched ffmpeg to
re-container the raw H.263 video, which is far from ideal.
We are also looking at better solutions, such as inserting dummy
frames to get the frame rate back to 29.97fps to solve the re-timing
problem and get rid of the need for ffmpeg.

> The problem:
> when the RTSP server runs on a different device than the media
> player's device, everything works great, BUT
> if the RTSP server runs on the same device (localhost) than after
> media player do RTSP OPTIONS and DESCRIBE it fails.
> that is, after DESCRIBE response (the same response that is returned
> when it works on 2 devices) I get the following
> error in logcat:
>
> 05-15 15:44:26.374: WARN/MediaPlayer(4243): info/warning (1, 26)
> 05-15 15:44:26.374: INFO/MediaPlayer(4243): Info (1,26)
> 05-15 15:44:26.374: ERROR/PlayerDriver(121): Command PLAYER_INIT
> completed with an error or info PVMFFailure
> 05-15 15:44:26.374: ERROR/MediaPlayer(4243): error (1, -1)
> 05-15 15:44:26.384: ERROR/MediaPlayer(4243): Error (1,-1)
> 05-15 15:44:26.384: DEBUG/VideoView(4243): Error: 1,-1
>
> I am really clueless on how to solve this one, so any help would be
> great

Have you tried changing the address on loopback that you are using
from 127.0.0.1 to something else in the 127.0.0.0/8 range, as there
may be some code that does not well tolerate the use of localhost
specifically.

Also, if you try to use loopback while there is no data connection,
the phone may mistakenly not realise that it can still use loopback.
We (Serval Project) encountered this problem while trying to point
SIPDroid at an asterisk instance running on localhost on the phone.
We only needed to patch a few lines in the end, but it was frustrating
in the meantime.

Paul.

> Thanks

inon

unread,
May 18, 2011, 2:31:45 PM5/18/11
to android-platform
Thanks Paul,
If you look at the SIPDroid code you can see that they are doineg that
same thing: streaming from the camera directly to an RTP stream.
this work and video is viewable on the other side, so maybe you have
different needs but for pure streaming this is sufficient.

as for the local host, I have tried all kinds of loopbacks including
the actual IP the device currently have - all fail with the same
result:
after DESCRIBE response media player fails...
the thing is that I didn't even get to the point where the stream
begins since SETUP and PLAY are never called.
Did you have a solution for Android streaming?
Inon

On May 17, 5:32 pm, Paul Gardner-Stephen

Saurav

unread,
Sep 30, 2011, 8:55:58 AM9/30/11
to inon, android-...@googlegroups.com
Hi;
I am trying to transmit video from an android device to pc wirelessly
on wifi network.I am using ffmpeg framework. But I cound’t figure out
how to use the ffserver. Any thoughts? How can I use the ffserver for
streaming .
http://www.roman10.net/?p=389
I have used this link as a reference.
I am quite new to this field so can u please suggest that is it
possible (streaming from android over wifi) with ffmpeg. Is it a good
way or there are better ways available ??
Reply all
Reply to author
Forward
0 new messages