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


Java Extractor类代码示例

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


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

示例1: prepare

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
@Override
public boolean prepare() throws ParserException {
  if (!prepared) {
    if (maybeSelfContained) {
      // Read up to the first sample. Once we're there, we know that the extractor must have
      // parsed a moov atom if the chunk contains one.
      NonBlockingInputStream inputStream = getNonBlockingInputStream();
      Assertions.checkState(inputStream != null);
      int result = extractor.read(inputStream, null);
      prepared = (result & Extractor.RESULT_NEED_SAMPLE_HOLDER) != 0;
    } else {
      // We know there isn't a moov atom. The extractor must have parsed one from a separate
      // initialization chunk.
      prepared = true;
    }
    if (prepared) {
      mediaFormat = extractor.getFormat();
      Map<UUID, byte[]> extractorPsshInfo = extractor.getPsshInfo();
      if (extractorPsshInfo != null) {
        psshInfo = extractorPsshInfo;
      }
    }
  }
  return prepared;
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:26,代码来源:Mp4MediaChunk.java

示例2: prepare

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
@Override
public boolean prepare() throws ParserException {
  if (!prepared) {
    if (maybeSelfContained) {
      // Read up to the first sample. Once we're there, we know that the extractor must have
      // parsed a moov atom if the chunk contains one.
      NonBlockingInputStream inputStream = getNonBlockingInputStream();
      Assertions.checkState(inputStream != null);
      int result = extractor.read(inputStream, null);
      prepared = (result & Extractor.RESULT_NEED_SAMPLE_HOLDER) != 0;
    } else {
      // We know there isn't a moov atom. The extractor must have parsed one from a separate
      // initialization chunk.
      prepared = true;
    }
    if (prepared) {
      mediaFormat = Assertions.checkNotNull(extractor.getFormat());
      psshInfo = extractor.getPsshInfo();
    }
  }
  return prepared;
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:23,代码来源:Mp4MediaChunk.java

示例3: Mp4MediaChunk

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
/**
 * @deprecated Use the other constructor, passing null as {@code psshInfo}.
 */
@Deprecated
public Mp4MediaChunk(DataSource dataSource, DataSpec dataSpec, Format format,
    int trigger, long startTimeUs, long endTimeUs, int nextChunkIndex,
    Extractor extractor, boolean maybeSelfContained, long sampleOffsetUs) {
  this(dataSource, dataSpec, format, trigger, startTimeUs, endTimeUs, nextChunkIndex,
      extractor, null, maybeSelfContained, sampleOffsetUs);
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:11,代码来源:Mp4MediaChunk.java

示例4: read

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
@Override
public boolean read(SampleHolder holder) throws ParserException {
  NonBlockingInputStream inputStream = getNonBlockingInputStream();
  Assertions.checkState(inputStream != null);
  int result = extractor.read(inputStream, holder);
  boolean sampleRead = (result & Extractor.RESULT_READ_SAMPLE) != 0;
  if (sampleRead) {
    holder.timeUs -= sampleOffsetUs;
  }
  return sampleRead;
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:12,代码来源:Mp4MediaChunk.java

示例5: DashChunkSource

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
private DashChunkSource(ManifestFetcher<MediaPresentationDescription> manifestFetcher,
    MediaPresentationDescription initialManifest, int adaptationSetIndex,
    int[] representationIndices, DataSource dataSource, FormatEvaluator formatEvaluator,
    long liveEdgeLatencyUs) {
  this.manifestFetcher = manifestFetcher;
  this.currentManifest = initialManifest;
  this.adaptationSetIndex = adaptationSetIndex;
  this.representationIndices = representationIndices;
  this.dataSource = dataSource;
  this.evaluator = formatEvaluator;
  this.liveEdgeLatencyUs = liveEdgeLatencyUs;
  this.evaluation = new Evaluation();
  this.headerBuilder = new StringBuilder();

  psshInfo = getPsshInfo(currentManifest, adaptationSetIndex);
  Representation[] representations = getFilteredRepresentations(currentManifest,
      adaptationSetIndex, representationIndices);
  long periodDurationUs = (representations[0].periodDurationMs == TrackRenderer.UNKNOWN_TIME_US)
      ? TrackRenderer.UNKNOWN_TIME_US : representations[0].periodDurationMs * 1000;
  this.trackInfo = new TrackInfo(representations[0].format.mimeType, periodDurationUs);

  this.formats = new Format[representations.length];
  this.representationHolders = new HashMap<String, RepresentationHolder>();
  int maxWidth = 0;
  int maxHeight = 0;
  for (int i = 0; i < representations.length; i++) {
    formats[i] = representations[i].format;
    maxWidth = Math.max(formats[i].width, maxWidth);
    maxHeight = Math.max(formats[i].height, maxHeight);
    Extractor extractor = mimeTypeIsWebm(formats[i].mimeType) ? new WebmExtractor()
        : new FragmentedMp4Extractor();
    representationHolders.put(formats[i].id,
        new RepresentationHolder(representations[i], extractor));
  }
  this.maxWidth = maxWidth;
  this.maxHeight = maxHeight;
  Arrays.sort(formats, new DecreasingBandwidthComparator());
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:39,代码来源:DashChunkSource.java

示例6: newInitializationChunk

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
private Chunk newInitializationChunk(RangedUri initializationUri, RangedUri indexUri,
    Representation representation, Extractor extractor, DataSource dataSource,
    int trigger) {
  int expectedExtractorResult = Extractor.RESULT_END_OF_STREAM;
  long indexAnchor = 0;
  RangedUri requestUri;
  if (initializationUri != null) {
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    expectedExtractorResult |= Extractor.RESULT_READ_INIT;
    requestUri = initializationUri.attemptMerge(indexUri);
    if (requestUri != null) {
      expectedExtractorResult |= Extractor.RESULT_READ_INDEX;
      if (extractor.hasRelativeIndexOffsets()) {
        indexAnchor = indexUri.start + indexUri.length;
      }
    } else {
      requestUri = initializationUri;
    }
  } else {
    requestUri = indexUri;
    if (extractor.hasRelativeIndexOffsets()) {
      indexAnchor = indexUri.start + indexUri.length;
    }
    expectedExtractorResult |= Extractor.RESULT_READ_INDEX;
  }
  DataSpec dataSpec = new DataSpec(requestUri.getUri(), requestUri.start, requestUri.length,
      representation.getCacheKey());

  return new InitializationLoadable(dataSource, dataSpec, trigger, representation.format,
      extractor, expectedExtractorResult, indexAnchor);
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:33,代码来源:DashChunkSource.java

示例7: InitializationLoadable

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
public InitializationLoadable(DataSource dataSource, DataSpec dataSpec, int trigger,
    Format format, Extractor extractor, int expectedExtractorResult,
    long indexAnchor) {
  super(dataSource, dataSpec, format, trigger);
  this.extractor = extractor;
  this.expectedExtractorResult = expectedExtractorResult;
  this.indexAnchor = indexAnchor;
  this.uri = dataSpec.uri;
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:10,代码来源:DashChunkSource.java

示例8: consumeStream

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
@Override
protected void consumeStream(NonBlockingInputStream stream) throws IOException {
  int result = extractor.read(stream, null);
  if (result != expectedExtractorResult) {
    throw new ParserException("Invalid extractor result. Expected "
        + expectedExtractorResult + ", got " + result);
  }
  if ((result & Extractor.RESULT_READ_INDEX) != 0) {
    representationHolders.get(format.id).segmentIndex =
        new DashWrappingSegmentIndex(extractor.getIndex(), uri, indexAnchor);
  }
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:13,代码来源:DashChunkSource.java

示例9: newMediaChunk

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
private static MediaChunk newMediaChunk(Format formatInfo, Uri uri, String cacheKey,
    Extractor extractor, Map<UUID, byte[]> psshInfo, DataSource dataSource, int chunkIndex,
    boolean isLast, long chunkStartTimeUs, long nextChunkStartTimeUs, int trigger) {
  int nextChunkIndex = isLast ? -1 : chunkIndex + 1;
  long nextStartTimeUs = isLast ? -1 : nextChunkStartTimeUs;
  long offset = 0;
  DataSpec dataSpec = new DataSpec(uri, offset, -1, cacheKey);
  // In SmoothStreaming each chunk contains sample timestamps relative to the start of the chunk.
  // To convert them the absolute timestamps, we need to set sampleOffsetUs to -chunkStartTimeUs.
  return new Mp4MediaChunk(dataSource, dataSpec, formatInfo, trigger, chunkStartTimeUs,
      nextStartTimeUs, nextChunkIndex, extractor, psshInfo, false, -chunkStartTimeUs);
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:13,代码来源:SmoothStreamingChunkSource.java

示例10: DashChunkSource

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
/**
 * @param dataSource A {@link DataSource} suitable for loading the media data.
 * @param evaluator Selects from the available formats.
 * @param representations The representations to be considered by the source.
 */
public DashChunkSource(DataSource dataSource, FormatEvaluator evaluator,
    Representation... representations) {
  this.dataSource = dataSource;
  this.evaluator = evaluator;
  this.formats = new Format[representations.length];
  this.extractors = new HashMap<String, Extractor>();
  this.segmentIndexes = new HashMap<String, DashSegmentIndex>();
  this.representations = new HashMap<String, Representation>();
  this.trackInfo = new TrackInfo(representations[0].format.mimeType,
      representations[0].periodDurationMs * 1000);
  this.evaluation = new Evaluation();
  int maxWidth = 0;
  int maxHeight = 0;
  for (int i = 0; i < representations.length; i++) {
    formats[i] = representations[i].format;
    maxWidth = Math.max(formats[i].width, maxWidth);
    maxHeight = Math.max(formats[i].height, maxHeight);
    Extractor extractor = formats[i].mimeType.startsWith(MimeTypes.VIDEO_WEBM)
        ? new WebmExtractor() : new FragmentedMp4Extractor();
    extractors.put(formats[i].id, extractor);
    this.representations.put(formats[i].id, representations[i]);
    DashSegmentIndex segmentIndex = representations[i].getIndex();
    if (segmentIndex != null) {
      segmentIndexes.put(formats[i].id, segmentIndex);
    }
  }
  this.maxWidth = maxWidth;
  this.maxHeight = maxHeight;
  Arrays.sort(formats, new DecreasingBandwidthComparator());
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:36,代码来源:DashChunkSource.java

示例11: newInitializationChunk

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
private Chunk newInitializationChunk(RangedUri initializationUri, RangedUri indexUri,
    Representation representation, Extractor extractor, DataSource dataSource,
    int trigger) {
  int expectedExtractorResult = Extractor.RESULT_END_OF_STREAM;
  long indexAnchor = 0;
  RangedUri requestUri;
  if (initializationUri != null) {
    // It's common for initialization and index data to be stored adjacently. Attempt to merge
    // the two requests together to request both at once.
    expectedExtractorResult |= Extractor.RESULT_READ_INIT;
    requestUri = initializationUri.attemptMerge(indexUri);
    if (requestUri != null) {
      expectedExtractorResult |= Extractor.RESULT_READ_INDEX;
      if (extractor.hasRelativeIndexOffsets()) {
        indexAnchor = indexUri.start + indexUri.length;
      }
    } else {
      requestUri = initializationUri;
    }
  } else {
    requestUri = indexUri;
    if (extractor.hasRelativeIndexOffsets()) {
      indexAnchor = indexUri.start + indexUri.length;
    }
    expectedExtractorResult |= Extractor.RESULT_READ_INDEX;
  }
  DataSpec dataSpec = new DataSpec(requestUri.getUri(), requestUri.start, requestUri.length,
      representation.getCacheKey());
  return new InitializationLoadable(dataSource, dataSpec, trigger, representation.format,
      extractor, expectedExtractorResult, indexAnchor);
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:32,代码来源:DashChunkSource.java

示例12: newMediaChunk

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
private Chunk newMediaChunk(Representation representation, DashSegmentIndex segmentIndex,
    Extractor extractor, DataSource dataSource, int segmentNum, int trigger) {
  int lastSegmentNum = segmentIndex.getLastSegmentNum();
  int nextSegmentNum = segmentNum == lastSegmentNum ? -1 : segmentNum + 1;
  long startTimeUs = segmentIndex.getTimeUs(segmentNum);
  long endTimeUs = segmentNum < lastSegmentNum ? segmentIndex.getTimeUs(segmentNum + 1)
      : startTimeUs + segmentIndex.getDurationUs(segmentNum);
  RangedUri segmentUri = segmentIndex.getSegmentUrl(segmentNum);
  DataSpec dataSpec = new DataSpec(segmentUri.getUri(), segmentUri.start, segmentUri.length,
      representation.getCacheKey());
  return new Mp4MediaChunk(dataSource, dataSpec, representation.format, trigger, startTimeUs,
      endTimeUs, nextSegmentNum, extractor, false, 0);
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:14,代码来源:DashChunkSource.java

示例13: consumeStream

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
@Override
protected void consumeStream(NonBlockingInputStream stream) throws IOException {
  int result = extractor.read(stream, null);
  if (result != expectedExtractorResult) {
    throw new ParserException("Invalid extractor result. Expected "
        + expectedExtractorResult + ", got " + result);
  }
  if ((result & Extractor.RESULT_READ_INDEX) != 0) {
    segmentIndexes.put(format.id,
        new DashWrappingSegmentIndex(extractor.getIndex(), uri, indexAnchor));
  }
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:13,代码来源:DashChunkSource.java

示例14: newMediaChunk

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
private static MediaChunk newMediaChunk(Format formatInfo, Uri uri, String cacheKey,
    Extractor extractor, DataSource dataSource, int chunkIndex,
    boolean isLast, long chunkStartTimeUs, long nextChunkStartTimeUs, int trigger) {
  int nextChunkIndex = isLast ? -1 : chunkIndex + 1;
  long nextStartTimeUs = isLast ? -1 : nextChunkStartTimeUs;
  long offset = 0;
  DataSpec dataSpec = new DataSpec(uri, offset, -1, cacheKey);
  // In SmoothStreaming each chunk contains sample timestamps relative to the start of the chunk.
  // To convert them the absolute timestamps, we need to set sampleOffsetUs to -chunkStartTimeUs.
  return new Mp4MediaChunk(dataSource, dataSpec, formatInfo, trigger, chunkStartTimeUs,
      nextStartTimeUs, nextChunkIndex, extractor, false, -chunkStartTimeUs);
}
 
开发者ID:edx,项目名称:edx-app-android,代码行数:13,代码来源:SmoothStreamingChunkSource.java

示例15: sampleAvailable

import com.google.android.exoplayer.parser.Extractor; //导入依赖的package包/类
@Override
public boolean sampleAvailable() throws ParserException {
  NonBlockingInputStream inputStream = getNonBlockingInputStream();
  int result = extractor.read(inputStream, null);
  return (result & Extractor.RESULT_NEED_SAMPLE_HOLDER) != 0;
}
 
开发者ID:Weco,项目名称:android-exoplayer,代码行数:7,代码来源:Mp4MediaChunk.java


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