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).
New for version 1.0.7
This release has logging capabilities through use of the loggy package for Dart code and the flutter_loggy package for Flutter code. The code includes both a Dart example and a Flutter example that demonstreate usage. By default the logging level is set to LogLevel.error
, which only logs exceptions.
New for version 1.0.0
As of the 1.0.0 release of this package, there is a cli utility included that can be used to return data for any API call currently supported by the package. If you want to get started quicky with the cli utility run these commands in a termainal session:
pub global activate easy_onvif
onvif --help
Please see the cli documentation README.md for more detailed usage information.
Getting Started
To use this package in your code, first add the dependency to your project:
dependencies:
...
easy_onvif: ^1.1.0
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 ipaddress],
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.
Supported Onvif Operations
Device Management
Onvif Operation | Dart Method | Dart Return Type | Test |
---|---|---|---|
CreateUsers | createUsers | Future<void> |
|
DeleteUsers | deleteUsers | Future<void> |
|
GetCapabilities | getCapabilities | Future<Capabilities> |
x |
GetDeviceInformation | getDeviceInformation | Future<GetDeviceInformationResponse> |
x |
GetHostname | getHostname | Future<HostnameInformation> |
x |
GetNetworkProtocols | getNetworkProtocols | Future<List<NetworkProtocol>> |
X |
GetNTP | getNtp | Future<NtpInformation> |
x |
GetServiceCapabilities | getServiceCapabilities | Future<DeviceServiceCapabilities> |
x |
GetServices | getServices | Future<List<Service>> |
x |
GetSystemDateAndTime | getSystemDateAndTime | Future<SystemDateAndTime> |
x |
GetSystemUris | getSystemUris | Future<GetSystemUrisResponse> |
x |
GetUsers | getUsers | Future<List<User>> |
x |
Media
Onvif Operation | Dart Method | Dart Return Type | Test |
---|---|---|---|
GetAudioSources | getAudioSources | Future<AudioSource> |
x |
GetProfiles | getProfiles | Future<List<Profile>> |
x |
GetSnapshotUri | getSnapshotUri | Future<MediaUri> |
x |
GetStreamUri | getStreamUri | Future<MediaUri> |
x |
GetVideoSources | getVideoSources | Future<VideoSources> |
x |
StartMulticastStreaming | startMulticastStreaming | Future<void> |
|
StopMulticastStreaming | stopMulticastStreaming | Future<void> |
|
PTZ
Onvif Operation | Dart Method | Dart Return Type | Test |
---|---|---|---|
AbsoluteMove | absoluteMove | Future<void> |
|
ContinuousMove | continuousMove | Future<void> |
|
GetCompatibleConfigurations | getCompatibleConfigurations | Future<List<PtzConfiguration>> |
x |
GetConfiguration | getConfiguration | Future<PtzConfiguration> |
x |
GetConfigurations | getConfigurations | Future<List<PtzConfiguration>> |
x |
GetPresets | getPresets | Future<List<Preset>> |
x |
GetStatus | getStatus | Future<PtzStatus> |
x |
GotoPreset | gotoPreset | Future<void> |
|
RelativeMove | relativeMove | Future<void> |
|
RemovePreset | removePreset | Future<void> |
|
SetPreset | setPreset | Future<String> |
x |
Stop | stop | Future<void> |
|
PTZ Helper Methods
Onvif Operation | Dart Method | Return Type |
---|---|---|
N/A | move | Future<void> |
N/A | moveDown | Future<void> |
N/A | moveLeft | Future<void> |
N/A | moveRight | Future<void> |
N/A | moveUp | Future<void> |
N/A | zoomIn | Future<void> |
N/A | zoomOut | Future<void> |
N/A | getCurrentPreset | Future<Preset?> |
Tested Onvif Devices
Manufacturer | Model |
---|---|
D-Link Corporation | DCS-6511 |
Happytimesoft | IPCamera |
ONVIF | ENP1A14-IR/25X |
Unknown | GX728MF-IR28 |
The values returned by the Onvif API GetDeviceInformation
call.
What's next
- More comprehensive unit tests
- Device discovery is planned for the 1.1.x release of the library.
Libraries
- cmd/onvif_device_management_command
- cmd/onvif_helper_command
- cmd/onvif_media_command
- cmd/onvif_ptz_command
- model/address
- model/analytics
- model/audio_decoder_configuration
- model/audio_encoder_configuration
- model/audio_output_configuration
- model/audio_source
- model/audio_source_configuration
- model/audio_sources_response
- model/backlight_compensation
- model/body
- model/bounds
- model/capabilities
- model/capabilities_response
- model/code
- model/compatible_configurations_response
- model/configuration
- model/configuration_response
- model/configurations_response
- model/date
- model/date_time
- model/detail
- model/device
- model/device_information_response
- model/device_service_capabilities
- model/envelope
- model/event
- model/events
- model/exposure
- model/focus
- model/get_metadata_configurations_response
- model/get_preset_response
- model/h264
- model/header
- model/hostname_information
- model/hostname_response
- model/i8n_text
- model/imaging
- model/media
- model/media_uri
- model/metadata_configuration
- model/misc_capabilities
- model/mpeg4
- model/multicast
- model/network_capabilities
- model/network_protocol
- model/network_protocols_response
- model/ntp
- model/ntp_information
- model/ntp_response
- model/pan_tilt
- model/pan_tilt_limits
- model/preset
- model/probe/app_sequence
- model/probe/endpoint_reference
- model/probe/probe_match
- model/probe/probe_matches
- model/profile
- model/profiles_response
- model/ptz
- model/ptz_configuration
- model/ptz_filter
- model/ptz_position
- model/ptz_speed
- model/ptz_status
- model/rate_control
- model/reason
- model/resolution
- model/root
- model/security_capabilities
- model/service
- model/service_capabilities_response
- model/services_response
- model/set_preset_response
- model/space
- model/space1d
- model/space2d
- model/status_response
- model/supported_version
- model/system
- model/system_capabilities
- model/system_date_and_time
- model/system_date_time_response
- model/system_log
- model/system_log_uris
- model/system_uris_response
- model/time
- model/time_zone
- model/uri_response
- model/user
- model/users_response
- model/version
- model/video_analytics_configuration
- model/video_encoder_configuration
- model/video_source
- model/video_source_configuration
- model/video_sources_response
- model/white_balance
- model/wide_dynamic_range
- model/window
- model/zoom
- model/zoom_limits
- onvif
- ONVIF Client Implementation in Dart
- util/extra
- util/util