Can Android natively play udp / RTP /RTSP Streams?

11,532

Yes, you can use e.g. the android.media.MediaPlayer class to do this. See http://developer.android.com/guide/topics/media/mediaplayer.html for more information about how to do it.

Share:
11,532
user1767754
Author by

user1767754

Updated on June 05, 2022

Comments

  • user1767754
    user1767754 almost 2 years

    I am a bit confused, is it possible to receive UDP / RTSP Streams with the Android SDK? I've searched for some solution, but obviously they are just forwarding the request to the android native player or vlc. I would like to playback a video-feed in a surface-view for example.

    Is it possible to receive streams without using third-party api's like ffmpeg?

  • user1767754
    user1767754 over 9 years
    Is this performant as well? I know that for example vlc playr has bad performance compare to ffplay from ffmpeg? but thanks for the answer so far
  • mstorsjo
    mstorsjo over 9 years
    This class should use the same hardware codecs as the native player app, and should otherwise be pretty much the same (unless the native player app has got a lot of customization), so it should be quite performant.
  • user1767754
    user1767754 over 9 years
    In the docs it says " If you're passing a URL to stream an online media file, the file must be capable of progressive download." Will this work with udp streaming?
  • mstorsjo
    mstorsjo over 9 years
    It will work with RTSP streaming over RTP/UDP yes. (It doesn't support other generic streaming protocols over UDP though.)
  • user1767754
    user1767754 over 9 years
    vid.setVideoURI(Uri.parse("udp://@192.168.1.142:1234")); should this work?
  • mstorsjo
    mstorsjo over 9 years
    No, you can't use direct UDP urls, you need to set it up via an RTSP url.
  • mstorsjo
    mstorsjo over 9 years
    Then you would have to manually set up UDP sockets for receiving data, manually parse the packets and feed it to MediaCodec for decoding. It of course is possible but then you have to do almost everything of it manually in your own code.
  • Ivan Verges
    Ivan Verges almost 9 years
    Some devices support a RAW UDP Stream like: "udp://@224.1.1.1:5000", using the common MediaPlayer class, but some others doesn't support that kind of playback. I'm trying to find a way to make a generic player that support this kind of UDP Stream like the VLC does, may somebody give me a clue of how to get it work?
  • Dr.jacky
    Dr.jacky over 8 years
    @mstorsjo Do you have any sample application that play RTP over UDP? please