xuxiuxi
2017-07-21 ec544e9cc330ce40aeb78e96aa362e245feecd4d
VisitFace/DemoForBsk/app/src/main/java/cn/com/basic/face/fragment/SurveillanceFragment.java
@@ -11,6 +11,7 @@
import android.view.SurfaceHolder;
import android.view.SurfaceView;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RadioButton;
import android.widget.RadioGroup;
@@ -69,6 +70,9 @@
    private RelativeLayout fragment_supervisory_exit_camera_relative_layout;
    @ViewInject(R.id.fragment_supervisory_enter_camera_relative_layout)
    private RelativeLayout fragment_supervisory_enter_camera_relative_layout;
    @ViewInject(R.id.fragment_surveillance_bottom_linear_layout)
    private LinearLayout fragment_surveillance_bottom_linear_layout;
    static boolean useNative = false;
@@ -93,6 +97,9 @@
            useNative = false;
        }
        //useNative = false;
        if (CommonVariables.EMULATOR) {
            useNative = false;
        }
        if (useNative) {
            System.loadLibrary("cvface_api");
            System.loadLibrary("opencv_java3");
@@ -142,6 +149,7 @@
            }
//            outputStream.writeBytes("busybox ifconfig wlan0 hw ether  00:e0:2c:31:1a:ba\n");
            RtspFaceNative.setLocalIP(ipAddress);
            System.out.println("ipaddr="+ipAddress);
        }
    }
@@ -169,15 +177,16 @@
        if (CommonVariables.FACE_SERVER) {
            fragment_supervisory_enter_camera_relative_layout.addView(MainActivity.getInstance().mPreview);
            fragment_supervisory_enter_camera_relative_layout.addView(MainActivity.getInstance().mDraw);
            //fragment_supervisory_exit_camera_relative_layout.setVisibility(View.GONE);
            //fragment_surveillance_bottom_linear_layout.setVisibility(View.GONE);
        }
        fragment_supervisory_enter_camera.getHolder().addCallback(new SurfaceHolder.Callback() {
            public void surfaceCreated(SurfaceHolder holder) {
                if (useNative) {
                    RtspFaceNative.setSurface(Integer.parseInt(CommonVariables.Camera.IN), fragment_supervisory_enter_camera.getHolder().getSurface());
                    RtspFaceNative.createPlayer(Integer.parseInt(CommonVariables.Camera.IN), DeviceMng.getInstance().getCamera1Address());
                    RtspFaceNative.setFaceCallback(Integer.parseInt(CommonVariables.Camera.IN), "cn/com/basic/face/util/RtspFaceNative", "faceCallBack");
                }
//                if (useNative) {
//                    RtspFaceNative.setSurface(Integer.parseInt(CommonVariables.Camera.IN), fragment_supervisory_enter_camera.getHolder().getSurface());
//                    RtspFaceNative.createPlayer(Integer.parseInt(CommonVariables.Camera.IN), DeviceMng.getInstance().getCamera1Address());
//                    RtspFaceNative.setFaceCallback(Integer.parseInt(CommonVariables.Camera.IN), "cn/com/basic/face/util/RtspFaceNative", "faceCallBack");
//                }
            }
            public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {}
@@ -187,14 +196,21 @@
        });
        fragment_supervisory_exit_camera.getHolder().addCallback(new SurfaceHolder.Callback() {
            public void surfaceCreated(SurfaceHolder holder) {
                if (useNative) {
                    RtspFaceNative.setSurface(Integer.parseInt(CommonVariables.Camera.OUT), fragment_supervisory_exit_camera.getHolder().getSurface());
                    RtspFaceNative.createPlayer(Integer.parseInt(CommonVariables.Camera.OUT), DeviceMng.getInstance().getCamera2Address());
                    RtspFaceNative.setFaceCallback(Integer.parseInt(CommonVariables.Camera.OUT), "cn/com/basic/face/util/RtspFaceNative", "faceCallBack");
                }
//                if (useNative) {
//                    RtspFaceNative.setSurface(Integer.parseInt(CommonVariables.Camera.OUT), fragment_supervisory_exit_camera.getHolder().getSurface());
//                    RtspFaceNative.createPlayer(Integer.parseInt(CommonVariables.Camera.OUT), DeviceMng.getInstance().getCamera2Address());
//                    RtspFaceNative.setFaceCallback(Integer.parseInt(CommonVariables.Camera.OUT), "cn/com/basic/face/util/RtspFaceNative", "faceCallBack");
//                }
            }
            public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {}
            public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
                System.out.print("width="+width+",height="+height);
                if (useNative) {
                    RtspFaceNative.setSurface(Integer.parseInt(CommonVariables.Camera.IN), fragment_supervisory_enter_camera.getHolder().getSurface());
                    RtspFaceNative.createPlayer(Integer.parseInt(CommonVariables.Camera.IN), DeviceMng.getInstance().getCamera1Address());
                    RtspFaceNative.setFaceCallback(Integer.parseInt(CommonVariables.Camera.IN), "cn/com/basic/face/util/RtspFaceNative", "faceCallBack");
                }
            }
            public void surfaceDestroyed(SurfaceHolder holder) {
                System.out.println("surfaceDestroyed");
            }