Skip to content

Commit

Permalink
no message
Browse files Browse the repository at this point in the history
  • Loading branch information
Nall-chan committed Aug 23, 2024
1 parent bf64322 commit 7c03c74
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 10 deletions.
22 changes: 20 additions & 2 deletions ONVIF Configurator/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,10 @@ public function GetConfigurationForm(): string
$this->SendDebug(\ONVIF\IO\Attribute::NbrOfInputs, $Capabilities[\ONVIF\IO\Attribute::NbrOfInputs], 0);
$this->SendDebug(\ONVIF\IO\Attribute::NbrOfOutputs, $Capabilities[\ONVIF\IO\Attribute::NbrOfOutputs], 0);
$this->SendDebug(\ONVIF\IO\Attribute::AnalyticsTokens, $Capabilities[\ONVIF\IO\Attribute::AnalyticsTokens], 0);
$this->SendDebug(\ONVIF\IO\Attribute::NbrOfRecordingJobs, $Capabilities[\ONVIF\IO\Attribute::NbrOfRecordingJobs], 0);

//Events
$OtherEvents = array_keys($this->GetEvents('', 0, [':VideoSource', ':PTZ', '/Relay', '/DigitalInput']));
$OtherEvents = array_keys($this->GetEvents('', 0, [':VideoSource', ':PTZ', '/Relay', '/DigitalInput', 'RecordingConfig/']));
$LastTopic = '';
$Events = [];
foreach ($OtherEvents as $Event) {
Expand Down Expand Up @@ -142,6 +143,23 @@ public function GetConfigurationForm(): string
}
$OutputValues = $this->GetConfigurationArray(\ONVIF\GUID::Output, $Capabilities[\ONVIF\IO\Attribute::NbrOfOutputs] > 0, $OutputTopics);

// Recording
$RecordingEvents = $this->GetEvents('/JobState', 0);
$RecordingTopics = [];
foreach (array_keys($RecordingEvents) as $Topic) {
$RecordingTopics[$Topic] = [
'moduleID' => \ONVIF\GUID::Recording,
'configuration' => [
'EventTopic' => $Topic
],
'location' => [$this->Translate('ONVIF Devices'), IPS_GetName($this->InstanceID)]
];
}
if (count($RecordingTopics) == 1) {
$RecordingTopics = array_shift($RecordingTopics);
}
$RecordingValues = $this->GetConfigurationArray(\ONVIF\GUID::Recording, $Capabilities[\ONVIF\IO\Attribute::NbrOfRecordingJobs] > 0, $RecordingTopics);

// Stream H264
$StreamCreateParams = [
'moduleID' => \ONVIF\GUID::Stream,
Expand Down Expand Up @@ -273,7 +291,7 @@ public function GetConfigurationForm(): string
$StreamJPEGValues[] = $Device;
}

