cmake_minimum_required(VERSION 3.22.1)

project(rtsp_player LANGUAGES C CXX)

set(FFMPEG_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/ffmpeg/include)
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(swscale SHARED IMPORTED)
set_target_properties(swscale PROPERTIES IMPORTED_LOCATION ${FFMPEG_LIB_DIR}/libswscale.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(rtsp_player SHARED rtsp_player_jni.cpp)

target_include_directories(rtsp_player PRIVATE ${FFMPEG_INCLUDE_DIR})

target_compile_features(rtsp_player PRIVATE cxx_std_17)

find_library(android-lib android)
find_library(log-lib log)

target_link_libraries(
    rtsp_player
    avformat
    avcodec
    avutil
    swscale
    ${android-lib}
    ${log-lib}
)
