Replaced surfaceview with textureview
This commit is contained in:
parent
04207ebcef
commit
51eb4db7bd
2 changed files with 10 additions and 45 deletions
|
@ -22,27 +22,27 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||||
import android.app.Fragment;
|
import android.app.Fragment;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
import android.view.SurfaceView;
|
import android.view.TextureView;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
import org.linphone.LinphoneManager;
|
import org.linphone.LinphoneManager;
|
||||||
import org.linphone.R;
|
import org.linphone.R;
|
||||||
import org.linphone.core.Core;
|
import org.linphone.core.Core;
|
||||||
import org.linphone.core.CoreListenerStub;
|
import org.linphone.core.CoreListenerStub;
|
||||||
import org.linphone.mediastream.video.AndroidVideoWindowImpl;
|
|
||||||
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
import org.linphone.mediastream.video.capture.hwconf.AndroidCameraConfiguration;
|
||||||
|
|
||||||
public class QrcodeFragment extends Fragment {
|
public class QrcodeFragment extends Fragment {
|
||||||
private SurfaceView mQrcodeView;
|
private TextureView mQrcodeView;
|
||||||
private CoreListenerStub mListener;
|
private CoreListenerStub mListener;
|
||||||
private AndroidVideoWindowImpl androidVideoWindowImpl;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public View onCreateView(
|
public View onCreateView(
|
||||||
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||||
View view = inflater.inflate(R.layout.qrcode, container, false);
|
View view = inflater.inflate(R.layout.qrcode, container, false);
|
||||||
|
|
||||||
mQrcodeView = (SurfaceView) view.findViewById(R.id.qrcodeCaptureSurface);
|
mQrcodeView = view.findViewById(R.id.qrcodeCaptureSurface);
|
||||||
|
|
||||||
|
LinphoneManager.getLc().setNativePreviewWindowId(mQrcodeView);
|
||||||
|
|
||||||
mListener =
|
mListener =
|
||||||
new CoreListenerStub() {
|
new CoreListenerStub() {
|
||||||
|
@ -81,26 +81,6 @@ public class QrcodeFragment extends Fragment {
|
||||||
private void launchQrcodeReader() {
|
private void launchQrcodeReader() {
|
||||||
setBackCamera(true);
|
setBackCamera(true);
|
||||||
|
|
||||||
androidVideoWindowImpl =
|
|
||||||
new AndroidVideoWindowImpl(
|
|
||||||
null,
|
|
||||||
mQrcodeView,
|
|
||||||
new AndroidVideoWindowImpl.VideoWindowListener() {
|
|
||||||
public void onVideoRenderingSurfaceReady(
|
|
||||||
AndroidVideoWindowImpl vw, SurfaceView surface) {}
|
|
||||||
|
|
||||||
public void onVideoRenderingSurfaceDestroyed(
|
|
||||||
AndroidVideoWindowImpl vw) {}
|
|
||||||
|
|
||||||
public void onVideoPreviewSurfaceReady(
|
|
||||||
AndroidVideoWindowImpl vw, SurfaceView surface) {
|
|
||||||
LinphoneManager.getLc()
|
|
||||||
.setNativePreviewWindowId(androidVideoWindowImpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void onVideoPreviewSurfaceDestroyed(AndroidVideoWindowImpl vw) {}
|
|
||||||
});
|
|
||||||
|
|
||||||
enableQrcodeReader(true);
|
enableQrcodeReader(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,21 +92,11 @@ public class QrcodeFragment extends Fragment {
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
launchQrcodeReader();
|
launchQrcodeReader();
|
||||||
if (androidVideoWindowImpl != null) {
|
|
||||||
synchronized (androidVideoWindowImpl) {
|
|
||||||
// LinphoneManager.getLc().setNativePreviewWindowId(androidVideoWindowImpl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
super.onResume();
|
super.onResume();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onPause() {
|
public void onPause() {
|
||||||
if (androidVideoWindowImpl != null) {
|
|
||||||
synchronized (androidVideoWindowImpl) {
|
|
||||||
// LinphoneManager.getLc().setNativePreviewWindowId(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
enableQrcodeReader(false);
|
enableQrcodeReader(false);
|
||||||
// setBackCamera(false);
|
// setBackCamera(false);
|
||||||
super.onPause();
|
super.onPause();
|
||||||
|
@ -134,10 +104,6 @@ public class QrcodeFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroy() {
|
public void onDestroy() {
|
||||||
if (androidVideoWindowImpl != null) {
|
|
||||||
androidVideoWindowImpl.release();
|
|
||||||
androidVideoWindowImpl = null;
|
|
||||||
}
|
|
||||||
super.onDestroy();
|
super.onDestroy();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,12 +1,11 @@
|
||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:id="@+id/qrcode_frame"
|
android:id="@+id/qrcode_frame"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:screenOrientation="portrait" >
|
android:screenOrientation="portrait" >
|
||||||
|
|
||||||
|
<TextureView
|
||||||
<SurfaceView
|
|
||||||
android:id="@+id/qrcodeCaptureSurface"
|
android:id="@+id/qrcodeCaptureSurface"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
|
|
Loading…
Reference in a new issue