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).
Table of contents
- New for version 2.0.0
- Getting Started
- Usage Example
- Connecting to an Onvif device
- Interacting with the device through Onvif operations
- Onvif cli (Onvif at the command prompt)
- Supported Onvif Operations
- Tested Onvif Devices
- What's next
- Features and bugs
- Known Issues
- Contributing
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+15
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.
version Display the package name and version.
Please see the cli documentation README.md for more detailed usage information.
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] |
GetDiscoveryMode | getDiscoveryMode | Future<String> | [ ] |
GetDNS | getDNS | Future<DnsInformation> | [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<bool> | [ ] |
ContinuousMove | continuousMove | Future<bool> | [x] |
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] |
GotoHomePosition | gotoHomePosition | Future<bool> | [ ] |
GotoPreset | gotoPreset | Future<bool> | [ ] |
RelativeMove | relativeMove | Future<void> | [ ] |
RemovePreset | removePreset | Future<void> | [ ] |
SetPreset | setPreset | Future<String> | [x] |
Stop | stop | Future<bool> | [x] |
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
The values returned by the Onvif API GetDeviceInformation
call.
Manufacturer | Model | Known Issue |
---|---|---|
D-Link Corporation | DCS-6511 | |
Happytimesoft | IPCamera | |
ONVIF | ENP1A14-IR/25X | |
TP-Link | TL-IPC43AN-4 | RelativeMove¹ |
Unknown | GX728MF-IR28 | |
TELEKOMSI | IPC-K22-TSI |
¹ 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
Features and bugs
Please file feature requests and bugs with the issue tracker.
Known Issues
Github Issue #23, in Flutter when using v2.0.13+4 and above you may see the following message when performing a dart pub get
:
Because every version of flutter from sdk depends on collection 1.16.0 and xml >=6.2.0 depends on collection ^1.17.0, flutter from sdk is incompatible with xml >=6.2.0.
And because easy_onvif >=2.0.13+11 depends on xml ^6.2.2, flutter from sdk is incompatible with easy_onvif >=2.0.13+11.
So, because cow depends on both flutter from sdk and easy_onvif ^2.0.13+13, version solving failed.
pub get failed (1; So, because cow depends on both flutter from sdk and easy_onvif ^2.0.13+13, version solving failed.)
The fix for this is to add the following section to your pubspec.yaml
:
dependency_overrides:
collection: ^1.17.0
Contributing
Any help from the open-source community is always welcome and needed:
- Found an issue?
- Please fill a bug report with details.
- Need a feature?
- Open a feature request with use cases.
- Are you using and liking the project?
- Promote the project: create an article or post about it
- Make a donation
- Do you have a project that uses this package
- let's cross promote, let me know and I'll add a link to your project
- Are you a developer?
- Fix a bug and send a pull request.
- Implement a new feature.
- Improve the Unit Tests.
- Have you already helped in any way?
- Many thanks from me, the contributors and everybody that uses this project!
If you donate 1 hour of your time, you can contribute a lot, because others will do the same, just be part and start with your 1 hour.
Libraries
- easy_onvif
- ONVIF Client Implementation in Dart
- meta
- DO NOT EDIT THIS FILE THIS FILE IS AUTOMATICALLY OVER WRITTEN BY PublishTools
- onvif_device_management_command
- onvif_helper_command
- onvif_media_command
- onvif_probe_command
- onvif_ptz_command
- onvif_version_command