Skip to content

Commit

Permalink
Improve setVideoEncoderConfigurationOptions to return arrays
Browse files Browse the repository at this point in the history
  • Loading branch information
Jessy committed Feb 21, 2020
1 parent f8ee914 commit c796477
Showing 1 changed file with 26 additions and 1 deletion.
27 changes: 26 additions & 1 deletion lib/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,32 @@ module.exports = function(Cam) {
this._envelopeFooter()
}, function(err, data, xml) {
if (callback) {
callback.call(this, err, err ? null : linerase(data[0].getVideoEncoderConfigurationOptionsResponse[0].options), xml);
let dataOut = null;
if (!err) {
dataOut = linerase(data[0].getVideoEncoderConfigurationOptionsResponse[0].options);
// Convert back to Array the lists of 1 element that linerase converted to object
if (dataOut.H264) {
if (!Array.isArray(dataOut.H264.resolutionsAvailable)) {dataOut.H264.resolutionsAvailable = [dataOut.H264.resolutionsAvailable];}
if (!Array.isArray(dataOut.H264.H264ProfilesSupported)) {dataOut.H264.H264ProfilesSupported = [dataOut.H264.H264ProfilesSupported];}
}
if (dataOut.MPEG4) {
if (!Array.isArray(dataOut.MPEG4.resolutionsAvailable)) {dataOut.MPEG4.resolutionsAvailable = [dataOut.MPEG4.resolutionsAvailable];}
if (!Array.isArray(dataOut.MPEG4.mpeg4ProfilesSupported)) {dataOut.MPEG4.mpeg4ProfilesSupported = [dataOut.MPEG4.mpeg4ProfilesSupported];}
}
if (dataOut.JPEG && !Array.isArray(dataOut.JPEG.resolutionsAvailable)) {dataOut.JPEG.resolutionsAvailable = [dataOut.JPEG.resolutionsAvailable];}
if (dataOut.extension) {
if (dataOut.extension.H264) {
if (!Array.isArray(dataOut.extension.H264.resolutionsAvailable)) {dataOut.extension.H264.resolutionsAvailable = [dataOut.extension.H264.resolutionsAvailable];}
if (!Array.isArray(dataOut.extension.H264.H264ProfilesSupported)) {dataOut.extension.H264.H264ProfilesSupported = [dataOut.extension.H264.H264ProfilesSupported];}
}
if (dataOut.extension.MPEG4) {
if (!Array.isArray(dataOut.extension.MPEG4.resolutionsAvailable)) {dataOut.extension.MPEG4.resolutionsAvailable = [dataOut.extension.MPEG4.resolutionsAvailable];}
if (!Array.isArray(dataOut.extension.MPEG4.mpeg4ProfilesSupported)) {dataOut.extension.MPEG4.mpeg4ProfilesSupported = [dataOut.extension.MPEG4.mpeg4ProfilesSupported];}
}
if (dataOut.extension.JPEG && !Array.isArray(dataOut.extension.JPEG.resolutionsAvailable)) {dataOut.extension.JPEG.resolutionsAvailable = [dataOut.extension.JPEG.resolutionsAvailable];}
}
}
callback.call(this, err, err ? null : dataOut, xml);
}
}.bind(this));
};
Expand Down

0 comments on commit c796477

Please sign in to comment.