当前位置: 首页>>代码示例>>Java>>正文


Java FormatEvaluator.AdaptiveEvaluator方法代码示例

本文整理汇总了Java中com.google.android.exoplayer.chunk.FormatEvaluator.AdaptiveEvaluator方法的典型用法代码示例。如果您正苦于以下问题:Java FormatEvaluator.AdaptiveEvaluator方法的具体用法?Java FormatEvaluator.AdaptiveEvaluator怎么用?Java FormatEvaluator.AdaptiveEvaluator使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.android.exoplayer.chunk.FormatEvaluator的用法示例。


在下文中一共展示了FormatEvaluator.AdaptiveEvaluator方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: buildTrackRenderers

import com.google.android.exoplayer.chunk.FormatEvaluator; //导入方法依赖的package包/类
protected void buildTrackRenderers(DrmSessionManager drmSessionManager) {
    Handler mainHandler = player.getMainHandler();
    LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(mainHandler, player);


    //Create the Sample Source to be used by the Video Renderer
    DataSource dataSourceVideo = createDataSource(okHttpClient, bandwidthMeter, userAgent);
    SmoothStreamingTrackSelector trackSelectorVideo = DefaultSmoothStreamingTrackSelector.newVideoInstance(context, true, false);
    ChunkSource chunkSourceVideo = new SmoothStreamingChunkSource(manifestFetcher, trackSelectorVideo, dataSourceVideo,
            new FormatEvaluator.AdaptiveEvaluator(bandwidthMeter), LIVE_EDGE_LATENCY_MS);
    ChunkSampleSource sampleSourceVideo = new ChunkSampleSource(chunkSourceVideo, loadControl, BUFFER_SEGMENTS_VIDEO * BUFFER_SEGMENT_SIZE,
            mainHandler, player, EMExoPlayer.RENDER_VIDEO);


    //Create the Sample Source to be used by the Audio Renderer
    DataSource dataSourceAudio = createDataSource(okHttpClient, bandwidthMeter, userAgent);
    SmoothStreamingTrackSelector trackSelectorAudio = DefaultSmoothStreamingTrackSelector.newAudioInstance();
    ChunkSource chunkSourceAudio = new SmoothStreamingChunkSource(manifestFetcher, trackSelectorAudio, dataSourceAudio, null, LIVE_EDGE_LATENCY_MS);
    ChunkSampleSource sampleSourceAudio = new ChunkSampleSource(chunkSourceAudio, loadControl, BUFFER_SEGMENTS_AUDIO * BUFFER_SEGMENT_SIZE,
            mainHandler, player, EMExoPlayer.RENDER_AUDIO);


    //Create the Sample Source to be used by the Closed Captions Renderer
    DataSource dataSourceCC = createDataSource(okHttpClient, bandwidthMeter, userAgent);
    SmoothStreamingTrackSelector trackSelectorCC = DefaultSmoothStreamingTrackSelector.newTextInstance();
    ChunkSource chunkSourceCC = new SmoothStreamingChunkSource(manifestFetcher, trackSelectorCC, dataSourceCC, null, LIVE_EDGE_LATENCY_MS);
    ChunkSampleSource sampleSourceCC = new ChunkSampleSource(chunkSourceCC, loadControl, BUFFER_SEGMENTS_TEXT * BUFFER_SEGMENT_SIZE,
            mainHandler, player, EMExoPlayer.RENDER_CLOSED_CAPTION);


    // Build the renderers
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context, sampleSourceVideo, MediaCodecSelector.DEFAULT,
            MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, MAX_JOIN_TIME, drmSessionManager, true, mainHandler, player, DROPPED_FRAME_NOTIFICATION_AMOUNT);
    EMMediaCodecAudioTrackRenderer audioRenderer = new EMMediaCodecAudioTrackRenderer(sampleSourceAudio, MediaCodecSelector.DEFAULT, drmSessionManager,
            true, mainHandler, player, AudioCapabilities.getCapabilities(context), streamType);
    TextTrackRenderer captionsRenderer = new TextTrackRenderer(sampleSourceCC, player, mainHandler.getLooper());


    // Invoke the callback
    TrackRenderer[] renderers = new TrackRenderer[EMExoPlayer.RENDER_COUNT];
    renderers[EMExoPlayer.RENDER_VIDEO] = videoRenderer;
    renderers[EMExoPlayer.RENDER_AUDIO] = audioRenderer;
    renderers[EMExoPlayer.RENDER_CLOSED_CAPTION] = captionsRenderer;
    player.onRenderers(renderers, bandwidthMeter);
}
 
