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


Java VideoFormatSelectorUtil类代码示例

本文整理汇总了Java中com.google.android.exoplayer.chunk.VideoFormatSelectorUtil的典型用法代码示例。如果您正苦于以下问题:Java VideoFormatSelectorUtil类的具体用法?Java VideoFormatSelectorUtil怎么用?Java VideoFormatSelectorUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VideoFormatSelectorUtil类属于com.google.android.exoplayer.chunk包,在下文中一共展示了VideoFormatSelectorUtil类的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getRepresentationIndices

import com.google.android.exoplayer.chunk.VideoFormatSelectorUtil; //导入依赖的package包/类
private static int[] getRepresentationIndices(AdaptationSet adaptationSet,
    String[] representationIds, boolean canIncludeAdditionalVideoRepresentations)
    throws IOException {
  List<Representation> availableRepresentations = adaptationSet.representations;
  List<Integer> selectedRepresentationIndices = new ArrayList<>();

  // Always select explicitly listed representations, failing if they're missing.
  for (int i = 0; i < representationIds.length; i++) {
    String representationId = representationIds[i];
    boolean foundIndex = false;
    for (int j = 0; j < availableRepresentations.size() && !foundIndex; j++) {
      if (availableRepresentations.get(j).format.id.equals(representationId)) {
        selectedRepresentationIndices.add(j);
        foundIndex = true;
      }
    }
    if (!foundIndex) {
      throw new IllegalStateException("Representation " + representationId + " not found.");
    }
  }

  // Select additional video representations, if supported by the device.
  if (canIncludeAdditionalVideoRepresentations) {
     int[] supportedVideoRepresentationIndices = VideoFormatSelectorUtil.selectVideoFormats(
         availableRepresentations, null, false, true, -1, -1);
     for (int i = 0; i < supportedVideoRepresentationIndices.length; i++) {
       int representationIndex = supportedVideoRepresentationIndices[i];
       if (!selectedRepresentationIndices.contains(representationIndex)) {
         Log.d(TAG, "Adding video format: " + availableRepresentations.get(i).format.id);
         selectedRepresentationIndices.add(representationIndex);
       }
     }

  }

  return Util.toArray(selectedRepresentationIndices);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:38,代码来源:DashTest.java

示例2: selectTracks

import com.google.android.exoplayer.chunk.VideoFormatSelectorUtil; //导入依赖的package包/类
@Override
public void selectTracks(MediaPresentationDescription manifest, int periodIndex, Output output)
    throws IOException {
  Period period = manifest.getPeriod(periodIndex);
  for (int i = 0; i < period.adaptationSets.size(); i++) {
    AdaptationSet adaptationSet = period.adaptationSets.get(i);
    if (adaptationSet.type == adaptationSetType) {
      if (adaptationSetType == AdaptationSet.TYPE_VIDEO) {
        int[] representations;
        if (filterVideoRepresentations) {
          representations = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
              context, adaptationSet.representations, null,
              filterProtectedHdContent && adaptationSet.hasContentProtection());
        } else {
          representations = Util.firstIntegersArray(adaptationSet.representations.size());
        }
        int representationCount = representations.length;
        if (representationCount > 1) {
          output.adaptiveTrack(manifest, periodIndex, i, representations);
        }
        for (int j = 0; j < representationCount; j++) {
          output.fixedTrack(manifest, periodIndex, i, representations[j]);
        }
      } else {
        for (int j = 0; j < adaptationSet.representations.size(); j++) {
          output.fixedTrack(manifest, periodIndex, i, j);
        }
      }
    }
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:32,代码来源:DefaultDashTrackSelector.java

示例3: selectTracks

import com.google.android.exoplayer.chunk.VideoFormatSelectorUtil; //导入依赖的package包/类
@Override
public void selectTracks(SmoothStreamingManifest manifest, Output output) throws IOException {
  for (int i = 0; i < manifest.streamElements.length; i++) {
    TrackElement[] tracks = manifest.streamElements[i].tracks;
    if (manifest.streamElements[i].type == streamElementType) {
      if (streamElementType == StreamElement.TYPE_VIDEO) {
        int[] trackIndices;
        if (filterVideoRepresentations) {
          trackIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
              context, Arrays.asList(tracks), null,
              filterProtectedHdContent && manifest.protectionElement != null);
        } else {
          trackIndices = Util.firstIntegersArray(tracks.length);
        }
        int trackCount = trackIndices.length;
        if (trackCount > 1) {
          output.adaptiveTrack(manifest, i, trackIndices);
        }
        for (int j = 0; j < trackCount; j++) {
          output.fixedTrack(manifest, i, trackIndices[j]);
        }
      } else {
        for (int j = 0; j < tracks.length; j++) {
          output.fixedTrack(manifest, i, j);
        }
      }
    }
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:30,代码来源:DefaultSmoothStreamingTrackSelector.java

示例4: onSingleManifest

import com.google.android.exoplayer.chunk.VideoFormatSelectorUtil; //导入依赖的package包/类
@Override
public void onSingleManifest(HlsPlaylist manifest) {
  Handler mainHandler = player.getMainHandler();

  LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

  int[] variantIndices = null;
  if (manifest instanceof HlsMasterPlaylist) {
    HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) manifest;
    try {
      variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
              context, masterPlaylist.variants, null, false);
    } catch (DecoderQueryException e) {
      callback.onRenderersError(e);
      return;
    }
  }

  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter,
      variantIndices, HlsChunkSource.ADAPTIVE_MODE_SPLICE, audioCapabilities);
  HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
      BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, true, mainHandler, player, DemoPlayer.TYPE_VIDEO);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource,
      MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);

  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  callback.onRenderers(null, null, renderers, bandwidthMeter);
}
 
