add log.h
authorPeng Li <seudut@gmail.com>
Mon, 30 Apr 2018 13:58:32 +0000 (21:58 +0800)
committerPeng Li <seudut@gmail.com>
Mon, 30 Apr 2018 13:58:32 +0000 (21:58 +0800)
app/src/main/java/ai/suanzi/rtmpclient/Ffmpeg.java
app/src/main/jni/Android.mk
app/src/main/jni/ai_suanzi_rtmpclient_Ffmpeg.cpp
app/src/main/jni/ai_suanzi_rtmpclient_Ffmpeg.h
app/src/main/jni/log.h [new file with mode: 0644]

index f3ec401..da3aed6 100644 (file)
@@ -16,4 +16,9 @@ public class Ffmpeg {
     }
 
     public native String getVersion();
+    public native int init(int width, int height);
+    public native int flush();
+    public native int close();
+    public native int process(byte[] data);
+    public native int play(Object surface, String fname);
 }
index b66632b..48a5675 100644 (file)
@@ -68,5 +68,5 @@ include $(CLEAR_VARS)
 LOCAL_MODULE := ffmpeg-jni
 LOCAL_SRC_FILES := ai_suanzi_rtmpclient_Ffmpeg.cpp
 LOCAL_SHARED_LIBRARIES := avdevice avcodec avformat avfilter swresample swscale avutil postproc x264
-LOCAL_LDLIBS :=-llog
+LOCAL_LDLIBS :=-llog -landroid
 include $(BUILD_SHARED_LIBRARY)
\ No newline at end of file
index ceba05b..59292bd 100644 (file)
@@ -2,7 +2,9 @@
 // Created by Peng Li on 30/4/2018.
 //
 #include "ai_suanzi_rtmpclient_Ffmpeg.h"
-#include <android/log.h>
+#include <android/native_window.h>
+#include <android/native_window_jni.h>
+#include "log.h"
 
 extern "C" {
     #include "libavformat/avformat.h"
@@ -12,11 +14,29 @@ extern "C" {
     #include "libavutil/time.h"
 }
 
-#define TAG "PENG"
-#define LOGE(...)  __android_log_print(ANDROID_LOG_ERROR,TAG,__VA_ARGS__)
 
 JNIEXPORT jstring JNICALL Java_ai_suanzi_rtmpclient_Ffmpeg_getVersion (JNIEnv *env, jobject obj) {
     jint v = avformat_version();
     LOGE("######### Ffmpeg JNI version i= %d", v);
     return env->NewStringUTF("====== Ffmpeg call =======");
+}
+
+JNIEXPORT jint JNICALL Java_ai_suanzi_rtmpclient_Ffmpeg_init (JNIEnv *, jobject, jint, jint) {
+    return 0;
+}
+
+JNIEXPORT jint JNICALL Java_ai_suanzi_rtmpclient_Ffmpeg_flush (JNIEnv *, jobject){
+    return 0;
+}
+
+JNIEXPORT jint JNICALL Java_ai_suanzi_rtmpclient_Ffmpeg_close (JNIEnv *, jobject){
+    return 0;
+}
+
+JNIEXPORT jint JNICALL Java_ai_suanzi_rtmpclient_Ffmpeg_process (JNIEnv *, jobject, jbyteArray){
+    return 0;
+}
+
+JNIEXPORT jint JNICALL Java_ai_suanzi_rtmpclient_Ffmpeg_play (JNIEnv *, jobject, jobject, jstring){
+    return 0;
 }
\ No newline at end of file
index 1f70183..6615073 100644 (file)
@@ -15,6 +15,46 @@ extern "C" {
 JNIEXPORT jstring JNICALL Java_ai_suanzi_rtmpclient_Ffmpeg_getVersion
   (JNIEnv *, jobject);
 
+/*
+ * Class:     ai_suanzi_rtmpclient_Ffmpeg
+ * Method:    init
+ * Signature: (II)I
+ */
+JNIEXPORT jint JNICALL Java_ai_suanzi_rtmpclient_Ffmpeg_init
+  (JNIEnv *, jobject, jint, jint);
+
+/*
+ * Class:     ai_suanzi_rtmpclient_Ffmpeg
+ * Method:    flush
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_ai_suanzi_rtmpclient_Ffmpeg_flush
+  (JNIEnv *, jobject);
+
+/*
+ * Class:     ai_suanzi_rtmpclient_Ffmpeg
+ * Method:    close
+ * Signature: ()I
+ */
+JNIEXPORT jint JNICALL Java_ai_suanzi_rtmpclient_Ffmpeg_close
+  (JNIEnv *, jobject);
+
+/*
+ * Class:     ai_suanzi_rtmpclient_Ffmpeg
+ * Method:    process
+ * Signature: ([B)I
+ */
+JNIEXPORT jint JNICALL Java_ai_suanzi_rtmpclient_Ffmpeg_process
+  (JNIEnv *, jobject, jbyteArray);
+
+/*
+ * Class:     ai_suanzi_rtmpclient_Ffmpeg
+ * Method:    play
+ * Signature: (Ljava/lang/Object;Ljava/lang/String;)I
+ */
+JNIEXPORT jint JNICALL Java_ai_suanzi_rtmpclient_Ffmpeg_play
+  (JNIEnv *, jobject, jobject, jstring);
+
 #ifdef __cplusplus
 }
 #endif
diff --git a/app/src/main/jni/log.h b/app/src/main/jni/log.h
new file mode 100644 (file)
index 0000000..ba5a36e
--- /dev/null
@@ -0,0 +1,20 @@
+//
+// Created by Peng Li on 30/4/2018.
+//
+
+#ifndef RTMPCLIENT_LOG_H
+#define RTMPCLIENT_LOG_H
+
+#include <android/log.h>
+
+#define LOG_TAG __FILE__
+
+#define LOGE(...)  __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
+#define LOGD(...)  __android_log_print(ANDROID_LOG_DEBUT, LOG_TAG, __VA_ARGS__)
+#define LOGI(...)  __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__)
+#define LOGW(...)  __android_log_print(ANDROID_LOG_WARN, LOG_TAG, __VA_ARGS__)
+#define LOGF(...)  __android_log_print(ANDROID_LOG_FATAL, LOG_TAG, __VA_ARGS__)
+#define LOGV(...)  __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
+
+
+#endif //RTMPCLIENT_LOG_H