Source: replay.js

  1. /**
  2. * @namespace cam
  3. * @description Replay section for Cam class
  4. * @author Roger Hardiman <opensource@rjh.org.uk>
  5. * @licence MIT
  6. */
  7. module.exports = function(Cam) {
  8. const linerase = require('./utils').linerase;
  9. /**
  10. * @callback Cam~ResponseUriCallback
  11. * @property {string} uri
  12. */
  13. /**
  14. * Receive Replay Stream URI
  15. * @param {Object} [options]
  16. * @param {string} [options.stream]
  17. * @param {string} [options.protocol]
  18. * @param {string} [options.recordingToken]
  19. * @param {Cam~ResponseUriCallback} [callback]
  20. */
  21. Cam.prototype.getReplayUri = function(options, callback) {
  22. if (callback === undefined) { callback = options; options = {}; }
  23. this._request({
  24. service: 'replay'
  25. , body: this._envelopeHeader() +
  26. '<GetReplayUri xmlns="http://www.onvif.org/ver10/replay/wsdl">' +
  27. '<StreamSetup>' +
  28. '<Stream xmlns="http://www.onvif.org/ver10/schema">' + (options.stream || 'RTP-Unicast') + '</Stream>' +
  29. '<Transport xmlns="http://www.onvif.org/ver10/schema">' +
  30. '<Protocol>' + (options.protocol || 'RTSP') + '</Protocol>' +
  31. '</Transport>' +
  32. '</StreamSetup>' +
  33. '<RecordingToken>' + (options.recordingToken) + '</RecordingToken>' +
  34. '</GetReplayUri>' +
  35. this._envelopeFooter()
  36. }, function(err, data, xml) {
  37. if (callback) {
  38. callback.call(this, err, err ? null : linerase(data).getReplayUriResponse.uri, xml);
  39. }
  40. }.bind(this));
  41. };
  42. };