Make client audio type support configurable
authorChristian Weiske <cweiske@cweiske.de>
Thu, 9 Nov 2017 22:26:40 +0000 (23:26 +0100)
committerChristian Weiske <cweiske@cweiske.de>
Thu, 9 Nov 2017 22:26:40 +0000 (23:26 +0100)
data/config.php.dist
src/mediatomb.php

index 67288599d1df8f95a057b8bf2ba78f8717f07d3f..92b3db6d4dfac33f759c33d1bd7a30809b4eeea3 100644 (file)
@@ -10,4 +10,12 @@ $mediatomb = array(
         'internetradio/Kindergeschichten/'
     ),
 );
         '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,
+    ],
+];
 ?>
 ?>
index d80e20ee8681f85fc41bc931d9e81fe05cc92fcb..532bbef892ed36d7fc2adc71863907e93c713a14 100644 (file)
@@ -65,7 +65,8 @@ function mediatombAddFile(&$listItems, $item)
 
     $di = $item->getDetailedItem();
     $itemUrl = $item->url;
 
     $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);
         //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
 /**
  * Single file mode - shows directories that only have a single file in them.
  * Each audio file gets its own virtual directory, containing only the