cmake_minimum_required(VERSION 3.18)
project(ffmpeg_decrypt)

# FFmpeg headers (from our cross-compiled build)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg_headers)

# 共享 iOS 的解密核心源文件（ilook-ios-player 是唯一源头，通过 sync.sh 同步到
# ios/ILookPlayerCore/，Android 直接引用同一份 .c/.h，消除双端副本）。
set(IOS_DECRYPT_CORE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../../../../ios/ILookPlayerCore/Sources/Engine)
include_directories(${IOS_DECRYPT_CORE_DIR})

# Pre-built FFmpeg shared libraries
set(FFMPEG_LIB_DIR ${CMAKE_CURRENT_SOURCE_DIR}/../jniLibs/${ANDROID_ABI})

add_library(avutil SHARED IMPORTED)
set_target_properties(avutil PROPERTIES IMPORTED_LOCATION ${FFMPEG_LIB_DIR}/libavutil.so)

add_library(avcodec SHARED IMPORTED)
set_target_properties(avcodec PROPERTIES IMPORTED_LOCATION ${FFMPEG_LIB_DIR}/libavcodec.so)

add_library(avformat SHARED IMPORTED)
set_target_properties(avformat PROPERTIES IMPORTED_LOCATION ${FFMPEG_LIB_DIR}/libavformat.so)

add_library(swscale SHARED IMPORTED)
set_target_properties(swscale PROPERTIES IMPORTED_LOCATION ${FFMPEG_LIB_DIR}/libswscale.so)

# Our JNI library
add_library(ffmpeg_decrypt SHARED
    ${IOS_DECRYPT_CORE_DIR}/ffmpeg_decrypt_core.c
    ffmpeg_decrypt_jni.c
)

target_link_libraries(ffmpeg_decrypt
    avformat avcodec swscale avutil
    android
    log
    jnigraphics
)
