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 Feb 29, 2024
1 parent 57ec710 commit 5b27715
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/lib/bluecherry/getRtspUrls.js {$escaleshellarg($onvif_addr)} {$escaleshellarg($user)} {$escaleshellarg($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 {$escaleshellarg($onvif_addr)} {$escaleshellarg($user)} {$escaleshellarg($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 5b27715

Please sign in to comment.