-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzoom_video_sdk_remote_camera_control.js
237 lines (233 loc) · 9.45 KB
/
zoom_video_sdk_remote_camera_control.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
import { ZoomVideoSDKErrors } from './zoom_video_sdk_defines.js'
import messages from './electron_zoomvideosdk_pb.js'
import { setUserInfo } from './zoom_video_sdk_user_util.js'
function checkCameraCtrlRange(range) {
if (range < 10) {
return 10
} else if (range > 100) {
return 100
} else {
return range
}
}
export default (function () {
var instance
/**
* Get the helper class instance to access the remote camera control.
* @module zoom_video_sdk_remote_camera_control
* @return {ZoomVideoSDKRemoteCameraControl}
*/
function init(opts) {
const clientOpts = {...opts}
// Private methods and variables
if (!clientOpts.addon) {
return null
}
const _addon = clientOpts.addon.GetRemoteCameraCtrlHelper()
return {
// Public methods and variables
/**
* Request to control remote camera.
* @method requestControlRemoteCamera
* @param {Object} user
* @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
*/
requestControlRemoteCamera: function (opts) {
if (_addon) {
const clientOpts = {...opts}
try {
const user = setUserInfo(clientOpts.user)
const RequestControlRemoteCameraParams = new messages.RequestControlRemoteCameraParams()
RequestControlRemoteCameraParams.setUser(user)
const bytes = RequestControlRemoteCameraParams.serializeBinary()
return _addon.RequestControlRemoteCamera(bytes)
} catch (error) {
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
}
}
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
},
/**
* Give up control of the remote camera.
* @method giveUpControlRemoteCamera
* @param {Object} user
* @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
Otherwise failed. To get extended error information, see {@link ZoomVideoSDKErrors} enum.
*/
giveUpControlRemoteCamera: function (opts) {
if (_addon) {
const clientOpts = {...opts}
try {
const user = setUserInfo(clientOpts.user)
const GiveUpControlRemoteCameraParams = new messages.GiveUpControlRemoteCameraParams()
GiveUpControlRemoteCameraParams.setUser(user)
const bytes = GiveUpControlRemoteCameraParams.serializeBinary()
return _addon.GiveUpControlRemoteCamera(bytes)
} catch (error) {
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
}
}
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
},
/**
* Turn the camera to the left.
* @method turnLeft
* @param {Number} range, 10 <= rotation range <= 100.
* @param {Object} user
* @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
*/
turnLeft: function (opts) {
if (_addon) {
const clientOpts = {...opts}
try {
let range = checkCameraCtrlRange(clientOpts.range)
const user = setUserInfo(clientOpts.user)
const RemoteCameraCtrlTurnLeftParams = new messages.RemoteCameraCtrlTurnLeftParams()
RemoteCameraCtrlTurnLeftParams.setRange(range)
RemoteCameraCtrlTurnLeftParams.setUser(user)
const bytes = RemoteCameraCtrlTurnLeftParams.serializeBinary()
return _addon.TurnLeft(bytes)
} catch (error) {
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
}
}
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
},
/**
* Turn the camera to the right.
* @method turnRight
* @param {Number} range, 10 <= rotation range <= 100.
* @param {Object} user
* @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
*/
turnRight: function (opts) {
if (_addon) {
const clientOpts = {...opts}
try {
const range = checkCameraCtrlRange(clientOpts.range)
const user = setUserInfo(clientOpts.user)
const RemoteCameraCtrlTurnRightParams = new messages.RemoteCameraCtrlTurnRightParams()
RemoteCameraCtrlTurnRightParams.setRange(range)
RemoteCameraCtrlTurnRightParams.setUser(user)
const bytes = RemoteCameraCtrlTurnRightParams.serializeBinary()
return _addon.TurnRight(bytes)
} catch (error) {
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
}
}
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
},
/**
* Turn the camera up.
* @method turnUp
* @param {Number} range, 10 <= rotation range <= 100.
* @param {Object} user
* @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
*/
turnUp: function (opts) {
if (_addon) {
const clientOpts = {...opts}
try {
const range = checkCameraCtrlRange(clientOpts.range)
const user = setUserInfo(clientOpts.user)
const RemoteCameraCtrlTurnUpParams = new messages.RemoteCameraCtrlTurnUpParams()
RemoteCameraCtrlTurnUpParams.setRange(range)
RemoteCameraCtrlTurnUpParams.setUser(user)
const bytes = RemoteCameraCtrlTurnUpParams.serializeBinary()
return _addon.TurnUp(bytes)
} catch (error) {
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
}
}
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
},
/**
* Turn the camera down.
* @method turnDown
* @param {Number} range, 10 <= rotation range <= 100.
* @param {Object} user
* @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
*/
turnDown: function (opts) {
if (_addon) {
const clientOpts = {...opts}
try {
const range = checkCameraCtrlRange(clientOpts.range)
const user = setUserInfo(clientOpts.user)
const RemoteCameraCtrlTurnDownParams = new messages.RemoteCameraCtrlTurnDownParams()
RemoteCameraCtrlTurnDownParams.setRange(range)
RemoteCameraCtrlTurnDownParams.setUser(user)
const bytes = RemoteCameraCtrlTurnDownParams.serializeBinary()
return _addon.TurnDown(bytes)
} catch (error) {
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
}
}
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
},
/**
* Zoom the camera in.
* @method zoomIn
* @param {Number} range, 10 <= zoom range <= 100.
* @param {Object} user
* @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
*/
zoomIn: function (opts) {
if (_addon) {
const clientOpts = {...opts}
try {
const range = checkCameraCtrlRange(clientOpts.range)
const user = setUserInfo(clientOpts.user)
const RemoteCameraCtrlZoomInParams = new messages.RemoteCameraCtrlZoomInParams()
RemoteCameraCtrlZoomInParams.setRange(range)
RemoteCameraCtrlZoomInParams.setUser(user)
const bytes = RemoteCameraCtrlZoomInParams.serializeBinary()
return _addon.ZoomIn(bytes)
} catch (error) {
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
}
}
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
},
/**
* Zoom the camera out.
* @method zoomOut
* @param {Number} range, 10 <= zoom range <= 100.
* @param {Object} user
* @return {Number} If the function succeed, the return value is ZoomVideoSDKErrors_Success.
Otherwise failed. To get extended error information, {@link ZoomVideoSDKErrors} enum.
*/
zoomOut: function (opts) {
if (_addon) {
const clientOpts = {...opts}
try {
const range = checkCameraCtrlRange(clientOpts.range)
const user = setUserInfo(clientOpts.user)
const RemoteCameraCtrlZoomOutParams = new messages.RemoteCameraCtrlZoomOutParams()
RemoteCameraCtrlZoomOutParams.setRange(range)
RemoteCameraCtrlZoomOutParams.setUser(user)
const bytes = RemoteCameraCtrlZoomOutParams.serializeBinary()
return _addon.ZoomOut(bytes)
} catch (error) {
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Invalid_Parameter;
}
}
return ZoomVideoSDKErrors.ZoomVideoSDKErrors_Internal_Error
}
}
};
return {
getInstance: function (opts) {
if (!instance) {
instance = init(opts)
}
return instance
}
}
})()