Skip to content

Commit

Permalink
Merge pull request #324 from RotemDoar/master
Browse files Browse the repository at this point in the history
feat: setOSD support DateAndTime
  • Loading branch information
agsh authored Jun 7, 2024
2 parents e336ef3 + bc8a28d commit a3ec9af
Showing 1 changed file with 30 additions and 22 deletions.
52 changes: 30 additions & 22 deletions lib/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -1282,17 +1282,19 @@ module.exports = function(Cam) {
};

/**
* SetOSD
* ONVIF can handle custom positons, date/time, text, font sizes, transparency, images etc. We only support Plain Text
* @param {Object} options
* @param {Object} options.OSDToken
* @param {string} [options.videoSourceConfigurationToken] Token of the Video Source Configuration, which has associated OSDs. Defaults to Active Source
* @param {string} [options.plaintext] Text to overlay
* @param {object|string} [options.position] String options: UpperLeft, UpperRight, LowerLeft or LowerRight. Default LowerLeft. Or an object with x and y position
* @param {number} [options.position.x] x position of OSD, range: -1 to 1, counting from left to right
* @param {number} [options.position.y] y position of OSD, range: -1 to 1, counting from up to down
* @param {Cam~GetOSDOptionsCallback} callback
*/
* SetOSD
* ONVIF can handle custom positons, date/time, text, font sizes, transparency, images etc. Both Plain Text and DateAndTime are supported.
* @param {Object} options
* @param {Object} options.OSDToken
* @param {string} [options.videoSourceConfigurationToken] Token of the Video Source Configuration, which has associated OSDs. Defaults to Active Source
* @param {object|string} [options.position] String options: UpperLeft, UpperRight, LowerLeft or LowerRight. Default LowerLeft. Or an object with x and y position
* @param {number} [options.position.x] x position of OSD, range: -1 to 1, counting from left to right
* @param {number} [options.position.y] y position of OSD, range: -1 to 1, counting from up to down
* @param {string} [options.plaintext] Plain text to overlay
* @param {string} [options.dateFormat] Date to overlay. Must be used with timeFormat, otherwise plaintext will be used.
* @param {string} [options.timeFormat] Time to overlay. Must be used with dateFormat, otherwise plaintext will be used.
* @param {Cam~GetOSDOptionsCallback} callback
*/
Cam.prototype.setOSD = function(options, callback) {
let mediaType = (this.media2Support ? 'media2' : 'media');
let mediaNS = (this.media2Support ? 'http://www.onvif.org/ver20/media/wsdl' : 'http://www.onvif.org/ver10/media/wsdl');
Expand All @@ -1308,19 +1310,25 @@ module.exports = function(Cam) {
<sch:Type>${typeof(options.position) === "object" ? "Custom" : (options.position ? options.position : "LowerLeft")}</sch:Type>
${typeof(options.position) === "object" ? ("<sch:Pos x=\"" + options.position.x + "\" y=\"" + options.position.y + "\"/>") : ""}
</sch:Position>
<sch:TextString IsPersistentText="false">
<sch:Type>Plain</sch:Type>
<sch:PlainText>${options.plaintext}</sch:PlainText>
</sch:TextString>
</wsdl:OSD>
</wsdl:SetOSD>` +

this._envelopeFooter()
}, function(err, data, xml) {
<sch:TextString IsPersistentText="false">
${
options.dateFormat && options.timeFormat
? `<sch:Type>DateAndTime</sch:Type>
<sch:DateFormat>${options.dateFormat}</sch:DateFormat>
<sch:TimeFormat>${options.timeFormat}</sch:TimeFormat>`
: `<sch:Type>Plain</sch:Type>
<sch:PlainText>${options.plaintext}</sch:PlainText>`}
</sch:TextString>
</wsdl:OSD>
</wsdl:SetOSD>` +
this._envelopeFooter(),
},
function(err, data, xml) {
if (callback) {
callback.call(this, err, err ? null : linerase(data), xml);
}
}.bind(this));
}.bind(this)
);
};

/**
Expand Down Expand Up @@ -1400,4 +1408,4 @@ module.exports = function(Cam) {
}
}.bind(this));
};
};
};

0 comments on commit a3ec9af

Please sign in to comment.