Skip to content

Commit

Permalink
feat: Add TS transmuxer
Browse files Browse the repository at this point in the history
  • Loading branch information
avelad committed Jul 4, 2023
1 parent b1e7cc4 commit 6aae2bc
Show file tree
Hide file tree
Showing 19 changed files with 1,232 additions and 159 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,10 @@ Shaka Player supports:
- Raw MP3 to MP3 in MP4
- Raw AC-3 to AC-3 in MP4
- Raw EC-3 to EC-3 in MP4
- AAC in MPEG-2 TS to AAC in MP4,
with help from [mux.js][] v6.2.0+
- H.264 in MPEG-2 TS to H.264 in MP4,
with help from [mux.js][] v6.2.0+
- AAC in MPEG-2 TS to AAC in MP4
- AC-3 in MPEG-2 TS to AC-3 in MP4
- EC-3 in MPEG-2 TS to EC-3 in MP4
- H.264 in MPEG-2 TS to H.264 in MP4
- Muxed AAC and H.264 in MPEG-2 TS to AAC and H.264 in MP4,
with help from [mux.js][] v6.2.0+

Expand Down
2 changes: 2 additions & 0 deletions build/types/transmuxer
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
+../../lib/transmuxer/adts.js
+../../lib/transmuxer/ec3.js
+../../lib/transmuxer/ec3_transmuxer.js
+../../lib/transmuxer/h264.js
+../../lib/transmuxer/mp3_transmuxer.js
+../../lib/transmuxer/mpeg_audio.js
+../../lib/transmuxer/muxjs_transmuxer.js
+../../lib/transmuxer/ts_transmuxer.js
32 changes: 32 additions & 0 deletions externs/shaka/codecs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @typedef {{
* data: Uint8Array,
* packetLength: number,
* pts: ?number,
* dts: ?number
* }}
*
* @summary MPEG_PES.
* @property {Uint8Array} data
* @property {number} packetLength
* @property {?number} pts
* @property {?number} dts
*/
shaka.extern.MPEG_PES;


/**
* @typedef {{
* data: !Uint8Array,
* fullData: !Uint8Array,
* type: number,
* time: ?number
* }}
*
* @summary VideoNalu.
* @property {!Uint8Array} data
* @property {!Uint8Array} fullData
* @property {number} type
* @property {?number} time
*/
shaka.extern.VideoNalu;
11 changes: 6 additions & 5 deletions karma.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,12 +360,13 @@ module.exports = (config) => {
clientArgs.testFiles.push('test/player_external.js');
} else {
// In a normal test run, we serve unit tests.
clientArgs.testFiles.push('test/**/*_unit.js');
// clientArgs.testFiles.push('test/**/*_unit.js');
clientArgs.testFiles.push('test/**/transmuxer_integration.js');

if (!settings.quick) {
// If --quick is present, we don't serve integration tests.
clientArgs.testFiles.push('test/**/*_integration.js');
}
// if (!settings.quick) {
// // If --quick is present, we don't serve integration tests.
// clientArgs.testFiles.push('test/**/*_integration.js');
// }
if (settings.external) {
// If --external is present, we serve external asset tests.
clientArgs.testFiles.push('demo/common/asset.js');
Expand Down
6 changes: 2 additions & 4 deletions lib/media/media_source_engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -426,8 +426,7 @@ shaka.media.MediaSourceEngine = class {
shaka.util.MimeUtils.getFullTypeWithAllCodecs(
stream.mimeType, stream.codecs);
const TransmuxerEngine = shaka.transmuxer.TransmuxerEngine;
if (needTransmux &&
TransmuxerEngine.isSupported(mimeTypeWithAllCodecs, contentType)) {
if (needTransmux) {
const transmuxerPlugin =
TransmuxerEngine.findTransmuxer(mimeTypeWithAllCodecs);
if (transmuxerPlugin) {
Expand Down Expand Up @@ -1649,8 +1648,7 @@ shaka.media.MediaSourceEngine = class {
shaka.util.MimeUtils.getFullTypeWithAllCodecs(
stream.mimeType, stream.codecs);
const TransmuxerEngine = shaka.transmuxer.TransmuxerEngine;
if (needTransmux &&
TransmuxerEngine.isSupported(newMimeTypeWithAllCodecs, contentType)) {
if (needTransmux) {
const transmuxerPlugin =
TransmuxerEngine.findTransmuxer(newMimeTypeWithAllCodecs);
if (transmuxerPlugin) {
Expand Down
2 changes: 2 additions & 0 deletions lib/mss/mss_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -629,10 +629,12 @@ shaka.mss.MssParser = class {
}
/** @type {shaka.util.Mp4Generator.StreamInfo} */
const streamInfo = {
encrypted: stream.encrypted,
timescale: stream.mssPrivateData.timescale,
duration: stream.mssPrivateData.duration,
videoNalus: videoNalus,
audioConfig: new Uint8Array([]),
videoConfig: new Uint8Array([]),
data: null, // Data is not necessary for init segement.
stream: stream,
};
Expand Down
2 changes: 2 additions & 0 deletions lib/transmuxer/aac_transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -188,10 +188,12 @@ shaka.transmuxer.AacTransmuxer = class {

/** @type {shaka.util.Mp4Generator.StreamInfo} */
const streamInfo = {
encrypted: stream.encrypted && stream.drmInfos.length > 0,
timescale: sampleRate,
duration: duration,
videoNalus: [],
audioConfig: new Uint8Array([]),
videoConfig: new Uint8Array([]),
data: {
sequenceNumber: this.frameIndex_,
baseMediaDecodeTime: baseMediaDecodeTime,
Expand Down
2 changes: 2 additions & 0 deletions lib/transmuxer/ac3_transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ shaka.transmuxer.Ac3Transmuxer = class {

/** @type {shaka.util.Mp4Generator.StreamInfo} */
const streamInfo = {
encrypted: stream.encrypted && stream.drmInfos.length > 0,
timescale: sampleRate,
duration: duration,
videoNalus: [],
audioConfig: audioConfig,
videoConfig: new Uint8Array([]),
data: {
sequenceNumber: this.frameIndex_,
baseMediaDecodeTime: baseMediaDecodeTime,
Expand Down
2 changes: 2 additions & 0 deletions lib/transmuxer/ec3_transmuxer.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,12 @@ shaka.transmuxer.Ec3Transmuxer = class {

/** @type {shaka.util.Mp4Generator.StreamInfo} */
const streamInfo = {
encrypted: stream.encrypted && stream.drmInfos.length > 0,
timescale: sampleRate,
duration: duration,
videoNalus: [],
audioConfig: audioConfig,
videoConfig: new Uint8Array([]),
data: {
sequenceNumber: this.frameIndex_,
baseMediaDecodeTime: baseMediaDecodeTime,
Expand Down
Loading

0 comments on commit 6aae2bc

Please sign in to comment.