ONVIF Client protocol Profile S (Live Streaming) Dart implementation

This is a wrapper to ONVIF protocol which allows you to get information about your NVT (network video transmitter) device, its media sources, control PTZ (pan-tilt-zoom) movements and manage presets. It will also allow you to get information about your NVR (network video recorder).

pub package Build Status

Table of contents

Buy me a coffee

New for version 2.0.0

Device discovery is finally here. If you're using that cli utilities that became available from v1.0.0, you can discover Onvif devices on your network with the command:

onvif probe

Or, in dart code:

final multicastProbe = MulticastProbe();

await multicastProbe.probe();

for (var device in multicastProbe.onvifDevices) {
  print(
      '${device.name} ${device.location} ${device.hardware} ${device.xaddr}');
}

Getting Started

To use this package in your code, first add the dependency to your project:

dependencies:
  ...
  easy_onvif: ^2.0.13+1

If you need additional help getting started with dart, check out these guides.

Usage Example

Import the easy_onvif library.

import 'package:easy_onvif/onvif.dart';

Connecting to an Onvif device

final onvif = await Onvif.connect(
 host: [hostname or ip address],
 username: [username],
 password: [password]);

Interacting with the device through Onvif operations

Refer to the tables below for the supported operations.

Through the deviceManagement operations you can get information about the connected device.

var deviceInfo = await onvif.deviceManagement.getDeviceInformation();

print(deviceInfo.model);

Many operations require you to supply a profileToken which can be retrieved through media operations.

var profiles = await onvif.media.getProfiles();

profiles.forEach((element) {
 print('${element.name}  ${element.token}');
});

var profileToken = profiles[0].token;

With the ptz operations you can get a list of camera presets from the connected device.

var presets = await onvif.ptz.getPresets(profileToken);

//get a specific preset
var preset = presets[11];

//print the preset values
print(
 'preset: ${preset.position.panTilt?.x}  ${preset.position.panTilt?.y}  ${preset.position.zoom?.x}');

//use the GotoPreset operation to point the camera to the given preset
await onvif.ptz.gotoPreset(profileToken, preset);

Be sure to look through the API Reference for information about the parameters required for the supported Onvif operations.

Onvif cli (Onvif at the command prompt)

A command line interface for controlling an Onvif device with cli commands

Install using dart pub:

dart pub global activate easy_onvif

Install using brew:

brew tap faithoflifedev/easy_onvif
brew install onvif

Run the following command to see help:

onvif --help

Result,

A command line interface for controlling Onvif compliant devices

Usage: onvif <command> [arguments]

Global options:
-h, --help           Print this usage information.
    --config-file    (defaults to "$HOME/.onvif/credentials.json")
    --log-level      [all, debug, info, warning, error, off (default)]

Available commands:
  authorize           Generate an authentication file for an Onvif device
  device-management   Device management commands.
  media               Media commands.
  probe               Probe/device discovery command.
  ptz                 PTZ commands.

Please see the cli documentation README.md for more detailed usage information.

Supported Onvif Operations

Device Management

Onvif OperationDart MethodDart Return TypeTest
CreateUserscreateUsersFuture<void>[ ]
DeleteUsersdeleteUsersFuture<void>[ ]
GetCapabilitiesgetCapabilitiesFuture<Capabilities>[x]
GetDeviceInformationgetDeviceInformationFuture<GetDeviceInformationResponse>[x]
GetHostnamegetHostnameFuture<HostnameInformation>[x]
GetNetworkProtocolsgetNetworkProtocolsFuture<List<NetworkProtocol>>[x]
GetNTPgetNtpFuture<NtpInformation>[x]
GetServiceCapabilitiesgetServiceCapabilitiesFuture<DeviceServiceCapabilities>[x]
GetServicesgetServicesFuture<List<Service>>[x]
GetSystemDateAndTimegetSystemDateAndTimeFuture<SystemDateAndTime>[x]
GetSystemUrisgetSystemUrisFuture<GetSystemUrisResponse>[x]
GetUsersgetUsersFuture<List<User>>[x]

Media

