com.google.android.exoplayer2.source.dash.manifest.EventStream Java Examples

The following examples show how to use com.google.android.exoplayer2.source.dash.manifest.EventStream. 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: DashMediaPeriod.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Updates the {@link DashManifest} and the index of this period in the manifest.
 *
 * @param manifest The updated manifest.
 * @param periodIndex the new index of this period in the updated manifest.
 */
public void updateManifest(DashManifest manifest, int periodIndex) {
  this.manifest = manifest;
  this.periodIndex = periodIndex;
  playerEmsgHandler.updateManifest(manifest);
  if (sampleStreams != null) {
    for (ChunkSampleStream<DashChunkSource> sampleStream : sampleStreams) {
      sampleStream.getChunkSource().updateManifest(manifest, periodIndex);
    }
    callback.onContinueLoadingRequested(this);
  }
  eventStreams = manifest.getPeriod(periodIndex).eventStreams;
  for (EventSampleStream eventSampleStream : eventSampleStreams) {
    for (EventStream eventStream : eventStreams) {
      if (eventStream.id().equals(eventSampleStream.eventStreamId())) {
        int lastPeriodIndex = manifest.getPeriodCount() - 1;
        eventSampleStream.updateEventStream(
            eventStream,
            /* eventStreamAppendable= */ manifest.dynamic && periodIndex == lastPeriodIndex);
        break;
      }
    }
  }
}
 
Example #2
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private static Pair<TrackGroupArray, TrackGroupInfo[]> buildTrackGroups(
    List<AdaptationSet> adaptationSets, List<EventStream> eventStreams) {
  int[][] groupedAdaptationSetIndices = getGroupedAdaptationSetIndices(adaptationSets);

  int primaryGroupCount = groupedAdaptationSetIndices.length;
  boolean[] primaryGroupHasEventMessageTrackFlags = new boolean[primaryGroupCount];
  boolean[] primaryGroupHasCea608TrackFlags = new boolean[primaryGroupCount];
  int totalEmbeddedTrackGroupCount = identifyEmbeddedTracks(primaryGroupCount, adaptationSets,
      groupedAdaptationSetIndices, primaryGroupHasEventMessageTrackFlags,
      primaryGroupHasCea608TrackFlags);

  int totalGroupCount = primaryGroupCount + totalEmbeddedTrackGroupCount + eventStreams.size();
  TrackGroup[] trackGroups = new TrackGroup[totalGroupCount];
  TrackGroupInfo[] trackGroupInfos = new TrackGroupInfo[totalGroupCount];

  int trackGroupCount = buildPrimaryAndEmbeddedTrackGroupInfos(adaptationSets,
      groupedAdaptationSetIndices, primaryGroupCount, primaryGroupHasEventMessageTrackFlags,
      primaryGroupHasCea608TrackFlags, trackGroups, trackGroupInfos);

  buildManifestEventTrackGroupInfos(eventStreams, trackGroups, trackGroupInfos, trackGroupCount);

  return Pair.create(new TrackGroupArray(trackGroups), trackGroupInfos);
}
 
Example #3
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private static Pair<TrackGroupArray, TrackGroupInfo[]> buildTrackGroups(
    List<AdaptationSet> adaptationSets, List<EventStream> eventStreams) {
  int[][] groupedAdaptationSetIndices = getGroupedAdaptationSetIndices(adaptationSets);

  int primaryGroupCount = groupedAdaptationSetIndices.length;
  boolean[] primaryGroupHasEventMessageTrackFlags = new boolean[primaryGroupCount];
  boolean[] primaryGroupHasCea608TrackFlags = new boolean[primaryGroupCount];
  int totalEmbeddedTrackGroupCount = identifyEmbeddedTracks(primaryGroupCount, adaptationSets,
      groupedAdaptationSetIndices, primaryGroupHasEventMessageTrackFlags,
      primaryGroupHasCea608TrackFlags);

  int totalGroupCount = primaryGroupCount + totalEmbeddedTrackGroupCount + eventStreams.size();
  TrackGroup[] trackGroups = new TrackGroup[totalGroupCount];
  TrackGroupInfo[] trackGroupInfos = new TrackGroupInfo[totalGroupCount];

  int trackGroupCount = buildPrimaryAndEmbeddedTrackGroupInfos(adaptationSets,
      groupedAdaptationSetIndices, primaryGroupCount, primaryGroupHasEventMessageTrackFlags,
      primaryGroupHasCea608TrackFlags, trackGroups, trackGroupInfos);

  buildManifestEventTrackGroupInfos(eventStreams, trackGroups, trackGroupInfos, trackGroupCount);

  return Pair.create(new TrackGroupArray(trackGroups), trackGroupInfos);
}
 