开发者ID:caspercba,项目名称:exoPlayerHLS,代码行数:34,代码来源:HlsRendererBuilder.java

示例5: onSingleManifest

import com.google.android.exoplayer.chunk.VideoFormatSelectorUtil; //导入依赖的package包/类
@Override
public void onSingleManifest(HlsPlaylist manifest) {
  if (canceled) {
    return;
  }

  Handler mainHandler = player.getMainHandler();
  LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

  int[] variantIndices = null;
  if (manifest instanceof HlsMasterPlaylist) {
    HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) manifest;
    try {
      variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
          context, masterPlaylist.variants, null, false);
    } catch (DecoderQueryException e) {
      player.onRenderersError(e);
      return;
    }
    if (variantIndices.length == 0) {
      player.onRenderersError(new IllegalStateException("No variants selected."));
      return;
    }
  }

  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter,
      variantIndices, HlsChunkSource.ADAPTIVE_MODE_SPLICE);
  HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
      BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player, DemoPlayer.TYPE_VIDEO);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      null, true, player.getMainHandler(), player, AudioCapabilities.getCapabilities(context));
  MetadataTrackRenderer<Map<String, Object>> id3Renderer = new MetadataTrackRenderer<>(
      sampleSource, new Id3Parser(), player, mainHandler.getLooper());
  Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
      mainHandler.getLooper());

  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_METADATA] = id3Renderer;
  renderers[DemoPlayer.TYPE_TEXT] = closedCaptionRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
 
开发者ID:vuthanhict,项目名称:ExoPlayerController,代码行数:48,代码来源:HlsRendererBuilder.java

示例6: onSingleManifest

