Skip to content

RFC: Mix VOD and Live

Nicholas Frederiksen edited this page Jul 1, 2021 · 9 revisions

Feature Description

#63: This feature gives the possibility to mix in a true live stream in a Channel Engine powered linear channel (VOD2Live).

Implementation Design

The intention is to keep the current VOD2Live session and playhead as it is to limit the risk of regressions. This means that modifications to the current engine/session class to be kept to the minimum. In a future refactoring this might need to be evaluated. To achieve this we will add a Stream Switcher between the video player and current VOD2Live session. By default this switcher will only pass through the media playlist request to the VOD2Live session and everything is as is. The switcher will on a regular basis poll a stream switch manager which is similar to the asset manager a module that contains site specific business logic. The switch manager returns a schedule in JSON that contains:

[ { start: <unixTs>, estEnd: <unixTs>, type: "live", url: "https://www.stream.com/live/src1/master.m3u8" },
  { start: <unixTs>, estEnd: <unixTs>, type: "live", url: "https://www.stream.com/live/src2/master.m3u8" },
  ...
]

The Stream Switcher acts upon this schedule and if the event type is live and the current time is within the time range, it will fetch the current manifest from a new component that handles live sessions. If it isn't, it will check and compare timestamps with the next item. Otherwise, it will fetch the current manifest from the VOD2Live session.

Similar to the VOD2Live session, the Live session has an internal playhead that similar to a video player increments the media sequences on a given interval. Different to the VOD2Live session handler this one only needs to fetch the live HLS from the live source and only rewrite the media sequence counters. The stream switcher will provide the current media sequence offset, the discontinuity sequence offset, and the segments from the most recent media sequence in order for the Live Session handler to do the manifest rewrite.

The Live Session handler will also need to rewrite the Live manifest's segment URIs with the absolute URIs. The Live Session handler must also hand over its media sequence offset, discontinuity sequence offset, and segments from the most recent media sequence back to the VOD2Live Session handler when switching back to VOD2Live (through the Stream Switcher) in order to sync up the sequence counters.

Development of this feature is active in branch feature/63/mix-live

Overlapping segments

Switching from a VOD2Live source to a true live source is not as easy as just start fetching manifests from another source as to ensure a smooth playback media segments from the sources needs to overlap, and a discontinuity tag need to be added by the switch. Assume that we have two sources (source A and source B).

  • Source A: VOD2Live manifest
  • Source B: Live manifest

During a switch the player would expect to receive the following manifests.

Manifest update X:

#EXT-X-MEDIA-SEQUENCE:761
#EXTINF:4,
vod2live_seg3.ts
#EXTINF:4,
vod2live_seg4.ts
#EXTINF:4,
vod2live_seg5.ts

Manifest update X+1:

#EXT-X-MEDIA-SEQUENCE:762
#EXTINF:4,
vod2live_seg4.ts
#EXTINF:4,
vod2live_seg5.ts
#EXT-X-DISCONTINUITY
#EXTINF:4,
live_seg14.ts

Manifest update X+2:

#EXT-X-MEDIA-SEQUENCE:763
#EXTINF:4,
vod2live_seg5.ts
#EXT-X-DISCONTINUITY
#EXTINF:4,
live_seg14.ts
#EXTINF:4,
live_seg15.ts
Clone this wiki locally