Skip to content

Commit

Permalink
Added disable live build option.
Browse files Browse the repository at this point in the history
A new build option --disable-live added to disable the ability to
play live content.

Issue #116

Change-Id: I35876f51bddc3689d60ff6dc1b736d74c8ed4f80
  • Loading branch information
TheModMaker committed Aug 25, 2015
1 parent 8fc33a5 commit 603fae9
Show file tree
Hide file tree
Showing 8 changed files with 189 additions and 145 deletions.
8 changes: 6 additions & 2 deletions build/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,28 +23,32 @@ name=
arguments=
function argsHelper() {
local arg=$1
local choices=
shift

while [[ $# -ne 0 ]]; do
if [[ $1 == $arg ]]; then
arguments="$arguments -D shaka.features.$2=false"
return 0
fi
choices="$choices [$1]"
shift 2
done

if [[ -z $name ]] && [[ $arg != -* ]]; then
name=$arg
else
echo "Usage: build.sh [--disable-dash] [--disable-offline] [--disable-http] [name]"
# There is an extra space at the beginning of $choices
echo "Usage: build.sh$choices [name]"
exit 1 # Exit here
fi
}

while [[ $# -ne 0 ]]; do
argsHelper "$1" --disable-dash "Dash" \
--disable-offline "Offline" \
--disable-http "Http"
--disable-http "Http" \
--disable-live "Live"
shift
done

Expand Down
19 changes: 12 additions & 7 deletions lib/dash/container_segment_index_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ goog.provide('shaka.dash.ContainerSegmentIndexSource');

goog.require('shaka.asserts');
goog.require('shaka.dash.LiveSegmentIndex');
goog.require('shaka.features');
goog.require('shaka.log');
goog.require('shaka.media.ISegmentIndexSource');
goog.require('shaka.media.Mp4SegmentIndexParser');
Expand Down Expand Up @@ -154,13 +155,17 @@ shaka.dash.ContainerSegmentIndexSource.prototype.create = function() {
return Promise.reject(error);
}

var segmentIndex = this.mpd_.type == 'dynamic' ?
new shaka.dash.LiveSegmentIndex(
references,
this.mpd_,
this.period_,
this.manifestCreationTime_) :
new shaka.media.SegmentIndex(references);
var segmentIndex;
if (shaka.features.Live && this.mpd_.type == 'dynamic') {
segmentIndex = new shaka.dash.LiveSegmentIndex(
references,
this.mpd_,
this.period_,
this.manifestCreationTime_);
} else {
shaka.asserts.assert(this.mpd_.type == 'static');
segmentIndex = new shaka.media.SegmentIndex(references);
}
return Promise.resolve(segmentIndex);
}));

Expand Down
4 changes: 3 additions & 1 deletion lib/dash/duration_segment_index_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ goog.provide('shaka.dash.DurationSegmentIndexSource');

goog.require('shaka.asserts');
goog.require('shaka.dash.DynamicLiveSegmentIndex');
goog.require('shaka.features');
goog.require('shaka.log');
goog.require('shaka.media.ISegmentIndexSource');
goog.require('shaka.media.SegmentIndex');
Expand Down Expand Up @@ -94,7 +95,7 @@ shaka.dash.DurationSegmentIndexSource.prototype.create = function() {
return Promise.resolve(this.segmentIndex_);
}

if (this.mpd_.type == 'dynamic') {
if (shaka.features.Live && this.mpd_.type == 'dynamic') {
try {
this.segmentIndex_ = new shaka.dash.DynamicLiveSegmentIndex(
this.mpd_, this.period_, this.representation_,
Expand All @@ -103,6 +104,7 @@ shaka.dash.DurationSegmentIndexSource.prototype.create = function() {
return Promise.reject(exception);
}
} else {
shaka.asserts.assert(this.mpd_.type == 'static');
var segmentTemplate = this.representation_.segmentTemplate;
var scaledSegmentDuration =
segmentTemplate.segmentDuration / segmentTemplate.timescale;
Expand Down
18 changes: 11 additions & 7 deletions lib/dash/list_segment_index_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ goog.provide('shaka.dash.ListSegmentIndexSource');

goog.require('shaka.asserts');
goog.require('shaka.dash.LiveSegmentIndex');
goog.require('shaka.features');
goog.require('shaka.log');
goog.require('shaka.media.ISegmentIndexSource');
goog.require('shaka.media.SegmentIndex');
Expand Down Expand Up @@ -174,13 +175,16 @@ shaka.dash.ListSegmentIndexSource.prototype.create = function() {
startByte, endByte)));
}

this.segmentIndex_ = this.mpd_.type == 'dynamic' ?
new shaka.dash.LiveSegmentIndex(
references,
this.mpd_,
this.period_,
this.manifestCreationTime_) :
new shaka.media.SegmentIndex(references);
if (shaka.features.Live && this.mpd_.type == 'dynamic') {
this.segmentIndex_ = new shaka.dash.LiveSegmentIndex(
references,
this.mpd_,
this.period_,
this.manifestCreationTime_);
} else {
shaka.asserts.assert(this.mpd_.type == 'static');
this.segmentIndex_ = new shaka.media.SegmentIndex(references);
}
return Promise.resolve(this.segmentIndex_);
};

18 changes: 11 additions & 7 deletions lib/dash/timeline_segment_index_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ goog.provide('shaka.dash.TimelineSegmentIndexSource');

goog.require('shaka.asserts');
goog.require('shaka.dash.LiveSegmentIndex');
goog.require('shaka.features');
goog.require('shaka.log');
goog.require('shaka.media.ISegmentIndexSource');
goog.require('shaka.media.SegmentIndex');
Expand Down Expand Up @@ -137,13 +138,16 @@ shaka.dash.TimelineSegmentIndexSource.prototype.create = function() {
mediaUrl));
}

