com.google.android.exoplayer2.Format类的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(8.5k)|赞(0)|评价(0)|浏览(155)

本文整理了Java中com.google.android.exoplayer2.Format类的一些代码示例,展示了Format类的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Format类的具体详情如下:
包路径:com.google.android.exoplayer2.Format
类名称:Format

Format介绍

[英]Representation of a media format.
[中]媒体格式的表示。

代码示例

代码示例来源:origin: google/ExoPlayer

@Nullable List<byte[]> initializationData,
 @C.SelectionFlags int selectionFlags) {
return createVideoContainerFormat(
  id,
 @Nullable List<byte[]> initializationData,
 @C.SelectionFlags int selectionFlags) {
return new Format(
  id,
  label,
 @Nullable List<byte[]> initializationData,
 @Nullable DrmInitData drmInitData) {
return createVideoSampleFormat(
  id,
  sampleMimeType,
 float pixelWidthHeightRatio,
 @Nullable DrmInitData drmInitData) {
return createVideoSampleFormat(
  id,
  sampleMimeType,
 @Nullable ColorInfo colorInfo,
 @Nullable DrmInitData drmInitData) {
return new Format(
  id,
 @C.SelectionFlags int selectionFlags,

代码示例来源:origin: google/ExoPlayer

return Format.createVideoContainerFormat(
    id,
    label,
  return Format.createAudioContainerFormat(
    id,
    label,
   accessibilityChannel = Format.NO_VALUE;
  return Format.createTextContainerFormat(
    id,
    label,
return Format.createContainerFormat(
  id, label, containerMimeType, sampleMimeType, codecs, bitrate, selectionFlags, language);

代码示例来源:origin: google/ExoPlayer

cea608TrackGroupIndex);
if (eventMessageTrackGroupIndex != C.INDEX_UNSET) {
 Format format = Format.createSampleFormat(firstAdaptationSet.id + ":emsg",
   MimeTypes.APPLICATION_EMSG, null, Format.NO_VALUE, null);
 trackGroups[eventMessageTrackGroupIndex] = new TrackGroup(format);
 Format format = Format.createTextSampleFormat(firstAdaptationSet.id + ":cea608",
   MimeTypes.APPLICATION_CEA608, 0, null);
 trackGroups[cea608TrackGroupIndex] = new TrackGroup(format);

代码示例来源:origin: google/ExoPlayer

/**
 * Returns the format of audio buffers output by the decoder. Will not be called until the first
 * output buffer has been dequeued, so the decoder may use input data to determine the format.
 * <p>
 * The default implementation returns a 16-bit PCM format with the same channel count and sample
 * rate as the input.
 */
protected Format getOutputFormat() {
 return Format.createAudioSampleFormat(null, MimeTypes.AUDIO_RAW, null, Format.NO_VALUE,
   Format.NO_VALUE, inputFormat.channelCount, inputFormat.sampleRate, C.ENCODING_PCM_16BIT,
   null, null, 0, null);
}

代码示例来源:origin: google/ExoPlayer

/**
 * @param flags A combination of {@code FLAG_*} values that control the behavior of the created
 *     readers.
 */
public DefaultTsPayloadReaderFactory(@Flags int flags) {
 this(
   flags,
   Collections.singletonList(
     Format.createTextSampleFormat(null, MimeTypes.APPLICATION_CEA608, 0, null)));
}

代码示例来源:origin: google/ExoPlayer

format = Format.createAudioSampleFormat(Integer.toString(trackId), mimeType, null,
   Format.NO_VALUE, maxInputSize, channelCount, sampleRate, pcmEncoding,
   initializationData, drmInitData, selectionFlags, language);
   Format.createVideoSampleFormat(
     Integer.toString(trackId),
     mimeType,
} else if (MimeTypes.APPLICATION_SUBRIP.equals(mimeType)) {
 type = C.TRACK_TYPE_TEXT;
 format = Format.createTextSampleFormat(Integer.toString(trackId), mimeType, selectionFlags,
   language, drmInitData);
} else if (MimeTypes.TEXT_SSA.equals(mimeType)) {
 initializationData.add(SSA_DIALOGUE_FORMAT);
 initializationData.add(codecPrivate);
 format = Format.createTextSampleFormat(Integer.toString(trackId), mimeType, null,
   Format.NO_VALUE, selectionFlags, language, Format.NO_VALUE, drmInitData,
   Format.OFFSET_SAMPLE_RELATIVE, initializationData);
 type = C.TRACK_TYPE_TEXT;
 format =
   Format.createImageSampleFormat(
     Integer.toString(trackId),
     mimeType,

代码示例来源:origin: google/ExoPlayer

@Override
public void onDownstreamFormatChanged(EventTime eventTime, MediaLoadData mediaLoadData) {
 logd(eventTime, "downstreamFormatChanged", Format.toLogString(mediaLoadData.trackFormat));
}

代码示例来源:origin: google/ExoPlayer

public static final Format VIDEO_FORMAT = Format.createVideoSampleFormat(null,
  MimeTypes.VIDEO_H264, null, Format.NO_VALUE, Format.NO_VALUE, 1280, 720, Format.NO_VALUE,
  null, null);
public static final Format AUDIO_FORMAT = Format.createAudioSampleFormat(null,
  MimeTypes.AUDIO_AAC, null, Format.NO_VALUE, Format.NO_VALUE, 2, 44100, null, null, 0, null);

代码示例来源:origin: google/ExoPlayer

Format.createVideoContainerFormat(
 String sampleMimeType = codecs != null ? MimeTypes.getMediaMimeType(codecs) : null;
 format =
   Format.createAudioContainerFormat(
case TYPE_SUBTITLES:
 format =
   Format.createTextContainerFormat(
   Format.createTextContainerFormat(

代码示例来源:origin: google/ExoPlayer

private static Format buildVideoFormat(String id) {
 return Format.createVideoSampleFormat(
   id,
   MimeTypes.VIDEO_H264,
   null,
   Format.NO_VALUE,
   Format.NO_VALUE,
   1024,
   768,
   Format.NO_VALUE,
   null,
   null);
}

代码示例来源:origin: google/ExoPlayer

private static void buildManifestEventTrackGroupInfos(List<EventStream> eventStreams,
  TrackGroup[] trackGroups, TrackGroupInfo[] trackGroupInfos, int existingTrackGroupCount) {
 for (int i = 0; i < eventStreams.size(); i++) {
  EventStream eventStream = eventStreams.get(i);
  Format format = Format.createSampleFormat(eventStream.id(), MimeTypes.APPLICATION_EMSG, null,
    Format.NO_VALUE, null);
  trackGroups[existingTrackGroupCount] = new TrackGroup(format);
  trackGroupInfos[existingTrackGroupCount++] = TrackGroupInfo.mpdEventTrack(i);
 }
}

代码示例来源:origin: google/ExoPlayer

private static Format newFormat(String id) {
  return Format.createContainerFormat(
    id,
    /* label= */ null,
    MimeTypes.VIDEO_MP4,
    MimeTypes.VIDEO_H264,
    /* codecs= */ null,
    /* bitrate= */ Format.NO_VALUE,
    /* selectionFlags= */ 0,
    /* language= */ null);
 }
}

代码示例来源:origin: google/ExoPlayer

private static Representation newRepresentations(DrmInitData drmInitData) {
 Format format =
   Format.createVideoContainerFormat(
     "id",
     "label",
     MimeTypes.VIDEO_MP4,
     MimeTypes.VIDEO_H264,
     /* codecs= */ "",
     Format.NO_VALUE,
     /* width= */ 1024,
     /* height= */ 768,
     Format.NO_VALUE,
     /* initializationData= */ null,
     /* selectionFlags= */ 0);
 if (drmInitData != null) {
  format = format.copyWithDrmInitData(drmInitData);
 }
 return Representation.newInstance("", 0, format, "", new SingleSegmentBase());
}

代码示例来源:origin: google/ExoPlayer

private static Format buildTextFormat(String id, String language, int selectionFlags) {
 return Format.createTextContainerFormat(
   id,
   /* label= */ null,
   /* containerMimeType= */ null,
   /* sampleMimeType= */ MimeTypes.TEXT_VTT,
   /* codecs= */ null,
   /* bitrate= */ Format.NO_VALUE,
   selectionFlags,
   language);
}

代码示例来源:origin: google/ExoPlayer

private static Format createVideoContainerFormat(String id) {
  return Format.createVideoContainerFormat(
    id,
    "label",
    /* containerMimeType= */ MimeTypes.APPLICATION_MP4,
    /* sampleMimeType= */ MimeTypes.VIDEO_H264,
    /* codecs= */ null,
    /* bitrate= */ 2500000,
    /* width= */ 1920,
    /* height= */ 1080,
    /* frameRate= */ Format.NO_VALUE,
    /* initializationData= */ null,
    /* selectionFlags= */ 0);
 }
}

代码示例来源:origin: google/ExoPlayer

protected Representation buildRepresentation(RepresentationInfo representationInfo,
  String contentId, String extraDrmSchemeType, ArrayList<SchemeData> extraDrmSchemeDatas,
  ArrayList<Descriptor> extraInbandEventStreams) {
 Format format = representationInfo.format;
 String drmSchemeType = representationInfo.drmSchemeType != null
   ? representationInfo.drmSchemeType : extraDrmSchemeType;
 ArrayList<SchemeData> drmSchemeDatas = representationInfo.drmSchemeDatas;
 drmSchemeDatas.addAll(extraDrmSchemeDatas);
 if (!drmSchemeDatas.isEmpty()) {
  filterRedundantIncompleteSchemeDatas(drmSchemeDatas);
  DrmInitData drmInitData = new DrmInitData(drmSchemeType, drmSchemeDatas);
  format = format.copyWithDrmInitData(drmInitData);
 }
 ArrayList<Descriptor> inbandEventStreams = representationInfo.inbandEventStreams;
 inbandEventStreams.addAll(extraInbandEventStreams);
 return Representation.newInstance(contentId, representationInfo.revisionId, format,
   representationInfo.baseUrl, representationInfo.segmentBase, inbandEventStreams);
}

代码示例来源:origin: google/ExoPlayer

return Format.createAudioContainerFormat(
  variantFormat.id,
  label,

代码示例来源:origin: google/ExoPlayer

private static Format buildAudioFormat(String id, String language, int selectionFlags) {
 return Format.createAudioSampleFormat(
   id,
   MimeTypes.AUDIO_AAC,
   /* codecs= */ null,
   /* bitrate= */ Format.NO_VALUE,
   /* maxInputSize= */ Format.NO_VALUE,
   /* channelCount= */ 2,
   /* sampleRate= */ 44100,
   /* initializationData= */ null,
   /* drmInitData= */ null,
   selectionFlags,
   language);
}

代码示例来源:origin: google/ExoPlayer

public static Format createTextSampleFormat(
  @Nullable String id,
  String sampleMimeType,
  @C.SelectionFlags int selectionFlags,
  @Nullable String language,
  @Nullable DrmInitData drmInitData) {
 return createTextSampleFormat(
   id,
   sampleMimeType,
   /* codecs= */ null,
   /* bitrate= */ NO_VALUE,
   selectionFlags,
   language,
   NO_VALUE,
   drmInitData,
   OFFSET_SAMPLE_RELATIVE,
   Collections.emptyList());
}

代码示例来源:origin: google/ExoPlayer

@Override
public void onUpstreamDiscarded(EventTime eventTime, MediaLoadData mediaLoadData) {
 logd(eventTime, "upstreamDiscarded", Format.toLogString(mediaLoadData.trackFormat));
}

相关文章