Skip to content

Commit

Permalink
correctly generate content protection even if multiple keys are in use
Browse files Browse the repository at this point in the history
  • Loading branch information
sannies committed Dec 10, 2014
1 parent 5c6dbcd commit 46dcfff
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 40 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
package com.castlabs.dash.dashfragmenter.formats.csf;

import com.castlabs.dash.dashfragmenter.sequences.DashFileSetSequence;
import com.castlabs.dash.helpers.AbstractManifestWriter;
import com.coremedia.iso.boxes.Container;
import com.googlecode.mp4parser.authoring.Track;
Expand Down Expand Up @@ -34,12 +35,13 @@ public class SegmentBaseSingleSidxManifestWriterImpl extends AbstractManifestWri
private final Map<Track, Long> trackBitrates;

public SegmentBaseSingleSidxManifestWriterImpl(
DashFileSetSequence dashFileSetSequence,
Map<String, List<Track>> adaptationSets,
Map<Track, Container> trackContainer,
Map<Track, Long> trackBitrates,
Map<Track, String> trackFilenames) {

super(trackContainer, trackBitrates);
super(trackContainer, trackBitrates, dashFileSetSequence);
this.adaptationSets = adaptationSets;
this.trackFilenames = trackFilenames;
this.trackContainer = trackContainer;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.castlabs.dash.dashfragmenter.formats.multiplefilessegementtemplate;

import com.castlabs.dash.dashfragmenter.sequences.DashFileSetSequence;
import com.castlabs.dash.helpers.AbstractManifestWriter;
import com.coremedia.iso.IsoFile;
import com.coremedia.iso.boxes.Container;
Expand Down Expand Up @@ -31,13 +32,15 @@ public class ExplodedSegmentListManifestWriterImpl extends AbstractManifestWrite
private final String initPattern;
private final String mediaPattern;

public ExplodedSegmentListManifestWriterImpl(Map<String, List<Track>> adaptationSets,
public ExplodedSegmentListManifestWriterImpl(
DashFileSetSequence dashFileSetSequence,
Map<String, List<Track>> adaptationSets,
Map<Track, Container> trackContainer,
Map<Track, Long> representationBitrates,
Map<Track, String> representationIds,
Map<Track, List<File>> trackToSegements,
String initPattern, String mediaPattern) {
super(trackContainer, representationBitrates);
super(trackContainer, representationBitrates, dashFileSetSequence);
this.trackBitrates = representationBitrates;
this.adaptationSets = adaptationSets;
this.trackToSegements = trackToSegements;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import com.googlecode.mp4parser.boxes.mp4.objectdescriptors.AudioSpecificConfig;
import com.googlecode.mp4parser.boxes.mp4.samplegrouping.CencSampleEncryptionInformationGroupEntry;
import com.googlecode.mp4parser.util.Path;
import mpegCenc2013.DefaultKIDAttribute;
import mpegDashSchemaMpd2011.*;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.FilenameUtils;
Expand Down Expand Up @@ -255,11 +256,11 @@ public MPDDocument createManifest(Map<File, String> subtitleLanguages,
Map<Track, Container> dashedFiles, Map<Track, List<File>> trackToFile) throws IOException {
MPDDocument mpdDocument;
if (!explode) {
mpdDocument = new SegmentBaseSingleSidxManifestWriterImpl(
mpdDocument = new SegmentBaseSingleSidxManifestWriterImpl(this,
trackFamilies, dashedFiles,
trackBitrate, representationIds).getManifest();
} else {
mpdDocument = new ExplodedSegmentListManifestWriterImpl(
mpdDocument = new ExplodedSegmentListManifestWriterImpl(this,
trackFamilies, dashedFiles, trackBitrate, representationIds,
trackToFile, initPattern, mediaPattern).getManifest();
}
Expand Down Expand Up @@ -841,44 +842,26 @@ public Map<File, String> getSubtitleLanguages(List<File> subtitles) throws ExitC
return languages;
}

private class StsdCorrectingTrack extends AbstractTrack {
Track track;
private class StsdCorrectingTrack extends WrappingTrack {
SampleDescriptionBox stsd;

public StsdCorrectingTrack(Track track, SampleDescriptionBox stsd) {
super(track.getName());
this.track = track;
super(track);
this.stsd = stsd;
}


public void close() throws IOException {
track.close();
}


public SampleDescriptionBox getSampleDescriptionBox() {
return stsd;
}

}

public long[] getSampleDurations() {
return track.getSampleDurations();
}


public TrackMetaData getTrackMetaData() {
return track.getTrackMetaData();
}


public String getHandler() {
return track.getHandler();
}


public List<Sample> getSamples() {
return track.getSamples();
}
public void addContentProtection(AdaptationSetType adaptationSet, UUID keyId) {
DescriptorType contentProtection = adaptationSet.addNewContentProtection();
final DefaultKIDAttribute defaultKIDAttribute = DefaultKIDAttribute.Factory.newInstance();
defaultKIDAttribute.setDefaultKID(Collections.singletonList(keyId.toString()));
contentProtection.set(defaultKIDAttribute);
contentProtection.setSchemeIdUri("urn:mpeg:dash:mp4protection:2011");
contentProtection.setValue("cenc");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

package com.castlabs.dash.helpers;

import com.castlabs.dash.dashfragmenter.sequences.DashFileSetSequence;
import com.coremedia.iso.boxes.Box;
import com.coremedia.iso.boxes.Container;
import com.coremedia.iso.boxes.MediaHeaderBox;
Expand All @@ -29,13 +30,16 @@ public abstract class AbstractManifestWriter {

private final Map<Track, Container> trackContainer;
private final Map<Track, Long> trackBitrates;
DashFileSetSequence dashFileSetSequence;


public AbstractManifestWriter(Map<Track, Container> trackContainer,
Map<Track, Long> trackBitrates) {
Map<Track, Long> trackBitrates,
DashFileSetSequence dashFileSetSequence) {

this.trackContainer = trackContainer;
this.trackBitrates = trackBitrates;
this.dashFileSetSequence = dashFileSetSequence;

}

Expand Down Expand Up @@ -168,16 +172,15 @@ protected AdaptationSetType createAdaptationSet(PeriodType periodType, List<Trac
}

if (keyId != null) {
DescriptorType contentProtection = adaptationSet.addNewContentProtection();
final DefaultKIDAttribute defaultKIDAttribute = DefaultKIDAttribute.Factory.newInstance();
defaultKIDAttribute.setDefaultKID(Collections.singletonList(keyId.toString()));
contentProtection.set(defaultKIDAttribute);
contentProtection.setSchemeIdUri("urn:mpeg:dash:mp4protection:2011");
contentProtection.setValue("cenc");
addContentProtection(adaptationSet, keyId);
}
return adaptationSet;
}

protected void addContentProtection(AdaptationSetType adaptationSet, UUID keyId) {
dashFileSetSequence.addContentProtection(adaptationSet, keyId);
}

protected void createInitialization(URLType urlType, Track track) {
long offset = 0;
for (Box box : trackContainer.get(track).getBoxes()) {
Expand Down

0 comments on commit 46dcfff

Please sign in to comment.