Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(DASH): Avoid "Possible encoding problem detected!" when appending chunked data #5376

Merged
merged 1 commit into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -729,11 +729,13 @@ shaka.media.MediaSourceEngine = class {
* @param {boolean=} seeked True if we just seeked
* @param {boolean=} adaptation True if we just automatically switched active
* variant(s).
* @param {boolean=} isChunkedData True if we add to the buffer from the
* partial read of the segment.
* @return {!Promise}
*/
async appendBuffer(
contentType, data, reference, stream, hasClosedCaptions, seeked = false,
adaptation = false) {
adaptation = false, isChunkedData = false) {
const ContentType = shaka.util.ManifestParserUtils.ContentType;

if (contentType == ContentType.TEXT) {
Expand Down Expand Up @@ -837,13 +839,13 @@ shaka.media.MediaSourceEngine = class {
let bufferedBefore = null;

await this.enqueueOperation_(contentType, () => {
if (goog.DEBUG && reference) {
if (goog.DEBUG && reference && !reference.isPreload() && !isChunkedData) {
bufferedBefore = this.getBuffered_(contentType);
}
this.append_(contentType, data);
});

if (goog.DEBUG && reference && !reference.isPreload()) {
if (goog.DEBUG && reference && !reference.isPreload() && !isChunkedData) {
const bufferedAfter = this.getBuffered_(contentType);
const newBuffered = shaka.media.TimeRangesUtils.computeAddedRange(
bufferedBefore, bufferedAfter);
Expand Down
10 changes: 7 additions & 3 deletions lib/media/streaming_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -1371,7 +1371,8 @@ shaka.media.StreamingEngine = class {
const dataToAppend = remaining.subarray(0, offset);
remaining = remaining.subarray(offset);
await this.append_(
mediaState, presentationTime, stream, reference, dataToAppend);
mediaState, presentationTime, stream, reference, dataToAppend,
/* isChunkedData= */ true);
}
};

Expand Down Expand Up @@ -1856,10 +1857,12 @@ shaka.media.StreamingEngine = class {
* @param {shaka.extern.Stream} stream
* @param {!shaka.media.SegmentReference} reference
* @param {BufferSource} segment
* @param {boolean=} isChunkedData
* @return {!Promise}
* @private
*/
async append_(mediaState, presentationTime, stream, reference, segment) {
async append_(mediaState, presentationTime, stream, reference, segment,
isChunkedData = false) {
const logPrefix = shaka.media.StreamingEngine.logPrefix_(mediaState);

const hasClosedCaptions = stream.closedCaptions &&
Expand Down Expand Up @@ -1914,7 +1917,8 @@ shaka.media.StreamingEngine = class {
stream,
hasClosedCaptions,
seeked,
adaptation);
adaptation,
isChunkedData);
this.destroyer_.ensureNotDestroyed();
shaka.log.v2(logPrefix, 'appended media segment');
}
Expand Down