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 com.zipow.videobox.view.video.VideoRenderer;
35import javax.microedition.khronos.opengles.GL10;
38import kotlin.jvm.functions.Function1;
39import us.zoom.business.common.ZmBusinessModuleMgr;
40import us.zoom.common.crossplatform.cmmlib.BuildConfig;
41import us.zoom.core.helper.ZMLog;
42import us.zoom.internal.impl.InMeetingShareControllerImpl;
43import us.zoom.docs.bridge.tocpp.IConfZoomDocs;
44import us.zoom.docs.conf.cplusenum.WebViewInstanceTag;
45import us.zoom.docs.service.StaticInnerService;
46import us.zoom.docs.ui.share.ZoomDocsShareFragment;
47import us.zoom.hybrid.safeweb.core.WebHelper;
48import us.zoom.internal.impl.InMeetingWhiteboardControllerImpl;
49import us.zoom.internal.jni.bean.CmmDocsCollaborationSource;
50import us.zoom.internal.jni.helper.ZoomMeetingSDKBridgeHelper;
51import us.zoom.internal.jni.helper.ZoomMeetingSDKDocsHelper;
52import us.zoom.internal.view.SDKWBViewerFragment;
53import us.zoom.libtools.fragmentmanager.ISafeTransaction;
54import us.zoom.libtools.fragmentmanager.SafeTransactionKt;
55import us.zoom.libtools.storage.PreferenceUtil;
56import us.zoom.libtools.utils.ZmDeviceUtils;
57import us.zoom.internal.SDKCustomizedMeetingUIHelper;
58import us.zoom.internal.SDKDisclaimerDialogManager;
59import us.zoom.internal.impl.MobileRTCVideoViewManagerImpl;
60import us.zoom.libtools.utils.ZmStringUtils;
61import us.zoom.unite.cplusenum.UnifyWebViewAppType;
62import us.zoom.unite.logic.UniteBaseLogic;
63import us.zoom.videomeetings.R;
68public class MobileRTCVideoView extends RelativeLayout implements SDKVideoView.Listener, GestureDetector.OnGestureListener, GestureDetector.OnDoubleTapListener {
94 super(context, attrs);
99 super(context, attrs, defStyle);
103 private void init(Context context) {
104 mView = (ViewGroup)LayoutInflater.from(context).inflate(R.layout.zm_videoview_sdk,
null,
false);
106 mShareView = (SDKShareInView)
mView.findViewById(R.id.zm_sdk_viewingShare);
114 if (inMeetingService !=
null) {
116 if (wbController instanceof InMeetingWhiteboardControllerImpl) {
125 if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
126 mVideoView.setPreserveEGLContextOnPause(
true);
138 if(!isInEditMode() && isEnabled) {
154 mVideoView.setZOrderMediaOverlay(isMediaOverlay);
175 if(!SDKCustomizedMeetingUIHelper.isSdkEnableCustomizedUI()|| !SDKCustomizedMeetingUIHelper.isSdkUsingCustomizedMeetingUI()) {
179 Mainboard mainboard = ZmMainBoardMgr.getMainboard();
180 if(mainboard !=
null && !((ZmSdkMainBoard)mainboard.getSdkMainBoard()).isSDKConfAppCreated()) {
188 if(SDKCustomizedMeetingUIHelper.isSdkEnableCustomizedUI() && SDKCustomizedMeetingUIHelper.isSdkUsingCustomizedMeetingUI()) {
191 Mainboard mainboard = ZmMainBoardMgr.getMainboard();
192 if(mainboard !=
null && !((ZmSdkMainBoard)mainboard.getSdkMainBoard()).isSDKConfAppCreated()) {
223 public boolean onFling(MotionEvent e1, MotionEvent e2,
float velocityX,
236 public boolean onScroll(MotionEvent e1, MotionEvent e2,
float distanceX,
280 Rect rect =
new Rect();
281 if (getGlobalVisibleRect(rect)) {
282 if (rect.width() * rect.height() >= getMeasuredWidth() * getMeasuredHeight()/2) {
296 Log.i(
TAG,
"surfaceCreated group index =" +
mVideoRender.getGroupIndex());
301 Log.i(
TAG,
"surfaceDestroyed group index =" +
mVideoRender.getGroupIndex());
316 super(glView, groupIndex);
322 long curTime = System.currentTimeMillis();
323 if(curTime < lastIdleTaskTime || curTime - lastIdleTaskTime > 500) {
325 SDKMainHandler.getInstance().post(
new Runnable() {
336 if(ZmDeviceUtils.getCPUKernalNumbers() < 2 && ZmDeviceUtils.getCPUKernelFrequency(0, ZmDeviceUtils.FLAG_MAX_FREQUENCY) < 1400000) {
348 Log.i(
TAG,
"onGLSurfaceChanged group index =" +
mGroupIndex +
", width=" + width +
", height=" + height);
350 if(!isInitialized()) {
354 SDKMainHandler.getInstance().post(
new Runnable() {
367 SDKMainHandler.getInstance().post(
new Runnable() {
381 if(
null!=inMeetingService){
383 if(
null!=shareController&&shareController instanceof InMeetingShareControllerImpl){
384 InMeetingShareControllerImpl shareControllerImpl=(InMeetingShareControllerImpl)shareController;
385 shareControllerImpl.setFragmentActivity(context);
392 super.onAttachedToWindow();
393 Context context = getContext();
394 SDKDisclaimerDialogManager.getInstance().setDisclaimerDialogContext(context);
396 if (context instanceof Activity) {
398 ZmUtils.detectGPUInfo((Activity) context);
400 if(context instanceof ContextWrapper){
401 context=((ContextWrapper)context).getBaseContext();
402 if (context instanceof Activity) {
404 ZmUtils.detectGPUInfo((Activity) context);
412 super.onDetachedFromWindow();
416 private static final String
WB_TAG =
TAG +
"Whiteboard";
419 boolean enableWBInView = PreferenceUtil.readBooleanValue(SDKConstants.SDK_ENABLE_SWITCH_WB_WITH_NORMAL_SHARE,
false);
420 if (!enableWBInView) {
421 if (BuildConfig.LOG_ENABLE) {
422 ZMLog.e(
TAG,
"addWBFragment fail for not enable the feature");
429 if (BuildConfig.LOG_ENABLE) {
430 ZMLog.e(
TAG,
"add WB Fragment fail for mFragmentContainer is null");
436 if (!(
activity instanceof FragmentActivity)) {
437 if (BuildConfig.LOG_ENABLE) {
438 ZMLog.e(
TAG,
"addWBFragment fail for basic Activity");
444 Fragment fragment = ((FragmentActivity)
activity).getSupportFragmentManager().findFragmentByTag(
WB_TAG);
445 if (fragment !=
null) {
446 if (BuildConfig.LOG_ENABLE) {
447 ZMLog.e(
TAG,
"addWBFragment fail for already add the fragment");
454 if (BuildConfig.LOG_ENABLE) {
455 ZMLog.e(
TAG,
"addWBFragment fail for null inMeetingWhiteboardController");
463 fragment =
new SDKWBViewerFragment((FragmentActivity)
activity);
464 Fragment finalFragment = fragment;
465 SafeTransactionKt.startSafeTransaction((FragmentActivity)
activity,
new Function1<ISafeTransaction, Unit>() {
467 public Unit invoke(ISafeTransaction iSafeTransaction) {
468 iSafeTransaction.add(R.id.wbFragmentContainer, finalFragment,
WB_TAG);
469 return Unit.INSTANCE;
478 boolean enableWBInView = PreferenceUtil.readBooleanValue(SDKConstants.SDK_ENABLE_SWITCH_WB_WITH_NORMAL_SHARE,
false);
479 if (!enableWBInView) {
480 if (BuildConfig.LOG_ENABLE) {
481 ZMLog.e(
TAG,
"removeWBFragment fail for not enable the feature");
487 if (BuildConfig.LOG_ENABLE) {
488 ZMLog.e(
TAG,
"remove WB Fragment fail for inMeetingWhiteboardController is null");
494 if (BuildConfig.LOG_ENABLE) {
495 ZMLog.e(
TAG,
"remove WB Fragment fail for mFragmentContainer is null");
500 if (!(
activity instanceof FragmentActivity)) {
501 if (BuildConfig.LOG_ENABLE) {
502 ZMLog.e(
TAG,
"removeWBFragment fail for basic Activity");
508 Fragment fragment = ((FragmentActivity)
activity).getSupportFragmentManager().findFragmentByTag(
WB_TAG);
509 if (fragment ==
null) {
510 if (BuildConfig.LOG_ENABLE) {
511 ZMLog.e(
TAG,
"removeWBFragment fail for can not find the fragment");
518 SafeTransactionKt.startSafeTransaction((FragmentActivity)
activity,
new Function1<ISafeTransaction, Unit>() {
520 public Unit invoke(ISafeTransaction iSafeTransaction) {
521 iSafeTransaction.remove(fragment);
522 return Unit.INSTANCE;
535 if (BuildConfig.LOG_ENABLE) {
536 ZMLog.e(
TAG,
"add doc Fragment fail for mFragmentContainer is null");
541 if (!(
activity instanceof FragmentActivity)) {
542 if (BuildConfig.LOG_ENABLE) {
543 ZMLog.e(
TAG,
"addDocFragment fail for basic Activity");
548 Fragment fragment = ((FragmentActivity)
activity).getSupportFragmentManager().findFragmentByTag(
DOC_TAG);
549 if (fragment !=
null) {
550 if (BuildConfig.LOG_ENABLE) {
551 ZMLog.e(
TAG,
"addDocFragment fail for already add the fragment");
556 Bundle bundle =
getBundle(shareSourceID);
557 if (bundle ==
null) {
558 if (BuildConfig.LOG_ENABLE) {
559 ZMLog.e(
TAG,
"addDocFragment fail for null bundle");
564 IConfZoomDocs docs = StaticInnerService.getConfDocs();
566 if (BuildConfig.LOG_ENABLE) {
567 ZMLog.e(
TAG,
"addDocFragment fail for null docs");
571 docs.setShareSourceId(shareSourceID);
573 fragment = ZoomDocsShareFragment.get(bundle);
574 Fragment finalFragment = fragment;
575 SafeTransactionKt.startSafeTransaction((FragmentActivity)
activity,
new Function1<ISafeTransaction, Unit>() {
577 public Unit invoke(ISafeTransaction iSafeTransaction) {
578 iSafeTransaction.add(R.id.wbFragmentContainer, finalFragment,
DOC_TAG);
579 return Unit.INSTANCE;
587 private @Nullable Bundle
getBundle(
long shareSourceID) {
588 CmmDocsCollaborationSource docsCollaborationSource = ZoomMeetingSDKDocsHelper.getInstance().getDocsCollaborationSource(shareSourceID);
589 if (docsCollaborationSource ==
null) {
592 Bundle bundle =
new Bundle();
593 String url = ZmStringUtils.isEmptyOrNull(docsCollaborationSource.url) ? WebHelper.WEB_BLANK : docsCollaborationSource.url;
594 bundle.putString(StaticInnerService.Consts.KEY_ARGS_URL, url);
595 bundle.putInt(UniteBaseLogic.UniteBundleWrapper.MODULE_TYPE, UnifyWebViewAppType.UnifyWebViewAppType_ZoomDocs);
596 bundle.putInt(StaticInnerService.Consts.KEY_WEBVIEW_INSTANCE_TAG, WebViewInstanceTag.kInstEditor);
597 bundle.putInt(StaticInnerService.Consts.KEY_ARGS_PROCESS, ZmBusinessModuleMgr.PROCESS_TYPE_CONF);
603 if (BuildConfig.LOG_ENABLE) {
604 ZMLog.e(
TAG,
"removeDocFragment fail for mFragmentContainer is null");
609 if (!(
activity instanceof FragmentActivity)) {
610 if (BuildConfig.LOG_ENABLE) {
611 ZMLog.e(
TAG,
"removeDocFragment fail for basic Activity");
616 Fragment fragment = ((FragmentActivity)
activity).getSupportFragmentManager().findFragmentByTag(
DOC_TAG);
617 if (fragment ==
null) {
618 if (BuildConfig.LOG_ENABLE) {
619 ZMLog.e(
TAG,
"removeDocFragment fail for can not find the fragment");
624 SafeTransactionKt.startSafeTransaction((FragmentActivity)
activity,
new Function1<ISafeTransaction, Unit>() {
626 public Unit invoke(ISafeTransaction iSafeTransaction) {
627 iSafeTransaction.remove(fragment);
628 return Unit.INSTANCE;
void onGLSurfaceCreated()
MobileRTCVideoRender(SDKVideoView glView, int groupIndex)
void onGLSurfaceDestroyed()
void onDrawFrame(GL10 gl, VideoRenderer renderer)
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...