import com.google.android.exoplayer.chunk.VideoFormatSelectorUtil; //导入依赖的package包/类
@Override
public void onSingleManifest(HlsPlaylist manifest) {
  if (canceled) {
    return;
  }

  Handler mainHandler = player.getMainHandler();
  LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

  int[] variantIndices = null;
  if (manifest instanceof HlsMasterPlaylist) {
    HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) manifest;
    try {
      variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
        context, masterPlaylist.variants, null, false);
    } catch (DecoderQueryException e) {
      player.onRenderersError(e);
      return;
    }
    if (variantIndices.length == 0) {
      player.onRenderersError(new IllegalStateException("No variants selected."));
      return;
    }
  }

  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter,
      variantIndices, HlsChunkSource.ADAPTIVE_MODE_SPLICE, audioCapabilities);
  HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
      BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player, MediaPlayer.TYPE_VIDEO);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource,
      MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);
  MetadataTrackRenderer<Map<String, Object>> id3Renderer = new MetadataTrackRenderer<>(
      sampleSource, new Id3Parser(), player, mainHandler.getLooper());
  Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
      mainHandler.getLooper());
  TrackRenderer[] renderers = new TrackRenderer[MediaPlayer.RENDERER_COUNT];
  renderers[MediaPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[MediaPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[MediaPlayer.TYPE_METADATA] = id3Renderer;
  renderers[MediaPlayer.TYPE_TEXT] = closedCaptionRenderer;
  player.onRenderers(null, null, renderers, bandwidthMeter);
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:46,代码来源:HlsRendererBuilder.java

示例7: selectTracks

import com.google.android.exoplayer.chunk.VideoFormatSelectorUtil; //导入依赖的package包/类
@Override
public void selectTracks(HlsMasterPlaylist playlist, Output output) throws IOException {
  if (type == TYPE_AUDIO || type == TYPE_SUBTITLE) {
    List<Variant> variants = type == TYPE_AUDIO ? playlist.audios : playlist.subtitles;
    if (variants != null && !variants.isEmpty()) {
      for (int i = 0; i < variants.size(); i++) {
        output.fixedTrack(playlist, variants.get(i));
      }
    }
    return;
  }

  // Type is TYPE_DEFAULT.

  ArrayList<Variant> enabledVariantList = new ArrayList<>();
  int[] variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
      context, playlist.variants, null, false);
  for (int i = 0; i < variantIndices.length; i++) {
    enabledVariantList.add(playlist.variants.get(variantIndices[i]));
  }

  ArrayList<Variant> definiteVideoVariants = new ArrayList<>();
  ArrayList<Variant> definiteAudioOnlyVariants = new ArrayList<>();
  for (int i = 0; i < enabledVariantList.size(); i++) {
    Variant variant = enabledVariantList.get(i);
    if (variant.format.height > 0 || variantHasExplicitCodecWithPrefix(variant, "avc")) {
      definiteVideoVariants.add(variant);
    } else if (variantHasExplicitCodecWithPrefix(variant, "mp4a")) {
      definiteAudioOnlyVariants.add(variant);
    }
  }

  if (!definiteVideoVariants.isEmpty()) {
    // We've identified some variants as definitely containing video. Assume variants within the
    // master playlist are marked consistently, and hence that we have the full set. Filter out
    // any other variants, which are likely to be audio only.
    enabledVariantList = definiteVideoVariants;
  } else if (definiteAudioOnlyVariants.size() < enabledVariantList.size()) {
    // We've identified some variants, but not all, as being audio only. Filter them out to leave
    // the remaining variants, which are likely to contain video.
    enabledVariantList.removeAll(definiteAudioOnlyVariants);
  } else {
    // Leave the enabled variants unchanged. They're likely either all video or all audio.
  }

  if (enabledVariantList.size() > 1) {
    Variant[] enabledVariants = new Variant[enabledVariantList.size()];
    enabledVariantList.toArray(enabledVariants);
    output.adaptiveTrack(playlist, enabledVariants);
  }
  for (int i = 0; i < enabledVariantList.size(); i++) {
    output.fixedTrack(playlist, enabledVariantList.get(i));
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:55,代码来源:DefaultHlsTrackSelector.java

示例8: onSingleManifest

import com.google.android.exoplayer.chunk.VideoFormatSelectorUtil; //导入依赖的package包/类
@Override
public void onSingleManifest(HlsPlaylist manifest) {
  if (canceled) {
    return;
  }

  Handler mainHandler = player.getMainHandler();
  LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

  int[] variantIndices = null;
  if (manifest instanceof HlsMasterPlaylist) {
    HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) manifest;
    try {
      variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
          context, masterPlaylist.variants, null, false);
    } catch (DecoderQueryException e) {
      player.onRenderersError(e);
      return;
    }
    if (variantIndices.length == 0) {
      player.onRenderersError(new IllegalStateException("No variants selected."));
      return;
    }
  }

  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter,
      variantIndices, HlsChunkSource.ADAPTIVE_MODE_SPLICE);
  HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
      BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player, Player.TYPE_VIDEO);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      null, true, player.getMainHandler(), player, AudioCapabilities.getCapabilities(context));
  MetadataTrackRenderer<Map<String, Object>> id3Renderer = new MetadataTrackRenderer<>(
      sampleSource, new Id3Parser(), player, mainHandler.getLooper());
  Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
      mainHandler.getLooper());

  TrackRenderer[] renderers = new TrackRenderer[Player.RENDERER_COUNT];
  renderers[Player.TYPE_VIDEO] = videoRenderer;
  renderers[Player.TYPE_AUDIO] = audioRenderer;
  renderers[Player.TYPE_METADATA] = id3Renderer;
  renderers[Player.TYPE_TEXT] = closedCaptionRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
 
