Skip to content

Commit

Permalink
Allow enabling of EMSG/608 outputs on DefaultDashChunkSource
Browse files Browse the repository at this point in the history
Issue #2176

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=148027655
  • Loading branch information
ojw28 committed Feb 23, 2017
1 parent 72e1eae commit a84216c
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1085,7 +1085,6 @@ private boolean readSample(ExtractorInput input) throws IOException, Interrupted
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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ interface Factory {

DashChunkSource createDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
DashManifest manifest, int periodIndex, int adaptationSetIndex,
TrackSelection trackSelection, long elapsedRealtimeOffsetMs);
TrackSelection trackSelection, long elapsedRealtimeOffsetMs,
boolean enableEventMessageTrack, boolean enableCea608Track);

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ private ChunkSampleStream<DashChunkSource> buildSampleStream(TrackSelection sele
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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,12 @@ public Factory(DataSource.Factory dataSourceFactory, int maxSegmentsPerLoad) {
@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);
}

}
Expand Down Expand Up @@ -106,10 +107,15 @@ public DashChunkSource createDashChunkSource(LoaderErrorThrower manifestLoaderEr
* @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;
Expand All @@ -126,7 +132,7 @@ public DefaultDashChunkSource(LoaderErrorThrower manifestLoaderErrorThrower,
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);
}
}

Expand Down Expand Up @@ -364,7 +370,6 @@ private static Chunk newMediaChunk(RepresentationHolder representationHolder,

protected static final class RepresentationHolder {

public final int trackType;
public final ChunkExtractorWrapper extractorWrapper;

public Representation representation;
Expand All @@ -374,10 +379,9 @@ protected static final class RepresentationHolder {
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;
Expand All @@ -388,8 +392,14 @@ public RepresentationHolder(long periodDurationUs, Representation representation
} 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.
Expand Down

0 comments on commit a84216c

Please sign in to comment.