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 Feb 29, 2024
1 parent e27ef63 commit 57ec710
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/lib/bluecherry/getRtspUrls.js {$escaleshellarg($onvif_addr)} {$escaleshellarg($onvif_username)} {$escaleshellarg($onvif_password)}");
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($onvif_username)} {$escaleshellarg($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 57ec710

Please sign in to comment.