From d91d66cae647b9c8deab6afadab2cf105afad078 Mon Sep 17 00:00:00 2001 From: Johan Lautakoksi Date: Tue, 9 May 2023 09:49:52 +0200 Subject: [PATCH] reverted server.ts back to original state --- server.ts | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/server.ts b/server.ts index 3e1e212..448c34a 100644 --- a/server.ts +++ b/server.ts @@ -4,7 +4,7 @@ import { ChannelEngine, ChannelEngineOpts, IAssetManager, IChannelManager, - VodRequest, VodResponse, Channel, ChannelProfile, SubtitleTracks + VodRequest, VodResponse, Channel, ChannelProfile } from "./index"; const STITCH_ENDPOINT = @@ -29,7 +29,7 @@ class RefAssetManager implements IAssetManager { ], }; this.pos = { - 1: 0, + 1: 1, }; } @@ -46,15 +46,28 @@ class RefAssetManager implements IAssetManager { return new Promise((resolve, reject) => { const channelId = vodRequest.playlistId; if (this.assets[channelId]) { - let vod: VodResponse = this.assets[channelId][this.pos[channelId]++]; + let vod = this.assets[channelId][this.pos[channelId]++]; if (this.pos[channelId] > this.assets[channelId].length - 1) { this.pos[channelId] = 0; } - vod.timedMetadata = { - 'start-date': new Date().toISOString(), - 'class': 'se.eyevinn.demo' + const payload = { + uri: vod.uri, + breaks: [ + { + pos: 100, + duration: 15 * 1000, + url: "https://maitv-vod.lab.eyevinn.technology/ads/6cd7d768_e214_4ebc_9f14_7ed89710115e_mp4/master.m3u8", + }, + ], }; - resolve(vod); + const buff = Buffer.from(JSON.stringify(payload)); + const encodedPayload = buff.toString("base64"); + const vodResponse = { + id: vod.id, + title: vod.title, + uri: STITCH_ENDPOINT + "?payload=" + encodedPayload, + }; + resolve(vodResponse); } else { reject("Invalid channelId provided"); } @@ -65,7 +78,7 @@ class RefAssetManager implements IAssetManager { class RefChannelManager implements IChannelManager { getChannels(): Channel[] { //return [ { id: '1', profile: this._getProfile() }, { id: 'faulty', profile: this._getProfile() } ]; - return [{ id: "1", profile: this._getProfile(), subtitleTracks: this._getSubtitleTracks()}]; + return [{ id: "1", profile: this._getProfile() }]; } _getProfile(): ChannelProfile[] { @@ -75,12 +88,6 @@ class RefChannelManager implements IChannelManager { { bw: 1313000, codecs: "avc1.4d001f,mp4a.40.2", resolution: [480, 214] }, ]; } - _getSubtitleTracks(): SubtitleTracks[] { - return [ - { language: "en", name: "english", default: true }, - { language: "sv", name: "swedish", default: false }, - ]; - } } const refAssetManager = new RefAssetManager(); @@ -98,4 +105,4 @@ const engineOptions: ChannelEngineOpts = { const engine = new ChannelEngine(refAssetManager, engineOptions); engine.start(); -engine.listen(process.env.PORT || 8000); +engine.listen(process.env.PORT || 8000); \ No newline at end of file