Commit 592b5eaf by olly Committed by Oliver Woodman

Support multiple CC channels in DASH

Issue: #5656
PiperOrigin-RevId: 241235377
parent 5db33dee
...@@ -5,7 +5,10 @@ ...@@ -5,7 +5,10 @@
* Update to Mockito 2 * Update to Mockito 2
* Add new `ExoPlaybackException` types for remote exceptions and out-of-memory * Add new `ExoPlaybackException` types for remote exceptions and out-of-memory
errors. errors.
* DASH: Parse role and accessibility descriptors into `Format.roleFlags`. * DASH:
* Parse role and accessibility descriptors into `Format.roleFlags`.
* Support multiple CEA-608 channels muxed into FMP4 representations
([#5656](https://github.com/google/ExoPlayer/issues/5656)).
* HLS: * HLS:
* Work around lack of LA_URL attribute in PlayReady key request init data. * Work around lack of LA_URL attribute in PlayReady key request init data.
* Prevent unnecessary reloads of initialization segments. * Prevent unnecessary reloads of initialization segments.
......
...@@ -17,12 +17,14 @@ package com.google.android.exoplayer2.source.dash; ...@@ -17,12 +17,14 @@ package com.google.android.exoplayer2.source.dash;
import android.os.SystemClock; import android.os.SystemClock;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import com.google.android.exoplayer2.Format;
import com.google.android.exoplayer2.source.chunk.ChunkSource; import com.google.android.exoplayer2.source.chunk.ChunkSource;
import com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler; import com.google.android.exoplayer2.source.dash.PlayerEmsgHandler.PlayerTrackEmsgHandler;
import com.google.android.exoplayer2.source.dash.manifest.DashManifest; import com.google.android.exoplayer2.source.dash.manifest.DashManifest;
import com.google.android.exoplayer2.trackselection.TrackSelection; import com.google.android.exoplayer2.trackselection.TrackSelection;
import com.google.android.exoplayer2.upstream.LoaderErrorThrower; import com.google.android.exoplayer2.upstream.LoaderErrorThrower;
import com.google.android.exoplayer2.upstream.TransferListener; import com.google.android.exoplayer2.upstream.TransferListener;
import java.util.List;
/** /**
* An {@link ChunkSource} for DASH streams. * An {@link ChunkSource} for DASH streams.
...@@ -41,10 +43,8 @@ public interface DashChunkSource extends ChunkSource { ...@@ -41,10 +43,8 @@ public interface DashChunkSource extends ChunkSource {
* @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between * @param elapsedRealtimeOffsetMs If known, an estimate of the instantaneous difference between
* server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds, * server-side unix time and {@link SystemClock#elapsedRealtime()} in milliseconds,
* specified as the server's unix time minus the local elapsed time. If unknown, set to 0. * specified as the server's unix time minus the local elapsed time. If unknown, set to 0.
* @param enableEventMessageTrack Whether the chunks generated by the source may output an event * @param enableEventMessageTrack Whether to output an event message track.
* message track. * @param closedCaptionFormats The {@link Format Formats} of closed caption tracks to be output.
* @param enableCea608Track Whether the chunks generated by the source may output a CEA-608
* track.
* @param transferListener The transfer listener which should be informed of any data transfers. * @param transferListener The transfer listener which should be informed of any data transfers.
* May be null if no listener is available. * May be null if no listener is available.
* @return The created {@link DashChunkSource}. * @return The created {@link DashChunkSource}.
...@@ -58,7 +58,7 @@ public interface DashChunkSource extends ChunkSource { ...@@ -58,7 +58,7 @@ public interface DashChunkSource extends ChunkSource {
int type, int type,
long elapsedRealtimeOffsetMs, long elapsedRealtimeOffsetMs,
boolean enableEventMessageTrack, boolean enableEventMessageTrack,
boolean enableCea608Track, List<Format> closedCaptionFormats,
@Nullable PlayerTrackEmsgHandler playerEmsgHandler, @Nullable PlayerTrackEmsgHandler playerEmsgHandler,
@Nullable TransferListener transferListener); @Nullable TransferListener transferListener);
} }
......
...@@ -54,7 +54,6 @@ import com.google.android.exoplayer2.util.MimeTypes; ...@@ -54,7 +54,6 @@ import com.google.android.exoplayer2.util.MimeTypes;
import com.google.android.exoplayer2.util.Util; import com.google.android.exoplayer2.util.Util;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
/** /**
...@@ -86,7 +85,7 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -86,7 +85,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
int trackType, int trackType,
long elapsedRealtimeOffsetMs, long elapsedRealtimeOffsetMs,
boolean enableEventMessageTrack, boolean enableEventMessageTrack,
boolean enableCea608Track, List<Format> closedCaptionFormats,
@Nullable PlayerTrackEmsgHandler playerEmsgHandler, @Nullable PlayerTrackEmsgHandler playerEmsgHandler,
@Nullable TransferListener transferListener) { @Nullable TransferListener transferListener) {
DataSource dataSource = dataSourceFactory.createDataSource(); DataSource dataSource = dataSourceFactory.createDataSource();
...@@ -104,7 +103,7 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -104,7 +103,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
elapsedRealtimeOffsetMs, elapsedRealtimeOffsetMs,
maxSegmentsPerLoad, maxSegmentsPerLoad,
enableEventMessageTrack, enableEventMessageTrack,
enableCea608Track, closedCaptionFormats,
playerEmsgHandler); playerEmsgHandler);
} }
...@@ -141,9 +140,8 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -141,9 +140,8 @@ public class DefaultDashChunkSource implements DashChunkSource {
* @param maxSegmentsPerLoad The maximum number of segments to combine into a single request. Note * @param maxSegmentsPerLoad The maximum number of segments to combine into a single request. Note
* that segments will only be combined if their {@link Uri}s are the same and if their data * that segments will only be combined if their {@link Uri}s are the same and if their data
* ranges are adjacent. * ranges are adjacent.
* @param enableEventMessageTrack Whether the chunks generated by the source may output an event * @param enableEventMessageTrack Whether to output an event message track.
* message track. * @param closedCaptionFormats The {@link Format Formats} of closed caption tracks to be output.
* @param enableCea608Track Whether the chunks generated by the source may output a CEA-608 track.
* @param playerTrackEmsgHandler The {@link PlayerTrackEmsgHandler} instance to handle emsg * @param playerTrackEmsgHandler The {@link PlayerTrackEmsgHandler} instance to handle emsg
* messages targeting the player. Maybe null if this is not necessary. * messages targeting the player. Maybe null if this is not necessary.
*/ */
...@@ -158,7 +156,7 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -158,7 +156,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
long elapsedRealtimeOffsetMs, long elapsedRealtimeOffsetMs,
int maxSegmentsPerLoad, int maxSegmentsPerLoad,
boolean enableEventMessageTrack, boolean enableEventMessageTrack,
boolean enableCea608Track, List<Format> closedCaptionFormats,
@Nullable PlayerTrackEmsgHandler playerTrackEmsgHandler) { @Nullable PlayerTrackEmsgHandler playerTrackEmsgHandler) {
this.manifestLoaderErrorThrower = manifestLoaderErrorThrower; this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
this.manifest = manifest; this.manifest = manifest;
...@@ -184,7 +182,7 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -184,7 +182,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
trackType, trackType,
representation, representation,
enableEventMessageTrack, enableEventMessageTrack,
enableCea608Track, closedCaptionFormats,
playerTrackEmsgHandler); playerTrackEmsgHandler);
} }
} }
...@@ -629,7 +627,7 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -629,7 +627,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
int trackType, int trackType,
Representation representation, Representation representation,
boolean enableEventMessageTrack, boolean enableEventMessageTrack,
boolean enableCea608Track, List<Format> closedCaptionFormats,
TrackOutput playerEmsgTrackOutput) { TrackOutput playerEmsgTrackOutput) {
this( this(
periodDurationUs, periodDurationUs,
...@@ -638,7 +636,7 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -638,7 +636,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
trackType, trackType,
representation, representation,
enableEventMessageTrack, enableEventMessageTrack,
enableCea608Track, closedCaptionFormats,
playerEmsgTrackOutput), playerEmsgTrackOutput),
/* segmentNumShift= */ 0, /* segmentNumShift= */ 0,
representation.getIndex()); representation.getIndex());
...@@ -783,7 +781,7 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -783,7 +781,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
int trackType, int trackType,
Representation representation, Representation representation,
boolean enableEventMessageTrack, boolean enableEventMessageTrack,
boolean enableCea608Track, List<Format> closedCaptionFormats,
TrackOutput playerEmsgTrackOutput) { TrackOutput playerEmsgTrackOutput) {
String containerMimeType = representation.format.containerMimeType; String containerMimeType = representation.format.containerMimeType;
if (mimeTypeIsRawText(containerMimeType)) { if (mimeTypeIsRawText(containerMimeType)) {
...@@ -799,12 +797,6 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -799,12 +797,6 @@ public class DefaultDashChunkSource implements DashChunkSource {
if (enableEventMessageTrack) { if (enableEventMessageTrack) {
flags |= FragmentedMp4Extractor.FLAG_ENABLE_EMSG_TRACK; flags |= FragmentedMp4Extractor.FLAG_ENABLE_EMSG_TRACK;
} }
// TODO: Use caption format information from the manifest if available.
List<Format> closedCaptionFormats =
enableCea608Track
? Collections.singletonList(
Format.createTextSampleFormat(null, MimeTypes.APPLICATION_CEA608, 0, null))
: Collections.emptyList();
extractor = extractor =
new FragmentedMp4Extractor( new FragmentedMp4Extractor(
flags, null, null, null, closedCaptionFormats, playerEmsgTrackOutput); flags, null, null, null, closedCaptionFormats, playerEmsgTrackOutput);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment