Skip to content

Commit

Permalink
wip: start by trying to handle multi-channel audio correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
birme committed Mar 9, 2023
1 parent 547c7d5 commit 0580c20
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
18 changes: 10 additions & 8 deletions engine/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,11 @@ export class ChannelEngine {
let m;
if (req.params.file.match(/master.m3u8/)) {
await this._handleMasterManifest(req, res, next);
} else if (m = req.params.file.match(/master(\d+).m3u8;session=(.*)$/)) {
} else if (m = req.params.file.match(/master(\d+)_(\S+)_([0-9]+)p.m3u8;session=(.*)$/)) {
req.params[0] = m[1];
req.params[1] = m[2];
req.params[2] = m[3];
req.params[3] = m[4];
await this._handleMediaManifest(req, res, next);
} else if (m = req.params.file.match(/master-(\S+)_(\S+).m3u8;session=(.*)$/)) {
req.params[0] = m[1];
Expand Down Expand Up @@ -705,21 +707,21 @@ export class ChannelEngine {
async _handleMediaManifest(req, res, next) {
debug(`x-playback-session-id=${req.headers["x-playback-session-id"]} req.url=${req.url}`);
debug(req.params);
const session = sessions[req.params[1]];
const sessionLive = sessionsLive[req.params[1]];
const session = sessions[req.params[3]];
const sessionLive = sessionsLive[req.params[3]];
if (session && sessionLive) {
try {
while (switcherStatus[req.params[1]] === null || switcherStatus[req.params[1]] === undefined) {
while (switcherStatus[req.params[3]] === null || switcherStatus[req.params[3]] === undefined) {
debug(`[${req.params[1]}]: (${switcherStatus[req.params[1]]}) Waiting for streamSwitcher to respond`);
await timer(500);
}
let body = null;
debug(`switcherStatus[${req.params[1]}]=[${switcherStatus[req.params[1]]}]`);
if (switcherStatus[req.params[1]]) {
debug(`[${req.params[1]}]: Responding with Live-stream manifest`);
debug(`switcherStatus[${req.params[3]}]=[${switcherStatus[req.params[3]]}]`);
if (switcherStatus[req.params[3]]) {
debug(`[${req.params[3]}]: Responding with Live-stream manifest`);
body = await sessionLive.getCurrentMediaManifestAsync(req.params[0]);
} else {
debug(`[${req.params[1]}]: Responding with VOD2Live manifest`);
debug(`[${req.params[3]}]: Responding with VOD2Live manifest`);
body = await session.getCurrentMediaManifestAsync(req.params[0], req.headers["x-playback-session-id"]);
}
//verbose(`[${session.sessionId}] body=`);
Expand Down
2 changes: 1 addition & 1 deletion engine/session.js
Original file line number Diff line number Diff line change
Expand Up @@ -1014,7 +1014,7 @@ class Session {
(profile.frameRate ? `,FRAME-RATE=${profile.frameRate.toFixed(3)}` : '') +
(audioGroupId ? `,AUDIO="${audioGroupId}"` : '') +
(hasClosedCaptions ? ',CLOSED-CAPTIONS="cc"' : '') + '\n';
m3u8 += "master" + profile.bw + ".m3u8;session=" + this._sessionId + "\n";
m3u8 += "master" + profile.bw + "_" + videoRange + "_" + profile.resolution[1] + "p" + ".m3u8;session=" + this._sessionId + "\n";
});
} else {
currentVod.getUsageProfiles().forEach(profile => {
Expand Down
12 changes: 8 additions & 4 deletions server-uhd.ts → server-multichan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,16 +69,20 @@ class RefChannelManager implements IChannelManager {

_getProfile(): ChannelProfile[] {
return [
{ resolution: [1280, 720], bw: 3725519, codecs: "avc1.64001F,mp4a.40.2" },
{ resolution: [1280, 720], bw: 5903428, codecs: "avc1.64001F,ac-3" },
{ resolution: [1280, 720], bw: 6676458, videoRange: "PQ", frameRate: 24.000, codecs: "hvc1.2.4.L93.90,mp4a.40.2" },
{ resolution: [640, 360], bw: 3663471, codecs: "avc1.64001F,mp4a.40.2" },
{ resolution: [1280, 720], bw: 5841380, codecs: "avc1.64001F,mp4a.40.2" },
{ resolution: [1920, 1080], bw: 8973571, codecs: "avc1.64001F,mp4a.40.2" },

{ resolution: [640, 360], bw: 4301519, codecs: "avc1.64001F,ec-3" },
{ resolution: [1280, 720], bw: 6479428, codecs: "avc1.64001F,ec-3" },
{ resolution: [1920, 1080], bw: 9611619, codecs: "avc1.640032,ec-3" },
];
}

_getAudioTracks(): AudioTracks[] {
return [
{ language: "ja", "name": "日本語", channels: 2, codecs: "mp4a.40.2", default: true },
{ language: "ja", "name": "日本語", channels: 6, codecs: "ac-3", default: true }
{ language: "ja", "name": "日本語", channels: 6, codecs: "ec-3", default: true }
];
}
}
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
"esModuleInterop": true,
"declaration": true
},
"include": ["./server.ts", "./server-demux.ts", "./server-livemix.ts", "server-uhd.ts", "./engine/**/*"]
"include": ["./server.ts", "./server-demux.ts", "./server-livemix.ts", "server-multichan.ts", "./engine/**/*"]
}

0 comments on commit 0580c20

Please sign in to comment.