Skip to content

Commit

Permalink
feat(cea): Add CEA parser for TS
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Nov 15, 2022
1 parent eaa5631 commit 7b0e83f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -580,6 +580,8 @@ shaka.media.MediaSourceEngine = class {
return;
}

let timestampOffset = this.sourceBuffers_[contentType].timestampOffset;

const uint8ArrayData = shaka.util.BufferUtils.toUint8(data);
let mimeType = this.sourceBufferTypes_[contentType];
if (this.transmuxers_[contentType]) {
Expand All @@ -590,7 +592,7 @@ shaka.media.MediaSourceEngine = class {
// The SourceBuffer timestampOffset may or may not be set yet, so this is
// the timestamp offset that would eventually compute for this segment
// either way.
const timestampOffset =
timestampOffset =
reference.startTime - (tsParser.getStartTime()[contentType] || 0);
const metadata = tsParser.getMetadata();
if (metadata.length) {
Expand Down Expand Up @@ -627,13 +629,11 @@ shaka.media.MediaSourceEngine = class {
} else {
const closedCaptions = this.captionParser_.parseFrom(data);
if (closedCaptions.length) {
const videoOffset =
this.sourceBuffers_[ContentType.VIDEO].timestampOffset;
this.textEngine_.storeAndAppendClosedCaptions(
closedCaptions,
reference.startTime,
reference.endTime,
videoOffset);
timestampOffset);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion test/media/media_source_engine_integration.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ describe('MediaSourceEngine', () => {
mediaSourceEngine.setSelectedClosedCaptionId('CC1');
await appendWithClosedCaptions(ContentType.VIDEO, 0);

expect(textDisplayer.appendSpy).toHaveBeenCalledTimes(3);
expect(textDisplayer.appendSpy).toHaveBeenCalledTimes(2);
});

it('extracts CEA-708 captions from previous segment from hls', async () => {
Expand Down

0 comments on commit 7b0e83f

Please sign in to comment.