Example #4
Source File: DashMediaPeriod.java    From MediaSDK with Apache License 2.0 6 votes vote down vote up
/**
 * Updates the {@link DashManifest} and the index of this period in the manifest.
 *
 * @param manifest The updated manifest.
 * @param periodIndex the new index of this period in the updated manifest.
 */
public void updateManifest(DashManifest manifest, int periodIndex) {
  this.manifest = manifest;
  this.periodIndex = periodIndex;
  playerEmsgHandler.updateManifest(manifest);
  if (sampleStreams != null) {
    for (ChunkSampleStream<DashChunkSource> sampleStream : sampleStreams) {
      sampleStream.getChunkSource().updateManifest(manifest, periodIndex);
    }
    callback.onContinueLoadingRequested(this);
  }
  eventStreams = manifest.getPeriod(periodIndex).eventStreams;
  for (EventSampleStream eventSampleStream : eventSampleStreams) {
    for (EventStream eventStream : eventStreams) {
      if (eventStream.id().equals(eventSampleStream.eventStreamId())) {
        int lastPeriodIndex = manifest.getPeriodCount() - 1;
        eventSampleStream.updateEventStream(
            eventStream,
            /* eventStreamAppendable= */ manifest.dynamic && periodIndex == lastPeriodIndex);
        break;
      }
    }
  }
}
 
Example #5
Source File: DashMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Updates the {@link DashManifest} and the index of this period in the manifest.
 *
 * @param manifest The updated manifest.
 * @param periodIndex the new index of this period in the updated manifest.
 */
public void updateManifest(DashManifest manifest, int periodIndex) {
  this.manifest = manifest;
  this.periodIndex = periodIndex;
  playerEmsgHandler.updateManifest(manifest);
  if (sampleStreams != null) {
    for (ChunkSampleStream<DashChunkSource> sampleStream : sampleStreams) {
      sampleStream.getChunkSource().updateManifest(manifest, periodIndex);
    }
    callback.onContinueLoadingRequested(this);
  }
  eventStreams = manifest.getPeriod(periodIndex).eventStreams;
  for (EventSampleStream eventSampleStream : eventSampleStreams) {
    for (EventStream eventStream : eventStreams) {
      if (eventStream.id().equals(eventSampleStream.eventStreamId())) {
        int lastPeriodIndex = manifest.getPeriodCount() - 1;
        eventSampleStream.updateEventStream(
            eventStream,
            /* eventStreamAppendable= */ manifest.dynamic && periodIndex == lastPeriodIndex);
        break;
      }
    }
  }
}
 
Example #6
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
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);
  }
}
 
Example #7
Source File: EventSampleStream.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public void updateEventStream(EventStream eventStream, boolean eventStreamAppendable) {
  long lastReadPositionUs = currentIndex == 0 ? C.TIME_UNSET : eventTimesUs[currentIndex - 1];

  this.eventStreamAppendable = eventStreamAppendable;
  this.eventStream = eventStream;
  this.eventTimesUs = eventStream.presentationTimesUs;
  if (pendingSeekPositionUs != C.TIME_UNSET) {
    seekToUs(pendingSeekPositionUs);
  } else if (lastReadPositionUs != C.TIME_UNSET) {
    currentIndex =
        Util.binarySearchCeil(
            eventTimesUs, lastReadPositionUs, /* inclusive= */ false, /* stayInBounds= */ false);
  }
}
 
Example #8
Source File: EventSampleStream.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
public EventSampleStream(
    EventStream eventStream, Format upstreamFormat, boolean eventStreamAppendable) {
  this.upstreamFormat = upstreamFormat;
  this.eventStream = eventStream;
  eventMessageEncoder = new EventMessageEncoder();
  pendingSeekPositionUs = C.TIME_UNSET;
  eventTimesUs = eventStream.presentationTimesUs;
  updateEventStream(eventStream, eventStreamAppendable);
}
 
Example #9
Source File: DashMediaPeriod.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
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);
  }
}
 
