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


Java AdaptationSet类代码示例

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


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

示例1: getDrmInitData

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的package包/类
private static DrmInitData getDrmInitData(MediaPresentationDescription manifest,
    int adaptationSetIndex) {
  AdaptationSet adaptationSet = manifest.periods.get(0).adaptationSets.get(adaptationSetIndex);
  String drmInitMimeType = mimeTypeIsWebm(adaptationSet.representations.get(0).format.mimeType)
      ? MimeTypes.VIDEO_WEBM : MimeTypes.VIDEO_MP4;
  if (adaptationSet.contentProtections.isEmpty()) {
    return null;
  } else {
    DrmInitData.Mapped drmInitData = null;
    for (ContentProtection contentProtection : adaptationSet.contentProtections) {
      if (contentProtection.uuid != null && contentProtection.data != null) {
        if (drmInitData == null) {
          drmInitData = new DrmInitData.Mapped(drmInitMimeType);
        }
        drmInitData.put(contentProtection.uuid, contentProtection.data);
      }
    }
    return drmInitData;
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:21,代码来源:DashChunkSource.java

示例2: selectTracks

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的package包/类
@Override
public void selectTracks(MediaPresentationDescription manifest, int periodIndex,
    Output output) throws IOException {
  Period period = manifest.getPeriod(periodIndex);
  int adaptationSetIndex = period.getAdaptationSetIndex(adaptationSetType);
  AdaptationSet adaptationSet = period.adaptationSets.get(adaptationSetIndex);
  int[] representationIndices = getRepresentationIndices(adaptationSet, representationIds,
      canIncludeAdditionalVideoRepresentations);
  if (representationIndices.length > representationIds.length) {
    includedAdditionalVideoRepresentations = true;
  }
  if (adaptationSetType == AdaptationSet.TYPE_VIDEO) {
    output.adaptiveTrack(manifest, periodIndex, adaptationSetIndex, representationIndices);
  }
  for (int i = 0; i < representationIndices.length; i++) {
    output.fixedTrack(manifest, periodIndex, adaptationSetIndex, representationIndices[i]);
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:19,代码来源:DashTest.java

示例3: fixedTrack

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的package包/类
@Override
public void fixedTrack(MediaPresentationDescription manifest, int periodIndex,
    int adaptationSetIndex, int representationIndex) {
  List<AdaptationSet> adaptationSets = manifest.getPeriod(periodIndex).adaptationSets;
  AdaptationSet adaptationSet = adaptationSets.get(adaptationSetIndex);
  Format representationFormat = adaptationSet.representations.get(representationIndex).format;
  String mediaMimeType = getMediaMimeType(representationFormat);
  if (mediaMimeType == null) {
    Log.w(TAG, "Skipped track " + representationFormat.id + " (unknown media mime type)");
    return;
  }
  MediaFormat trackFormat = getTrackFormat(adaptationSet.type, representationFormat,
      mediaMimeType, manifest.dynamic ? C.UNKNOWN_TIME_US : manifest.duration * 1000);
  if (trackFormat == null) {
    Log.w(TAG, "Skipped track " + representationFormat.id + " (unknown media format)");
    return;
  }
  tracks.add(new ExposedTrack(trackFormat, adaptationSetIndex, representationFormat));
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:20,代码来源:DashChunkSource.java

示例4: getTrackFormat

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的package包/类
private static MediaFormat getTrackFormat(int adaptationSetType, Format format,
    String mediaMimeType, long durationUs) {
  switch (adaptationSetType) {
    case AdaptationSet.TYPE_VIDEO:
      return MediaFormat.createVideoFormat(format.id, mediaMimeType, format.bitrate,
          MediaFormat.NO_VALUE, durationUs, format.width, format.height, null);
    case AdaptationSet.TYPE_AUDIO:
      return MediaFormat.createAudioFormat(format.id, mediaMimeType, format.bitrate,
          MediaFormat.NO_VALUE, durationUs, format.audioChannels, format.audioSamplingRate, null,
          format.language);
    case AdaptationSet.TYPE_TEXT:
      return MediaFormat.createTextFormat(format.id, mediaMimeType, format.bitrate,
          durationUs, format.language);
    default:
      return null;
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:18,代码来源:DashChunkSource.java

示例5: getDrmInitData

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的package包/类
private static DrmInitData getDrmInitData(AdaptationSet adaptationSet) {
  if (adaptationSet.contentProtections.isEmpty()) {
    return null;
  } else {
    DrmInitData.Mapped drmInitData = null;
    for (int i = 0; i < adaptationSet.contentProtections.size(); i++) {
      ContentProtection contentProtection = adaptationSet.contentProtections.get(i);
      if (contentProtection.uuid != null && contentProtection.data != null) {
        if (drmInitData == null) {
          drmInitData = new DrmInitData.Mapped();
        }
        drmInitData.put(contentProtection.uuid, contentProtection.data);
      }
    }
    return drmInitData;
  }
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:18,代码来源:DashChunkSource.java

示例6: buildManifest

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的package包/类
private static MediaPresentationDescription buildManifest(List<Representation> representations) {
  Representation firstRepresentation = representations.get(0);
  AdaptationSet adaptationSet = new AdaptationSet(0, AdaptationSet.TYPE_UNKNOWN, representations);
  Period period = new Period(null, firstRepresentation.periodStartMs,
      firstRepresentation.periodDurationMs, Collections.singletonList(adaptationSet));
  long duration = firstRepresentation.periodDurationMs - firstRepresentation.periodStartMs;
  return new MediaPresentationDescription(-1, duration, -1, false, -1, -1, null, null,
      Collections.singletonList(period));
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:10,代码来源:DashChunkSource.java

示例7: buildRenderers

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的package包/类
@Override
public TrackRenderer[] buildRenderers(HostActivity host, ExoPlayer player, Surface surface) {
  Handler handler = new Handler();
  LogcatLogger logger = new LogcatLogger(TAG, player);
  LoadControl loadControl = new DefaultLoadControl(new DefaultAllocator(BUFFER_SEGMENT_SIZE));
  String userAgent = TestUtil.getUserAgent(host);

  // Build the video renderer.
  DataSource videoDataSource = new DefaultUriDataSource(host, null, userAgent);
  videoTrackSelector = new TrackSelector(AdaptationSet.TYPE_VIDEO,
      canIncludeAdditionalVideoFormats, videoFormats);
  ChunkSource videoChunkSource = new DashChunkSource(mpd, videoTrackSelector, videoDataSource,
      new FormatEvaluator.RandomEvaluator(0));
  ChunkSampleSource videoSampleSource = new ChunkSampleSource(videoChunkSource, loadControl,
      VIDEO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, handler, logger, VIDEO_EVENT_ID,
      MIN_LOADABLE_RETRY_COUNT);
  DebugMediaCodecVideoTrackRenderer videoRenderer = new DebugMediaCodecVideoTrackRenderer(host,
      videoSampleSource, MediaCodecSelector.DEFAULT, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT,
      0, handler, logger, 50);
  videoCounters = videoRenderer.codecCounters;
  player.sendMessage(videoRenderer, DebugMediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surface);

  // Build the audio renderer.
  DataSource audioDataSource = new DefaultUriDataSource(host, null, userAgent);
  TrackSelector audioTrackSelector = new TrackSelector(AdaptationSet.TYPE_AUDIO, false,
      audioFormats);
  ChunkSource audioChunkSource = new DashChunkSource(mpd, audioTrackSelector, audioDataSource,
      null);
  ChunkSampleSource audioSampleSource = new ChunkSampleSource(audioChunkSource, loadControl,
      AUDIO_BUFFER_SEGMENTS * BUFFER_SEGMENT_SIZE, handler, logger, AUDIO_EVENT_ID,
      MIN_LOADABLE_RETRY_COUNT);
  MediaCodecAudioTrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(
      audioSampleSource, MediaCodecSelector.DEFAULT, handler, logger);
  audioCounters = audioRenderer.codecCounters;

  TrackRenderer[] renderers = new TrackRenderer[RENDERER_COUNT];
  renderers[VIDEO_RENDERER_INDEX] = videoRenderer;
  renderers[AUDIO_RENDERER_INDEX] = audioRenderer;
  return renderers;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:41,代码来源:DashTest.java

示例8: TrackSelector

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的package包/类
private TrackSelector(int adaptationSetType, boolean canIncludeAdditionalVideoRepresentations,
    String[] representationIds) {
  Assertions.checkState(!canIncludeAdditionalVideoRepresentations
      || adaptationSetType == AdaptationSet.TYPE_VIDEO);
  this.adaptationSetType = adaptationSetType;
  this.canIncludeAdditionalVideoRepresentations = canIncludeAdditionalVideoRepresentations;
  this.representationIds = representationIds;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:9,代码来源:DashTest.java

示例9: getRepresentationIndices

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的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

示例10: selectTracks

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的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

示例11: adaptiveTrack

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的package包/类
@Override
public void adaptiveTrack(MediaPresentationDescription manifest, int periodIndex,
    int adaptationSetIndex, int[] representationIndices) {
  if (adaptiveFormatEvaluator == null) {
    Log.w(TAG, "Skipping adaptive track (missing format evaluator)");
    return;
  }
  AdaptationSet adaptationSet = manifest.getPeriod(periodIndex).adaptationSets.get(
      adaptationSetIndex);
  int maxWidth = 0;
  int maxHeight = 0;
  Format maxHeightRepresentationFormat = null;
  Format[] representationFormats = new Format[representationIndices.length];
  for (int i = 0; i < representationFormats.length; i++) {
    Format format = adaptationSet.representations.get(representationIndices[i]).format;
    if (maxHeightRepresentationFormat == null || format.height > maxHeight) {
      maxHeightRepresentationFormat = format;
    }
    maxWidth = Math.max(maxWidth, format.width);
    maxHeight = Math.max(maxHeight, format.height);
    representationFormats[i] = format;
  }
  Arrays.sort(representationFormats, new DecreasingBandwidthComparator());
  long trackDurationUs = live ? C.UNKNOWN_TIME_US : manifest.duration * 1000;
  String mediaMimeType = getMediaMimeType(maxHeightRepresentationFormat);
  if (mediaMimeType == null) {
    Log.w(TAG, "Skipped adaptive track (unknown media mime type)");
    return;
  }
  MediaFormat trackFormat = getTrackFormat(adaptationSet.type, maxHeightRepresentationFormat,
      mediaMimeType, trackDurationUs);
  if (trackFormat == null) {
    Log.w(TAG, "Skipped adaptive track (unknown media format)");
    return;
  }
  tracks.add(new ExposedTrack(trackFormat.copyAsAdaptive(null), adaptationSetIndex,
      representationFormats, maxWidth, maxHeight));
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:39,代码来源:DashChunkSource.java

示例12: buildManifest

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的package包/类
private static MediaPresentationDescription buildManifest(long durationMs,
    int adaptationSetType, List<Representation> representations) {
  AdaptationSet adaptationSet = new AdaptationSet(0, adaptationSetType, representations);
  Period period = new Period(null, 0, Collections.singletonList(adaptationSet));
  return new MediaPresentationDescription(-1, durationMs, -1, false, -1, -1, null, null,
      Collections.singletonList(period));
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:8,代码来源:DashChunkSource.java

示例13: PeriodHolder

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的package包/类
public PeriodHolder(int localIndex, MediaPresentationDescription manifest, int manifestIndex,
    ExposedTrack selectedTrack) {
  this.localIndex = localIndex;

  Period period = manifest.getPeriod(manifestIndex);
  long periodDurationUs = getPeriodDurationUs(manifest, manifestIndex);
  AdaptationSet adaptationSet = period.adaptationSets.get(selectedTrack.adaptationSetIndex);
  List<Representation> representations = adaptationSet.representations;

  startTimeUs = period.startMs * 1000;
  drmInitData = getDrmInitData(adaptationSet);

  if (!selectedTrack.isAdaptive()) {
    representationIndices = new int[] {
        getRepresentationIndex(representations, selectedTrack.fixedFormat.id)};
  } else {
    representationIndices = new int[selectedTrack.adaptiveFormats.length];
    for (int j = 0; j < selectedTrack.adaptiveFormats.length; j++) {
      representationIndices[j] = getRepresentationIndex(
          representations, selectedTrack.adaptiveFormats[j].id);
    }
  }

  representationHolders = new HashMap<>();
  for (int i = 0; i < representationIndices.length; i++) {
    Representation representation = representations.get(representationIndices[i]);
    RepresentationHolder representationHolder = new RepresentationHolder(startTimeUs,
        periodDurationUs, representation);
    representationHolders.put(representation.format.id, representationHolder);
  }
  updateRepresentationIndependentProperties(periodDurationUs,
      representations.get(representationIndices[0]));
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:34,代码来源:DashChunkSource.java

示例14: buildMpd

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的package包/类
private static MediaPresentationDescription buildMpd(long durationMs,
    List<Representation> representations, boolean live, boolean limitTimeshiftBuffer) {
  AdaptationSet adaptationSet = new AdaptationSet(0, AdaptationSet.TYPE_VIDEO, representations);
  Period period = new Period(null, 0, Collections.singletonList(adaptationSet));
  return new MediaPresentationDescription(AVAILABILITY_START_TIME_MS, durationMs, -1, live, -1,
      (limitTimeshiftBuffer) ? LIVE_TIMESHIFT_BUFFER_DEPTH_MS : -1, null, null,
      Collections.singletonList(period));
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:9,代码来源:DashChunkSourceTest.java

示例15: buildMultiPeriodVodMpd

import com.google.android.exoplayer.dash.mpd.AdaptationSet; //导入依赖的package包/类
private static MediaPresentationDescription buildMultiPeriodVodMpd() {
  List<Period> periods = new ArrayList<>();
  long timeMs = 0;
  long periodDurationMs = VOD_DURATION_MS;
  for (int i = 0; i < 2; i++) {
    Representation representation = buildVodRepresentation(REGULAR_VIDEO);
    AdaptationSet adaptationSet = new AdaptationSet(0, AdaptationSet.TYPE_VIDEO,
        Collections.singletonList(representation));
    Period period = new Period(null, timeMs, Collections.singletonList(adaptationSet));
    periods.add(period);
    timeMs += periodDurationMs;
  }
  return buildMultiPeriodMpd(timeMs, periods, false, false);
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:15,代码来源:DashChunkSourceTest.java


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