Skip to content

Commit

Permalink
Do not clone whole channel just to combine the channel
Browse files Browse the repository at this point in the history
  • Loading branch information
vexorian committed Aug 9, 2021
1 parent f1db474 commit 58aa84d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
22 changes: 22 additions & 0 deletions src/helperFuncs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
getCurrentProgramAndTimeElapsed: getCurrentProgramAndTimeElapsed,
createLineup: createLineup,
getWatermark: getWatermark,
generateChannelContext: generateChannelContext,
}

let channelCache = require('./channel-cache');
Expand All @@ -10,6 +11,17 @@ const randomJS = require("random-js");
const Random = randomJS.Random;
const random = new Random( randomJS.MersenneTwister19937.autoSeed() );

const CHANNEL_CONTEXT_KEYS = [
"disableFillerOverlay",
"watermark",
"icon",
"offlinePicture",
"offlineSoundtrack",
"name",
"transcoding",
"number",
];

module.exports.random = random;

function getCurrentProgramAndTimeElapsed(date, channel) {
Expand Down Expand Up @@ -260,6 +272,7 @@ function pickRandomWithMaxDuration(channel, fillers, maxDuration) {
}
}

// any channel thing used here should be added to channel context
function getWatermark( ffmpegSettings, channel, type) {
if (! ffmpegSettings.enableFFMPEGTranscoding || ffmpegSettings.disableChannelOverlay ) {
return null;
Expand Down Expand Up @@ -301,3 +314,12 @@ function getWatermark( ffmpegSettings, channel, type) {
return result;
}


function generateChannelContext(channel) {
let channelContext = {};
for (let i = 0; i < CHANNEL_CONTEXT_KEYS.length; i++) {
let key = CHANNEL_CONTEXT_KEYS[i];
channelContext[key] = JSON.parse( JSON.stringify(channel[key] ) );
}
return channelContext;
}
2 changes: 1 addition & 1 deletion src/video.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ function video( channelDB , fillerDB, db) {
};
}

let combinedChannel = JSON.parse( JSON.stringify(brandChannel) );
let combinedChannel = helperFuncs.generateChannelContext(brandChannel);
combinedChannel.transcoding = channel.transcoding;

let playerContext = {
Expand Down

0 comments on commit 58aa84d

Please sign in to comment.