$Values = array_merge($EventValues, $InputValues, $OutputValues, $StreamValues, $StreamJPEGValues);
$Values = array_merge($EventValues, $InputValues, $OutputValues, $RecordingValues, $StreamValues, $StreamJPEGValues);
$Form['actions'][0]['values'] = $Values;
$this->SendDebug('FORM', json_encode($Form), 0);
$this->SendDebug('FORM', json_last_error_msg(), 0);
Expand Down
16 changes: 15 additions & 1 deletion ONVIF IO/module.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public function Create(): void
$this->RegisterAttributeInteger(\ONVIF\IO\Attribute::NbrOfVideoSources, 0);
$this->RegisterAttributeInteger(\ONVIF\IO\Attribute::NbrOfAudioSources, 0);
$this->RegisterAttributeInteger(\ONVIF\IO\Attribute::NbrOfSerialPorts, 0);
$this->RegisterAttributeInteger(\ONVIF\IO\Attribute::NbrOfRecordingJobs, 0);
$this->RegisterAttributeBoolean(\ONVIF\IO\Attribute::HasSnapshotUri, false);
$this->RegisterAttributeBoolean(\ONVIF\IO\Attribute::HasRTSPStreaming, false);
$this->RegisterAttributeBoolean(\ONVIF\IO\Attribute::RuleSupport, false);
Expand Down Expand Up @@ -165,6 +166,7 @@ public function ForwardData(string $JSONString): string
$Capabilities[\ONVIF\IO\Attribute::NbrOfOutputs] = $this->ReadAttributeInteger(\ONVIF\IO\Attribute::NbrOfOutputs);
$Capabilities[\ONVIF\IO\Attribute::NbrOfInputs] = $this->ReadAttributeInteger(\ONVIF\IO\Attribute::NbrOfInputs);
$Capabilities[\ONVIF\IO\Attribute::NbrOfSerialPorts] = $this->ReadAttributeInteger(\ONVIF\IO\Attribute::NbrOfSerialPorts);
$Capabilities[\ONVIF\IO\Attribute::NbrOfRecordingJobs] = $this->ReadAttributeInteger(\ONVIF\IO\Attribute::NbrOfRecordingJobs);
$Capabilities[\ONVIF\IO\Attribute::HasSnapshotUri] = $this->ReadAttributeBoolean(\ONVIF\IO\Attribute::HasSnapshotUri);
$Capabilities[\ONVIF\IO\Attribute::HasRTSPStreaming] = $this->ReadAttributeBoolean(\ONVIF\IO\Attribute::HasRTSPStreaming);
$Capabilities[\ONVIF\IO\Attribute::AnalyticsModuleSupport] = $this->ReadAttributeBoolean(\ONVIF\IO\Attribute::AnalyticsModuleSupport);
Expand Down Expand Up @@ -499,6 +501,7 @@ protected function StartConnection()
$NbrOfOutputs = 0;
$NbrOfInputs = 0;
$NbrOfSerialPorts = 0;
$NbrOfRecordingJobs = 0;
$RelayOutputs = [];
$DigitalInputs = [];
$AnalyticsModuleSupport = false;
Expand All @@ -516,6 +519,7 @@ protected function StartConnection()
$NbrOfAudioSources = $this->ReadAttributeInteger(\ONVIF\IO\Attribute::NbrOfAudioSources);
$NbrOfInputs = $this->ReadAttributeInteger(\ONVIF\IO\Attribute::NbrOfInputs);
$NbrOfOutputs = $this->ReadAttributeInteger(\ONVIF\IO\Attribute::NbrOfOutputs);
$NbrOfRecordingJobs = $this->ReadAttributeInteger(\ONVIF\IO\Attribute::NbrOfRecordingJobs);
}
$XAddr = $this->ReadAttributeArray(\ONVIF\IO\Attribute::XAddr);

Expand All @@ -536,6 +540,7 @@ protected function StartConnection()
$NbrOfInputs = $this->ReadAttributeInteger(\ONVIF\IO\Attribute::NbrOfInputs);
$NbrOfOutputs = $this->ReadAttributeInteger(\ONVIF\IO\Attribute::NbrOfOutputs);
$NbrOfSerialPorts = $this->ReadAttributeInteger(\ONVIF\IO\Attribute::NbrOfSerialPorts);
$NbrOfRecordingJobs = $this->ReadAttributeInteger(\ONVIF\IO\Attribute::NbrOfRecordingJobs);
$XAddr = $this->ReadAttributeArray(\ONVIF\IO\Attribute::XAddr);
}
// 4. ONVIF Request GetServiceCapabilities an \ONVIF\WSDL::Management
Expand Down Expand Up @@ -701,13 +706,16 @@ protected function StartConnection()
if ($XAddr[\ONVIF\NS::Recording]) {
$RecordingCapabilities = $this->GetServiceCapabilities($XAddr[\ONVIF\NS::Recording], \ONVIF\WSDL::Recording); // noch ohne Funktion.. todo
if ($RecordingCapabilities) {
$NbrOfRecordingJobs = $RecordingCapabilities['Capabilities']['MaxRecordingJobs'] ?? $NbrOfRecordingJobs;
} else {
if ($this->Profile->HasProfile(\ONVIF\Profile::G)) { //Profile G ist GetServiceCapabilities bei Recording Pflicht
$this->Warnings = array_merge($this->Warnings, [$this->Translate('Failed to get Recording service capabilities. Device reported ONVIF G scope, but is not compliant!')]);
$this->LogMessage($this->Translate('Failed to get Recording service capabilities. Device reported ONVIF G scope, but is not compliant!'), KL_WARNING);
}
}
}
// Variablen in Attribute schreiben:
$this->WriteAttributeInteger(\ONVIF\IO\Attribute::NbrOfRecordingJobs, $NbrOfRecordingJobs);
// 4g.ONVIF Request GetNodes an \ONVIF\WSDL::Replay
if ($XAddr[\ONVIF\NS::Replay]) {
$ReplayCapabilities = $this->GetServiceCapabilities($XAddr[\ONVIF\NS::Replay], \ONVIF\WSDL::Replay); // noch ohne Funktion.. todo
Expand Down Expand Up @@ -1729,6 +1737,7 @@ protected function GetCapabilities(): bool
$this->WriteAttributeInteger(\ONVIF\IO\Attribute::NbrOfOutputs, $NbrOfOutputs);
return !is_a($Result, 'SoapFault');
}

