faithoflifedev / easy_onvif_workspace

This package works with a variety of ONVIF compatible devices allowing for IP Cameras and NVRs (network video recorders) to be integrated into Dart and Flutter applications.
33 stars 21 forks source link

camera recording #40

Closed Flynn2018 closed 1 year ago

Flynn2018 commented 1 year ago

Can the plugin provide methods to control the camera for recording, such as starting and ending recording? And also add the feature to get stream address of playback video?

faithoflifedev commented 1 year ago

Hi @Flynn2018 ,

The package does not yet support recording/playback as part of the high-level API, however you could access this functionality with low-level calls:

As shown here in the README

So you could so something like: (you will have to refer to the appropriate Onvif spec doc for tags and namespaces)

// sample low level request
//
// build a xml fragment for the specific Onvif operation
final tt = 'http://www.onvif.org/ver10/schema';
final trp = 'http://www.onvif.org/ver10/replay/wsdl';

Transport.builder.element('GetReplayUri', nest: () {
  Transport.builder.namespace(trp);

  Transport.builder.element('StreamSetup', nest: () {
    Transport.builder.element('Stream', nest: () {
      Transport.builder.namespace(tt);
      Transport.builder.text('RTP-Unicast',);
    });

    Transport.builder.element('Transport', nest: () {
      Transport.builder.namespace(tt);
      Transport.builder.element('Protocol', nest: () {
        Transport.builder.text('RTSP');
      });
    });
  });

  Transport.builder.element('RecordingToken', nest: () {
    Transport.builder.text(recordingToken);
  });
});

final requestFragment = Transport.builder.buildFragment();

// build the soap request envelope and send the request
final envelope = await onvif.transport.sendRequest(
    [device reply uri determined through deviceManagement.getServices],
    transport.securedEnvelope(requestFragment),
);

print(envelope.body.response);

In terms of adding support for this functionality, it would likely be a few months before this is added to the package. Though donations do help items move up on the priority list :-)

Also, if you are able to get things working with low-level calls, please pass along some sample code as it would make creating the high-level supporting methods much easier.

faithoflifedev commented 1 year ago

@Flynn2018 ,

Initial support for recording has been added to v2.1.1-dev.1, but I don't really have a device to fully test the new code. Please let me know if any of it works for you.