Skip to content

Commit

Permalink
Added support for multiple BaseURL elements.
Browse files Browse the repository at this point in the history
Added a new class called FailoverUri which handles multiple URLs and
switches to others when one fails.  This is also handles the request
itself.  This replaces SegmentMetadata as well as a number of manual
requests.

The MPD parser now produces arrays of URIs rather than just one.  The
MPD Processor then converts it to a FailoverUri inside the manifest.

Added unit tests to test the new functionality and updated the old ones
to the new changes.

This does not support failover on subtitles since subtitles are handled
by the browser.

Closes #68

Change-Id: I5410104827b9e4102b243444b1b5a3f01dcaf10d
  • Loading branch information
TheModMaker committed Aug 10, 2015
1 parent 7623b58 commit 899c322
Show file tree
Hide file tree
Showing 44 changed files with 882 additions and 616 deletions.
103 changes: 103 additions & 0 deletions assets/angel_one_failover.mpd
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0"?>
<MPD xmlns="urn:mpeg:DASH:schema:MPD:2011" type="static" mediaPresentationDuration="PT59.994S" minBufferTime="PT1S" profiles="urn:webm:dash:profile:webm-on-demand:2012">
<BaseURL>//shaka-player-demo.appspot.com/assets/angel_one/</BaseURL>
<Period id="0" start="PT0S" duration="PT59.994S">
<AdaptationSet id="6" mimeType="audio/webm" codecs="vorbis" lang="en" audioSamplingRate="48000" subsegmentStartsWithSAP="1">
<Role value="main" />
<Representation id="6" bandwidth="112375">
<BaseURL>does_not_exist.webm</BaseURL>
<BaseURL>a-en.webm</BaseURL>
<SegmentBase indexRange="815951-816145">
<Initialization range="0-4521"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="7" mimeType="audio/webm" codecs="vorbis" lang="de" audioSamplingRate="48000" subsegmentStartsWithSAP="1">
<Representation id="7" bandwidth="91060">
<BaseURL>does_not_exist.webm</BaseURL>
<BaseURL>a-de.webm</BaseURL>
<SegmentBase indexRange="682068-682263">
<Initialization range="0-4521"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="8" mimeType="audio/webm" codecs="vorbis" lang="es" audioSamplingRate="48000" subsegmentStartsWithSAP="1">
<Representation id="8" bandwidth="96408">
<BaseURL>does_not_exist.webm</BaseURL>
<BaseURL>a-es.webm</BaseURL>
<SegmentBase indexRange="728008-728202">
<Initialization range="0-4521"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="9" mimeType="audio/webm" codecs="vorbis" lang="fr" audioSamplingRate="48000" subsegmentStartsWithSAP="1">
<Representation id="9" bandwidth="94640">
<BaseURL>does_not_exist.webm</BaseURL>
<BaseURL>a-fr.webm</BaseURL>
<SegmentBase indexRange="721029-721223">
<Initialization range="0-4521"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="10" mimeType="audio/webm" codecs="vorbis" lang="it" audioSamplingRate="48000" subsegmentStartsWithSAP="1">
<Representation id="10" bandwidth="94290">
<BaseURL>does_not_exist.webm</BaseURL>
<BaseURL>a-it.webm</BaseURL>
<SegmentBase indexRange="723532-723726">
<Initialization range="0-4521"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="15" mimeType="video/webm" codecs="vp8" subsegmentAlignment="true" subsegmentStartsWithSAP="1" bitstreamSwitching="true">
<Representation id="15" bandwidth="1018197" width="768" height="576">
<BaseURL>does_not_exist.webm</BaseURL>
<BaseURL>v-768x576-1M.webm</BaseURL>
<SegmentBase indexRange="7575534-7575696">
<Initialization range="0-249"/>
</SegmentBase>
</Representation>
<Representation id="16" bandwidth="514685" width="768" height="576">
<BaseURL>does_not_exist.webm</BaseURL>
<BaseURL>v-768x576-500k.webm</BaseURL>
<SegmentBase indexRange="3796169-3796331">
<Initialization range="0-249"/>
</SegmentBase>
</Representation>
<Representation id="17" bandwidth="265431" width="576" height="432">
<BaseURL>does_not_exist.webm</BaseURL>
<BaseURL>v-576x432-250k.webm</BaseURL>
<SegmentBase indexRange="1909141-1909303">
<Initialization range="0-249"/>
</SegmentBase>
</Representation>
<Representation id="18" bandwidth="137319" width="432" height="324">
<BaseURL>does_not_exist.webm</BaseURL>
<BaseURL>v-432x324-125k.webm</BaseURL>
<SegmentBase indexRange="980929-981091">
<Initialization range="0-249"/>
</SegmentBase>
</Representation>
</AdaptationSet>
<AdaptationSet id="19" mimeType="text/vtt" lang="en">
<Role value="main" />
<Representation id="19">
<BaseURL>subs/s-en.vtt</BaseURL>
</Representation>
</AdaptationSet>
<AdaptationSet id="20" mimeType="text/vtt" lang="fr">
<Representation id="20">
<BaseURL>subs/s-fr.vtt</BaseURL>
</Representation>
</AdaptationSet>
<AdaptationSet id="21" mimeType="text/vtt" lang="pt-BR">
<Representation id="21">
<BaseURL>subs/s-pt-BR.vtt</BaseURL>
</Representation>
</AdaptationSet>
<AdaptationSet id="22" mimeType="text/vtt" lang="el">
<Representation id="22">
<BaseURL>subs/s-el.vtt</BaseURL>
</Representation>
</AdaptationSet>
</Period>
</MPD>
18 changes: 9 additions & 9 deletions lib/dash/container_segment_index_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ goog.require('shaka.log');
goog.require('shaka.media.ISegmentIndexSource');
goog.require('shaka.media.Mp4SegmentIndexParser');
goog.require('shaka.media.SegmentIndex');
goog.require('shaka.media.SegmentMetadata');
goog.require('shaka.media.SegmentReference');
goog.require('shaka.media.WebmSegmentIndexParser');
goog.require('shaka.util.FailoverUri');
goog.require('shaka.util.TypedBind');


