Merge branch 'feature/texture_view' into 'master'

Feature/texture view

See merge request BC/public/linphone-android!2
This commit is contained in:
Sylvain Berfini 2018-10-22 10:39:47 +02:00
commit f2c05495ce
6 changed files with 29 additions and 66 deletions

View file

@ -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

View file

@ -1,20 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/video_frame"
android:layout_width="match_parent"
android:layout_height="match_parent">
android:layout_height="match_parent"
android:background="@color/colorB">
<org.linphone.mediastream.video.display.GL2JNIView
<TextureView
android:visibility="visible"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:id="@+id/videoSurface" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<SurfaceView
<TextureView
android:id="@+id/videoCaptureSurface"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="300dp"
android:layout_height="200dp"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true" />
</RelativeLayout>
</RelativeLayout>
</FrameLayout>

View file

@ -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

View file

@ -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;

@ -1 +1 @@
Subproject commit c452cbe61ae875ae6833153760e681f8beb384ed
Subproject commit 3792f8c5cffc991425d4664d12873c8b60b3d934

@ -1 +1 @@
Subproject commit 14739e69fd85078f94d8a431d76ad0e8fbcab4ae
Subproject commit b44b9fcacb6db7948092ef107055b092f53b0def