UNPKG

onvif-nvt-ts

Version:

Wrapper for ONVIF spec to control NVT (Network Video Transitter) devices. Forked and added TypeScript support from onvif-nvt.

75 lines 2.94 kB
"use strict"; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const soap_1 = __importDefault(require("../utils/soap")); /** * @class * <p> * {@link https://www.onvif.org/specs/srv/media/ONVIF-Media2-Service-Spec-v1712.pdf}<br> * {@link https://www.onvif.org/ver20/media/wsdl/media.wsdl}<br> * </p> */ class Media2 { constructor() { this.soap = new soap_1.default(); this.timeDiff = 0; this.serviceAddress = null; this.username = null; this.password = null; this.namespaceAttributes = [ // 'xmlns:tns1="http://www.onvif.org/ver10/topics"', // 'xmlns:trt="http://www.onvif.org/ver10/media/wsdl"' // 'xmlns:trt="http://www.onvif.org/ver10/media/wsdl"', // 'xmlns:tt="http://www.onvif.org/ver10/schema"' 'xmlns:tr2="http://www.onvif.org/ver20/media/wsdl"' ]; } /** * Call this function directly after instantiating a Media2 object. * @param timeDiff The onvif device's time difference. * @param serviceAddress An url object from url package - require('url'). * @param username Optional only if the device does NOT have a user. * @param password Optional only if the device does NOT have a password. */ init(timeDiff, serviceAddress, username, password) { this.timeDiff = timeDiff; this.serviceAddress = serviceAddress; this.username = username; this.password = password; } /** * Private function for creating a SOAP request. * @param body The body of the xml. */ createRequest(body) { return this.soap.createRequest({ body: body, xmlns: this.namespaceAttributes, diff: this.timeDiff, username: this.username, password: this.password }); } // --------------------------------------------- // Media2 API // --------------------------------------------- getProfiles() { // let soapBody = '<trt:GetProfiles/>' const soapBody = '<GetProfiles xmlns="http://www.onvif.org/ver10/media/wsdl"/>'; const soapEnvelope = this.createRequest(soapBody); // console.log(soapEnvelope) return this.soap.makeRequest('media2', this.serviceAddress, 'GetProfiles', soapEnvelope); } getSnapshotUri(profileToken) { let soapBody = ''; soapBody += '<trt:GetSnapshotUri>'; soapBody += '<trt:ProfileToken>' + profileToken + '</trt:ProfileToken>'; soapBody += '</trt:GetSnapshotUri>'; const soapEnvelope = this.createRequest(soapBody); return this.soap.makeRequest('media2', this.serviceAddress, 'GetSnapshotUri', soapEnvelope); } } exports.default = Media2; //# sourceMappingURL=media2.js.map