开发者ID:PJakcson,项目名称:Mediathek,代码行数:48,代码来源:HlsRendererBuilder.java

示例9: onSingleManifest

import com.google.android.exoplayer.chunk.VideoFormatSelectorUtil; //导入依赖的package包/类
@Override
public void onSingleManifest(HlsPlaylist manifest) {
    if (canceled) {
        return;
    }

    Handler mainHandler = player.getMainHandler();
    LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
    DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

    int[] variantIndices = null;
    if (manifest instanceof HlsMasterPlaylist) {
        HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) manifest;
        try {
            variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
                    context, masterPlaylist.variants, null, false);
        } catch (DecoderQueryException e) {
            player.onRenderersError(e);
            return;
        }
        if (variantIndices.length == 0) {
            player.onRenderersError(new IllegalStateException("No variants selected."));
            return;
        }
    }

    DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
    HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter,
            variantIndices, HlsChunkSource.ADAPTIVE_MODE_SPLICE, audioCapabilities);
    HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
            BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player, VideoPlayer.TYPE_VIDEO);
    MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource,
            MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
    MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);
    MetadataTrackRenderer<Map<String, Object>> id3Renderer = new MetadataTrackRenderer<>(
            sampleSource, new Id3Parser(), player, mainHandler.getLooper());
    Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
            mainHandler.getLooper());

    TrackRenderer[] renderers = new TrackRenderer[VideoPlayer.RENDERER_COUNT];
    renderers[VideoPlayer.TYPE_VIDEO] = videoRenderer;
    renderers[VideoPlayer.TYPE_AUDIO] = audioRenderer;
    renderers[VideoPlayer.TYPE_METADATA] = id3Renderer;
    renderers[VideoPlayer.TYPE_TEXT] = closedCaptionRenderer;
    player.onRenderers(null, null, renderers, bandwidthMeter);
}
 
开发者ID:nextux,项目名称:sbs-android-tv,代码行数:47,代码来源:HlsRendererBuilder.java

示例10: onSingleManifest

