Skip to content

Commit

Permalink
reverted server.ts back to original state
Browse files Browse the repository at this point in the history
  • Loading branch information
Johan Lautakoksi committed May 9, 2023
1 parent 8ebb18d commit d91d66c
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { ChannelEngine, ChannelEngineOpts,
IAssetManager, IChannelManager,
VodRequest, VodResponse, Channel, ChannelProfile, SubtitleTracks
VodRequest, VodResponse, Channel, ChannelProfile
} from "./index";

const STITCH_ENDPOINT =
Expand All @@ -29,7 +29,7 @@ class RefAssetManager implements IAssetManager {
],
};
this.pos = {
1: 0,
1: 1,
};
}

Expand All @@ -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");
}
Expand All @@ -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[] {
Expand All @@ -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();
Expand All @@ -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);

0 comments on commit d91d66c

Please sign in to comment.