| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254 |
- import { ZoomVideoSDKErrors, ZoomVideoSDKSuppressBackgroundNoiseLevel, ZoomVideoSDKEchoCancellationLevel } from './zoom_video_sdk_defines.js'
- import messages from './electron_zoomvideosdk_pb.js'
- export default (function () {
- var instance
- /**
- * Zoom Video SDK Audio Setting
- * @module zoom_video_sdk_audio_setting
- * @return {ZoomVideoSDKAudioSetting}
- */
- function init (opts) {
- const clientOpts = {...opts}
- // Private methods and variables
- if (!clientOpts.addon) {
- return null
- }
- const _addon = clientOpts.addon.GetAudioSetting()
- return {
- // Public methods and variables
- /**
- * Get the suppress background noise level.
- * @method getSuppressBackgroundNoiseLevel
- * @return {Object} contains err and level. the level value is suppress background noise level. {@link ZoomVideoSDKSuppressBackgroundNoiseLevel} enum.
- */
- getSuppressBackgroundNoiseLevel: function (opts) {
- if (_addon) {
- try {
- return _addon.GetSuppressBackgroundNoiseLevel()
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Set the suppress background noise level.
- * @method setSuppressBackgroundNoiseLevel
- * @param {Number} level The new suppress background noise level to be set {@link ZoomVideoSDKSuppressBackgroundNoiseLevel} enum.
- * @return {Object} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- setSuppressBackgroundNoiseLevel: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const level = clientOpts.level || ZoomVideoSDKSuppressBackgroundNoiseLevel.ZoomVideoSDKSuppressBackgroundNoiseLevel_Auto
- const SetSuppressBackgroundNoiseLevelParams = new messages.SetSuppressBackgroundNoiseLevelParams()
- SetSuppressBackgroundNoiseLevelParams.setLevel(level)
- const bytes = SetSuppressBackgroundNoiseLevelParams.serializeBinary()
- return _addon.SetSuppressBackgroundNoiseLevel(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Enable or disable the original input of mic.
- * @method enableMicOriginalInput
- * @param {Boolean} bEnable TRUE indicates to enable the original input of mic.
- * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- enableMicOriginalInput: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const bEnable = clientOpts.bEnable
- const EnableMicOriginalInputParams = new messages.EnableMicOriginalInputParams()
- EnableMicOriginalInputParams.setBenable(bEnable)
- const bytes = EnableMicOriginalInputParams.serializeBinary()
- return _addon.EnableMicOriginalInput(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Get the flag to enable/disable the original input of mic.
- * @method isMicOriginalInputEnable
- * @return {Object} contains err and bEnable.
- */
- isMicOriginalInputEnable: function () {
- if (_addon) {
- try {
- return _addon.IsMicOriginalInputEnable()
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Set whether to enable the function of high fidelity music mode or not. This function is valid only if mic original input is enabled, otherwise invalid.
- * @method EnableHighFidelityMusicMode
- * @param {Boolean} bEnable True means to enable the function, FALSE not.
- * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- enableHighFidelityMusicMode: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const bEnable = clientOpts.bEnable
- const EnableHighFidelityMusicModeParams = new messages.EnableHighFidelityMusicModeParams()
- EnableHighFidelityMusicModeParams.setBenable(bEnable)
- const bytes = EnableHighFidelityMusicModeParams.serializeBinary()
- return _addon.EnableHighFidelityMusicMode(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Check whether the high fidelity music mode is enabled or not.
- * @method isHighFidelityMusicModeEnable
- * @return {Object} contains err and bEnable. If bEnable is TRUE, it means the echo cancellation is enabled
- */
- isHighFidelityMusicModeEnable: function () {
- if (_addon) {
- try {
- return _addon.IsHighFidelityMusicModeEnable()
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Set whether to disable the function of echo cancellation or not. This function is valid only if mic original input is enabled, otherwise invalid.
- * @method enableEchoCancellation
- * @param {Boolean} bEnable True means to enable the function, FALSE not.
- * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- enableEchoCancellation: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const bEnable = clientOpts.bEnable
- const EnableEchoCancellationParams = new messages.EnableEchoCancellationParams()
- EnableEchoCancellationParams.setBenable(bEnable)
- const bytes = EnableEchoCancellationParams.serializeBinary()
- return _addon.EnableEchoCancellation(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Check whether the echo cancellation is enabled or not.
- * @method isEchoCancellationEnable
- * @return {Object} contains err and bEnable. If bEnable is TRUE, it means the echo cancellation is disabled
- */
- isEchoCancellationEnable: function () {
- if (_addon) {
- try {
- return _addon.IsEchoCancellationEnable()
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Enable or disable the stereo audio. This function is valid only if mic original input is enabled, otherwise invalid.
- * @method enableStereoAudio
- * @param {Boolean} bEnable TRUE indicates to enable the stereo audio.
- * @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- enableStereoAudio: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const bEnable = clientOpts.bEnable
- const EnableStereoAudioParams = new messages.EnableStereoAudioParams()
- EnableStereoAudioParams.setBenable(bEnable)
- const bytes = EnableStereoAudioParams.serializeBinary()
- return _addon.EnableStereoAudio(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Get the flag to enable/disable the stereo audio.
- * @method isStereoAudioEnable
- * @return {Object} contains err and bEnable.
- */
- isStereoAudioEnable: function () {
- if (_addon) {
- try {
- return _addon.IsStereoAudioEnable()
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Get the echo cancellation level.
- * @method getEchoCancellationLevel
- * @return {Object} contains err and level. level echo cancellation level.
- */
- getEchoCancellationLevel: function () {
- if (_addon) {
- try {
- return _addon.GetEchoCancellationLevel()
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- },
- /**
- * Set the echo cancellation level.
- * @method setEchoCancellationLevel
- * @param {Number} level The new echo cancellation level to be set {@link ZoomVideoSDKEchoCancellationLevel} enum.
- * @return {Object} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
- Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
- */
- setEchoCancellationLevel: function (opts) {
- if (_addon) {
- const clientOpts = {...opts}
- try {
- const level = clientOpts.level || ZoomVideoSDKEchoCancellationLevel.ZoomVideoSDKEchoCancellationLevel_Default
- const SetEchoCancellationLevelParams = new messages.SetEchoCancellationLevelParams()
- SetEchoCancellationLevelParams.setLevel(level)
- const bytes = SetEchoCancellationLevelParams.serializeBinary()
- return _addon.SetEchoCancellationLevel(bytes)
- } catch (error) {
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
- }
- }
- return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
- }
- }
- };
- return {
- getInstance: function (opts) {
- if (!instance) {
- instance = init(opts)
- }
- return instance
- }
- }
- })()
|