import com.google.android.exoplayer.chunk.VideoFormatSelectorUtil; //导入依赖的package包/类
@Override
public void onSingleManifest(HlsPlaylist manifest) {
  Handler mainHandler = player.getMainHandler();
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

  int[] variantIndices = null;
  if (manifest instanceof HlsMasterPlaylist) {
    HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) manifest;
    try {
      variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
              context, masterPlaylist.variants, null, false);
    } catch (DecoderQueryException e) {
      callback.onRenderersError(e);
      return;
    }
  }

  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter,
      variantIndices, HlsChunkSource.ADAPTIVE_MODE_SPLICE, audioCapabilities);
  HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, true, 3, REQUESTED_BUFFER_SIZE,
      REQUESTED_BUFFER_DURATION_MS, mainHandler, player, DemoPlayer.TYPE_VIDEO);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource,
      MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);

  MetadataTrackRenderer<Map<String, Object>> id3Renderer =
      new MetadataTrackRenderer<Map<String, Object>>(sampleSource, new Id3Parser(),
          player.getId3MetadataRenderer(), mainHandler.getLooper());

  Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
      mainHandler.getLooper());

  // Build the debug renderer.
  TrackRenderer debugRenderer = debugTextView != null
      ? new DebugTrackRenderer(debugTextView, player, videoRenderer) : null;

  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_TIMED_METADATA] = id3Renderer;
  renderers[DemoPlayer.TYPE_TEXT] = closedCaptionRenderer;
  renderers[DemoPlayer.TYPE_DEBUG] = debugRenderer;
  callback.onRenderers(null, null, renderers);
}
 
开发者ID:korrio,项目名称:AdvancedVideoView,代码行数:46,代码来源:HlsRendererBuilder.java

示例11: onSingleManifest

import com.google.android.exoplayer.chunk.VideoFormatSelectorUtil; //导入依赖的package包/类
@Override
public void onSingleManifest(HlsPlaylist manifest) {
  if (canceled) {
    return;
  }

  Handler mainHandler = player.getMainHandler();
  LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

  int[] variantIndices = null;
  if (manifest instanceof HlsMasterPlaylist) {
    HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) manifest;
    try {
      variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
          context, masterPlaylist.variants, null, false);
    } catch (DecoderQueryException e) {
      player.onRenderersError(e);
      return;
    }
    if (variantIndices.length == 0) {
      player.onRenderersError(new IllegalStateException("No variants selected."));
      return;
    }
  }

  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter,
      variantIndices, HlsChunkSource.ADAPTIVE_MODE_SPLICE);
  HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
      BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player, FlyingPlayer.TYPE_VIDEO);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
      sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
      null, true, player.getMainHandler(), player, AudioCapabilities.getCapabilities(context));
  MetadataTrackRenderer<Map<String, Object>> id3Renderer = new MetadataTrackRenderer<>(
      sampleSource, new Id3Parser(), player, mainHandler.getLooper());
  Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
      mainHandler.getLooper());

  TrackRenderer[] renderers = new TrackRenderer[FlyingPlayer.RENDERER_COUNT];
  renderers[FlyingPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[FlyingPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[FlyingPlayer.TYPE_METADATA] = id3Renderer;
  renderers[FlyingPlayer.TYPE_TEXT] = closedCaptionRenderer;
  player.onRenderers(renderers, bandwidthMeter);
}
 
开发者ID:birdcopy,项目名称:Android-Birdcopy-Application,代码行数:48,代码来源:HlsRendererBuilder.java

示例12: onSingleManifest

import com.google.android.exoplayer.chunk.VideoFormatSelectorUtil; //导入依赖的package包/类
@Override
        public void onSingleManifest(HlsPlaylist manifest) {
            if (canceled) {
                return;
            }

            Handler mainHandler = player.getMainHandler();
            //Allocator资源的分配,设置默认的资源分配(初始化一个空的资源池来装)
            //数据加载控制
            LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
            //如果数据传输是开放的,那创建一个带宽采样并更新的时候,可以记录传输的字节数
            DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
            //对于主播放列表,以最大的可能去发现设备能够播放的类型
            int[] variantIndices = null;
            if (manifest instanceof HlsMasterPlaylist) {
                HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) manifest;
                try {
                    variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
                            context, masterPlaylist.variants, null, false);
                } catch (DecoderQueryException e) {
                    //解码器查询错误
                    player.onRenderersError(e);
                    return;
                }
                if (variantIndices.length == 0) {
                    //不支持播放,没有可以选择的变量
                    player.onRenderersError(new IllegalStateException("No variants selected."));
                    return;
                }
            }

            //创建采样源用于渲染
            DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
            HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter,
                    variantIndices, HlsChunkSource.ADAPTIVE_MODE_SPLICE);
            HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
                    BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player, OkPlayer.TYPE_VIDEO);

            //创建渲染器
            //5000是最大加载事件
            MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(context,
                    sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
            MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource,
                    null, true, player.getMainHandler(), player, AudioCapabilities.getCapabilities(context));
