Meeting SDK for Android API Reference
Loading...
Searching...
No Matches
ZoomSDKAudioRawDataHelper.java
Go to the documentation of this file.
1package us.zoom.sdk;
2
3import java.lang.ref.WeakReference;
4import java.nio.ByteBuffer;
5
6import us.zoom.common.crossplatform.cmmlib.BuildConfig;
7import us.zoom.core.helper.ZMLog;
8import us.zoom.internal.ErrorCodeMapping;
9import us.zoom.internal.RTCConference;
10import us.zoom.internal.event.RTCConferenceEventUI;
11import us.zoom.internal.event.RTCVideoRawDataDelegate;
12import us.zoom.internal.helper.SDKMeetingInterfaceHelper;
13import us.zoom.internal.impl.ZoomSDKAudioRawDataSender;
14import us.zoom.internal.jni.helper.ZoomMeetingSDKBridgeHelper;
15import us.zoom.internal.sdkcore.delegate.jni.MSDKCoreMeetingServiceHelperDelegateJNI;
16
21
22 private static final String TAG = "ZoomSDKAudioRawDataHelper";
23
24 private static class AudioSlot {
25 WeakReference<IZoomSDKAudioRawDataDelegate> weakReference;
26 RTCConferenceEventUI receiver;
27 RTCConferenceEventUI.SimpleRTCConferenceEventUIListener listener;
29 }
30
31 private final AudioSlot currentSlot = new AudioSlot();
32 private final AudioSlot mainSlot = new AudioSlot();
34
36
37 private RTCVideoRawDataDelegate rtcAudioRawDataDelegate;
38
39 MSDKCoreMeetingServiceHelperDelegateJNI.SimpleMSDKCoreMeetingServiceHelperDelegate mMSDKCoreMeetingServiceListener =
40 new MSDKCoreMeetingServiceHelperDelegateJNI.SimpleMSDKCoreMeetingServiceHelperDelegate() {
41 @Override
42 public void onCoreConfLeaveComplete(int ret) {
44 }
45
46 @Override
47 public void onMeetingSilentModeChanged(int ret) {
48 if (SDKMeetingInterfaceHelper.isInSlientMode()) {
51 }
52 }
53 };
54
56 @Override
57 public void onMeetingStatusChanged(MeetingStatus meetingStatus, int errorCode, int internalErrorCode) {
58 if (meetingStatus == MeetingStatus.MEETING_STATUS_JOIN_BACKSTAGE) {
60 } else if (meetingStatus == MeetingStatus.MEETING_STATUS_LEAVE_BACKSTAGE) {
63 }
64 }
65
66 @Override
67 public void onMeetingParameterNotification(MeetingParameter meetingParameter) {
68 }
69 };
70
71 private void onConfLeave() {
74 MSDKCoreMeetingServiceHelperDelegateJNI.getInstance().removeListener(mMSDKCoreMeetingServiceListener);
76 if (meetingService != null) {
78 }
80 virtualAudioMic=null;
81 }
82
83 RTCVideoRawDataDelegate.SimpleRTCVideoRawDataListener audioRawdataListener = new RTCVideoRawDataDelegate.SimpleRTCVideoRawDataListener() {
84
85 public void onUninitialize() {
86 if (null != virtualAudioMic) {
87 virtualAudioMic.onMicUninitialized();
88 }
89 }
90
91 public void onDeviceInitialize(long nativeHandle) {
92 if (null != virtualAudioMic) {
93 IZoomSDKAudioRawDataSender sender = new ZoomSDKAudioRawDataSender(nativeHandle);
94 virtualAudioMic.onMicInitialize(sender);
95 }
96 }
97
98 public void onStartSendData() {
99 if (null != virtualAudioMic) {
100 virtualAudioMic.onMicStartSend();
101 }
102 }
103
104 public void onStopSendData() {
105 if (null != virtualAudioMic) {
106 virtualAudioMic.onMicStopSend();
107 }
108 }
109
110 public void onDeviceUninitialize() {
111 if (null != virtualAudioMic) {
112 virtualAudioMic.onMicUninitialized();
113 }
114 }
115 };
116
121
122 @Override
126
127 @Override
129 if (SDKMeetingInterfaceHelper.isInSlientMode()) {
131 }
132 if (null == delegate || !isValidSource(sources)) {
134 }
137 }
138 AudioSlot slot = getSlot(sources);
139 if (slot == null || slot.weakReference != null) {
141 }
142 if (isDelegateInUse(delegate)) {
144 }
145 if (null == RTCConference.getInstance()) {
147 }
148
150 slot.receiver = RTCConferenceEventUI.createIndependentReceiver();
151 slot.listener = createSlotListener(slot);
152 slot.receiver.addListener(slot.listener);
153 slot.weakReference = new WeakReference<>(delegate);
154 int ret = RTCConference.getInstance().getAudioRawDataHelper().start(
155 slot.receiver.getNativeHandle(), sources.getValue());
156 MobileRTCRawDataError error= ErrorCodeMapping.mapping(ret);
158 slot.receiver.removeListener(slot.listener);
159 slot.receiver = null;
160 slot.listener = null;
161 slot.weakReference = null;
162 }
163 ZoomMeetingSDKBridgeHelper.getInstance().trackingMSDKInteractEvent(TAG, "subscribe", error.ordinal());
164 return error;
165 }
166
167 @Override
171
172 @Override
174 if (!isValidSource(sources)) {
176 }
177 if (null == RTCConference.getInstance()) {
179 }
180 AudioSlot slot = getSlot(sources);
181 if (slot == null) {
183 }
184 if (slot.receiver != null && slot.listener != null) {
185 slot.receiver.removeListener(slot.listener);
186 }
187 slot.weakReference = null;
188 slot.listener = null;
189 slot.receiver = null;
190 int ret = RTCConference.getInstance().getAudioRawDataHelper().stop(sources.getValue());
191 MobileRTCRawDataError error= ErrorCodeMapping.mapping(ret);
192 ZoomMeetingSDKBridgeHelper.getInstance().trackingMSDKInteractEvent(TAG, "unSubscribe", error.ordinal());
193 return error;
194 }
195
196 @Override
198 if (null == RTCConference.getInstance()) {
200 }
201
202 if (SDKMeetingInterfaceHelper.isInSlientMode()) {
204 }
205 if (this.virtualAudioMic == audioMic) {
207 }
208 this.virtualAudioMic = audioMic;
209
210 int result = 0;
211 if (null == audioMic) {
212 result = RTCConference.getInstance().getAudioRawDataHelper().setVirtualAudioMic(0);
214 } else {
215 rtcAudioRawDataDelegate = new RTCVideoRawDataDelegate(audioRawdataListener);
216 result = RTCConference.getInstance().getAudioRawDataHelper().setVirtualAudioMic(rtcAudioRawDataDelegate.getRecevHandle());
217 }
218 if (result != 0) {
219 this.virtualAudioMic = null;
220 }
221 MobileRTCRawDataError error= ErrorCodeMapping.mapping(result);
222 ZoomMeetingSDKBridgeHelper.getInstance().trackingMSDKInteractEvent(TAG, "setExternalAudioSource", error.ordinal());
223 return error;
224 }
225
230
231 private boolean isLocalInWebinarBackstage() {
233 return inMeetingService != null
234 && inMeetingService.getMeetingType() == MeetingType.MEETING_TYPE_BACKSTAGE;
235 }
236
239 return currentSlot;
240 }
242 return mainSlot;
243 }
244 return null;
245 }
246
248 IZoomSDKAudioRawDataDelegate current = currentSlot.weakReference != null ? currentSlot.weakReference.get() : null;
249 IZoomSDKAudioRawDataDelegate main = mainSlot.weakReference != null ? mainSlot.weakReference.get() : null;
250 return delegate == current || delegate == main;
251 }
252
253 private void ensureMeetingListener() {
255 return;
256 }
258 if (meetingService != null) {
259 meetingService.addListener(meetingStatusListener);
261 }
262 MSDKCoreMeetingServiceHelperDelegateJNI.getInstance().addListener(mMSDKCoreMeetingServiceListener);
263 }
264
265 private void rebindCurrentSession() {
266 if (currentSlot.weakReference == null || currentSlot.receiver == null) {
267 return;
268 }
269 IZoomSDKAudioRawDataDelegate delegate = currentSlot.weakReference.get();
270 if (delegate == null || RTCConference.getInstance() == null) {
271 return;
272 }
273 RTCConference.getInstance().getAudioRawDataHelper().stop(
275 RTCConference.getInstance().getAudioRawDataHelper().start(
276 currentSlot.receiver.getNativeHandle(),
278 }
279
280 private RTCConferenceEventUI.SimpleRTCConferenceEventUIListener createSlotListener(final AudioSlot slot) {
281 return new RTCConferenceEventUI.SimpleRTCConferenceEventUIListener() {
282 @Override
283 public void onMixedAudioRawDataReceived(ByteBuffer buffer, int bufferLen, int sampleRate,int channel,long timeStamp, long nativeHandle) {
284 dispatchMixed(slot, buffer, bufferLen, sampleRate, channel, timeStamp, nativeHandle);
285 }
286
287 @Override
288 public void onOneWayAudioRawDataReceivedImpl(ByteBuffer buffer, int bufferLen, int sampleRate, int channel, int userId,long timeStamp, long nativeHandle) {
289 dispatchOneWay(slot, buffer, bufferLen, sampleRate, channel, userId, timeStamp, nativeHandle);
290 }
291
292 @Override
293 public void onShareAudioRawDataReceived(ByteBuffer buffer, int bufferLen, int sampleRate, int channel,long timeStamp, long userId, long nativeHandle) {
294 dispatchShare(slot, buffer, bufferLen, sampleRate, channel, timeStamp, userId, nativeHandle);
295 }
296 };
297 }
298
299 private void dispatchMixed(AudioSlot slot, ByteBuffer buffer, int bufferLen, int sampleRate, int channel, long timeStamp, long nativeHandle) {
300 if (null == slot.weakReference) {
301 return;
302 }
303 IZoomSDKAudioRawDataDelegate dataDelegate = slot.weakReference.get();
304 if (null != dataDelegate) {
305 ZoomSDKAudioRawData rawData = new ZoomSDKAudioRawData(buffer, bufferLen, sampleRate,channel,timeStamp, nativeHandle);
306 dataDelegate.onMixedAudioRawDataReceived(rawData);
307 } else if (BuildConfig.LOG_ENABLE) {
308 ZMLog.d(TAG, "onMixedAudioRawDataReceived dataDelegate is null");
309 }
310 }
311
312 private void dispatchOneWay(AudioSlot slot, ByteBuffer buffer, int bufferLen, int sampleRate, int channel, int userId, long timeStamp, long nativeHandle) {
313 if (null == slot.weakReference) {
314 return;
315 }
316 IZoomSDKAudioRawDataDelegate dataDelegate = slot.weakReference.get();
317 if (null != dataDelegate) {
318 ZoomSDKAudioRawData rawData = new ZoomSDKAudioRawData(buffer, bufferLen, sampleRate,channel,timeStamp,nativeHandle);
319 dataDelegate.onOneWayAudioRawDataReceived(rawData, userId);
320 } else if (BuildConfig.LOG_ENABLE) {
321 ZMLog.d(TAG, "onOneWayAudioRawDataReceivedImpl dataDelegate is null");
322 }
323 }
324
325 private void dispatchShare(AudioSlot slot, ByteBuffer buffer, int bufferLen, int sampleRate, int channel, long timeStamp, long userId, long nativeHandle) {
326 if (null == slot.weakReference) {
327 return;
328 }
329 IZoomSDKAudioRawDataDelegate dataDelegate = slot.weakReference.get();
330 if (null != dataDelegate) {
331 ZoomSDKAudioRawData rawData = new ZoomSDKAudioRawData(buffer, bufferLen, sampleRate,channel,timeStamp, nativeHandle);
332 dataDelegate.onShareAudioRawDataReceived(rawData, userId);
333 } else if (BuildConfig.LOG_ENABLE) {
334 ZMLog.d(TAG, "onShareAudioRawDataReceived dataDelegate is null");
335 }
336 }
337}
WeakReference< IZoomSDKAudioRawDataDelegate > weakReference
RTCConferenceEventUI.SimpleRTCConferenceEventUIListener listener
RTCConferenceEventUI.SimpleRTCConferenceEventUIListener createSlotListener(final AudioSlot slot)
void dispatchMixed(AudioSlot slot, ByteBuffer buffer, int bufferLen, int sampleRate, int channel, long timeStamp, long nativeHandle)
boolean isValidSource(ZoomSDKSessionSource sources)
boolean isDelegateInUse(IZoomSDKAudioRawDataDelegate delegate)
MobileRTCRawDataError unSubscribe()
unsubscribe CurrentSession audio raw data
MobileRTCRawDataError subscribe(IZoomSDKAudioRawDataDelegate delegate, ZoomSDKSessionSource sources)
subscribe audio raw data from one source.
void dispatchOneWay(AudioSlot slot, ByteBuffer buffer, int bufferLen, int sampleRate, int channel, int userId, long timeStamp, long nativeHandle)
void dispatchShare(AudioSlot slot, ByteBuffer buffer, int bufferLen, int sampleRate, int channel, long timeStamp, long userId, long nativeHandle)
RTCVideoRawDataDelegate.SimpleRTCVideoRawDataListener audioRawdataListener
MSDKCoreMeetingServiceHelperDelegateJNI.SimpleMSDKCoreMeetingServiceHelperDelegate mMSDKCoreMeetingServiceListener
MobileRTCRawDataError subscribe(IZoomSDKAudioRawDataDelegate delegate)
subscribe audio raw data.
AudioSlot getSlot(ZoomSDKSessionSource sources)
MobileRTCRawDataError setExternalAudioSource(IZoomSDKVirtualAudioMicEvent audioMic)
Set external audio source.
MobileRTCRawDataError unSubscribe(ZoomSDKSessionSource sources)
unsubscribe audio raw data for one source.
Zoom SDK audio raw data bean.
Zoom SDK global manager.
Definition ZoomSDK.java:12
InMeetingService getInMeetingService()
Gets the in-meeting service instance.
Definition ZoomSDK.java:303
static ZoomSDK getInstance()
Gets a shared instance of Zoom SDK. Must call from the main thread.
Definition ZoomSDK.java:25
MeetingService getMeetingService()
Gets the instance of meeting service.
Definition ZoomSDK.java:275
Enumeration of meeting status.
MEETING_TYPE_BACKSTAGE
Webinar backstage.
Enumeration of raw data errors.
void onShareAudioRawDataReceived(ZoomSDKAudioRawData rawData, long userId)
share audio raw data received callback
void onOneWayAudioRawDataReceived(ZoomSDKAudioRawData rawData, int userId)
User audio raw data received callback.
void onMixedAudioRawDataReceived(ZoomSDKAudioRawData rawData)
mixed audio raw data received callback
Interface for sending audio raw data.
Interfaces of Zoom services in meeting. The AI Companion brand has been retired. AI-powered features ...
MeetingType getMeetingType()
Gets the type of the current meeting.
ZOOM meeting service.
void addListener(MeetingServiceListener listener)
void removeListener(MeetingServiceListener listener)