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


Java MediaFormat.createTextFormat方法代码示例

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


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

示例1: getTrackFormat

import com.google.android.exoplayer.MediaFormat; //导入方法依赖的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

示例2: parseStsd

import com.google.android.exoplayer.MediaFormat; //导入方法依赖的package包/类
private static StsdDataHolder parseStsd(ParsableByteArray stsd, long durationUs) {
  stsd.setPosition(Atom.FULL_HEADER_SIZE);
  int numberOfEntries = stsd.readInt();
  StsdDataHolder holder = new StsdDataHolder(numberOfEntries);
  for (int i = 0; i < numberOfEntries; i++) {
    int childStartPosition = stsd.getPosition();
    int childAtomSize = stsd.readInt();
    Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
    int childAtomType = stsd.readInt();
    if (childAtomType == Atom.TYPE_avc1 || childAtomType == Atom.TYPE_avc3
        || childAtomType == Atom.TYPE_encv || childAtomType == Atom.TYPE_mp4v
        || childAtomType == Atom.TYPE_hvc1 || childAtomType == Atom.TYPE_hev1
        || childAtomType == Atom.TYPE_s263) {
      parseVideoSampleEntry(stsd, childStartPosition, childAtomSize, durationUs, holder, i);
    } else if (childAtomType == Atom.TYPE_mp4a || childAtomType == Atom.TYPE_enca
        || childAtomType == Atom.TYPE_ac_3) {
      parseAudioSampleEntry(stsd, childAtomType, childStartPosition, childAtomSize, durationUs,
          holder, i);
    } else if (childAtomType == Atom.TYPE_TTML) {
      holder.mediaFormat = MediaFormat.createTextFormat(MimeTypes.APPLICATION_TTML, durationUs);
    } else if (childAtomType == Atom.TYPE_tx3g) {
      holder.mediaFormat = MediaFormat.createTextFormat(MimeTypes.APPLICATION_TX3G, durationUs);
    }
    stsd.setPosition(childStartPosition + childAtomSize);
  }
  return holder;
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:28,代码来源:AtomParsers.java

示例3: newMediaChunk

import com.google.android.exoplayer.MediaFormat; //导入方法依赖的package包/类
private Chunk newMediaChunk(RepresentationHolder representationHolder, DataSource dataSource,
    int segmentNum, int trigger) {
  Representation representation = representationHolder.representation;
  DashSegmentIndex segmentIndex = representationHolder.segmentIndex;

  long startTimeUs = segmentIndex.getTimeUs(segmentNum);
  long endTimeUs = startTimeUs + segmentIndex.getDurationUs(segmentNum);

  int absoluteSegmentNum = segmentNum + representationHolder.segmentNumShift;
  boolean isLastSegment = !currentManifest.dynamic
      && segmentNum == segmentIndex.getLastSegmentNum();

  RangedUri segmentUri = segmentIndex.getSegmentUrl(segmentNum);
  DataSpec dataSpec = new DataSpec(segmentUri.getUri(), segmentUri.start, segmentUri.length,
      representation.getCacheKey());

  long sampleOffsetUs = representation.periodStartMs * 1000
      - representation.presentationTimeOffsetUs;
  if (representation.format.mimeType.equals(MimeTypes.TEXT_VTT)) {
    if (representationHolder.vttHeaderOffsetUs != sampleOffsetUs) {
      // Update the VTT header.
      headerBuilder.setLength(0);
      headerBuilder.append(C.WEBVTT_EXO_HEADER).append("=")
          .append(C.WEBVTT_EXO_HEADER_OFFSET).append(sampleOffsetUs)
          .append("\n");
      representationHolder.vttHeader = headerBuilder.toString().getBytes();
      representationHolder.vttHeaderOffsetUs = sampleOffsetUs;
    }
    return new SingleSampleMediaChunk(dataSource, dataSpec, Chunk.TRIGGER_INITIAL,
        representation.format, startTimeUs, endTimeUs, absoluteSegmentNum, isLastSegment,
        MediaFormat.createTextFormat(MimeTypes.TEXT_VTT), null, representationHolder.vttHeader);
  } else {
    return new ContainerMediaChunk(dataSource, dataSpec, trigger, representation.format,
        startTimeUs, endTimeUs, absoluteSegmentNum, isLastSegment, sampleOffsetUs,
        representationHolder.extractorWrapper, representationHolder.format, drmInitData, true);
  }
}
 
开发者ID:XueyanLiu,项目名称:miku,代码行数:38,代码来源:DashChunkSource.java

示例4: parseStsd

import com.google.android.exoplayer.MediaFormat; //导入方法依赖的package包/类
/**
 * Parses a stsd atom (defined in 14496-12).
 *
 * @param stsd The stsd atom to parse.
 * @param trackId The track's identifier in its container.
 * @param durationUs The duration of the track in microseconds.
 * @param rotationDegrees The rotation of the track in degrees.
 * @param language The language of the track.
 * @param isQuickTime True for QuickTime media. False otherwise.
 * @return An object containing the parsed data.
 */
private static StsdData parseStsd(ParsableByteArray stsd, int trackId, long durationUs,
    int rotationDegrees, String language, boolean isQuickTime) {
  stsd.setPosition(Atom.FULL_HEADER_SIZE);
  int numberOfEntries = stsd.readInt();
  StsdData out = new StsdData(numberOfEntries);
  for (int i = 0; i < numberOfEntries; i++) {
    int childStartPosition = stsd.getPosition();
    int childAtomSize = stsd.readInt();
    Assertions.checkArgument(childAtomSize > 0, "childAtomSize should be positive");
    int childAtomType = stsd.readInt();
    if (childAtomType == Atom.TYPE_avc1 || childAtomType == Atom.TYPE_avc3
        || childAtomType == Atom.TYPE_encv || childAtomType == Atom.TYPE_mp4v
        || childAtomType == Atom.TYPE_hvc1 || childAtomType == Atom.TYPE_hev1
        || childAtomType == Atom.TYPE_s263) {
      parseVideoSampleEntry(stsd, childAtomType, childStartPosition, childAtomSize, trackId,
          durationUs, rotationDegrees, out, i);
    } else if (childAtomType == Atom.TYPE_mp4a || childAtomType == Atom.TYPE_enca
        || childAtomType == Atom.TYPE_ac_3 || childAtomType == Atom.TYPE_ec_3
        || childAtomType == Atom.TYPE_dtsc || childAtomType == Atom.TYPE_dtse
        || childAtomType == Atom.TYPE_dtsh || childAtomType == Atom.TYPE_dtsl
        || childAtomType == Atom.TYPE_samr || childAtomType == Atom.TYPE_sawb
        || childAtomType == Atom.TYPE_lpcm || childAtomType == Atom.TYPE_sowt) {
      parseAudioSampleEntry(stsd, childAtomType, childStartPosition, childAtomSize, trackId,
          durationUs, language, isQuickTime, out, i);
    } else if (childAtomType == Atom.TYPE_TTML) {
      out.mediaFormat = MediaFormat.createTextFormat(Integer.toString(trackId),
          MimeTypes.APPLICATION_TTML, MediaFormat.NO_VALUE, durationUs, language);
    } else if (childAtomType == Atom.TYPE_tx3g) {
      out.mediaFormat = MediaFormat.createTextFormat(Integer.toString(trackId),
          MimeTypes.APPLICATION_TX3G, MediaFormat.NO_VALUE, durationUs, language);
    } else if (childAtomType == Atom.TYPE_wvtt) {
      out.mediaFormat = MediaFormat.createTextFormat(Integer.toString(trackId),
          MimeTypes.APPLICATION_MP4VTT, MediaFormat.NO_VALUE, durationUs, language);
    } else if (childAtomType == Atom.TYPE_stpp) {
      out.mediaFormat = MediaFormat.createTextFormat(Integer.toString(trackId),
          MimeTypes.APPLICATION_TTML, MediaFormat.NO_VALUE, durationUs, language,
          0 /* subsample timing is absolute */);
    }
    stsd.setPosition(childStartPosition + childAtomSize);
  }
  return out;
}
 
开发者ID:asifkhan11,项目名称:ExoPlayer-Demo,代码行数:54,代码来源:AtomParsers.java


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