diff --git a/lib/media.js b/lib/media.js
index a0f09f3..7df3093 100644
--- a/lib/media.js
+++ b/lib/media.js
@@ -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');
@@ -1308,19 +1310,25 @@ module.exports = function(Cam) {
${typeof(options.position) === "object" ? "Custom" : (options.position ? options.position : "LowerLeft")}
${typeof(options.position) === "object" ? ("") : ""}
-
- Plain
- ${options.plaintext}
-
-
- ` +
-
- this._envelopeFooter()
- }, function(err, data, xml) {
+
+ ${
+ options.dateFormat && options.timeFormat
+ ? `DateAndTime
+ ${options.dateFormat}
+ ${options.timeFormat}`
+ : `Plain
+ ${options.plaintext}`}
+
+
+ ` +
+ this._envelopeFooter(),
+ },
+ function(err, data, xml) {
if (callback) {
callback.call(this, err, err ? null : linerase(data), xml);
}
- }.bind(this));
+ }.bind(this)
+ );
};
/**
@@ -1400,4 +1408,4 @@ module.exports = function(Cam) {
}
}.bind(this));
};
-};
+};
\ No newline at end of file