Example #10
Source File: DashMediaPeriod.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private static Pair<TrackGroupArray, TrackGroupInfo[]> buildTrackGroups(
    List<AdaptationSet> adaptationSets, List<EventStream> eventStreams) {
  int[][] groupedAdaptationSetIndices = getGroupedAdaptationSetIndices(adaptationSets);

  int primaryGroupCount = groupedAdaptationSetIndices.length;
  boolean[] primaryGroupHasEventMessageTrackFlags = new boolean[primaryGroupCount];
  Format[][] primaryGroupCea608TrackFormats = new Format[primaryGroupCount][];
  int totalEmbeddedTrackGroupCount =
      identifyEmbeddedTracks(
          primaryGroupCount,
          adaptationSets,
          groupedAdaptationSetIndices,
          primaryGroupHasEventMessageTrackFlags,
          primaryGroupCea608TrackFormats);

  int totalGroupCount = primaryGroupCount + totalEmbeddedTrackGroupCount + eventStreams.size();
  TrackGroup[] trackGroups = new TrackGroup[totalGroupCount];
  TrackGroupInfo[] trackGroupInfos = new TrackGroupInfo[totalGroupCount];

  int trackGroupCount =
      buildPrimaryAndEmbeddedTrackGroupInfos(
          adaptationSets,
          groupedAdaptationSetIndices,
          primaryGroupCount,
          primaryGroupHasEventMessageTrackFlags,
          primaryGroupCea608TrackFormats,
          trackGroups,
          trackGroupInfos);

  buildManifestEventTrackGroupInfos(eventStreams, trackGroups, trackGroupInfos, trackGroupCount);

  return Pair.create(new TrackGroupArray(trackGroups), trackGroupInfos);
}
 
Example #11
Source File: EventSampleStream.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void updateEventStream(EventStream eventStream, boolean eventStreamAppendable) {
  long lastReadPositionUs = currentIndex == 0 ? C.TIME_UNSET : eventTimesUs[currentIndex - 1];

  this.eventStreamAppendable = eventStreamAppendable;
  this.eventStream = eventStream;
  this.eventTimesUs = eventStream.presentationTimesUs;
  if (pendingSeekPositionUs != C.TIME_UNSET) {
    seekToUs(pendingSeekPositionUs);
  } else if (lastReadPositionUs != C.TIME_UNSET) {
    currentIndex =
        Util.binarySearchCeil(
            eventTimesUs, lastReadPositionUs, /* inclusive= */ false, /* stayInBounds= */ false);
  }
}
 
Example #12
Source File: EventSampleStream.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public EventSampleStream(
    EventStream eventStream, Format upstreamFormat, boolean eventStreamAppendable) {
  this.upstreamFormat = upstreamFormat;
  this.eventStream = eventStream;
  eventMessageEncoder = new EventMessageEncoder();
  pendingSeekPositionUs = C.TIME_UNSET;
  eventTimesUs = eventStream.presentationTimesUs;
  updateEventStream(eventStream, eventStreamAppendable);
}
 
Example #13
Source File: DashMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
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);
  }
}
 
Example #14
Source File: DashMediaPeriod.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private static Pair<TrackGroupArray, TrackGroupInfo[]> buildTrackGroups(
    List<AdaptationSet> adaptationSets, List<EventStream> eventStreams) {
  int[][] groupedAdaptationSetIndices = getGroupedAdaptationSetIndices(adaptationSets);

  int primaryGroupCount = groupedAdaptationSetIndices.length;
  boolean[] primaryGroupHasEventMessageTrackFlags = new boolean[primaryGroupCount];
  Format[][] primaryGroupCea608TrackFormats = new Format[primaryGroupCount][];
  int totalEmbeddedTrackGroupCount =
      identifyEmbeddedTracks(
          primaryGroupCount,
          adaptationSets,
          groupedAdaptationSetIndices,
          primaryGroupHasEventMessageTrackFlags,
          primaryGroupCea608TrackFormats);

  int totalGroupCount = primaryGroupCount + totalEmbeddedTrackGroupCount + eventStreams.size();
  TrackGroup[] trackGroups = new TrackGroup[totalGroupCount];
  TrackGroupInfo[] trackGroupInfos = new TrackGroupInfo[totalGroupCount];

  int trackGroupCount =
      buildPrimaryAndEmbeddedTrackGroupInfos(
          adaptationSets,
          groupedAdaptationSetIndices,
          primaryGroupCount,
          primaryGroupHasEventMessageTrackFlags,
          primaryGroupCea608TrackFormats,
          trackGroups,
          trackGroupInfos);

  buildManifestEventTrackGroupInfos(eventStreams, trackGroups, trackGroupInfos, trackGroupCount);

  return Pair.create(new TrackGroupArray(trackGroups), trackGroupInfos);
}
 
