0

我正在使用此代码在 ExoPlayer 上使用 HLS 播放简单的 MPEG-TS:

LoadControl loadControl = new DefaultLoadControl(new BufferPool(BUFFER_SEGMENT_SIZE));
String userAgent = getUserAgent(mContext);
Log.d(TAG, userAgent);
HlsMasterPlaylist manifest = newSimpleMasterPlaylist("http://192.168.1.1/rtp/239.0.0.77:8208");
DataSource dataSource = new HttpDataSource(userAgent, null, null);
HlsChunkSource chunkSource = new HlsChunkSource(dataSource, manifest);
HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true, 2);
MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource,
MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 100, mainHandler, null, 50);
MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);
ExoPlayer exoPlayer = ExoPlayer.Factory.newInstance(RENDERER_COUNT);
exoPlayer.prepare(videoRenderer,audioRenderer);
// Pass the surface to the video renderer.
exoPlayer.sendMessage(videoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surface);
exoPlayer.setPlayWhenReady(true);

使用这种其他方法:

private HlsMasterPlaylist newSimpleMasterPlaylist(String mediaPlaylistUrl) {
return new HlsMasterPlaylist(Uri.parse(""),
Collections.singletonList(new Variant(mediaPlaylistUrl, 0)));
}

它不起作用。我得到:

11-03 09:56:10.785: D/dalvikvm(10907): GC_FOR_ALLOC freed 3K, 8% free 4422K/4780K, paused 33ms, total 34ms
11-03 09:56:14.005: D/dalvikvm(10907): GC_FOR_ALLOC freed 5K, 7% free 5383K/5732K, paused 40ms, total 40ms
11-03 09:56:18.085: D/dalvikvm(10907): GC_FOR_ALLOC freed 11K, 6% free 6663K/7024K, paused 37ms, total 37ms
11-03 09:56:25.075: D/dalvikvm(10907): GC_FOR_ALLOC freed 14K, 4% free 8392K/8724K, paused 41ms, total 41ms
11-03 09:56:33.115: D/dalvikvm(10907): GC_FOR_ALLOC freed 21K, 4% free 10697K/11036K, paused 37ms, total 37ms
11-03 09:56:44.155: D/dalvikvm(10907): GC_FOR_ALLOC freed 28K, 3% free 13707K/14096K, paused 50ms, total 51ms
11-03 09:56:58.485: D/dalvikvm(10907): GC_FOR_ALLOC freed 40K, 3% free 17741K/18108K, paused 34ms, total 34ms

我认为使用单个 MPEG2TS 文件,我可以使用此代码创建单个媒体播放列表,它会起作用,但我不知道该怎么做。

谢谢

4

1 回答 1

0

我目前在 ExoPlayer 中没有看到 MPEG-TS(或 MP2T)支持。

是什么让你相信这种方法会奏效?

注意:什么是“HlsChunkSource”?我在标准 ExoPlayer 源代码中没有找到对它的引用。

于 2014-11-20T17:51:36.517 回答