Merge pull request #354 from vexorian/20210808_dev

Do not clone whole channel just to combine the channel
This commit is contained in:
vexorian 2021-08-08 23:37:26 -04:00 committed by GitHub
commit e001fc2ce7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 23 additions and 1 deletions

View File

@ -2,6 +2,7 @@ module.exports = {
getCurrentProgramAndTimeElapsed: getCurrentProgramAndTimeElapsed,
createLineup: createLineup,
getWatermark: getWatermark,
generateChannelContext: generateChannelContext,
}
let channelCache = require('./channel-cache');
@ -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) {
@ -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;
@ -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;
}

View File

@ -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 = {