plugins {
    id 'com.android.library'
}

def WEBRTC_INC_PATH = "${projectDir}/deps/webrtc/src"
def WEBRTC_LIB_PATH = "${projectDir}/deps/webrtc/lib"

android {
    namespace 'com.acgist.mediasoup'
    compileSdk 32
    defaultConfig {
        minSdk 31
        targetSdk 32
        versionCode 100
        versionName "1.0.0"
        consumerProguardFiles "consumer-rules.pro"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        externalNativeBuild {
            cmake {
                cFlags '-std=c17'
                cppFlags '-std=c++17'
                // CPU架构：x86_64、x86、arm64-v8a、armeabi-v7a
                abiFilters 'arm64-v8a'
                arguments "-DLIBWEBRTC_INCLUDE_PATH=" + WEBRTC_INC_PATH,
                          "-DLIBWEBRTC_BINARY_PATH="  + WEBRTC_LIB_PATH,
                          "-DMEDIASOUPCLIENT_BUILD_TESTS=OFF",
                          "-DMEDIASOUPCLIENT_LOG_TRACE=OFF",
                          "-DMEDIASOUPCLIENT_LOG_DEV=OFF"
            }
        }
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_17
        targetCompatibility JavaVersion.VERSION_17
    }
    externalNativeBuild {
        cmake {
            path file('CMakeLists.txt')
            version '3.22.1'
        }
    }
}

dependencies {
    api fileTree(dir: WEBRTC_LIB_PATH, include: ['libwebrtc.jar'])
    implementation fileTree(dir: 'libs', include: ['*.a', '*.so', '*.jar'])
    implementation 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