开发者ID:ayaseruri,项目名称:luxunPro,代码行数:47,代码来源:SmoothStreamRenderBuilder.java

示例2: buildRenderers

import com.google.android.exoplayer.chunk.FormatEvaluator; //导入方法依赖的package包/类
private void buildRenderers() {
    Period period = manifest.getPeriod(0);
    Handler mainHandler = player.getMainHandler();
    LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(mainHandler, player);

    boolean hasContentProtection = false;
    for (int i = 0; i < period.adaptationSets.size(); i++) {
        AdaptationSet adaptationSet = period.adaptationSets.get(i);
        if (adaptationSet.type != AdaptationSet.TYPE_UNKNOWN) {
            hasContentProtection |= adaptationSet.hasContentProtection();
        }
    }

    // Check drm support if necessary.
    boolean filterHdContent = false;
    StreamingDrmSessionManager drmSessionManager = null;
    if (hasContentProtection) {
        if (Util.SDK_INT < 18) {
            player.onRenderersError(
                    new UnsupportedDrmException(UnsupportedDrmException.REASON_UNSUPPORTED_SCHEME));
            return;
        }
        try {
            drmSessionManager = StreamingDrmSessionManager.newWidevineInstance(
                    player.getPlaybackLooper(), drmCallback, null, player.getMainHandler(), player);
            filterHdContent = getWidevineSecurityLevel(drmSessionManager) != SECURITY_LEVEL_1;
        } catch (UnsupportedDrmException e) {
            player.onRenderersError(e);
            return;
        }
    }

    // Build the video renderer.
    DataSource videoDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ChunkSource videoChunkSource = new DashChunkSource(manifestFetcher,
            DefaultDashTrackSelector.newVideoInstance(context, true, filterHdContent),
            videoDataSource, new FormatEvaluator.AdaptiveEvaluator(bandwidthMeter), LIVE_EDGE_LATENCY_MS,
            elapsedRealtimeOffset, mainHandler, player, ExoPlayerWrapper.TYPE_VIDEO);
    ChunkSampleSource videoSampleSource = new ChunkSampleSource(videoChunkSource, loadControl,
            VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player,
            ExoPlayerWrapper.TYPE_VIDEO);
    TrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context, videoSampleSource,
            MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000,
            drmSessionManager, true, mainHandler, player, 50);

    // Build the audio renderer.
    DataSource audioDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ChunkSource audioChunkSource = new DashChunkSource(manifestFetcher,
            DefaultDashTrackSelector.newAudioInstance(), audioDataSource, null, LIVE_EDGE_LATENCY_MS,
            elapsedRealtimeOffset, mainHandler, player, ExoPlayerWrapper.TYPE_AUDIO);
    ChunkSampleSource audioSampleSource = new ChunkSampleSource(audioChunkSource, loadControl,
            AUDIO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player,
            ExoPlayerWrapper.TYPE_AUDIO);
    TrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(audioSampleSource,
            MediaCodecSelector.DEFAULT, drmSessionManager, true, mainHandler, player,
            AudioCapabilities.getCapabilities(context), AudioManager.STREAM_MUSIC);

    // Build the text renderer.
    DataSource textDataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    ChunkSource textChunkSource = new DashChunkSource(manifestFetcher,
            DefaultDashTrackSelector.newTextInstance(), textDataSource, null, LIVE_EDGE_LATENCY_MS,
            elapsedRealtimeOffset, mainHandler, player, ExoPlayerWrapper.TYPE_TEXT);
    ChunkSampleSource textSampleSource = new ChunkSampleSource(textChunkSource, loadControl,
            TEXT_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player,
            ExoPlayerWrapper.TYPE_TEXT);
    TrackRenderer textRenderer = new TextTrackRenderer(textSampleSource, player,
            mainHandler.getLooper());

    // Invoke the callback.
    TrackRenderer[] renderers = new TrackRenderer[ExoPlayerWrapper.RENDERER_COUNT];
    renderers[ExoPlayerWrapper.TYPE_VIDEO] = videoRenderer;
    renderers[ExoPlayerWrapper.TYPE_AUDIO] = audioRenderer;
    renderers[ExoPlayerWrapper.TYPE_TEXT] = textRenderer;
    player.onRenderers(renderers, bandwidthMeter);
}
 
开发者ID:cklar,项目名称:ExoPlayerWrapper,代码行数:77,代码来源:DashRendererBuilder.java


注:本文中的com.google.android.exoplayer.chunk.FormatEvaluator.AdaptiveEvaluator方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。