From: Christian Weiske Date: Thu, 9 Nov 2017 22:26:40 +0000 (+0100) Subject: Make client audio type support configurable X-Git-Url: https://git.cweiske.de/noxon-gateway.git/commitdiff_plain/fa31828a09690f4e6310d23e2a61a639cf699b70 Make client audio type support configurable --- diff --git a/data/config.php.dist b/data/config.php.dist index 6728859..92b3db6 100644 --- a/data/config.php.dist +++ b/data/config.php.dist @@ -10,4 +10,12 @@ $mediatomb = array( 'internetradio/Kindergeschichten/' ), ); + +//MIME types in addition to MP3 files that the clients +//support (and do not need transcoding for) +$clientSupport = [ + '127.0.0.1' => [ + 'audio/ogg' => true, + ], +]; ?> diff --git a/src/mediatomb.php b/src/mediatomb.php index d80e20e..532bbef 100644 --- a/src/mediatomb.php +++ b/src/mediatomb.php @@ -65,7 +65,8 @@ function mediatombAddFile(&$listItems, $item) $di = $item->getDetailedItem(); $itemUrl = $item->url; - if ($di->mimetype !== 'audio/mpeg') { + if (!clientSupportsType($di->mimetype)) { + //client wants transcoded file //noxon iRadio cube does not want to play .ogg files $itemUrl = $host1 . 'transcode-nocache.php' . '?url=' . urlencode($itemUrl); @@ -78,6 +79,20 @@ function mediatombAddFile(&$listItems, $item) ); } +function clientSupportsType($mimetype) +{ + if ($mimetype === 'audio/mpeg') { + return true; + } + $ip = $_SERVER['REMOTE_ADDR']; + if (isset($GLOBALS['clientSupport'][$ip][$mimetype]) + && $GLOBALS['clientSupport'][$ip][$mimetype] === true + ) { + return true; + } + return false; +} + /** * Single file mode - shows directories that only have a single file in them. * Each audio file gets its own virtual directory, containing only the