From 7af8e20494162a78c002dfa303dfd8d6fb360bad Mon Sep 17 00:00:00 2001 From: Sylvain Berfini Date: Mon, 22 Oct 2018 10:39:47 +0200 Subject: [PATCH] Feature/texture view --- CHANGELOG.md | 1 + res/layout/video.xml | 21 ++++-- res/raw/linphonerc_factory | 1 - .../org/linphone/call/CallVideoFragment.java | 68 ++++--------------- submodules/linphone | 2 +- submodules/mediastreamer2 | 2 +- 6 files changed, 29 insertions(+), 66 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 23d31a6a7..c4e42c543 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,7 @@ Group changes to describe their impact on the project, as follows: ## [Incomming] - feature: support of H265 codec. +- feature: use TextureView instead of GL2JNIView, easier to use and will fix issues ## [4.0.1] - 2018-06-26 diff --git a/res/layout/video.xml b/res/layout/video.xml index 86b7465e8..f0fe5abe3 100644 --- a/res/layout/video.xml +++ b/res/layout/video.xml @@ -1,20 +1,27 @@ - + android:layout_height="match_parent" + android:background="@color/colorB"> - + + - - \ No newline at end of file + + + \ No newline at end of file diff --git a/res/raw/linphonerc_factory b/res/raw/linphonerc_factory index 24084a6d7..edb966667 100644 --- a/res/raw/linphonerc_factory +++ b/res/raw/linphonerc_factory @@ -32,7 +32,6 @@ playback_dev_id= ringer_dev_id= capture_dev_id= dtmf_player_amp=0.1 - #remove this property for any application that is not Linphone public version itself ec_calibrator_cool_tones=1 diff --git a/src/android/org/linphone/call/CallVideoFragment.java b/src/android/org/linphone/call/CallVideoFragment.java index 83bbbc6f0..9a768f89e 100644 --- a/src/android/org/linphone/call/CallVideoFragment.java +++ b/src/android/org/linphone/call/CallVideoFragment.java @@ -27,8 +27,8 @@ import android.view.GestureDetector.OnDoubleTapListener; import android.view.GestureDetector.OnGestureListener; import android.view.LayoutInflater; import android.view.MotionEvent; -import android.view.SurfaceHolder; -import android.view.SurfaceView; +import android.view.Surface; +import android.view.TextureView; import android.view.View; import android.view.View.OnTouchListener; import android.view.ViewGroup; @@ -46,12 +46,10 @@ import org.linphone.core.Call; import org.linphone.core.Core; import org.linphone.core.VideoDefinition; import org.linphone.mediastream.Log; -import org.linphone.mediastream.video.AndroidVideoWindowImpl; public class CallVideoFragment extends Fragment implements OnGestureListener, OnDoubleTapListener, CompatibilityScaleGestureListener { - private SurfaceView mVideoView; - private SurfaceView mCaptureView; - private AndroidVideoWindowImpl androidVideoWindowImpl; + private TextureView mVideoView; + private TextureView mCaptureView; private GestureDetector mGestureDetector; private float mZoomFactor = 1.f; private float mZoomCenterX, mZoomCenterY; @@ -73,30 +71,9 @@ public class CallVideoFragment extends Fragment implements OnGestureListener, On mVideoView = view.findViewById(R.id.videoSurface); mCaptureView = view.findViewById(R.id.videoCaptureSurface); - mCaptureView.getHolder().setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS); // Warning useless because value is ignored and automatically set by new APIs. - - fixZOrder(mVideoView, mCaptureView); - - androidVideoWindowImpl = new AndroidVideoWindowImpl(mVideoView, mCaptureView, new AndroidVideoWindowImpl.VideoWindowListener() { - public void onVideoRenderingSurfaceReady(AndroidVideoWindowImpl vw, SurfaceView surface) { - mVideoView = surface; - LinphoneManager.getLc().setNativeVideoWindowId(vw); - } - - public void onVideoRenderingSurfaceDestroyed(AndroidVideoWindowImpl vw) { - - } - - public void onVideoPreviewSurfaceReady(AndroidVideoWindowImpl vw, SurfaceView surface) { - mCaptureView = surface; - LinphoneManager.getLc().setNativePreviewWindowId(mCaptureView); - resizePreview(); - } - - public void onVideoPreviewSurfaceDestroyed(AndroidVideoWindowImpl vw) { - - } - }); + + LinphoneManager.getLc().setNativeVideoWindowId(mVideoView); + LinphoneManager.getLc().setNativePreviewWindowId(mCaptureView); mVideoView.setOnTouchListener(new OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { @@ -178,17 +155,15 @@ public class CallVideoFragment extends Fragment implements OnGestureListener, On Log.e("mCaptureView is null !"); return; } - mCaptureView.getHolder().setFixedSize(width, height); + + RelativeLayout.LayoutParams newLp = new RelativeLayout.LayoutParams(width, height); + newLp.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, 1); // Clears the rule, as there is no removeRule until API 17. + newLp.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, 1); + mCaptureView.setLayoutParams(newLp); Log.d("Video preview size set to " + width + "x" + height); } } - private void fixZOrder(SurfaceView video, SurfaceView preview) { - video.setZOrderOnTop(false); - preview.setZOrderOnTop(true); - preview.setZOrderMediaOverlay(true); // Needed to be able to display control layout over - } - public void switchCamera() { try { String currentDevice = LinphoneManager.getLc().getVideoDevice(); @@ -223,11 +198,6 @@ public class CallVideoFragment extends Fragment implements OnGestureListener, On if (LinphonePreferences.instance().isOverlayEnabled()) { LinphoneService.instance().destroyOverlay(); } - if (androidVideoWindowImpl != null) { - synchronized (androidVideoWindowImpl) { - LinphoneManager.getLc().setNativeVideoWindowId(androidVideoWindowImpl); - } - } mGestureDetector = new GestureDetector(inCallActivity, this); mScaleDetector = Compatibility.getScaleGestureDetector(inCallActivity, this); @@ -237,15 +207,6 @@ public class CallVideoFragment extends Fragment implements OnGestureListener, On @Override public void onPause() { - if (androidVideoWindowImpl != null) { - synchronized (androidVideoWindowImpl) { - /* - * this call will destroy native opengl renderer which is used by - * androidVideoWindowImpl - */ - LinphoneManager.getLc().setNativeVideoWindowId(null); - } - } if (LinphonePreferences.instance().isOverlayEnabled()) { LinphoneService.instance().createOverlay(); } @@ -338,11 +299,6 @@ public class CallVideoFragment extends Fragment implements OnGestureListener, On mVideoView.setOnTouchListener(null); mVideoView = null; } - if (androidVideoWindowImpl != null) { - // Prevent linphone from crashing if correspondent hang up while you are rotating - androidVideoWindowImpl.release(); - androidVideoWindowImpl = null; - } if (mGestureDetector != null) { mGestureDetector.setOnDoubleTapListener(null); mGestureDetector = null; diff --git a/submodules/linphone b/submodules/linphone index c452cbe61..3792f8c5c 160000 --- a/submodules/linphone +++ b/submodules/linphone @@ -1 +1 @@ -Subproject commit c452cbe61ae875ae6833153760e681f8beb384ed +Subproject commit 3792f8c5cffc991425d4664d12873c8b60b3d934 diff --git a/submodules/mediastreamer2 b/submodules/mediastreamer2 index 14739e69f..b44b9fcac 160000 --- a/submodules/mediastreamer2 +++ b/submodules/mediastreamer2 @@ -1 +1 @@ -Subproject commit 14739e69fd85078f94d8a431d76ad0e8fbcab4ae +Subproject commit b44b9fcacb6db7948092ef107055b092f53b0def