Java Code Examples for com.google.android.exoplayer2.C#TRACK_TYPE_METADATA

The following examples show how to use com.google.android.exoplayer2.C#TRACK_TYPE_METADATA . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MimeTypes.java    From K-Sonic with MIT License 6 votes vote down vote up
/**
 * Returns the {@link C}{@code .TRACK_TYPE_*} constant that corresponds to a specified mime type.
 * {@link C#TRACK_TYPE_UNKNOWN} if the mime type is not known or the mapping cannot be
 * established.
 *
 * @param mimeType The mimeType.
 * @return The {@link C}{@code .TRACK_TYPE_*} constant that corresponds to a specified mime type.
 */
public static int getTrackType(String mimeType) {
  if (TextUtils.isEmpty(mimeType)) {
    return C.TRACK_TYPE_UNKNOWN;
  } else if (isAudio(mimeType)) {
    return C.TRACK_TYPE_AUDIO;
  } else if (isVideo(mimeType)) {
    return C.TRACK_TYPE_VIDEO;
  } else if (isText(mimeType) || APPLICATION_CEA608.equals(mimeType)
      || APPLICATION_CEA708.equals(mimeType) || APPLICATION_MP4CEA608.equals(mimeType)
      || APPLICATION_SUBRIP.equals(mimeType) || APPLICATION_TTML.equals(mimeType)
      || APPLICATION_TX3G.equals(mimeType) || APPLICATION_MP4VTT.equals(mimeType)
      || APPLICATION_RAWCC.equals(mimeType) || APPLICATION_VOBSUB.equals(mimeType)
      || APPLICATION_PGS.equals(mimeType)) {
    return C.TRACK_TYPE_TEXT;
  } else if (APPLICATION_ID3.equals(mimeType)
      || APPLICATION_EMSG.equals(mimeType)
      || APPLICATION_SCTE35.equals(mimeType)
      || APPLICATION_CAMERA_MOTION.equals(mimeType)) {
    return C.TRACK_TYPE_METADATA;
  } else {
    return C.TRACK_TYPE_UNKNOWN;
  }
}
 
Example 2
Source File: EventLogger.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private static String getTrackTypeString(int trackType) {
  switch (trackType) {
    case C.TRACK_TYPE_AUDIO:
      return "audio";
    case C.TRACK_TYPE_DEFAULT:
      return "default";
    case C.TRACK_TYPE_METADATA:
      return "metadata";
    case C.TRACK_TYPE_CAMERA_MOTION:
      return "camera motion";
    case C.TRACK_TYPE_NONE:
      return "none";
    case C.TRACK_TYPE_TEXT:
      return "text";
    case C.TRACK_TYPE_VIDEO:
      return "video";
    default:
      return trackType >= C.TRACK_TYPE_CUSTOM_BASE ? "custom (" + trackType + ")" : "?";
  }
}
 