//            MetadataTrackRenderer<Map<String, Object>> id3Renderer = new MetadataTrackRenderer<>(
//                    sampleSource, new Id3Parser(), player, mainHandler.getLooper());
//            Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
//                    mainHandler.getLooper());

            //填充渲染器列表并回调
            TrackRenderer[] renderers = new TrackRenderer[OkPlayer.RENDERER_COUNT];
            renderers[OkPlayer.TYPE_VIDEO] = videoRenderer;
            renderers[OkPlayer.TYPE_AUDIO] = audioRenderer;
//            renderers[OkPlayer.TYPE_METADATA] = id3Renderer;
//            renderers[OkPlayer.TYPE_TEXT] = closedCaptionRenderer;
            player.onRenderers(renderers, bandwidthMeter);
        }
 
开发者ID:succlz123,项目名称:OkPlayer,代码行数:58,代码来源:HlsRendererBuilder.java

示例13: onSingleManifest

import com.google.android.exoplayer.chunk.VideoFormatSelectorUtil; //导入依赖的package包/类
@Override
public void onSingleManifest(HlsPlaylist manifest) {
  if (canceled) {
    return;
  }

  Handler mainHandler = player.getMainHandler();
  LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
  DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();

  int[] variantIndices = null;
  if (manifest instanceof HlsMasterPlaylist) {
    HlsMasterPlaylist masterPlaylist = (HlsMasterPlaylist) manifest;
    try {
      variantIndices = VideoFormatSelectorUtil.selectVideoFormatsForDefaultDisplay(
          context, masterPlaylist.variants, null, false);
    } catch (DecoderQueryException e) {
      player.onRenderersError(e);
      return;
    }
    if (variantIndices.length == 0) {
      player.onRenderersError(new IllegalStateException("No variants selected."));
      return;
    }
  }

  DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);
  HlsChunkSource chunkSource = new HlsChunkSource(dataSource, url, manifest, bandwidthMeter,
      variantIndices, HlsChunkSource.ADAPTIVE_MODE_SPLICE, audioCapabilities);
  HlsSampleSource sampleSource = new HlsSampleSource(chunkSource, loadControl,
      BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, mainHandler, player, DemoPlayer.TYPE_VIDEO);
  MediaCodecVideoTrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource,
      MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT, 5000, mainHandler, player, 50);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);
  MetadataTrackRenderer<Map<String, Object>> id3Renderer = new MetadataTrackRenderer<>(
      sampleSource, new Id3Parser(), player, mainHandler.getLooper());
  Eia608TrackRenderer closedCaptionRenderer = new Eia608TrackRenderer(sampleSource, player,
      mainHandler.getLooper());

  TrackRenderer[] renderers = new TrackRenderer[DemoPlayer.RENDERER_COUNT];
  renderers[DemoPlayer.TYPE_VIDEO] = videoRenderer;
  renderers[DemoPlayer.TYPE_AUDIO] = audioRenderer;
  renderers[DemoPlayer.TYPE_METADATA] = id3Renderer;
  renderers[DemoPlayer.TYPE_TEXT] = closedCaptionRenderer;
  player.onRenderers(null, null, renderers, bandwidthMeter);
}
 
开发者ID:raphanda,项目名称:ExoPlayer,代码行数:47,代码来源:HlsRendererBuilder.java


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