Expand All @@ -39,10 +39,10 @@ goog.require('shaka.util.TypedBind');
* @param {!shaka.dash.mpd.Period} period
* @param {string} containerType The container type, which must be either
* 'mp4' or 'webm'.
* @param {!shaka.media.SegmentMetadata} indexMetadata Metadata info for the
* container's index metadata.
* @param {shaka.media.SegmentMetadata} initMetadata Metadata info for the
* container's headers, which is required for WebM containers and ignored
* @param {!shaka.util.FailoverUri} indexMetadata The location of the
* container's segment index.
* @param {shaka.util.FailoverUri} initMetadata The location of the container's
* headers, which is required for WebM containers and ignored
* for MP4 containers.
* @param {number} manifestCreationTime The time, in seconds, when the manifest
* was created.
Expand All @@ -64,10 +64,10 @@ shaka.dash.ContainerSegmentIndexSource = function(
/** @private {string} */
this.containerType_ = containerType;

/** @private {!shaka.media.SegmentMetadata} */
/** @private {!shaka.util.FailoverUri} */
this.indexMetadata_ = indexMetadata;

/** @private {shaka.media.SegmentMetadata} */
/** @private {shaka.util.FailoverUri} */
this.initMetadata_ = initMetadata;

/** @private {number} */
Expand Down Expand Up @@ -128,13 +128,13 @@ shaka.dash.ContainerSegmentIndexSource.prototype.create = function() {
var parser = new shaka.media.Mp4SegmentIndexParser();
references = parser.parse(new DataView(indexData),
this.indexMetadata_.startByte,
this.indexMetadata_.url);
this.indexMetadata_.urls);
} else if (this.containerType_ == 'webm') {
shaka.asserts.assert(initData);
var parser = new shaka.media.WebmSegmentIndexParser();
references = parser.parse(new DataView(indexData),
new DataView(initData),
this.indexMetadata_.url);
this.indexMetadata_.urls);
} else {
shaka.asserts.unreachable();
}
Expand Down
5 changes: 2 additions & 3 deletions lib/dash/list_segment_index_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,8 @@ shaka.dash.ListSegmentIndexSource.prototype.create = function() {
new shaka.media.SegmentReference(
scaledStartTime,
scaledEndTime,
startByte,
endByte,
new goog.Uri(segmentUrl.mediaUrl)));
new shaka.util.FailoverUri(
segmentUrl.mediaUrl, startByte, endByte)));
}

this.segmentIndex_ = this.mpd_.type == 'dynamic' ?
Expand Down
Loading

0 comments on commit 899c322

Please sign in to comment.