Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: setOSD support DateAndTime #324

Merged
merged 3 commits into from
Jun 7, 2024
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 34 additions & 25 deletions lib/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -1281,19 +1281,21 @@
}.bind(this));
};

/**
* 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
*/
Cam.prototype.setOSD = function(options, callback) {
/**

Check failure on line 1284 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (16.x)

Expected indentation of 1 tab but found 3 spaces

Check failure on line 1284 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (18.x)

Expected indentation of 1 tab but found 3 spaces

Check failure on line 1284 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Expected indentation of 1 tab but found 3 spaces
* 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) {

Check failure on line 1298 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (16.x)

Mixed spaces and tabs

Check failure on line 1298 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (18.x)

Mixed spaces and tabs

Check failure on line 1298 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Mixed spaces and tabs
let mediaType = (this.media2Support ? 'media2' : 'media');
let mediaNS = (this.media2Support ? 'http://www.onvif.org/ver20/media/wsdl' : 'http://www.onvif.org/ver10/media/wsdl');
if (callback === undefined) { callback = options; options = {}; }
Expand All @@ -1308,19 +1310,26 @@
<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

Check failure on line 1315 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (16.x)

Expected indentation of 1 tab but found 6

Check failure on line 1315 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (18.x)

Expected indentation of 1 tab but found 6

Check failure on line 1315 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Expected indentation of 1 tab but found 6
? `<sch:Type>DateAndTime</sch:Type>

Check failure on line 1316 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (16.x)

Expected indentation of 2 tabs but found 7

Check failure on line 1316 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (18.x)

Expected indentation of 2 tabs but found 7

Check failure on line 1316 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Expected indentation of 2 tabs but found 7
<sch:DateFormat>${options.dateFormat}</sch:DateFormat>
<sch:TimeFormat>${options.timeFormat}</sch:TimeFormat>`
: `<sch:Type>Plain</sch:Type>

Check failure on line 1319 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (16.x)

Expected indentation of 2 tabs but found 7

Check failure on line 1319 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (18.x)

Expected indentation of 2 tabs but found 7

Check failure on line 1319 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Expected indentation of 2 tabs but found 7
<sch:PlainText>${options.plaintext}</sch:PlainText>`
}

Check failure on line 1321 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (16.x)

Mixed spaces and tabs

Check failure on line 1321 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (18.x)

Mixed spaces and tabs

Check failure on line 1321 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Mixed spaces and tabs
</sch:TextString>
</wsdl:OSD>
</wsdl:SetOSD>` +
this._envelopeFooter(),

Check failure on line 1325 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (16.x)

Mixed spaces and tabs

Check failure on line 1325 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (18.x)

Mixed spaces and tabs

Check failure on line 1325 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Mixed spaces and tabs
},

Check failure on line 1326 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (16.x)

Mixed spaces and tabs

Check failure on line 1326 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (18.x)

Mixed spaces and tabs

Check failure on line 1326 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Mixed spaces and tabs
function (err, data, xml) {

Check failure on line 1327 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (16.x)

Mixed spaces and tabs

Check failure on line 1327 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (16.x)

Unexpected space before function parentheses

Check failure on line 1327 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (18.x)

Mixed spaces and tabs

Check failure on line 1327 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (18.x)

Unexpected space before function parentheses

Check failure on line 1327 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Mixed spaces and tabs

Check failure on line 1327 in lib/media.js

View workflow job for this annotation

GitHub Actions / Test (20.x)

Unexpected space before function parentheses
if (callback) {
callback.call(this, err, err ? null : linerase(data), xml);
callback.call(this, err, err ? null : linerase(data), xml);
}
}.bind(this));
}.bind(this)
);
};

/**
Expand Down Expand Up @@ -1400,4 +1409,4 @@
}
}.bind(this));
};
};
};