3import android.app.Activity;
4import android.content.Context;
5import android.content.ContextWrapper;
6import android.graphics.Rect;
7import android.os.Build;
8import android.os.Bundle;
9import android.util.AttributeSet;
10import android.util.Log;
11import android.view.GestureDetector;
12import android.view.LayoutInflater;
13import android.view.MotionEvent;
14import android.view.View;
15import android.view.ViewGroup;
16import android.widget.FrameLayout;
17import android.widget.RelativeLayout;
19import androidx.annotation.NonNull;
20import androidx.annotation.Nullable;
21import androidx.fragment.app.Fragment;
22import androidx.fragment.app.FragmentActivity;
24import com.zipow.videobox.mainboard.Mainboard;
25import com.zipow.videobox.mainboard.ZmMainBoardMgr;
26import com.zipow.videobox.mainboard.module.ZmSdkMainBoard;
27import com.zipow.videobox.sdk.SDKConstants;
28import com.zipow.videobox.sdk.SDKMainHandler;
29import com.zipow.videobox.sdk.SDKShareInView;
30import com.zipow.videobox.sdk.SDKVideoRenderer;
31import com.zipow.videobox.sdk.SDKVideoView;
32import com.zipow.videobox.utils.ZmUtils;
33import us.zoom.component.features.webwhiteboard.MeetingWebWbMgr;
34import us.zoom.component.features.webwhiteboard.uinotify.WebWbUiNotify;
36import javax.microedition.khronos.opengles.GL10;
39import kotlin.jvm.functions.Function1;
40import us.zoom.business.common.ZmBusinessModuleMgr;
41import us.zoom.common.crossplatform.cmmlib.BuildConfig;
42import us.zoom.core.helper.ZMLog;
43import us.zoom.internal.impl.InMeetingShareControllerImpl;
44import us.zoom.docs.bridge.tocpp.IConfZoomDocs;
45import us.zoom.docs.conf.cplusenum.WebViewInstanceTag;
46import us.zoom.docs.service.StaticInnerService;
47import us.zoom.docs.ui.share.ZoomDocsShareFragment;
48import us.zoom.hybrid.safeweb.core.WebHelper;
49import us.zoom.internal.impl.InMeetingWhiteboardControllerImpl;
50import us.zoom.internal.jni.bean.CmmDocsCollaborationSource;
51import us.zoom.internal.jni.helper.ZoomMeetingSDKBridgeHelper;
52import us.zoom.internal.jni.helper.ZoomMeetingSDKDocsHelper;
53import us.zoom.internal.view.SDKWBViewerFragment;
54import us.zoom.libtools.fragmentmanager.ISafeTransaction;
55import us.zoom.libtools.fragmentmanager.SafeTransactionKt;
56import us.zoom.libtools.storage.PreferenceUtil;
57import us.zoom.libtools.utils.ZmDeviceUtils;
58import us.zoom.internal.SDKCustomizedMeetingUIHelper;
59import us.zoom.internal.SDKDisclaimerDialogManager;
60import us.zoom.internal.impl.MobileRTCVideoViewManagerImpl;
61import us.zoom.libtools.utils.ZmStringUtils;
62import us.zoom.unite.cplusenum.UnifyWebViewAppType;
63import us.zoom.unite.logic.UniteBaseLogic;
64import us.zoom.videomeetings.R;
69public class MobileRTCVideoView extends RelativeLayout implements SDKVideoView.Listener, GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
95 super(context, attrs);
100 super(context, attrs, defStyle);
104 private void init(Context context) {
105 mView = (ViewGroup)LayoutInflater.from(context).inflate(R.layout.zm_videoview_sdk,
null,
false);
107 mShareView = (SDKShareInView)
mView.findViewById(R.id.zm_sdk_viewingShare);
115 if (inMeetingService !=
null) {
117 if (wbController instanceof InMeetingWhiteboardControllerImpl) {
126 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
127 mVideoView.setPreserveEGLContextOnPause(
true);
139 if(!isInEditMode() && isEnabled) {
155 mVideoView.setZOrderMediaOverlay(isMediaOverlay);
176 if(!SDKCustomizedMeetingUIHelper.isSdkEnableCustomizedUI()|| !SDKCustomizedMeetingUIHelper.isSdkUsingCustomizedMeetingUI()) {
180 Mainboard mainboard = ZmMainBoardMgr.getMainboard();
181 if(mainboard !=
null && !((ZmSdkMainBoard)mainboard.getSdkMainBoard()).isSDKConfAppCreated()) {
189 if(SDKCustomizedMeetingUIHelper.isSdkEnableCustomizedUI() && SDKCustomizedMeetingUIHelper.isSdkUsingCustomizedMeetingUI()) {
192 Mainboard mainboard = ZmMainBoardMgr.getMainboard();
193 if(mainboard !=
null && !((ZmSdkMainBoard)mainboard.getSdkMainBoard()).isSDKConfAppCreated()) {
224 public boolean onFling(MotionEvent e1, MotionEvent e2,
float velocityX,
237 public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX,
281 Rect rect =
new Rect();
282 if (getGlobalVisibleRect(rect)) {
283 if (rect.width() * rect.height() >= getMeasuredWidth() * getMeasuredHeight()/2) {
297 Log.i(
TAG,
"surfaceCreated group index =" +
mVideoRender.getGroupIndex());
302 Log.i(
TAG,
"surfaceDestroyed group index =" +
mVideoRender.getGroupIndex());
317 super(glView, groupIndex);
323 long curTime = System.currentTimeMillis();
324 if(curTime < lastIdleTaskTime || curTime - lastIdleTaskTime > 500) {
326 SDKMainHandler.getInstance().post(
new Runnable() {
338 if(ZmDeviceUtils.getCPUKernalNumbers() < 2 && ZmDeviceUtils.getCPUKernelFrequency(0, ZmDeviceUtils.FLAG_MAX_FREQUENCY) < 1400000) {
350 Log.i(
TAG,
"onGLSurfaceChanged group index =" +
mGroupIndex +
", width=" + width +
", height=" + height);
352 if(!isInitialized()) {
356 SDKMainHandler.getInstance().post(
new Runnable() {
369 SDKMainHandler.getInstance().post(
new Runnable() {
383 if(
null!=inMeetingService){
385 if(
null!=shareController&&shareController instanceof InMeetingShareControllerImpl){
386 InMeetingShareControllerImpl shareControllerImpl=(InMeetingShareControllerImpl)shareController;
387 shareControllerImpl.setFragmentActivity(context);
394 super.onAttachedToWindow();
395 Context context = getContext();
396 SDKDisclaimerDialogManager.getInstance().setDisclaimerDialogContext(context);
398 if (context instanceof Activity) {
400 ZmUtils.detectGPUInfo((Activity) context);
402 if(context instanceof ContextWrapper){
403 context=((ContextWrapper)context).getBaseContext();
404 if (context instanceof Activity) {
406 ZmUtils.detectGPUInfo((Activity) context);
414 super.onDetachedFromWindow();
418 private static final String
WB_TAG =
TAG +
"Whiteboard";
421 boolean enableWBInView = PreferenceUtil.readBooleanValue(SDKConstants.SDK_ENABLE_SWITCH_WB_WITH_NORMAL_SHARE,
false);
422 if (!enableWBInView) {
423 if (BuildConfig.LOG_ENABLE) {
424 ZMLog.e(
TAG,
"addWBFragment fail for not enable the feature");
431 if (BuildConfig.LOG_ENABLE) {
432 ZMLog.e(
TAG,
"add WB Fragment fail for mFragmentContainer is null");
438 if (!(
activity instanceof FragmentActivity)) {
439 if (BuildConfig.LOG_ENABLE) {
440 ZMLog.e(
TAG,
"addWBFragment fail for basic Activity");
446 Fragment fragment = ((FragmentActivity)
activity).getSupportFragmentManager().findFragmentByTag(
WB_TAG);
447 if (fragment !=
null) {
448 if (BuildConfig.LOG_ENABLE) {
449 ZMLog.e(
TAG,
"addWBFragment fail for already add the fragment");
456 if (BuildConfig.LOG_ENABLE) {
457 ZMLog.e(
TAG,
"addWBFragment fail for null inMeetingWhiteboardController");
465 fragment =
new SDKWBViewerFragment((FragmentActivity)
activity);
466 Fragment finalFragment = fragment;
467 SafeTransactionKt.startSafeTransaction((FragmentActivity)
activity,
new Function1<ISafeTransaction, Unit>() {
469 public Unit invoke(ISafeTransaction iSafeTransaction) {
470 iSafeTransaction.add(R.id.wbFragmentContainer, finalFragment,
WB_TAG);
471 return Unit.INSTANCE;
481 if (MeetingWebWbMgr.INSTANCE.getWbUseCase().isPresentingWhiteboard()) {
482 WebWbUiNotify wbUiNotify = MeetingWebWbMgr.INSTANCE.getWbUiNotify();
483 if (wbUiNotify !=
null) {
484 wbUiNotify.canvasReallyLoadUrl(
true);
493 boolean enableWBInView = PreferenceUtil.readBooleanValue(SDKConstants.SDK_ENABLE_SWITCH_WB_WITH_NORMAL_SHARE,
false);
494 if (!enableWBInView) {
495 if (BuildConfig.LOG_ENABLE) {
496 ZMLog.e(
TAG,
"removeWBFragment fail for not enable the feature");
502 if (BuildConfig.LOG_ENABLE) {
503 ZMLog.e(
TAG,
"remove WB Fragment fail for inMeetingWhiteboardController is null");
509 if (BuildConfig.LOG_ENABLE) {
510 ZMLog.e(
TAG,
"remove WB Fragment fail for mFragmentContainer is null");
515 if (!(
activity instanceof FragmentActivity)) {
516 if (BuildConfig.LOG_ENABLE) {
517 ZMLog.e(
TAG,
"removeWBFragment fail for basic Activity");
523 Fragment fragment = ((FragmentActivity)
activity).getSupportFragmentManager().findFragmentByTag(
WB_TAG);
524 if (fragment ==
null) {
525 if (BuildConfig.LOG_ENABLE) {
526 ZMLog.e(
TAG,
"removeWBFragment fail for can not find the fragment");
533 SafeTransactionKt.startSafeTransaction((FragmentActivity)
activity,
new Function1<ISafeTransaction, Unit>() {
535 public Unit invoke(ISafeTransaction iSafeTransaction) {
536 iSafeTransaction.remove(fragment);
537 return Unit.INSTANCE;
550 if (BuildConfig.LOG_ENABLE) {
551 ZMLog.e(
TAG,
"add doc Fragment fail for mFragmentContainer is null");
556 if (!(
activity instanceof FragmentActivity)) {
557 if (BuildConfig.LOG_ENABLE) {
558 ZMLog.e(
TAG,
"addDocFragment fail for basic Activity");
563 Fragment fragment = ((FragmentActivity)
activity).getSupportFragmentManager().findFragmentByTag(
DOC_TAG);
564 if (fragment !=
null) {
565 if (BuildConfig.LOG_ENABLE) {
566 ZMLog.e(
TAG,
"addDocFragment fail for already add the fragment");
571 Bundle bundle =
getBundle(shareSourceID);
572 if (bundle ==
null) {
573 if (BuildConfig.LOG_ENABLE) {
574 ZMLog.e(
TAG,
"addDocFragment fail for null bundle");
579 IConfZoomDocs docs = StaticInnerService.getConfDocs();
581 if (BuildConfig.LOG_ENABLE) {
582 ZMLog.e(
TAG,
"addDocFragment fail for null docs");
586 docs.setShareSourceId(shareSourceID);
588 fragment = ZoomDocsShareFragment.get(bundle);
589 Fragment finalFragment = fragment;
590 SafeTransactionKt.startSafeTransaction((FragmentActivity)
activity,
new Function1<ISafeTransaction, Unit>() {
592 public Unit invoke(ISafeTransaction iSafeTransaction) {
593 iSafeTransaction.add(R.id.wbFragmentContainer, finalFragment,
DOC_TAG);
594 return Unit.INSTANCE;
602 private @Nullable Bundle
getBundle(
long shareSourceID) {
603 CmmDocsCollaborationSource docsCollaborationSource = ZoomMeetingSDKDocsHelper.getInstance().getDocsCollaborationSource(shareSourceID);
604 if (docsCollaborationSource ==
null) {
607 Bundle bundle =
new Bundle();
608 String url = ZmStringUtils.isEmptyOrNull(docsCollaborationSource.url) ? WebHelper.WEB_BLANK : docsCollaborationSource.url;
609 bundle.putString(StaticInnerService.Consts.KEY_ARGS_URL, url);
610 bundle.putInt(UniteBaseLogic.UniteBundleWrapper.MODULE_TYPE, UnifyWebViewAppType.UnifyWebViewAppType_ZoomDocs);
611 bundle.putInt(StaticInnerService.Consts.KEY_WEBVIEW_INSTANCE_TAG, WebViewInstanceTag.kInstEditor);
612 bundle.putInt(StaticInnerService.Consts.KEY_ARGS_PROCESS, ZmBusinessModuleMgr.PROCESS_TYPE_CONF);
618 if (BuildConfig.LOG_ENABLE) {
619 ZMLog.e(
TAG,
"removeDocFragment fail for mFragmentContainer is null");
624 if (!(
activity instanceof FragmentActivity)) {
625 if (BuildConfig.LOG_ENABLE) {
626 ZMLog.e(
TAG,
"removeDocFragment fail for basic Activity");
631 Fragment fragment = ((FragmentActivity)
activity).getSupportFragmentManager().findFragmentByTag(
DOC_TAG);
632 if (fragment ==
null) {
633 if (BuildConfig.LOG_ENABLE) {
634 ZMLog.e(
TAG,
"removeDocFragment fail for can not find the fragment");
639 SafeTransactionKt.startSafeTransaction((FragmentActivity)
activity,
new Function1<ISafeTransaction, Unit>() {
641 public Unit invoke(ISafeTransaction iSafeTransaction) {
642 iSafeTransaction.remove(fragment);
643 return Unit.INSTANCE;
void onGLSurfaceCreated()
MobileRTCVideoRender(SDKVideoView glView, int groupIndex)
void onDrawFrameInternal(GL10 gl)
void onGLSurfaceDestroyed()
void onGLSurfaceChanged(final int width, final int height)
static final int RENDERER_FPS
static final int RENDERER_FPS_LOW_PERFORMANCE
synchronized MobileRTCVideoViewManager getVideoViewMgr()
boolean isVisibleToUser()
MobileRTCSDKError removeDocFragment()
MobileRTCVideoView(Context context, AttributeSet attrs, int defStyle)
FrameLayout mFragmentContainer
boolean onSingleTapConfirmed(MotionEvent e)
static final String WB_TAG
MobileRTCVideoViewManagerImpl mVideoViewMgr
void setZOrderOnTop(boolean onTop)
Controls whether the surface of the view is in its top window. Usually it is placed behind the window...
MobileRTCVideoView(Context context)
boolean onDoubleTapEvent(MotionEvent e)
InMeetingWhiteboardControllerImpl inMeetingWhiteboardController
MobileRTCSDKError addWhiteBoardFragment()
boolean onDoubleTap(MotionEvent e)
SDKShareInView mShareView
static final String DOC_TAG
boolean onFling(MotionEvent e1, MotionEvent e2, float velocityX, float velocityY)
boolean onSingleTapUp(MotionEvent e)
void onShowPress(MotionEvent e)
boolean onDown(MotionEvent e)
GestureDetector mGestureDetector
void onLongPress(MotionEvent e)
MobileRTCVideoRender mVideoRender
void setZOrderMediaOverlay(boolean isMediaOverlay)
Sets whether the surface view is placed at the top of another regular surface view in the window....
MobileRTCVideoView(Context context, AttributeSet attrs)
void initActivity(Context context)
void onDetachedFromWindow()
synchronized MobileRTCVideoViewManager getVideoViewManager()
Gets a manager object of the video view.
MobileRTCSDKError addDocFragment(long shareSourceID)
boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY)
Bundle getBundle(long shareSourceID)
void beforeGLContextDestroyed()
void onPause()
Pauses video view rendering.
void setGestureDetectorEnabled(boolean isEnabled)
Sets whether to enable gesture detector of shared unit. Default value: disabled.
void initVideoView(Context context)
MobileRTCSDKError removeWhiteboardFragment()
void onAttachedToWindow()
void onResume()
Resumes video view rendering.
void init(Context context)
InMeetingService getInMeetingService()
Gets the in-meeting service instance.
static ZoomSDK getInstance()
Gets a shared instance of Zoom SDK. Must call from the main thread.
Enumeration of common SDK errors.
Interfaces of Zoom services in meeting.
InMeetingShareController getInMeetingShareController()
Gets the share controller instance in meeting.
InMeetingWhiteboardController getInMeetingWhiteboardController()
Gets the new whiteboard controller instance.
Share controller in meeting.
Meeting MobileRTCVideoView manager class. Get the manager object by the interface in MobileRTCVideoVi...