4

I'm new on ExoPlayer , i'm currently heading to use it to play Native Udp Stream ( From french digital Television : 1080p 5-10 mbps in Variable bitrate ) I manage to play some udp stream with some tests videos from http://jell.yfish.us/ on different devices . I have make some different video decoding test with HLS and Udp Streaming with this code for UDP :

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.myactivity);

    sufaceview = (SurfaceView) findViewById(R.id.surfaceView2);


    BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
    TrackSelection.Factory videoTrackSelectionFactory =
            new AdaptiveTrackSelection.Factory(bandwidthMeter);
    TrackSelector trackSelector =
            new DefaultTrackSelector(videoTrackSelectionFactory);

    LoadControl loadControl = new DefaultLoadControl(
            new DefaultAllocator(true, C.DEFAULT_BUFFER_SEGMENT_SIZE),
            15000, 60000, 2500, 6000);


    player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl);


    Uri uri =
            Uri.parse
                    ("udp://@239.192.2.2:1234");

    final DefaultBandwidthMeter bandwidthMeterA = new DefaultBandwidthMeter();

    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
            Util.getUserAgent(this, "teveolauncher"), bandwidthMeterA);

    extractorsFactory = new DefaultExtractorsFactory();

    DataSource.Factory udsf = new UdpDataSource.Factory() {
        @Override
        public DataSource createDataSource() {
            return new UdpDataSource(null, 3000, 100000);
        }
    };
    ExtractorsFactory tsExtractorFactory = new ExtractorsFactory() {
        @Override
        public Extractor[] createExtractors() {
            return new TsExtractor[]{new TsExtractor(MODE_SINGLE_PMT,
                    new TimestampAdjuster(0), new DefaultTsPayloadReaderFactory())};
        }
    };



    MediaSource videoSource = new ExtractorMediaSource
            (uri, udsf, tsExtractorFactory, null, null);

    player.setVideoSurfaceView(sufaceview);
    player.prepare(videoSource);
    player.setPlayWhenReady(true);

}

For HLS I just Change the MediaSource and the datasourceFactory :

    DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
            Util.getUserAgent(this, "teveolauncher"), bandwidthMeterA);

    MediaSource videoSource = new HlsMediaSource
            (uri, dataSourceFactory, null, null);

I Know Udpstreaming is not officialy supported by ExoPlayer but the UdpDataSource class seems to work well.

After all the test , i noticed video with a variable biterate like french DTT can't be decoded correctly but with Constatnt biterate video like Jell yfish the decoding process is perfect .

There is some coding improvement to make VBR video decoded correctly ? Thank you by advance :) Sorry for my bad english :)

Andrii Omelchenko
  • 13,183
  • 12
  • 43
  • 79

1 Answers1

-1
    Uri uri = Uri.parse("udp://@239.192.2.2:1234");

I think UDP is not a protocol - it's a transport, (like TCP). You can't use a tcp://host:port/ URL either.

Or does it work?

Ondrej
  • 7
  • 5