\TrassirServer
Basic low-level Trassir Server NVRs interraction class.
Based on: https://github.com/dglushakov/TrassirNVR
Synopsis
class TrassirServer
{
- // constants
- const LOG_PATH = 'exports/trassirdebug.log';
- // members
- protected bool/int $debug = false;
- protected string $name = '';
- protected string|null $ip = NULL;
- protected string $sdkProtocol = 'https';
- protected integer $port = 8080;
- protected integer $httpVideoPort = 555;
- protected string $httpVideoProtocol = 'http';
- protected string $guid = '';
- protected string|false $sid = false;
- protected string $userName = '';
- protected string $password = '';
- protected $sdkPassword;
- protected $cache = '';
- protected integer $cacheTimeout = 900;
- protected array $serverObjects = ;
- protected array $channels = ;
- protected array $channelNames = ;
- protected array $trassirUsers = ;
- protected array $serviceAccountNames = ;
- protected $stream_context;
- // methods
- public void __construct()
- protected bool initialConnect()
- protected void initCache()
- protected void setIp()
- protected void setPort()
- protected void setUserName()
- protected void setDebug()
- protected void setPassword()
- protected void setSdkPassword()
- public string|null getName()
- public string getGuid()
- protected bool checkConnection()
- protected void logDebug()
- protected bool|string login()
- protected string clearReply()
- protected array apiRequest()
- public array getServerObjects()
- public array getHealth()
- public array getChannels()
- public array getServerSettings()
- protected array getUsers()
- public bool createUser()
- protected bool restrictUserRighs()
- protected bool/array setUserACL()
- public bool assignUserChannels()
- public array getUserNames()
- public string/bool getUserGuid()
- public array getUserSettings()
- protected array setUserSettings()
- public string saveScreenshot()
- public bool|string getLiveVideoStream()
- public array getChannelRecordMode()
- public array setChannelRecordMode()
- protected array getCameras()
- public string getCameraIp()
- public array getCameraProtocols()
- public array getCameraModels()
- public array createCamera()
- public array getAllCameraIps()
- public void setModelMismatch()
- public int getModelMismatch()
Constants
Name | Value |
---|---|
LOG_PATH | 'exports/trassirdebug.log' |
Members
protected
- $cache
—
Caching object placeholder - $cacheTimeout
—
int
Session caching interval in seconds - $channelNames
—
array
Contains array of available channel names as guid=>name - $channels
—
array
Available Trassir Server channels as index=>chandata - $debug
—
bool/int
Object instance debug flag - $guid
—
string
Contains current instance GUID - $httpVideoPort
—
int
HTTP Video Streaming port - $httpVideoProtocol
—
string
Default http video streaming protocol - $ip
—
string|null
Contains IP address of Trassir server host - $name
—
string
Contains current instance Trassir Server hostname - $password
—
string
Password for connecting Trassir Server NVR - $port
—
int
Contains Trassir server HTTPS port for further API requests - $sdkPassword
—
string
Trassir SDK API key - $sdkProtocol
—
string
Basic transport protocol for Trassir SDK interraction - $serverObjects
—
array
Current instance server objects tree - $serviceAccountNames
—
array
Contains default service users account names which will be ignored by some safe methods - $sid
—
string|false
Current instance session ID - $stream_context
—
resource
Stream context for working with self-signed certs - $trassirUsers
—
array
Contains available users array as index=>username or guid - $userName
—
string
Username for connecting Trassir Server NVR
Methods
protected
- apiRequest() — Performs SDK API request to connected Trassir Server
- checkConnection() — Checking is NVR online or not to prevent further errors
- clearReply() — Returns clean JSON data without shitty comments at the end
- getCameras() — Returns array of all available IP cameras GUIDs
- getUsers() — Returns array of server users/their guids
- initCache() — Inits system caching object for further usage and storing SID
- initialConnect() — Performs initial Server object connection
- logDebug() — Do some debug output and logging in the future
- login() — Get current NVR session ID (sid) using login and password
- restrictUserRighs()
- setDebug() — Modify current instance debug flag
- setIp() — Sets current instance IP
- setPassword() — Sets current instance password
- setPort() — Sets current instance HTTPS port
- setSdkPassword() — Sets Trassir SDK API key into current instance
- setUserACL() — Sets user ACL for some channels permissions.
- setUserName() — Sets current instance username
- setUserSettings() — Sets some user setting on Trassir Server by its guid
public
- __construct() — Creates new instance of TrassirServer object
- assignUserChannels() — Set some user ACL to allow him basic usage of his cameras
- createCamera() — Creates new camera device on remote Trassir Server NVR
- createUser() — Creates user on Trassir Server.
- getAllCameraIps() — Returns array of all registered cameras as IP=>guid
- getCameraIp() — Returns camera IP by its GUID
- getCameraModels() — Returns array of supported cameras for selected protocol
- getCameraProtocols() — Returns array of available supported camera protocols (vendors)
- getChannelRecordMode() — Returns channel recording type. Possible values: 1 - permanent, 2 - manual, 3 - on detector
- getChannels() — Returns array of available channels as guid=>name
- getGuid() — Returns curren instance GUID
- getHealth() — Returns array of system health indicators. Also fills channels_health
- getLiveVideoStream() — Returns URL to some channel video stream
- getModelMismatch() — Returns current some camera model mismatch warning state
- getName() — Returns current instance server hostname
- getServerObjects() — Returns all of server objects (channels, IP-devices etc.)
- getServerSettings() — Returns server settings main tree
- getUserGuid() — Returns existing user GUID by its login
- getUserNames() — Returns registered non system users as login=>guid
- getUserSettings() — Returns full array of some user settings by its guid
- saveScreenshot() — Saves channel screenshot to local file system
- setChannelRecordMode() — Sets channel record mode. Possible values: 1 - permanent, 2 - manual, 3 - on detector
- setModelMismatch() — Disables/enables model mismatch warning on some cameras.