protected function GetScopes(): false|array
{
$ScopeResult = $this->SendData('', \ONVIF\WSDL::Management, 'GetScopes', true);
Expand All @@ -1746,6 +1755,7 @@ protected function GetScopes(): false|array
}
return array_column($Scopes, 'ScopeItem');
}

protected function GetNodes(): false|array
{
$XAddr = $this->ReadAttributeArray(\ONVIF\IO\Attribute::XAddr);
Expand All @@ -1761,6 +1771,7 @@ protected function GetNodes(): false|array
}
return $Result;
}

protected function GetVideoSources($Uri, $WSDL): false|array
{
$VideoSources = $this->SendData($Uri, $WSDL, 'GetVideoSources', true);
Expand Down Expand Up @@ -1900,6 +1911,8 @@ protected function GetServices(): bool
/** @todo */
// Welche Capabilities brauchen wir?
case \ONVIF\NS::Recording:
$Query = '//' . $NSKey . ':Capabilities/@MaxRecordingJobs';
$this->WriteAttributeIntegerByXPathQuery(\ONVIF\IO\Attribute::NbrOfRecordingJobs, $Query, $xPath);
break;
case \ONVIF\NS::Replay:
break;
Expand Down Expand Up @@ -2052,7 +2065,7 @@ protected function GetSystemDateAndTime(): bool
* @param array $Params
* @return \SoapFault|\stdClass
*/
protected function SendData(string $URI, string $wsdl, string $Function, bool $UseLogin = false, array $Params = [], string &$Response = '', array $Header = [], int $Timeout = 5): SoapFault|stdClass
protected function SendData(string $URI, string $wsdl, string $Function, bool $UseLogin = false, array $Params = [], string &$Response = '', array $Header = [], int $Timeout = 5): null|SoapFault|stdClass
{
if ($URI == '') {
$URI = $this->Host . '/onvif/device_service';
Expand Down Expand Up @@ -2103,6 +2116,7 @@ protected function SendData(string $URI, string $wsdl, string $Function, bool $U
unset($ONVIFClient);
return $Result;
}

protected function GetEventReceiverFormValues(): array
{
$EventList = [];
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
[![Run Tests](https://github.com/Nall-chan/ONVIF/workflows/Run%20Tests/badge.svg)](https://github.com/Nall-chan/ONVIF/actions)
[![Spenden](https://www.paypalobjects.com/de_DE/DE/i/btn/btn_donate_SM.gif)](#3-spenden)[![Wunschliste](https://img.shields.io/badge/Wunschliste-Amazon-ff69fb.svg)](#3-spenden)

# ONVIF Profil S & T Library <!-- omit in toc -->
# ONVIF Profil S, T & G Library <!-- omit in toc -->

Einbinden von ONVIF kompatiblen Geräten in IPS.

Expand All @@ -29,7 +29,7 @@ Einbinden von ONVIF kompatiblen Geräten in IPS.
## 1. Vorbemerkungen

### Zur Library
Diese Library wurde nicht dazu entwickelt komplett den Profil S & T Spezifikationen zu entsprechen oder deren gesamten Funktionsumfang abzubilden.
Diese Library wurde nicht dazu entwickelt komplett den Profile Spezifikationen S, T und G zu entsprechen oder deren gesamten Funktionsumfang abzubilden.
Vielmehr liegt der Schwerpunkt auf eine einfache und unkomplizierte Integration bestimmter Bestandteile (LiveStream, Steuerung) und Funktionen (Events, Digital Ein-/Ausgänge) in Symcon.
Dadurch ist es auch möglich Geräte in Symcon einzubinden welche ihrerseits die Spezifikationen nicht vollständig oder nicht korrekt umsetzen.
Dennoch wird geprüft ob Geräte sich nicht an verpflichtende Funktionen halten und diese als Popup in der Konfiguration der IO-Instanzen gemeldet.
Expand Down Expand Up @@ -84,7 +84,7 @@ Für das Discovery werden Pakete über die Multicast-Adresse `239.255.255.250` a
## 2. Voraussetzungen

* IP-Symcon ab Version 7.0
* Kameras oder Video-Encoder mit ONVIF Profil S und/oder Profil T Unterstützung.
* Kameras oder Video-Encoder mit ONVIF Profil S und/oder Profil T & G Unterstützung.

## 3. Software-Installation

Expand Down Expand Up @@ -119,6 +119,8 @@ Für das Discovery werden Pakete über die Multicast-Adresse `239.255.255.250` a
- __ONVIF Events__ ([Dokumentation](ONVIF%20Events/README.md))
Bildet empfangbare ONVIF-Ereignisse in Symcon ab.

- __ONVIF Recording__ ([Dokumentation](ONVIF%20Recording/README.md))
Anzeige und Steuerung von vom Gerät verwalteten Aufzeichnungen.

## 5. Anhang

Expand Down
8 changes: 4 additions & 4 deletions libs/ONVIF.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function __doRequest(string $request, string $location, string $action, i
$curl_errno = curl_errno($ch);
if ($curl_errno) {
throw new \SoapFault((string) $curl_errno, curl_error($ch));
return '';
return null;
}
if (!is_bool($response)) {
$Parts = explode("\r\n\r\n<?xml", $response);
Expand All @@ -90,17 +90,17 @@ public function __doRequest(string $request, string $location, string $action, i
$response = '';
}
}
if ($http_code > 400) { /*&& ($response == ''))*/
if ($http_code > 400) {
throw new \SoapFault('http:' . $http_code, explode("\r\n", $this->__last_response_headers)[0]);
return '';
return null;
}
return is_bool($response) ? '' : $response;
}
}

class ONVIF
{
public $client;
public ONVIFsoapClient $client;

public function __construct(string $wsdl, string $service, ?string $username = null, ?string $password = null, array $Headers = [], int $Timeout = 5)
{
Expand Down
2 changes: 2 additions & 0 deletions libs/wsdl.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ class GUID
public const Stream = '{FA889450-38B6-7E20-D4DC-F2C6D0B074FB}';
public const ImageGrabber = '{18EA97C1-3CEC-80B7-4CAA-D91F8A2A0599}';
public const Event = '{62584C2E-4542-4EBF-1E92-299F4CF364E4}';
public const Recording = '{24EE27C1-F77B-4EEE-9C9E-C53C674EFF47}';
}
}

Expand Down Expand Up @@ -234,6 +235,7 @@ class Attribute
public const NbrOfVideoSources = 'NbrOfVideoSources';
public const NbrOfAudioSources = 'NbrOfAudioSources';
public const NbrOfSerialPorts = 'NbrOfSerialPorts';
public const NbrOfRecordingJobs = 'NbrOfRecordingJobs';
public const HasSnapshotUri = 'HasSnapshotUri';
public const HasRTSPStreaming = 'HasRTSPStreaming';
public const RuleSupport = 'RuleSupport';
Expand Down

0 comments on commit 7c03c74

Please sign in to comment.