共三处修改!!!!!!!
1.
surface.c对应的Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
# our source files
#
LOCAL_SRC_FILES:= \
surface.cpp
LOCAL_SHARED_LIBRARIES := \
libskia \
libsurfaceflinger\
libgui\
libutils \
liblog
LOCAL_C_INCLUDES += \
$(JNI_H_INCLUDE) \
external/skia/src/core \
external/skia/include/core \
frameworks/base/include \
frameworks/base/native/include
# Optional tag would mean it doesn't get installed by default
LOCAL_MODULE_TAGS := optional
LOCAL_PRELINK_MODULE := false
LOCAL_ARM_MODE := arm
LOCAL_MODULE:= libjnivideo
include $(BUILD_SHARED_LIBRARY)
+++++
2.
int AndroidSurface_updateSurface(bool autoscale) {
if(surface == NULL) {
return ANDROID_SURFACE_RESULT_JNI_EXCEPTION;
}
if (!surface->isValid()) { //Surface::isValid()
return ANDROID_SURFACE_RESULT_NOT_VALID;
}
+++++
3.
static
Surface* getNativeSurface(JNIEnv* env, jobject jsurface) {
jclass clazz = env->FindClass("android/view/Surface");
jfieldID field_surface = env->GetFieldID(clazz, ANDROID_VIEW_SURFACE_JNI_ID, "I");//"mSurface"
if(field_surface == NULL) {
return NULL;
}
return (Surface *) env->GetIntField(jsurface, field_surface);
}
因为 android2.2以上的版本,android.view.Surface里面没有“mSurface"了,而是用了一个常量 ANDROID_VIEW_SURFACE_JNI_ID, 区分下版本就行了。
++++++++整体参考框架++++
you must copy libjnivideo.so and libjniaudio.so into lib/armeabi of your project for eclipse, which pack them into apk. If you run this project on not froyo OS you will have errors because some libraries don't be there or have other name and dalvik can't find them
I tried several times and passed finally. Here is my configuration changed for elair: from the eclair source, copy your native directory to frameworks/base/, modify the file of native/video/jni/Android.mk to add libui to LOCAL_SHARED_LIBRARIES list and replace libsurfaceflinger_client with libsurfaceflinger, modify surface.cpp to replace #include with #include , add libjniaudio.so and libjnivideo.so to the end of myandroid/build/core/prelink-linux-arm.map, then I get the libjniaudio.so and libjnivideo.so in out/target/product/generic/obj/lib for eclair. I try them in my emulator, the result is exactly beyond my imagination. It will be better if your project can fit any android version. Anyway, Thank you for your porting. If possible, I will send the three .s