Răsfoiți Sursa

#2331 Live video streaming

Alex Trofimov 5 ani în urmă
părinte
comite
b96d01a5d6

+ 5 - 1
modules/boonex/stream/classes/BxStrmEngineNGINX.php

@@ -19,7 +19,11 @@ class BxStrmEngineNGINX extends BxDol
         if (!$sHost || !$sApp)
             return false;
 
-        $sUrl = "http://{$sHost}/stat";
+        $sUrl = str_replace(
+            ['{host}', '{app}', '{key}'], 
+            [$sHost, $sApp, $sStreamKey], 
+            getParam('bx_stream_server_nginx_stats_url')
+        );
         $s = bx_file_get_contents($sUrl);
         if (!$s)
             return false;

+ 2 - 0
modules/boonex/stream/install/langs/en.xml

@@ -7,6 +7,7 @@
 
     <string name="_bx_stream_options_cat_streaming"><![CDATA[Streaming]]></string>
     <string name="_bx_stream_options_cat_engine_ome"><![CDATA[OvenMediaEngine]]></string>
+    <string name="_bx_stream_options_cat_engine_nginx"><![CDATA[NGINX]]></string>
     <string name="_bx_stream_options_cat_general"><![CDATA[General]]></string>
 
     <string name="_bx_stream_option_engine"><![CDATA[Server Software]]></string>
@@ -15,6 +16,7 @@
     <string name="_bx_stream_option_ome_policy_secret"><![CDATA[OvenMediaEngine Signed Policy Secret Key]]></string>
 
     <string name="_bx_stream_option_ome_api_port"><![CDATA[OvenMediaEngine API Port]]></string>
+    <string name="_bx_stream_option_nginx_stats_url"><![CDATA[NGINX Stats URL]]></string>
     <string name="_bx_stream_option_server_host"><![CDATA[Server Hostname]]></string>
     <string name="_bx_stream_option_app"><![CDATA[Application Name]]></string>
     <string name="_bx_stream_option_sources_pattern"><![CDATA[Sources Pattern]]></string>

+ 9 - 1
modules/boonex/stream/install/sql/enable.sql

@@ -32,7 +32,15 @@ INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `c
 ('bx_stream_server_ome_policy_secret', '', @iCategId, '_bx_stream_option_ome_policy_secret', 'digit', '', '', '', 20);
 
 INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `order`)
-VALUES (@iTypeId, 'bx_stream_general', '_bx_stream_options_cat_general', 3);
+VALUES (@iTypeId, 'bx_stream_engine_nginx', '_bx_stream_options_cat_engine_nginx', 3);
+SET @iCategId = LAST_INSERT_ID();
+
+INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `check`, `check_error`, `extra`, `order`) VALUES
+
+('bx_stream_server_nginx_stats_url', 'http://{host}/stat', @iCategId, '_bx_stream_option_nginx_stats_url', 'digit', '', '', '', 10);
+
+INSERT INTO `sys_options_categories` (`type_id`, `name`, `caption`, `order`)
+VALUES (@iTypeId, 'bx_stream_general', '_bx_stream_options_cat_general', 4);
 SET @iCategId = LAST_INSERT_ID();
 
 INSERT INTO `sys_options` (`name`, `value`, `category_id`, `caption`, `type`, `check`, `check_error`, `extra`, `order`) VALUES

+ 8 - 2
modules/boonex/stream/template/stream_viewers.html

@@ -2,10 +2,16 @@
 <script>
     var fFunc = function () {
         $.getJSON('__url__', function (oData) {
-            if ('undefined' !== typeof(oData.viewers))
+            if ('undefined' !== typeof(oData.viewers)) {
                 $('#bx-stream-viewers-__suffix__').html(oData.viewers);
-            if ('undefined' !== typeof(oData.num) && false !== oData.num)
+            }
+            if ('undefined' !== typeof(oData.num) && false !== oData.num) {
                 $('#bx-stream-processing').hide();
+                $('.bx-stream-badge').show();
+            }
+            if ('undefined' !== typeof(oData.num) && false === oData.num) {
+                $('.bx-stream-badge').hide();
+            }
         }).always(function() {
             setTimeout(fFunc, 10000);
         });