Alex Trofimov пре 5 година
родитељ
комит
4fb59efd28

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

@@ -11,10 +11,50 @@
 
 class BxStrmEngineNGINX extends BxDol
 {
-    public function getViewersNum($aContentInfo)
+    public function getViewersNum($sStreamKey)
     {
+        $sHost = getParam('bx_stream_server_host');
+        $sApp = getParam('bx_stream_app');
+
+        if (!$sHost || !$sApp)
+            return false;
+
+        $sUrl = "http://{$sHost}/stat";
+        $s = bx_file_get_contents($sUrl);
+        if (!$s)
+            return false;
+
+        $o = @simplexml_load_string ($s);
+        if (!$o)
+            return false;
+
+        foreach ($o->server->application as $oApp) {
+            if ($sApp == $oApp->name && $sStreamKey == $oApp->live->stream->name)
+                return (int)$oApp->live->stream->nclients;
+        }
+
         return false;
     }
+
+    public function getRtmpSettings($sStreamKey)
+    {
+        $sHost = getParam('bx_stream_server_host');
+        $sApp = getParam('bx_stream_app');
+        
+        if (!$sHost || !$sApp)
+            return false;
+
+        $sBaseUrl = "rtmp://$sHost:1935/$sApp";
+        return ['server' => $sBaseUrl, 'key' => $sStreamKey];
+    }
+
+    public function getRtmpIngestUrl($sStreamKey)
+    {
+        if (!($a = $this->getRtmpSettings($sStreamKey)))
+            return false;
+        list ($sBaseUrl, $sStreamKey) = $a;
+        return $a['server'] . '/' . $a['key'];
+    }
 }
 
 /** @} */

+ 1 - 1
modules/boonex/stream/classes/BxStrmEngineOvenMediaEngine.php

@@ -58,7 +58,7 @@ class BxStrmEngineOvenMediaEngine extends BxDol
 
         $sBaseUrl = "rtmp://$sHost:1935/$sApp";
         if (!$sPolicySecret)
-            return [$sBaseUrl, $sStreamKey];
+            return ['server' => $sBaseUrl, 'key' => $sStreamKey];
 
         return ['server' => $sBaseUrl, 'key' => str_replace($sBaseUrl . '/', '', $this->_signUrl($sBaseUrl . '/' . $sStreamKey, $sPolicySecret))];
     }

+ 2 - 2
modules/boonex/stream/classes/BxStrmModule.php

@@ -93,13 +93,13 @@ class BxStrmModule extends BxBaseModTextModule
             'inputs' => array(
                 'url' => array(
                     'type' => 'text',
-                    'name' => 'url',
+                    'name' => 'url'.time(),
                     'caption' => _t('_bx_stream_form_entry_input_server'),
                     'value' => $a['server'],
                 ),
                 'key' => array(
                     'type' => 'password',
-                    'name' => 'key',
+                    'name' => 'key'.time(),
                     'caption' => _t('_bx_stream_form_entry_input_stream_key'),
                     'value' => $a['key'],
                 ),