houxiao
2017-04-28 1b4d2718a4864190a47d8b7863f36a9ae0b8055c
VisitFace/RtspNativeCodec/app/src/main/cpp/native-codec-jni.cpp
@@ -51,7 +51,7 @@
#define LOGV(...) __android_log_print(ANDROID_LOG_VERBOSE, LOG_TAG, __VA_ARGS__)
#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__)
// for native window JNI
// for native windowRender JNI
#include <android/native_window_jni.h>
#include <android/asset_manager.h>
#include <android/asset_manager_jni.h>
@@ -307,7 +307,6 @@
    live_daemon_running = false;
}
extern "C" {
jboolean Java_com_example_nativecodec_NativeCodec_createStreamingMediaPlayer_rtsp(JNIEnv* env,
@@ -442,24 +441,54 @@
}
// set the playing state for the streaming media player
void Java_com_example_nativecodec_NativeCodec_setPlayingStreamingMediaPlayer(JNIEnv* env,
        jclass clazz, jboolean isPlaying)
//void Java_com_example_nativecodec_NativeCodec_setPlayingStreamingMediaPlayer(JNIEnv* env,
//        jclass clazz, jboolean isPlaying)
//{
//    LOGV("@@@ playpause: %d", isPlaying);
//    if (mlooper) {
//        if (isPlaying) {
//            mlooper->post(kMsgResume, &data);
//        } else {
//            mlooper->post(kMsgPause, &data);
//        }
//    }
//}
// rewind the streaming media player
//void Java_RtspNativeCodec_rewindStreamingMediaPlayer(JNIEnv *env, jclass clazz)
//{
//    LOGV("@@@ rewind");
//    if (mlooper) {
//        mlooper->post(kMsgSeek, &data);
//    }
//}
// set the surface
void Java_RtspNativeCodec_setSurface(JNIEnv *env, jclass clazz, jint cameraIdx, jobject surface)
{
    LOGV("@@@ playpause: %d", isPlaying);
    if (mlooper) {
        if (isPlaying) {
            mlooper->post(kMsgResume, &data);
        } else {
            mlooper->post(kMsgPause, &data);
        }
    LOGV("@@@ Java_RtspNativeCodec_setSurface");
    // obtain a native windowRender from a Java surface
    if (data.window) {
        ANativeWindow_release(data.window);
        data.window = NULL;
    }
    data.window = ANativeWindow_fromSurface(env, surface);
    LOGV("@@@ setsurface %p", data.window);
}
jboolean Java_RtspNativeCodec_createPlayer(JNIEnv* env, jclass clazz, jobject assetMgr, jint cameraIdx, jstring uri)
{
    LOGV("@@@ Java_RtspNativeCodec_createPlayer");
    return JNI_TRUE;
}
// shut down the native media system
void Java_com_example_nativecodec_NativeCodec_shutdown(JNIEnv* env, jclass clazz)
void Java_RtspNativeCodec_shutdown(JNIEnv* env, jclass clazz, jint cameraIdx)
{
    LOGV("@@@ shutdown");
    LOGV("@@@ Java_RtspNativeCodec_shutdown");
    if (mlooper) {
        mlooper->post(kMsgDecodeDone, &data, true /* flush */);
        mlooper->quit();
@@ -472,27 +501,14 @@
    }
}
// set the surface
void Java_com_example_nativecodec_NativeCodec_setSurface(JNIEnv *env, jclass clazz, jobject surface)
jboolean Java_RtspNativeCodec_setFaceCallback(JNIEnv* env, jclass clazz, jobject assetMgr, jint cameraIdx, jstring func)
{
    // obtain a native window from a Java surface
    if (data.window) {
        ANativeWindow_release(data.window);
        data.window = NULL;
    }
    data.window = ANativeWindow_fromSurface(env, surface);
    LOGV("@@@ setsurface %p", data.window);
    return JNI_TRUE;
}
// rewind the streaming media player
void Java_com_example_nativecodec_NativeCodec_rewindStreamingMediaPlayer(JNIEnv *env, jclass clazz)
jboolean Java_RtspNativeCodec_getFaceList(JNIEnv* env, jclass clazz, jobject assetMgr, jint cameraIdx, jobjectRefType faceList)
{
    LOGV("@@@ rewind");
    if (mlooper) {
        mlooper->post(kMsgSeek, &data);
    }
    return JNI_TRUE;
}
}