Onvif OperationDart MethodDart Return TypeTest
GetAudioSourcesgetAudioSourcesFuture<AudioSource>[x]
GetProfilesgetProfilesFuture<List<Profile>>[x]
GetSnapshotUrigetSnapshotUriFuture<MediaUri>[x]
GetStreamUrigetStreamUriFuture<MediaUri>[x]
GetVideoSourcesgetVideoSourcesFuture<VideoSources>[x]
StartMulticastStreamingstartMulticastStreamingFuture<void>[ ]
StopMulticastStreamingstopMulticastStreamingFuture<void>[ ]

PTZ

Onvif OperationDart MethodDart Return TypeTest
AbsoluteMoveabsoluteMoveFuture<bool>[ ]
ContinuousMovecontinuousMoveFuture<bool>[x]
GetCompatibleConfigurationsgetCompatibleConfigurationsFuture<List<PtzConfiguration>>[x]
GetConfigurationgetConfigurationFuture<PtzConfiguration>[x]
GetConfigurationsgetConfigurationsFuture<List<PtzConfiguration>>[x]
GetPresetsgetPresetsFuture<List<Preset>>[x]
GetStatusgetStatusFuture<PtzStatus>[x]
GotoPresetgotoPresetFuture<bool>[ ]
RelativeMoverelativeMoveFuture<void>[ ]
RemovePresetremovePresetFuture<void>[ ]
SetPresetsetPresetFuture<String>[x]
StopstopFuture<bool>[x]

PTZ Helper Methods

Onvif OperationDart MethodReturn Type
N/AmoveFuture<void>
N/AmoveDownFuture<void>
N/AmoveLeftFuture<void>
N/AmoveRightFuture<void>
N/AmoveUpFuture<void>
N/AzoomInFuture<void>
N/AzoomOutFuture<void>
N/AgetCurrentPresetFuture<Preset?>

Tested Onvif Devices

The values returned by the Onvif API GetDeviceInformation call.

ManufacturerModelKnown Issue
D-Link CorporationDCS-6511
HappytimesoftIPCamera
ONVIFENP1A14-IR/25X
TP-LinkTL-IPC43AN-4RelativeMove┬╣
UnknownGX728MF-IR28

┬╣ For TP-Link, RelativeMove is not properly supported on the tested device, however easy_onvif falls back to GetStatus and AbsoluteMove to simulate a relative move.

What's next

  • More comprehensive unit tests

Libraries

absolute_move_response
address
analytics
app_sequence
audio_decoder_configuration
audio_encoder_configuration
audio_output_configuration
audio_source
audio_source_configuration
audio_sources_response
backlight_compensation
body
bounds
capabilities
capabilities_response
code
compatible_configurations_response
configuration
configuration_response
configurations_response
continuous_move_response
date
date_time
detail
device
device_information_response
device_service_capabilities
easy_onvif
ONVIF Client Implementation in Dart
endpoint_reference
envelope
event
events
exposure
extra
focus
get_metadata_configurations_response
get_preset_response
goto_preset_response
h264
hostname_information
hostname_response
i8n_text
imaging
media
media_uri
meta
meta_update
metadata_configuration
misc_capabilities
mpeg4
multicast
network_capabilities
network_protocol
network_protocols_response
ntp
ntp_information
ntp_response
onvif_authorize_command
onvif_device_management_command
onvif_helper_command
onvif_media_command
onvif_probe_command
onvif_ptz_command
onvif_version_command
pan_tilt
pan_tilt_limits
preset
probe_match
probe_matches
profile
profiles_response
ptz
ptz_configuration
ptz_filter
ptz_position
ptz_speed
ptz_status
rate_control
reason
resolution
root
security_capabilities
service
service_capabilities_response
services_response
set_preset_response
space
space1d
space2d
status_response
stderr_printer
stop_response
supported_version
system
system_capabilities
system_date_and_time
system_date_time_response
system_log
system_log_uris
system_uris_response
time
time_zone
uri_response
user
users_response
util
version
video_analytics_configuration
video_encoder_configuration
video_source
video_source_configuration
video_sources_response
white_balance
wide_dynamic_range
window
zoom
zoom_limits