Example #15
Source File: EventSampleStream.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
void updateEventStream(EventStream eventStream, boolean eventStreamUpdatable) {
  long lastReadPositionUs = currentIndex == 0 ? C.TIME_UNSET : eventTimesUs[currentIndex - 1];

  this.eventStreamUpdatable = eventStreamUpdatable;
  this.eventStream = eventStream;
  this.eventTimesUs = eventStream.presentationTimesUs;
  if (pendingSeekPositionUs != C.TIME_UNSET) {
    seekToUs(pendingSeekPositionUs);
  } else if (lastReadPositionUs != C.TIME_UNSET) {
    currentIndex = Util.binarySearchCeil(eventTimesUs, lastReadPositionUs, false, false);
  }
}
 
Example #16
Source File: EventSampleStream.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
EventSampleStream(EventStream eventStream, Format upstreamFormat, boolean eventStreamUpdatable) {
  this.upstreamFormat = upstreamFormat;
  this.eventStream = eventStream;
  eventMessageEncoder = new EventMessageEncoder();
  pendingSeekPositionUs = C.TIME_UNSET;
  eventTimesUs = eventStream.presentationTimesUs;
  updateEventStream(eventStream, eventStreamUpdatable);
}
 
Example #17
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Updates the {@link DashManifest} and the index of this period in the manifest.
 *
 * @param manifest The updated manifest.
 * @param periodIndex the new index of this period in the updated manifest.
 */
public void updateManifest(DashManifest manifest, int periodIndex) {
  this.manifest = manifest;
  if (this.periodIndex != periodIndex) {
    eventDispatcher =
        eventDispatcher.withParameters(
            /* windowIndex= */ 0,
            eventDispatcher.mediaPeriodId.copyWithPeriodIndex(periodIndex),
            manifest.getPeriod(periodIndex).startMs);
  }
  this.periodIndex = periodIndex;
  playerEmsgHandler.updateManifest(manifest);
  if (sampleStreams != null) {
    for (ChunkSampleStream<DashChunkSource> sampleStream : sampleStreams) {
      sampleStream.getChunkSource().updateManifest(manifest, periodIndex);
    }
    callback.onContinueLoadingRequested(this);
  }
  eventStreams = manifest.getPeriod(periodIndex).eventStreams;
  for (EventSampleStream eventSampleStream : eventSampleStreams) {
    for (EventStream eventStream : eventStreams) {
      if (eventStream.id().equals(eventSampleStream.eventStreamId())) {
        eventSampleStream.updateEventStream(eventStream, manifest.dynamic);
        break;
      }
    }
  }
}
 
Example #18
Source File: EventSampleStream.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
void updateEventStream(EventStream eventStream, boolean eventStreamUpdatable) {
  long lastReadPositionUs = currentIndex == 0 ? C.TIME_UNSET : eventTimesUs[currentIndex - 1];

  this.eventStreamUpdatable = eventStreamUpdatable;
  this.eventStream = eventStream;
  this.eventTimesUs = eventStream.presentationTimesUs;
  if (pendingSeekPositionUs != C.TIME_UNSET) {
    seekToUs(pendingSeekPositionUs);
  } else if (lastReadPositionUs != C.TIME_UNSET) {
    currentIndex = Util.binarySearchCeil(eventTimesUs, lastReadPositionUs, false, false);
  }
}
 
Example #19
Source File: EventSampleStream.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
EventSampleStream(EventStream eventStream, Format upstreamFormat, boolean eventStreamUpdatable) {
  this.upstreamFormat = upstreamFormat;
  this.eventStream = eventStream;
  eventMessageEncoder = new EventMessageEncoder();
  pendingSeekPositionUs = C.TIME_UNSET;
  eventTimesUs = eventStream.presentationTimesUs;
  updateEventStream(eventStream, eventStreamUpdatable);
}
 
Example #20
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
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);
  }
}
 
Example #21
Source File: DashMediaPeriod.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Updates the {@link DashManifest} and the index of this period in the manifest.
 *
 * @param manifest The updated manifest.
 * @param periodIndex the new index of this period in the updated manifest.
 */
