Recently, I am studying and researching ijkplayer. Its source code is compiled with Android.mk. In order to facilitate development and debugging, the compilation method is now replaced with CMake. You can directly view, jump, and debug ijkplayer source code in Android Studio . See my github for details: A4ijkplayer
As long as the source code of ffmpeg is not modified, other codes including ijkplayer’s C code and Java code can be modified, run and debugged in Android Studio.
This article is based on the latest k0.8.8 version of ijkplayer, compiled with ffmpeg 4.0 (based on ff4.0–ijk0.8.8–20210426–001 version), and includes openssl (that is, supports https network video), yuv, sdl, soundtouch and other modules, the entire project has been uploaded to my github warehouse A4ijkplayer
Among them, ffmpeg (libijkffmpeg.so) needs to be compiled first. You can refer to my previous article for compilation (Android ijkplayer compilation steps and records), or directly use my compiled one.
Compile the CMakeList.txt of ijkplayer as follows:
cmake_minimum_required(VERSION 3.4.1) set(PATH_TO_A4_PRJ_CPP ${CMAKE_CURRENT_SOURCE_DIR}) set(PATH_TO_A4_IJK_MEDIA ${PATH_TO_A4_PRJ_CPP}/ijkmedia) set(PATH_TO_A4_IJK_PROF ${PATH_TO_A4_PRJ_CPP}/ijkprof) set(PATH_TO_OTHER_LIBS ${PATH_TO_A4_PRJ_CPP}/otherlibs) message (${ANDROID_ABI}) message(${PATH_TO_A4_PRJ_CPP}) message (${PATH_TO_A4_IJK_MEDIA}) # Need to add NDEBUG macro definition, otherwise the internal assert will be wrong at runtime add_definitions(-DNDEBUG) # <------- Files in the ijkmedia/ijkj4a directory file(GLOB_RECURSE SOURCE_C_FILES_OF_IJKJ4A "${PATH_TO_A4_IJK_MEDIA}/ijkj4a/*.c") # <------- Files under the ijkmedia/ijksdl directory file(GLOB_RECURSE SOURCE_C_FILES_OF_IJKSDL "${PATH_TO_A4_IJK_MEDIA}/ijksdl/*.c") # <------- Files in the ijkmedia/ijksoundtouch directory file(GLOB_RECURSE SOURCE_CPP_FILES_OF_IJKSOUNDTOUCH "${PATH_TO_A4_IJK_MEDIA}/ijksoundtouch/*.cpp") # <------- Files under the ijkmedia/ijkplayer directory file(GLOB_RECURSE SOURCE_C_FILES_OF_IJKPLAYER "${PATH_TO_A4_IJK_MEDIA}/ijkplayer/*.c") file(GLOB_RECURSE SOURCE_CPP_FILES_OF_IJKPLAYER "${PATH_TO_A4_IJK_MEDIA}/ijkplayer/*.cpp") # <------- Files under the ijkmedia/ijkyuv directory #file(GLOB_RECURSE SOURCE_CC_FILES_OF_IJKYUV "${PATH_TO_A4_IJK_MEDIA}/ijkyuv/*.cc") set(SOURCE_COMMON_CC_FILES_OF_IJKYUV #ijkmedia/ijkyuv ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/compare.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/compare_common.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/compare_posix.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/convert.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/convert_argb.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/convert_from.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/convert_from_argb.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/convert_to_argb.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/convert_to_i420.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/cpu_id.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/format_conversion.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/planar_functions.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/rotate.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/rotate_argb.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/rotate_mips.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/row_any.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/row_common.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/row_mips.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/row_posix.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/scale.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/scale_argb.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/scale_common.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/scale_mips.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/scale_posix.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/video_common.cc ) # The code related to the abi architecture under the ijkyuv directory if(${ANDROID_ABI} STREQUAL "armeabi-v7a") set(SOURCE_ABI_CC_FILES_OF_IJKYUV ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/compare_neon.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/rotate_neon.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/row_neon.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/scale_neon.cc ) elseif(${ANDROID_ABI} STREQUAL "arm64-v8a") set(SOURCE_ABI_CC_FILES_OF_IJKYUV ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/compare_neon64.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/rotate_neon64.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/row_neon64.cc ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/source/scale_neon64.cc ) endif() # <------- Files in the cpp/ijkprof directory file(GLOB_RECURSE SOURCE_C_FILES_OF_IJKPROF "${PATH_TO_A4_IJK_PROF}/*.c") include_directories( ${PATH_TO_OTHER_LIBS}/ffmpeg/include ${PATH_TO_OTHER_LIBS}/ffmpeg/include/${ANDROID_ABI} ${PATH_TO_A4_IJK_MEDIA} ${PATH_TO_A4_IJK_PROF} ${PATH_TO_A4_IJK_MEDIA}/ijkj4a ${PATH_TO_A4_IJK_MEDIA}/ijksdl ${PATH_TO_A4_IJK_MEDIA}/ijksoundtouch ${PATH_TO_A4_IJK_MEDIA}/ijksoundtouch/include ${PATH_TO_A4_IJK_MEDIA}/ijkyuv ${PATH_TO_A4_IJK_MEDIA}/ijkyuv/include ${PATH_TO_A4_IJK_MEDIA}/ijkplayer ) add_library( a4ijkplayer SHARED ${SOURCE_C_FILES_OF_IJKJ4A} ${SOURCE_C_FILES_OF_IJKSDL} ${SOURCE_CPP_FILES_OF_IJKSOUNDTOUCH} ${SOURCE_COMMON_CC_FILES_OF_IJKYUV} ${SOURCE_ABI_CC_FILES_OF_IJKYUV} ${SOURCE_C_FILES_OF_IJKPLAYER} ${SOURCE_CPP_FILES_OF_IJKPLAYER} ${SOURCE_C_FILES_OF_IJKPROF} ) target_link_libraries( # Specifies the target library. a4ijkplayer ${PATH_TO_OTHER_LIBS}/ffmpeg/libs/${ANDROID_ABI}/libijkffmpeg.so log android EGL GLESv2 jnigraphics OpenSLES m z )
Points to note:
1. It is necessary to add the NDEBUG macro definition in CMakeList, otherwise the internal assert will be wrong at runtime
add_definitions(-DNDEBUG)
2. Connect to SDL, or directly see this related submission of my github A4ijkplayer project
1) Modify ijksdl/android/ijksdl_android_jni.h, add the following SDL_JNI_OnLoad function declaration:
JNIEXPORT jint JNICALL SDL_JNI_OnLoad(JavaVM *vm, void *reserved);
2) Modify ijksdl/android/ijksdl_android_jni.c, delete the JNI_OnUnload function, and change the JNI_OnLoad function name to SDL_JNI_OnLoad
JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM *vm, void *reserved) Change to ====>> JNIEXPORT jint JNICALL SDL_JNI_OnLoad(JavaVM *vm, void *reserved)
3) Modify ijkplayer/android/ijkplayer_jni.c, and add the call of SDL_JNI_OnLoad in its JNI_OnLoad function:
SDL_JNI_OnLoad(vm,reserved);
github project source code: A4ijkplayer
Screenshot of running effect:
ijkplayer native code debugging screenshot: