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 {
output.sampleData(nalStartCode, 4);
// Write the NAL unit type byte.
output.sampleData(nalPrefix, 1);
// TODO: Don't try and process the SEI NAL unit if the payload is encrypted.
processSeiNalUnitPayload = cea608TrackOutput != null
&& NalUnitUtil.isNalUnitSei(track.format.sampleMimeType, nalPrefixData[4]);
sampleBytesWritten += 5;
......
......@@ -29,7 +29,8 @@ public interface DashChunkSource extends ChunkSource {
DashChunkSource createDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
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;
AdaptationSet adaptationSet = period.adaptationSets.get(adaptationSetIndex);
DashChunkSource chunkSource = chunkSourceFactory.createDashChunkSource(
manifestLoaderErrorThrower, manifest, index, adaptationSetIndex, selection,
elapsedRealtimeOffset);
elapsedRealtimeOffset, false, false);
return new ChunkSampleStream<>(adaptationSet.type, chunkSource, this, allocator, positionUs,
minLoadableRetryCount, eventDispatcher);
}
......
......@@ -70,11 +70,12 @@ public class DefaultDashChunkSource implements DashChunkSource {
@Override
public DashChunkSource createDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
DashManifest manifest, int periodIndex, int adaptationSetIndex,
TrackSelection trackSelection, long elapsedRealtimeOffsetMs) {
TrackSelection trackSelection, long elapsedRealtimeOffsetMs,
boolean enableEventMessageTrack, boolean enableCea608Track) {
DataSource dataSource = dataSourceFactory.createDataSource();
return new DefaultDashChunkSource(manifestLoaderErrorThrower, manifest, periodIndex,
adaptationSetIndex, trackSelection, dataSource, elapsedRealtimeOffsetMs,
maxSegmentsPerLoad);
maxSegmentsPerLoad, enableEventMessageTrack, enableCea608Track);
}
}
......@@ -106,10 +107,15 @@ public class DefaultDashChunkSource implements DashChunkSource {
* @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 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,
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.manifest = manifest;
this.adaptationSetIndex = adaptationSetIndex;
......@@ -126,7 +132,7 @@ public class DefaultDashChunkSource implements DashChunkSource {
for (int i = 0; i < representationHolders.length; i++) {
Representation representation = representations.get(trackSelection.getIndexInTrackGroup(i));
representationHolders[i] = new RepresentationHolder(periodDurationUs, representation,
adaptationSet.type);
enableEventMessageTrack, enableCea608Track, adaptationSet.type);
}
}
......@@ -364,7 +370,6 @@ public class DefaultDashChunkSource implements DashChunkSource {
protected static final class RepresentationHolder {
public final int trackType;
public final ChunkExtractorWrapper extractorWrapper;
public Representation representation;
......@@ -374,10 +379,9 @@ public class DefaultDashChunkSource implements DashChunkSource {
private int segmentNumShift;
public RepresentationHolder(long periodDurationUs, Representation representation,
int trackType) {
boolean enableEventMessageTrack, boolean enableCea608Track, int trackType) {
this.periodDurationUs = periodDurationUs;
this.representation = representation;
this.trackType = trackType;
String containerMimeType = representation.format.containerMimeType;
if (mimeTypeIsRawText(containerMimeType)) {
extractorWrapper = null;
......@@ -388,8 +392,14 @@ public class DefaultDashChunkSource implements DashChunkSource {
} else if (mimeTypeIsWebm(containerMimeType)) {
extractor = new MatroskaExtractor();
} else {
extractor = new FragmentedMp4Extractor(FragmentedMp4Extractor.FLAG_ENABLE_CEA608_TRACK
| FragmentedMp4Extractor.FLAG_ENABLE_EMSG_TRACK);
int flags = 0;
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,
// 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