Commit 6f2cfe7b authored by Sylvain Berfini's avatar Sylvain Berfini 🎩

Forward null window id to Java AndroidPlatformHelper so it can remove the...

Forward null window id to Java AndroidPlatformHelper so it can remove the SurfaceListener that can cause setNativeVideoWindowId to be called when there is no Core
parent 8ce0d753
......@@ -258,7 +258,7 @@ void AndroidPlatformHelpers::setVideoPreviewWindow (void *windowId) {
JNIEnv *env = ms_get_jni_env();
if (env && mJavaHelper) {
string displayFilter = L_C_TO_STRING(linphone_core_get_video_display_filter(getCore()->getCCore()));
if (windowId && (displayFilter.empty() || displayFilter == "MSAndroidTextureDisplay")) {
if ((displayFilter.empty() || displayFilter == "MSAndroidTextureDisplay")) {
env->CallVoidMethod(mJavaHelper, mSetNativePreviewVideoWindowId, (jobject)windowId);
} else {
_setPreviewVideoWindow((jobject)windowId);
......@@ -270,7 +270,7 @@ void AndroidPlatformHelpers::setVideoWindow (void *windowId) {
JNIEnv *env = ms_get_jni_env();
if (env && mJavaHelper) {
string displayFilter = L_C_TO_STRING(linphone_core_get_video_display_filter(getCore()->getCCore()));
if (windowId && (displayFilter.empty() || displayFilter == "MSAndroidTextureDisplay")) {
if ((displayFilter.empty() || displayFilter == "MSAndroidTextureDisplay")) {
env->CallVoidMethod(mJavaHelper, mSetNativeVideoWindowId, (jobject)windowId);
} else {
_setVideoWindow((jobject)windowId);
......
......@@ -84,7 +84,7 @@ public class AndroidPlatformHelper {
private String mUserCertificatePath;
private Surface mSurface;
private SurfaceTexture mSurfaceTexture;
private TextureView mPreviewTextureView;
private TextureView mPreviewTextureView, mVideoTextureView;
private boolean mDozeModeEnabled;
private BroadcastReceiver mDozeReceiver;
private IntentFilter mDozeIntentFilter;
......@@ -354,6 +354,15 @@ public class AndroidPlatformHelper {
}
public synchronized void setVideoPreviewView(Object view) {
if (view == null) {
setNativePreviewWindowId(mNativePtr, null);
if (mPreviewTextureView != null) {
mPreviewTextureView.setSurfaceTextureListener(null);
mPreviewTextureView = null;
}
return;
}
if (view instanceof Surface) {
Surface surface = (Surface) view;
setNativePreviewWindowId(mNativePtr, surface);
......@@ -368,7 +377,6 @@ public class AndroidPlatformHelper {
}
mPreviewTextureView = (TextureView)view;
ViewGroup.LayoutParams lp = mPreviewTextureView.getLayoutParams();
mPreviewTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
......@@ -384,8 +392,10 @@ public class AndroidPlatformHelper {
@Override
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
Log.i("[Platform Helper] Preview window surface is no longer available");
setNativePreviewWindowId(mNativePtr, null);
mPreviewTextureView = null;
if (mPreviewTextureView != null) {
setNativePreviewWindowId(mNativePtr, null);
mPreviewTextureView = null;
}
return false;
}
......@@ -402,6 +412,15 @@ public class AndroidPlatformHelper {
}
public synchronized void setVideoRenderingView(Object view) {
if (view == null) {
setNativeVideoWindowId(mNativePtr, null);
if (mVideoTextureView != null) {
mVideoTextureView.setSurfaceTextureListener(null);
mVideoTextureView = null;
}
return;
}
if (view instanceof Surface) {
Surface surface = (Surface) view;
setNativeVideoWindowId(mNativePtr, surface);
......@@ -415,8 +434,8 @@ public class AndroidPlatformHelper {
"so you can keep using your existing application code for managing video views.");
}
TextureView textureView = (TextureView)view;
textureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
mVideoTextureView = (TextureView)view;
mVideoTextureView.setSurfaceTextureListener(new TextureView.SurfaceTextureListener() {
@Override
public void onSurfaceTextureAvailable(SurfaceTexture surface, int width, int height) {
Log.i("[Platform Helper] Rendering window surface is available");
......@@ -434,8 +453,11 @@ public class AndroidPlatformHelper {
public boolean onSurfaceTextureDestroyed(SurfaceTexture surface) {
if (mSurfaceTexture == surface) {
Log.i("[Platform Helper] Rendering window surface is no longer available");
setNativeVideoWindowId(mNativePtr, null);
mSurfaceTexture = null;
if (mVideoTextureView != null) {
setNativeVideoWindowId(mNativePtr, null);
mSurfaceTexture = null;
mVideoTextureView = null;
}
}
return false;
}
......@@ -446,9 +468,9 @@ public class AndroidPlatformHelper {
}
});
if (textureView.isAvailable()) {
if (mVideoTextureView.isAvailable()) {
Log.i("[Platform Helper] Rendering window surface is available");
mSurfaceTexture = textureView.getSurfaceTexture();
mSurfaceTexture = mVideoTextureView.getSurfaceTexture();
mSurface = new Surface(mSurfaceTexture);
setNativeVideoWindowId(mNativePtr, mSurface);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment