Skip to content

Commit

Permalink
www/ajax/discoverCameras.php: rework postAdd() 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 e27ef63 commit b51c13b
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions www/ajax/discoverCameras.php
Original file line number Diff line number Diff line change
Expand Up @@ -313,24 +313,32 @@ public function postAdd()
foreach ($passwords as $pass_arr) {
foreach ($pass_arr as $login => $password) {
$onvif_username = $login;
$onvif_password = $password;
$onvif_password = $password;

try {
$p = @popen("/usr/lib/bluecherry/onvif_tool \"{$onvif_addr}\" \"{$onvif_username}\" \"{$onvif_password}\" get_stream_urls", "r");
if (!$p)
break;

$media_service = fgets($p);
if (!$media_service)
{
$err['onvif_ip'][] = $ip;
break(2);
}
$main_stream = fgets($p);
$sub_stream = fgets($p);
pclose($p);
$json_out = shell_exec("node /usr/share/bluecherry/onvif/getRtspUrls.js " . escapeshellarg($onvif_addr) .' '. escapeshellarg($onvif_username) .' '. escapeshellarg($onvif_password));
if ($json_out) {
$urls = json_decode($json_out, /*associative=*/true);
$main_stream = $urls[0]['rtspUri'];
$sub_stream = $urls[1]['rtspUri'];
} else {
$p = @popen("/usr/lib/bluecherry/onvif_tool " . escapeshellarg($onvif_addr) .' '. escapeshellarg($onvif_username) .' '. escapeshellarg($onvif_password). " get_stream_urls", "r");
if (!$p)
break;

$media_service = fgets($p);
if (!$media_service)
{
$err['onvif_ip'][] = $ip;
break(2);
}
$main_stream = fgets($p);
$sub_stream = fgets($p);
pclose($p);
}

if ($main_stream)
{
{
$password_ch = true;

$media_uri = trim($main_stream);
Expand Down

0 comments on commit b51c13b

Please sign in to comment.