feat: add fallback + new config options for cdn urls

This commit is contained in:
Andreas Hubel 2024-01-29 00:33:47 +01:00
parent fb6a0eac53
commit b6d80d2dd0
No known key found for this signature in database
GPG key ID: 1291899EC534ECDE
7 changed files with 38 additions and 6 deletions

View file

@ -145,6 +145,9 @@
"default": "",
"examples": ["s1", "s2", "s3", "s4", "q1", "divoc", "cccb"]
},
"capacity": {
"type": ["integer", "null"]
},
"streamingConfig": {
"$ref": "#/definitions/RoomStreamingConfig"
}

View file

@ -26,8 +26,9 @@ class ConferenceJson extends Conference
if (!$r) {
continue;
}
$streamId = isset($r->streamId) ? $r->streamId : $r->slug;
$this->rooms[$r->slug] = array_merge(
['stream' => $r->streamId],
['stream' => $streamId],
get_object_vars($r),
(isset($r->streamingConfig) ? get_object_vars($r->streamingConfig) : []),
(isset($r->streamingConfig->chat) ? get_object_vars($r->streamingConfig->chat) : [])
@ -38,7 +39,7 @@ class ConferenceJson extends Conference
if ( isset($c->streamingConfig->overviewPage->sections) ) {
foreach($c->streamingConfig->overviewPage->sections as $s) {
$groups[$s->title] = array_map(
function($r) { return $r->slug; },
function($r) { return $r->slug; },
@$s->items ?: @$s->rooms ?: []
);
}

View file

@ -71,10 +71,16 @@ class Room
}
public function getThumb() {
if ($this->conference->has('cdn.thumbnail_url')) {
return str_replace('{streamId}', $this->getStream(), $this->conference->get('cdn.thumbnail_url'));
}
return proto().'://'.joinpath([$GLOBALS['CONFIG']['CDN'], 'thumbnail', $this->getStream(), 'thumb.jpeg']);
}
public function getPoster() {
if ($this->conference->has('cdn.poster_url')) {
return str_replace('{streamId}', $this->getStream(), $this->conference->get('cdn.poster_url'));
}
return proto().'://'.joinpath([$GLOBALS['CONFIG']['CDN'], 'thumbnail', $this->getStream(), 'poster.jpeg']);
}
@ -258,7 +264,7 @@ class Room
}
public function hasAudio() {
return $this->get('AUDIO');
return $this->get('AUDIO') && $this->getConference()->get('AUDIO') !== FALSE;
}
public function hasSlides() {
@ -273,11 +279,21 @@ class Room
return $this->get('DASH', true);
}
public function hasCustomStreamingUrl() {
return $this->conference->has('cdn.hls_playlist_url');
}
public function getHLSPlaylistUrl() {
if ($this->conference->has('cdn.hls_playlist_url')) {
return str_replace('{streamId}', rawurlencode($this->getStream()), $this->conference->get('cdn.hls_playlist_url'));
}
return proto().'://'.joinpath([$GLOBALS['CONFIG']['CDN'], 'hls', rawurlencode($this->getStream()).'/native_hd.m3u8']);
}
public function getDashManifestUrl() {
if ($this->conference->has('cdn.dash_manifest_url')) {
return str_replace('{streamId}', rawurlencode($this->getStream()), $this->conference->get('cdn.dash_manifest_url'));
}
return proto().'://'.joinpath([$GLOBALS['CONFIG']['CDN'], 'dash', rawurlencode($this->getStream()).'/manifest.mpd']);
}
@ -315,7 +331,7 @@ class Room
return count($this->getTranslations()) > 0;
}
public function isValidLanguage($language) {
public function isValidLanguage($language) {
return ($language === 'native' || $this->isTranslationEndpoint($language));
}

View file

@ -368,9 +368,9 @@ class Schedule
$key = $slug;
if (isset($room['name'])) {
$key = $room['name'];
} elseif ($room['SCHEDULE_NAME']) {
} elseif (isset($room['SCHEDULE_NAME'])) {
$key = $room['SCHEDULE_NAME'];
} elseif ($room['DISPLAY']) {
} elseif (isset($room['DISPLAY'])) {
$key = $room['DISPLAY'];
}
$this->mapping[$key] = $slug;

View file

@ -150,6 +150,9 @@ class Stream
switch($proto)
{
case 'hls':
if ($this->getRoom()->getConference()->has('cdn.hls_playlist_url')) {
return str_replace('{streamId}', $this->getRoom()->getStream(), $this->getRoom()->getConference()->get('cdn.hls_playlist_url'));
}
return proto().'://'.joinpath([$GLOBALS['CONFIG']['CDN'], 'hls', rawurlencode($this->getRoom()->getStream()).'/'.rawurlencode($this->getLanguage()).'_'.rawurlencode($selection).'.m3u8']);
}
@ -261,6 +264,9 @@ class Stream
);
}
public function getPoster() {
if ($this->room->getConference()->has('cdn.poster_url')) {
return str_replace('{streamId}', $this->getRoom()->getStream(), $this->room->getConference()->get('cdn.poster_url'));
}
return proto().'://'.joinpath([$GLOBALS['CONFIG']['CDN'], 'thumbnail', $this->getRoom()->getStream(), 'poster.jpeg']);
}
}

View file

@ -1,7 +1,11 @@
<div class="video-wrap"
data-voc-player
data-h264-only="<?=h($room->h264Only())?>"
<? if(!$room->hasCustomStreamingUrl()): ?>
data-stream="<?=h($room->getStream())?>"
<? else: ?>
data-source="<?=h($room->getHLSPlaylistUrl())?>"
<? endif ?>
data-poster="<?=h($stream->getPoster())?>"
data-preferred-language="<?=($stream->getLanguage())?>"
></div>

View file

@ -53,6 +53,8 @@ function formatRooms($conference) {
unset($config['guid']);
unset($config['name']);
unset($config['slug']);
unset($config['capacity']);
if (isset($config['chat'])) {
foreach ($config['chat'] as $k => $v) {
unset($config[$k]);