houxiao
2017-04-11 3839ef806215a981ef9b2e83dafaab5e1d694764
VisitFace/RtspNativeCodec/app/src/main/java/com/example/nativecodec/NativeCodec.java
@@ -33,6 +33,8 @@
import android.widget.RadioButton;
import android.widget.Spinner;
import com.bsk.zhangbo.demoforbsk.util.RtspFaceNative;
import java.io.IOException;
public class NativeCodec extends Activity {
@@ -52,13 +54,15 @@
    boolean mCreated = false;
    boolean mIsPlaying = false;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        setContentView(R.layout.main);
        init();
        RtspFaceNative.init();
        mGLView1 = (MyGLSurfaceView) findViewById(R.id.glsurfaceview1);
@@ -185,13 +189,20 @@
                    }
                    if (mSourceString != null) {
                        setSurface(1, mSurfaceHolder1.getSurface());
                        RtspFaceNative.setSurface(1, mSurfaceHolder1.getSurface());
                        mGLView1VideoSink.useAsSinkForNative();
                        //mCreated = createStreamingMediaPlayer(getResources().getAssets(), mSourceString);
                        mCreated = createPlayer(1, "rtsp://admin:admin12345@192.168.1.70:554/h264/ch1/main/av_stream");
                        mCreated = createPlayer(2, "rtsp://admin:admin12345@192.168.1.70:554/h264/ch1/main/av_stream");
                        //#todo ok
                        mCreated = RtspFaceNative.createPlayer(1, "rtsp://admin:admin12345@192.168.1.70:554/h264/ch1/main/av_stream");
                        //mCreated = RtspFaceNative.createPlayer(2, "rtsp://admin:admin12345@192.168.1.70:554/h264/ch1/main/av_stream");
                        //mCreated = createPlayer(1, "rtsp://192.168.1.56:8554");
                        RtspFaceNative.setFaceCallback(1, "com/bsk/zhangbo/demoforbsk/util/RtspFaceNative", "faceCallBack");
                        //byte[] arr = new byte[5];
                        //arr[0] = 3; arr[1] = 4; arr[2] = 5;
                        //RtspFaceNative.getFaceList(1, arr);
                    }
                }
@@ -266,8 +277,8 @@
    @Override
    protected void onDestroy()
    {
        shutdown(1);
        shutdown(2);
        RtspFaceNative.shutdown(1);
        RtspFaceNative.shutdown(2);
        mCreated = false;
        super.onDestroy();
    }
@@ -286,16 +297,21 @@
    //public static native void setSurface(Surface surface);
    //public static native void rewindStreamingMediaPlayer();
    public static native void init();
    public static native void setSurface(int cameraIdx, Surface surface);
    public static native boolean createPlayer(int cameraIdx, String uri);
    public static native void shutdown(int cameraIdx);
    //public static native void init();
    //public static native void setSurface(int cameraIdx, Surface surface);
    //public static native boolean createPlayer(int cameraIdx, String uri);
    //public static native void shutdown(int cameraIdx);
    //// typedef void (* Java_com_example_nativecodec_NativeCodec_FaceCallback_func)(int cameraIdx, int count);
    //public static native boolean setFaceCallback(int cameraIdx, String func);
    //public static native void lockFace(int cameraIdx);
    //public static native void releaseFace(int cameraIdx);
    //public static native boolean getFaceList(int cameraIdx, byte[] faceListPb);
    //public static native boolean getFaceImages(int cameraIdx, byte[] faceImagesIdx, byte[] faceImages);
    /** Load jni .so on initialization */
    static {
        System.loadLibrary("rtspface");
        System.loadLibrary("opencv_java3");
    }
    // VideoSink abstracts out the difference between Surface and SurfaceTexture
@@ -324,7 +340,7 @@
        void useAsSinkForNative() {
            Surface s = mSurfaceHolder.getSurface();
            Log.i("@@@", "setting surface " + s);
            setSurface(1, s);
            RtspFaceNative.setSurface(1, s);
        }
    }
@@ -345,7 +361,7 @@
        void useAsSinkForNative() {
            SurfaceTexture st = mMyGLSurfaceView.getSurfaceTexture();
            Surface s = new Surface(st);
            setSurface(2, s);
            RtspFaceNative.setSurface(2, s);
            s.release();
        }