public void updateManifest(DashManifest manifest, int periodIndex) {
  this.manifest = manifest;
  if (this.periodIndex != periodIndex) {
    eventDispatcher =
        eventDispatcher.withParameters(
            /* windowIndex= */ 0,
            eventDispatcher.mediaPeriodId.copyWithPeriodIndex(periodIndex),
            manifest.getPeriod(periodIndex).startMs);
  }
  this.periodIndex = periodIndex;
  playerEmsgHandler.updateManifest(manifest);
  if (sampleStreams != null) {
    for (ChunkSampleStream<DashChunkSource> sampleStream : sampleStreams) {
      sampleStream.getChunkSource().updateManifest(manifest, periodIndex);
    }
    callback.onContinueLoadingRequested(this);
  }
  eventStreams = manifest.getPeriod(periodIndex).eventStreams;
  for (EventSampleStream eventSampleStream : eventSampleStreams) {
    for (EventStream eventStream : eventStreams) {
      if (eventStream.id().equals(eventSampleStream.eventStreamId())) {
        eventSampleStream.updateEventStream(eventStream, manifest.dynamic);
        break;
      }
    }
  }
}
 
Example #22
Source File: EventSampleStream.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
public void updateEventStream(EventStream eventStream, boolean eventStreamAppendable) {
  long lastReadPositionUs = currentIndex == 0 ? C.TIME_UNSET : eventTimesUs[currentIndex - 1];

  this.eventStreamAppendable = eventStreamAppendable;
  this.eventStream = eventStream;
  this.eventTimesUs = eventStream.presentationTimesUs;
  if (pendingSeekPositionUs != C.TIME_UNSET) {
    seekToUs(pendingSeekPositionUs);
  } else if (lastReadPositionUs != C.TIME_UNSET) {
    currentIndex =
        Util.binarySearchCeil(
            eventTimesUs, lastReadPositionUs, /* inclusive= */ false, /* stayInBounds= */ false);
  }
}
 
Example #23
Source File: EventSampleStream.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
public EventSampleStream(
    EventStream eventStream, Format upstreamFormat, boolean eventStreamAppendable) {
  this.upstreamFormat = upstreamFormat;
  this.eventStream = eventStream;
  eventMessageEncoder = new EventMessageEncoder();
  pendingSeekPositionUs = C.TIME_UNSET;
  eventTimesUs = eventStream.presentationTimesUs;
  updateEventStream(eventStream, eventStreamAppendable);
}
 
Example #24
Source File: DashMediaPeriod.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
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);
  }
}
 
Example #25
Source File: DashMediaPeriod.java    From MediaSDK with Apache License 2.0 5 votes vote down vote up
private static Pair<TrackGroupArray, TrackGroupInfo[]> buildTrackGroups(
    DrmSessionManager<?> drmSessionManager,
    List<AdaptationSet> adaptationSets,
    List<EventStream> eventStreams) {
  int[][] groupedAdaptationSetIndices = getGroupedAdaptationSetIndices(adaptationSets);

  int primaryGroupCount = groupedAdaptationSetIndices.length;
  boolean[] primaryGroupHasEventMessageTrackFlags = new boolean[primaryGroupCount];
  Format[][] primaryGroupCea608TrackFormats = new Format[primaryGroupCount][];
  int totalEmbeddedTrackGroupCount =
      identifyEmbeddedTracks(
          primaryGroupCount,
          adaptationSets,
          groupedAdaptationSetIndices,
          primaryGroupHasEventMessageTrackFlags,
          primaryGroupCea608TrackFormats);

  int totalGroupCount = primaryGroupCount + totalEmbeddedTrackGroupCount + eventStreams.size();
  TrackGroup[] trackGroups = new TrackGroup[totalGroupCount];
  TrackGroupInfo[] trackGroupInfos = new TrackGroupInfo[totalGroupCount];

  int trackGroupCount =
      buildPrimaryAndEmbeddedTrackGroupInfos(
          drmSessionManager,
          adaptationSets,
          groupedAdaptationSetIndices,
          primaryGroupCount,
          primaryGroupHasEventMessageTrackFlags,
          primaryGroupCea608TrackFormats,
          trackGroups,
          trackGroupInfos);

  buildManifestEventTrackGroupInfos(eventStreams, trackGroups, trackGroupInfos, trackGroupCount);

  return Pair.create(new TrackGroupArray(trackGroups), trackGroupInfos);
}