Commit a84216c3 by olly Committed by Oliver Woodman

Allow enabling of EMSG/608 outputs on DefaultDashChunkSource

Issue #2176

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=148027655
parent 72e1eae6
...@@ -1085,7 +1085,6 @@ public final class FragmentedMp4Extractor implements Extractor { ...@@ -1085,7 +1085,6 @@ public final class FragmentedMp4Extractor implements Extractor {
output.sampleData(nalStartCode, 4); output.sampleData(nalStartCode, 4);
// Write the NAL unit type byte. // Write the NAL unit type byte.
output.sampleData(nalPrefix, 1); output.sampleData(nalPrefix, 1);
// TODO: Don't try and process the SEI NAL unit if the payload is encrypted.
processSeiNalUnitPayload = cea608TrackOutput != null processSeiNalUnitPayload = cea608TrackOutput != null
&& NalUnitUtil.isNalUnitSei(track.format.sampleMimeType, nalPrefixData[4]); && NalUnitUtil.isNalUnitSei(track.format.sampleMimeType, nalPrefixData[4]);
sampleBytesWritten += 5; sampleBytesWritten += 5;
......
...@@ -29,7 +29,8 @@ public interface DashChunkSource extends ChunkSource { ...@@ -29,7 +29,8 @@ public interface DashChunkSource extends ChunkSource {
DashChunkSource createDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower, DashChunkSource createDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
DashManifest manifest, int periodIndex, int adaptationSetIndex, DashManifest manifest, int periodIndex, int adaptationSetIndex,
TrackSelection trackSelection, long elapsedRealtimeOffsetMs); TrackSelection trackSelection, long elapsedRealtimeOffsetMs,
boolean enableEventMessageTrack, boolean enableCea608Track);
} }
......
...@@ -203,7 +203,7 @@ import java.util.List; ...@@ -203,7 +203,7 @@ import java.util.List;
AdaptationSet adaptationSet = period.adaptationSets.get(adaptationSetIndex); AdaptationSet adaptationSet = period.adaptationSets.get(adaptationSetIndex);
DashChunkSource chunkSource = chunkSourceFactory.createDashChunkSource( DashChunkSource chunkSource = chunkSourceFactory.createDashChunkSource(
manifestLoaderErrorThrower, manifest, index, adaptationSetIndex, selection, manifestLoaderErrorThrower, manifest, index, adaptationSetIndex, selection,
elapsedRealtimeOffset); elapsedRealtimeOffset, false, false);
return new ChunkSampleStream<>(adaptationSet.type, chunkSource, this, allocator, positionUs, return new ChunkSampleStream<>(adaptationSet.type, chunkSource, this, allocator, positionUs,
minLoadableRetryCount, eventDispatcher); minLoadableRetryCount, eventDispatcher);
} }
......
...@@ -70,11 +70,12 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -70,11 +70,12 @@ public class DefaultDashChunkSource implements DashChunkSource {
@Override @Override
public DashChunkSource createDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower, public DashChunkSource createDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
DashManifest manifest, int periodIndex, int adaptationSetIndex, DashManifest manifest, int periodIndex, int adaptationSetIndex,
TrackSelection trackSelection, long elapsedRealtimeOffsetMs) { TrackSelection trackSelection, long elapsedRealtimeOffsetMs,
boolean enableEventMessageTrack, boolean enableCea608Track) {
DataSource dataSource = dataSourceFactory.createDataSource(); DataSource dataSource = dataSourceFactory.createDataSource();
return new DefaultDashChunkSource(manifestLoaderErrorThrower, manifest, periodIndex, return new DefaultDashChunkSource(manifestLoaderErrorThrower, manifest, periodIndex,
adaptationSetIndex, trackSelection, dataSource, elapsedRealtimeOffsetMs, adaptationSetIndex, trackSelection, dataSource, elapsedRealtimeOffsetMs,
maxSegmentsPerLoad); maxSegmentsPerLoad, enableEventMessageTrack, enableCea608Track);
} }
} }
...@@ -106,10 +107,15 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -106,10 +107,15 @@ public class DefaultDashChunkSource implements DashChunkSource {
* @param maxSegmentsPerLoad The maximum number of segments to combine into a single request. * @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 * Note that segments will only be combined if their {@link Uri}s are the same and if their
* data ranges are adjacent. * data ranges are adjacent.
* @param enableEventMessageTrack Whether the chunks generated by the source may output an event
* message track.
* @param enableEventMessageTrack Whether the chunks generated by the source may output a CEA-608
* track.
*/ */
public DefaultDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower, public DefaultDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
DashManifest manifest, int periodIndex, int adaptationSetIndex, TrackSelection trackSelection, DashManifest manifest, int periodIndex, int adaptationSetIndex, TrackSelection trackSelection,
DataSource dataSource, long elapsedRealtimeOffsetMs, int maxSegmentsPerLoad) { DataSource dataSource, long elapsedRealtimeOffsetMs, int maxSegmentsPerLoad,
boolean enableEventMessageTrack, boolean enableCea608Track) {
this.manifestLoaderErrorThrower = manifestLoaderErrorThrower; this.manifestLoaderErrorThrower = manifestLoaderErrorThrower;
this.manifest = manifest; this.manifest = manifest;
this.adaptationSetIndex = adaptationSetIndex; this.adaptationSetIndex = adaptationSetIndex;
...@@ -126,7 +132,7 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -126,7 +132,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
for (int i = 0; i < representationHolders.length; i++) { for (int i = 0; i < representationHolders.length; i++) {
Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i)); Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
representationHolders[i] = new RepresentationHolder(periodDurationUs, representation, representationHolders[i] = new RepresentationHolder(periodDurationUs, representation,
adaptationSet.type); enableEventMessageTrack, enableCea608Track, adaptationSet.type);
} }
} }
...@@ -364,7 +370,6 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -364,7 +370,6 @@ public class DefaultDashChunkSource implements DashChunkSource {
protected static final class RepresentationHolder { protected static final class RepresentationHolder {
public final int trackType;
public final ChunkExtractorWrapper extractorWrapper; public final ChunkExtractorWrapper extractorWrapper;
public Representation representation; public Representation representation;
...@@ -374,10 +379,9 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -374,10 +379,9 @@ public class DefaultDashChunkSource implements DashChunkSource {
private int segmentNumShift; private int segmentNumShift;
public RepresentationHolder(long periodDurationUs, Representation representation, public RepresentationHolder(long periodDurationUs, Representation representation,
int trackType) { boolean enableEventMessageTrack, boolean enableCea608Track, int trackType) {
this.periodDurationUs = periodDurationUs; this.periodDurationUs = periodDurationUs;
this.representation = representation; this.representation = representation;
this.trackType = trackType;
String containerMimeType = representation.format.containerMimeType; String containerMimeType = representation.format.containerMimeType;
if (mimeTypeIsRawText(containerMimeType)) { if (mimeTypeIsRawText(containerMimeType)) {
extractorWrapper = null; extractorWrapper = null;
...@@ -388,8 +392,14 @@ public class DefaultDashChunkSource implements DashChunkSource { ...@@ -388,8 +392,14 @@ public class DefaultDashChunkSource implements DashChunkSource {
} else if (mimeTypeIsWebm(containerMimeType)) { } else if (mimeTypeIsWebm(containerMimeType)) {
extractor = new MatroskaExtractor(); extractor = new MatroskaExtractor();
} else { } else {
extractor = new FragmentedMp4Extractor(FragmentedMp4Extractor.FLAG_ENABLE_CEA608_TRACK int flags = 0;
| FragmentedMp4Extractor.FLAG_ENABLE_EMSG_TRACK); if (enableEventMessageTrack) {
flags |= FragmentedMp4Extractor.FLAG_ENABLE_EMSG_TRACK;
}
if (enableCea608Track) {
flags |= FragmentedMp4Extractor.FLAG_ENABLE_CEA608_TRACK;
}
extractor = new FragmentedMp4Extractor(flags);
} }
// Prefer drmInitData obtained from the manifest over drmInitData obtained from the stream, // Prefer drmInitData obtained from the manifest over drmInitData obtained from the stream,
// as per DASH IF Interoperability Recommendations V3.0, 7.5.3. // as per DASH IF Interoperability Recommendations V3.0, 7.5.3.
......
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