Example 3
Source File: MimeTypes.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Returns the {@link C}{@code .TRACK_TYPE_*} constant that corresponds to a specified MIME type.
 * {@link C#TRACK_TYPE_UNKNOWN} if the MIME type is not known or the mapping cannot be
 * established.
 *
 * @param mimeType The MIME type.
 * @return The {@link C}{@code .TRACK_TYPE_*} constant that corresponds to a specified MIME type.
 */
public static int getTrackType(@Nullable String mimeType) {
  if (TextUtils.isEmpty(mimeType)) {
    return C.TRACK_TYPE_UNKNOWN;
  } else if (isAudio(mimeType)) {
    return C.TRACK_TYPE_AUDIO;
  } else if (isVideo(mimeType)) {
    return C.TRACK_TYPE_VIDEO;
  } else if (isText(mimeType) || APPLICATION_CEA608.equals(mimeType)
      || APPLICATION_CEA708.equals(mimeType) || APPLICATION_MP4CEA608.equals(mimeType)
      || APPLICATION_SUBRIP.equals(mimeType) || APPLICATION_TTML.equals(mimeType)
      || APPLICATION_TX3G.equals(mimeType) || APPLICATION_MP4VTT.equals(mimeType)
      || APPLICATION_RAWCC.equals(mimeType) || APPLICATION_VOBSUB.equals(mimeType)
      || APPLICATION_PGS.equals(mimeType) || APPLICATION_DVBSUBS.equals(mimeType)) {
    return C.TRACK_TYPE_TEXT;
  } else if (APPLICATION_ID3.equals(mimeType)
      || APPLICATION_EMSG.equals(mimeType)
      || APPLICATION_SCTE35.equals(mimeType)) {
    return C.TRACK_TYPE_METADATA;
  } else if (APPLICATION_CAMERA_MOTION.equals(mimeType)) {
    return C.TRACK_TYPE_CAMERA_MOTION;
  } else {
    return getTrackTypeForCustomMimeType(mimeType);
  }
}
 
Example 4
Source File: DashMediaPeriod.java    From K-Sonic with MIT License 6 votes vote down vote up
private ChunkSampleStream<DashChunkSource> buildSampleStream(int adaptationSetIndex,
    TrackSelection selection, long positionUs) {
  AdaptationSet adaptationSet = adaptationSets.get(adaptationSetIndex);
  int embeddedTrackCount = 0;
  int[] embeddedTrackTypes = new int[2];
  boolean enableEventMessageTrack = hasEventMessageTrack(adaptationSet);
  if (enableEventMessageTrack) {
    embeddedTrackTypes[embeddedTrackCount++] = C.TRACK_TYPE_METADATA;
  }
  boolean enableCea608Track = hasCea608Track(adaptationSet);
  if (enableCea608Track) {
    embeddedTrackTypes[embeddedTrackCount++] = C.TRACK_TYPE_TEXT;
  }
  if (embeddedTrackCount < embeddedTrackTypes.length) {
    embeddedTrackTypes = Arrays.copyOf(embeddedTrackTypes, embeddedTrackCount);
  }
  DashChunkSource chunkSource = chunkSourceFactory.createDashChunkSource(
      manifestLoaderErrorThrower, manifest, periodIndex, adaptationSetIndex, selection,
      elapsedRealtimeOffset, enableEventMessageTrack, enableCea608Track);
  ChunkSampleStream<DashChunkSource> stream = new ChunkSampleStream<>(adaptationSet.type,
      embeddedTrackTypes, chunkSource, this, allocator, positionUs, minLoadableRetryCount,
      eventDispatcher);
  return stream;
}
 
Example 5
Source File: Util.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Maps a {@link C} {@code TRACK_TYPE_*} constant to the corresponding {@link C}
 * {@code DEFAULT_*_BUFFER_SIZE} constant.
 *
 * @param trackType The track type.
 * @return The corresponding default buffer size in bytes.
 */
public static int getDefaultBufferSize(int trackType) {
  switch (trackType) {
    case C.TRACK_TYPE_DEFAULT:
      return C.DEFAULT_MUXED_BUFFER_SIZE;
    case C.TRACK_TYPE_AUDIO:
      return C.DEFAULT_AUDIO_BUFFER_SIZE;
    case C.TRACK_TYPE_VIDEO:
      return C.DEFAULT_VIDEO_BUFFER_SIZE;
    case C.TRACK_TYPE_TEXT:
      return C.DEFAULT_TEXT_BUFFER_SIZE;
    case C.TRACK_TYPE_METADATA:
      return C.DEFAULT_METADATA_BUFFER_SIZE;
    default:
      throw new IllegalStateException();
  }
}
 
Example 6
Source File: MimeTypes.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Returns the {@link C}{@code .TRACK_TYPE_*} constant that corresponds to a specified MIME type.
 * {@link C#TRACK_TYPE_UNKNOWN} if the MIME type is not known or the mapping cannot be
 * established.
 *
 * @param mimeType The MIME type.
 * @return The {@link C}{@code .TRACK_TYPE_*} constant that corresponds to a specified MIME type.
 */
public static int getTrackType(@Nullable String mimeType) {
  if (TextUtils.isEmpty(mimeType)) {
    return C.TRACK_TYPE_UNKNOWN;
  } else if (isAudio(mimeType)) {
    return C.TRACK_TYPE_AUDIO;
  } else if (isVideo(mimeType)) {
    return C.TRACK_TYPE_VIDEO;
  } else if (isText(mimeType) || APPLICATION_CEA608.equals(mimeType)
      || APPLICATION_CEA708.equals(mimeType) || APPLICATION_MP4CEA608.equals(mimeType)
      || APPLICATION_SUBRIP.equals(mimeType) || APPLICATION_TTML.equals(mimeType)
      || APPLICATION_TX3G.equals(mimeType) || APPLICATION_MP4VTT.equals(mimeType)
      || APPLICATION_RAWCC.equals(mimeType) || APPLICATION_VOBSUB.equals(mimeType)
      || APPLICATION_PGS.equals(mimeType) || APPLICATION_DVBSUBS.equals(mimeType)) {
    return C.TRACK_TYPE_TEXT;
  } else if (APPLICATION_ID3.equals(mimeType)
      || APPLICATION_EMSG.equals(mimeType)
      || APPLICATION_SCTE35.equals(mimeType)) {
    return C.TRACK_TYPE_METADATA;
  } else if (APPLICATION_CAMERA_MOTION.equals(mimeType)) {
    return C.TRACK_TYPE_CAMERA_MOTION;
  } else {
    return getTrackTypeForCustomMimeType(mimeType);
  }
}
 
Example 7
Source File: EventLogger.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private static String getTrackTypeString(int trackType) {
  switch (trackType) {
    case C.TRACK_TYPE_AUDIO:
      return "audio";
    case C.TRACK_TYPE_DEFAULT:
      return "default";
    case C.TRACK_TYPE_METADATA:
      return "metadata";
    case C.TRACK_TYPE_NONE:
      return "none";
    case C.TRACK_TYPE_TEXT:
      return "text";
    case C.TRACK_TYPE_VIDEO:
      return "video";
    default:
      return trackType >= C.TRACK_TYPE_CUSTOM_BASE ? "custom (" + trackType + ")" : "?";
  }
}
 
Example 8
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public static TrackGroupInfo embeddedEmsgTrack(int[] adaptationSetIndices,
    int primaryTrackGroupIndex) {
  return new TrackGroupInfo(
      C.TRACK_TYPE_METADATA,
      CATEGORY_EMBEDDED,
      adaptationSetIndices,
      primaryTrackGroupIndex,
      C.INDEX_UNSET,
      C.INDEX_UNSET,
      -1);
}
 
Example 9
Source File: AtomParsers.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
/** Returns the track type for a given handler value. */
private static int getTrackTypeForHdlr(int hdlr) {
  if (hdlr == TYPE_soun) {
    return C.TRACK_TYPE_AUDIO;
  } else if (hdlr == TYPE_vide) {
    return C.TRACK_TYPE_VIDEO;
  } else if (hdlr == TYPE_text || hdlr == TYPE_sbtl || hdlr == TYPE_subt || hdlr == TYPE_clcp) {
    return C.TRACK_TYPE_TEXT;
  } else if (hdlr == TYPE_meta) {
    return C.TRACK_TYPE_METADATA;
  } else {
    return C.TRACK_TYPE_UNKNOWN;
  }
}
 
Example 10
Source File: HlsSampleStreamWrapper.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public TrackOutput track(int id, int type) {
  @Nullable TrackOutput trackOutput = null;
  if (MAPPABLE_TYPES.contains(type)) {
    // Track types in MAPPABLE_TYPES are handled manually to ignore IDs.
    trackOutput = getMappedTrackOutput(id, type);
  } else /* non-mappable type track */ {
    for (int i = 0; i < sampleQueues.length; i++) {
      if (sampleQueueTrackIds[i] == id) {
        trackOutput = sampleQueues[i];
        break;
      }
    }
  }

  if (trackOutput == null) {
    if (tracksEnded) {
      return createDummyTrackOutput(id, type);
    } else {
      // The relevant SampleQueue hasn't been constructed yet - so construct it.
      trackOutput = createSampleQueue(id, type);
    }
  }

  if (type == C.TRACK_TYPE_METADATA) {
    if (emsgUnwrappingTrackOutput == null) {
      emsgUnwrappingTrackOutput = new EmsgUnwrappingTrackOutput(trackOutput, metadataType);
    }
    return emsgUnwrappingTrackOutput;
  }
  return trackOutput;
}
 
Example 11
Source File: MetadataRenderer.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param output The output.
 * @param outputLooper The looper associated with the thread on which the output should be called.
 *     If the output makes use of standard Android UI components, then this should normally be the
 *     looper associated with the application's main thread, which can be obtained using {@link
 *     android.app.Activity#getMainLooper()}. Null may be passed if the output should be called
 *     directly on the player's internal rendering thread.
 * @param decoderFactory A factory from which to obtain {@link MetadataDecoder} instances.
 */
public MetadataRenderer(
    MetadataOutput output, @Nullable Looper outputLooper, MetadataDecoderFactory decoderFactory) {
  super(C.TRACK_TYPE_METADATA);
  this.output = Assertions.checkNotNull(output);
  this.outputHandler =
      outputLooper == null ? null : Util.createHandler(outputLooper, /* callback= */ this);
  this.decoderFactory = Assertions.checkNotNull(decoderFactory);
  formatHolder = new FormatHolder();
  buffer = new MetadataInputBuffer();
  pendingMetadata = new Metadata[MAX_PENDING_METADATA_COUNT];
  pendingMetadataTimestamps = new long[MAX_PENDING_METADATA_COUNT];
}
 
Example 12
Source File: DashMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public static TrackGroupInfo mpdEventTrack(int eventStreamIndex) {
  return new TrackGroupInfo(
      C.TRACK_TYPE_METADATA,
      CATEGORY_MANIFEST_EVENTS,
      new int[0],
      /* primaryTrackGroupIndex= */ -1,
      C.INDEX_UNSET,
      C.INDEX_UNSET,
      eventStreamIndex);
}
 
Example 13
Source File: MetadataRenderer.java    From K-Sonic with MIT License 5 votes vote down vote up
/**
 * @param output The output.
 * @param outputLooper The looper associated with the thread on which the output should be called.
 *     If the output makes use of standard Android UI components, then this should normally be the
 *     looper associated with the application's main thread, which can be obtained using
 *     {@link android.app.Activity#getMainLooper()}. Null may be passed if the output should be
 *     called directly on the player's internal rendering thread.
 * @param decoderFactory A factory from which to obtain {@link MetadataDecoder} instances.
 */
public MetadataRenderer(Output output, Looper outputLooper,
    MetadataDecoderFactory decoderFactory) {
  super(C.TRACK_TYPE_METADATA);
  this.output = Assertions.checkNotNull(output);
  this.outputHandler = outputLooper == null ? null : new Handler(outputLooper, this);
  this.decoderFactory = Assertions.checkNotNull(decoderFactory);
  formatHolder = new FormatHolder();
  buffer = new MetadataInputBuffer();
  pendingMetadata = new Metadata[MAX_PENDING_METADATA_COUNT];
  pendingMetadataTimestamps = new long[MAX_PENDING_METADATA_COUNT];
}
 
Example 14
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
public static TrackGroupInfo mpdEventTrack(int eventStreamIndex) {
  return new TrackGroupInfo(
      C.TRACK_TYPE_METADATA,
      CATEGORY_MANIFEST_EVENTS,
      null,
      -1,
      C.INDEX_UNSET,
      C.INDEX_UNSET,
      eventStreamIndex);
}
 
Example 15
Source File: MetadataRenderer.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param output The output.
 * @param outputLooper The looper associated with the thread on which the output should be called.
 *     If the output makes use of standard Android UI components, then this should normally be the
 *     looper associated with the application's main thread, which can be obtained using {@link
 *     android.app.Activity#getMainLooper()}. Null may be passed if the output should be called
 *     directly on the player's internal rendering thread.
 * @param decoderFactory A factory from which to obtain {@link MetadataDecoder} instances.
 */
public MetadataRenderer(
    MetadataOutput output, @Nullable Looper outputLooper, MetadataDecoderFactory decoderFactory) {
  super(C.TRACK_TYPE_METADATA);
  this.output = Assertions.checkNotNull(output);
  this.outputHandler =
      outputLooper == null ? null : Util.createHandler(outputLooper, /* callback= */ this);
  this.decoderFactory = Assertions.checkNotNull(decoderFactory);
  formatHolder = new FormatHolder();
  buffer = new MetadataInputBuffer();
  pendingMetadata = new Metadata[MAX_PENDING_METADATA_COUNT];
  pendingMetadataTimestamps = new long[MAX_PENDING_METADATA_COUNT];
}
 
Example 16
Source File: MetadataRenderer.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * @param output The output.
 * @param outputLooper The looper associated with the thread on which the output should be called.
 *     If the output makes use of standard Android UI components, then this should normally be the
 *     looper associated with the application's main thread, which can be obtained using {@link
 *     android.app.Activity#getMainLooper()}. Null may be passed if the output should be called
 *     directly on the player's internal rendering thread.
 * @param decoderFactory A factory from which to obtain {@link MetadataDecoder} instances.
 */
public MetadataRenderer(
    MetadataOutput output, @Nullable Looper outputLooper, MetadataDecoderFactory decoderFactory) {
  super(C.TRACK_TYPE_METADATA);
  this.output = Assertions.checkNotNull(output);
  this.outputHandler =
      outputLooper == null ? null : Util.createHandler(outputLooper, /* callback= */ this);
  this.decoderFactory = Assertions.checkNotNull(decoderFactory);
  formatHolder = new FormatHolder();
  buffer = new MetadataInputBuffer();
  pendingMetadata = new Metadata[MAX_PENDING_METADATA_COUNT];
  pendingMetadataTimestamps = new long[MAX_PENDING_METADATA_COUNT];
}
 
Example 17
Source File: DashMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public static TrackGroupInfo embeddedEmsgTrack(int[] adaptationSetIndices,
    int primaryTrackGroupIndex) {
  return new TrackGroupInfo(
      C.TRACK_TYPE_METADATA,
      CATEGORY_EMBEDDED,
      adaptationSetIndices,
      primaryTrackGroupIndex,
      C.INDEX_UNSET,
      C.INDEX_UNSET,
      /* eventStreamGroupIndex= */ -1);
}
 
Example 18
Source File: DashMediaPeriod.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
public static TrackGroupInfo embeddedEmsgTrack(int[] adaptationSetIndices,
    int primaryTrackGroupIndex) {
  return new TrackGroupInfo(
      C.TRACK_TYPE_METADATA,
      CATEGORY_EMBEDDED,
      adaptationSetIndices,
      primaryTrackGroupIndex,
      C.INDEX_UNSET,
      C.INDEX_UNSET,
      /* eventStreamGroupIndex= */ -1);
}
 
Example 19
Source File: DashMediaPeriod.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public static TrackGroupInfo embeddedEmsgTrack(int[] adaptationSetIndices,
    int primaryTrackGroupIndex) {
  return new TrackGroupInfo(
      C.TRACK_TYPE_METADATA,
      CATEGORY_EMBEDDED,
      adaptationSetIndices,
      primaryTrackGroupIndex,
      C.INDEX_UNSET,
      C.INDEX_UNSET,
      /* eventStreamGroupIndex= */ -1);
}
 
Example 20
Source File: HlsSampleStreamWrapper.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
@Override
public TrackOutput track(int id, int type) {
  @Nullable TrackOutput trackOutput = null;
  if (MAPPABLE_TYPES.contains(type)) {
    // Track types in MAPPABLE_TYPES are handled manually to ignore IDs.
    trackOutput = getMappedTrackOutput(id, type);
  } else /* non-mappable type track */ {
    for (int i = 0; i < sampleQueues.length; i++) {
      if (sampleQueueTrackIds[i] == id) {
        trackOutput = sampleQueues[i];
        break;
      }
    }
  }

  if (trackOutput == null) {
    if (tracksEnded) {
      return createDummyTrackOutput(id, type);
    } else {
      // The relevant SampleQueue hasn't been constructed yet - so construct it.
      trackOutput = createSampleQueue(id, type);
    }
  }

  if (type == C.TRACK_TYPE_METADATA) {
    if (emsgUnwrappingTrackOutput == null) {
      emsgUnwrappingTrackOutput = new EmsgUnwrappingTrackOutput(trackOutput, metadataType);
    }
    return emsgUnwrappingTrackOutput;
  }
  return trackOutput;
}