Skip to content

Commit

Permalink
Merge branch 'main' into segment-sequence-representation
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Oct 12, 2023
2 parents 57d3031 + bab8153 commit 2e9180b
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
6 changes: 4 additions & 2 deletions lib/dash/dash_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,10 @@ shaka.dash.DashParser = class {
* @exportInterface
*/
onInitialVariantChosen(variant) {
if (this.manifest_ && this.lowLatencyMode_ &&
this.minTotalAvailabilityTimeOffset_) {
// For live it is necessary that the first time we update the manifest with
// a shorter time than indicated to take into account that the last segment
// added could be halfway, for example
if (this.manifest_ && this.manifest_.presentationTimeline.isLive()) {
const stream = variant.video || variant.audio;
if (stream && stream.segmentIndex) {
const availabilityEnd =
Expand Down
20 changes: 16 additions & 4 deletions lib/media/segment_prefetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
* SPDX-License-Identifier: Apache-2.0
*/

goog.provide('shaka.media.SegmentPrefetch');

goog.require('goog.asserts');
goog.require('shaka.net.NetworkingEngine');
goog.require('shaka.log');
goog.require('shaka.media.InitSegmentReference');
goog.require('shaka.media.SegmentReference');
goog.provide('shaka.media.SegmentPrefetch');
goog.require('shaka.log');
goog.require('shaka.net.NetworkingEngine');
goog.require('shaka.util.Uint8ArrayUtils');


/**
* @summary
Expand Down Expand Up @@ -227,10 +230,19 @@ shaka.media.SegmentPrefetchOperation = class {
* @public
*/
dispatchFetch(reference, stream) {
// We need to store the data, because streamDataCallback_ might not be
// available when you start getting the first data.
let buffered = new Uint8Array(0);
this.operation_ = this.fetchDispatcher_(
reference, stream, async (data) => {
if (buffered.byteLength > 0) {
buffered = shaka.util.Uint8ArrayUtils.concat(buffered, data);
} else {
buffered = data;
}
if (this.streamDataCallback_) {
await this.streamDataCallback_(data);
await this.streamDataCallback_(buffered);
buffered = new Uint8Array(0);
}
});
}
Expand Down

0 comments on commit 2e9180b

Please sign in to comment.