capture video in background
authorPeng Li <seudut@gmail.com>
Wed, 2 May 2018 02:44:11 +0000 (10:44 +0800)
committerPeng Li <seudut@gmail.com>
Wed, 2 May 2018 02:44:11 +0000 (10:44 +0800)
app/src/main/java/ai/suanzi/rtmpclient/MainActivity.java
app/src/main/jni/ai_suanzi_rtmpclient_Ffmpeg.cpp

index 6b29b83..c309797 100644 (file)
@@ -1,6 +1,7 @@
 package ai.suanzi.rtmpclient;
 
 import android.graphics.ImageFormat;
+import android.graphics.SurfaceTexture;
 import android.support.v7.app.AppCompatActivity;
 import android.os.Bundle;
 import android.util.Log;
@@ -73,8 +74,18 @@ public class MainActivity extends AppCompatActivity implements SurfaceHolder.Cal
 
         //
         mCamera.setPreviewCallback(this);
+
+        /*try{
+            mCamera.setPreviewTexture(st);
+        }catch (IOException e){
+            e.printStackTrace();
+        }*/
+
     }
 
+    SurfaceTexture st = new SurfaceTexture(0);
+
+
     @Override
     protected void onPause(){
         super.onPause();
@@ -89,6 +100,30 @@ public class MainActivity extends AppCompatActivity implements SurfaceHolder.Cal
         Log.e(TAG, "OnResume");
     }
 
+    @Override
+    protected void onStop() {
+        super.onStop();
+        Log.e(TAG,"onStop");
+    }
+
+    @Override
+    protected void onStart(){
+        super.onStart();
+        Log.e(TAG,"onStart");
+    }
+
+    @Override
+    protected void onDestroy(){
+        super.onDestroy();
+        Log.e(TAG,"onDestroy");
+    }
+
+    @Override
+    protected void onRestart(){
+        super.onStart();
+        Log.e(TAG,"onRestart");
+    }
+
     // class StreamTask AsyncTask
     private class StreamTask extends AsyncTask<Void, Void, Void>{
         private byte[] data;
index 485afea..a901482 100644 (file)
@@ -39,7 +39,7 @@ JNIEXPORT jint JNICALL Java_ai_suanzi_rtmpclient_Ffmpeg_init (JNIEnv *env, jobje
 
        //const char* out_path = "/storage/emulated/0/Movies/output.flv";
 
-    const char* out_path = "rtmp://192.168.0.101:1935/myapp/suanzi";
+    const char* out_path = "rtmp://192.168.1.35:1935/myapp/suanzi";
 
 
     LOGE("Ffmpeg init, width=%d, heigh=%d", width, height);