aboutsummaryrefslogtreecommitdiff
path: root/lib/helper.php
diff options
context:
space:
mode:
authorMaZderMind2015-02-28 20:50:25 +0100
committerMaZderMind2015-02-28 20:50:25 +0100
commit510e6cdbf2f073693cec5831795001d33122b112 (patch)
tree166234619e9ae0f241d593df0192421bbec60001 /lib/helper.php
parent71bd0739effaf4306502611244fbe33af408ab7a (diff)
generate switcher based on config
Diffstat (limited to '')
-rw-r--r--lib/helper.php58
1 files changed, 56 insertions, 2 deletions
diff --git a/lib/helper.php b/lib/helper.php
index 87bd6c5..647d657 100644
--- a/lib/helper.php
+++ b/lib/helper.php
@@ -14,9 +14,9 @@ function link_room($room)
function link_player($room, $format = 'hd', $translated = false)
{
- $isDefaultFormat = in_array($format, array('hd', 'video'));
+ $defaultformat = room_has_hd($room) ? 'hd' : 'sd';
- return rawurlencode($room).'/'.($isDefaultFormat ? '' : rawurlencode($format).'/').($translated ? 'translated/' : '');
+ return rawurlencode($room).'/'.($defaultformat == $format ? '' : rawurlencode($format).'/').($translated ? 'translated/' : '');
}
function link_stream($protocol, $room, $format, $translated = false)
@@ -134,3 +134,57 @@ function _get($array, $keychain, $default)
return _get($array[$key], array_slice($keychain, 1), $default);
}
+
+
+
+function room_has_hd($room)
+{
+ $formats = get("ROOMS.$room.FORMATS");
+ return count(array_intersect(array('rtmp-hd', 'hls-hd', 'webm-hd'), $formats)) > 0;
+}
+
+function room_has_sd($room)
+{
+ $formats = get("ROOMS.$room.FORMATS");
+ return count(array_intersect(array('rtmp-sd', 'hls-sd', 'webm-sd'), $formats)) > 0;
+}
+
+function room_has_video($room)
+{
+ return room_has_hd($room) || room_has_sd($room);
+}
+
+function room_has_audio($room)
+{
+ $formats = get("ROOMS.$room.FORMATS");
+ return count(array_intersect(array('audio-mp3', 'audio-opus'), $formats)) > 0;
+}
+
+function room_has_slides($room)
+{
+ $formats = get("ROOMS.$room.FORMATS");
+ return count(array_intersect(array('slides'), $formats)) > 0;
+}
+
+function room_has_rtmp($room)
+{
+ $formats = get("ROOMS.$room.FORMATS");
+ return count(array_intersect(array('rtmp-hd', 'rtmp-sd'), $formats)) > 0;
+}
+
+function room_has_webm($room)
+{
+ $formats = get("ROOMS.$room.FORMATS");
+ return count(array_intersect(array('webm-hd', 'webm-sd'), $formats)) > 0;
+}
+
+function room_has_hls($room)
+{
+ $formats = get("ROOMS.$room.FORMATS");
+ return count(array_intersect(array('hls-hd', 'hls-sd'), $formats)) > 0;
+}
+
+function startswith($needle, $haystack)
+{
+ return substr($haystack, 0, strlen($needle)) == $needle;
+}