Skip to content

Commit

Permalink
www/ajax/addip.php: rework postCheckOnvifPort() to use getRtspUrls.js…
Browse files Browse the repository at this point in the history
… and fall back to onvif_tool
  • Loading branch information
andrey-utkin committed Mar 6, 2024
1 parent 9d0b65b commit 006c56a
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions www/ajax/addip.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,25 @@ public function postCheckOnvifPort()
$pass = Inp::post('pass');
$onvif_addr = $ip.":".$port;

$p = @popen("/usr/lib/bluecherry/onvif_tool \"{$onvif_addr}\" \"{$user}\" \"{$pass}\" get_stream_urls", "r");

if (!$p){
data::responseJSON($stat, $msg);
exit;
$json_out = shell_exec("node /usr/share/bluecherry/onvif/getRtspUrls.js {$escapeshellarg($onvif_addr)} {$escapeshellarg($user)} {$escapeshellarg($pass)}");
if ($json_out) {
$urls = json_decode($json_out);
$main_stream = urls[0].rtspUri;
$sub_stream = urls[1].rtspUri;
} else {
$p = @popen("/usr/lib/bluecherry/onvif_tool {$escapeshellarg($onvif_addr)} {$escapeshellarg($user)} {$escapeshellarg($pass)} get_stream_urls", "r");

if (!$p){
data::responseJSON($stat, $msg);
exit;
}

$media_service = fgets($p);
$main_stream = fgets($p);
$sub_stream = fgets($p);
pclose($p);
}

$media_service = fgets($p);
$main_stream = fgets($p);
$sub_stream = fgets($p);
pclose($p);
if ($media_service && $main_stream){
if ($main_stream) {
$stat = 6;
$msg = AIP_CHECK_ONVIF_SUCCESS;

Expand Down

0 comments on commit 006c56a

Please sign in to comment.