this.segmentIndex_ = this.mpd_.type == 'dynamic' ?
new shaka.dash.LiveSegmentIndex(
references,
this.mpd_,
this.period_,
this.manifestCreationTime_) :
new shaka.media.SegmentIndex(references);
if (shaka.features.Live && this.mpd_.type == 'dynamic') {
this.segmentIndex_ = new shaka.dash.LiveSegmentIndex(
references,
this.mpd_,
this.period_,
this.manifestCreationTime_);
} else {
shaka.asserts.assert(this.mpd_.type == 'static');
this.segmentIndex_ = new shaka.media.SegmentIndex(references);
}

return Promise.resolve(this.segmentIndex_);
};
Expand Down
35 changes: 22 additions & 13 deletions lib/player/dash_video_source.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,12 @@ shaka.player.DashVideoSource.prototype.load = function() {
this.captionsLang_[i], this.captionsMime_[i]);
}

if (!shaka.features.Live && mpd.type == 'dynamic') {
var error = new Error('Live manifest support not enabled.');
error.type = 'stream';
return Promise.reject(error);
}

var mpdProcessor =
new shaka.dash.MpdProcessor(this.interpretContentProtection_);
this.manifestInfo = mpdProcessor.process(mpd, this.networkCallback_);
Expand All @@ -194,17 +200,20 @@ shaka.player.DashVideoSource.prototype.load = function() {
};


/** @override */
shaka.player.DashVideoSource.prototype.onUpdateManifest = function(url) {
var mpdRequest = new shaka.dash.MpdRequest(url, this.mpdRequestTimeout);
return mpdRequest.send().then(shaka.util.TypedBind(this,
/** @param {!shaka.dash.mpd.Mpd} mpd */
function(mpd) {
var mpdProcessor =
new shaka.dash.MpdProcessor(this.interpretContentProtection_);
var newManifestInfo = mpdProcessor.process(mpd, this.networkCallback_);
return Promise.resolve(newManifestInfo);
})
);
};
if (shaka.features.Live) {
/** @override */
shaka.player.DashVideoSource.prototype.onUpdateManifest = function(url) {
var mpdRequest = new shaka.dash.MpdRequest(url, this.mpdRequestTimeout);
return mpdRequest.send().then(shaka.util.TypedBind(this,
/** @param {!shaka.dash.mpd.Mpd} mpd */
function(mpd) {
var mpdProcessor =
new shaka.dash.MpdProcessor(this.interpretContentProtection_);
var newManifestInfo =
mpdProcessor.process(mpd, this.networkCallback_);
return Promise.resolve(newManifestInfo);
})
);
};
}

Loading

0 comments on commit 603fae9

Please sign in to comment.