package {
    // See: http://go/android-license-faq
    // A large-scale-change added 'default_applicable_licenses' to import
    // all of the 'license_kinds' from "frameworks_av_license"
    // to get the below license kinds:
    //   SPDX-license-identifier-Apache-2.0
    default_applicable_licenses: ["frameworks_av_license"],
}

cc_library_headers {
    name: "libcodec2_internal",

    export_include_dirs: [
        "internal",
    ],

    // TODO: Remove this when this module is moved back to frameworks/av.
    vendor_available: true,

    min_sdk_version: "29",
    apex_available: [
        "//apex_available:platform",
        "com.android.media.swcodec",
    ],

}

cc_library_headers {
    name: "libcodec2_vndk_headers",
    vendor_available: true,
    min_sdk_version: "29",

    export_include_dirs: [
        "include",
    ],
    apex_available: [
        "//apex_available:platform",
        "com.android.media.swcodec",
    ],
}

// !!!DO NOT DEPEND ON THIS SHARED LIBRARY DIRECTLY!!!
// use libcodec2-impl-defaults instead
cc_library {
    name: "libcodec2_vndk",
    vendor_available: true,
    min_sdk_version: "29",
    // TODO: b/147147883
    double_loadable: true,
    apex_available: [
        "//apex_available:platform",
        "com.android.media.swcodec",
    ],

    defaults: [
        "aconfig_lib_cc_static_link.defaults",
        "libcodec2_hal_selection",
    ],

    srcs: [
        "C2AllocatorBlob.cpp",
        "C2AllocatorIon.cpp",
        "C2AllocatorGralloc.cpp",
        "C2Buffer.cpp",
        "C2Config.cpp",
        "C2DmaBufAllocator.cpp",
        "C2Fence.cpp",
        "C2PlatformStorePluginLoader.cpp",
        "C2Store.cpp",
        "platform/C2BqBuffer.cpp",
        "platform/C2BqPoolInvalidator.cpp",
        "platform/C2SurfaceSyncObj.cpp",
        "platform/C2IgbaBuffer.cpp",
        "types.cpp",
        "util/C2Debug.cpp",
        "util/C2InterfaceHelper.cpp",
        "util/C2InterfaceUtils.cpp",
        "util/C2ParamUtils.cpp",
    ],

    export_include_dirs: [
        "include",
    ],

    export_shared_lib_headers: [
        "libbase",
        "libdmabufheap",
        "android.hardware.media.bufferpool@2.0",
        "android.hardware.media.bufferpool2-V2-ndk",
    ],

    local_include_dirs: [
        "internal",
    ],

    header_libs: [
        "media_plugin_headers",
        "libcodec2_headers",
    ],

    shared_libs: [
        "android.hardware.graphics.bufferqueue@2.0",
        "android.hardware.graphics.common@1.2",
        "android.hardware.common-V2-ndk",
        "android.hardware.common.fmq-V1-ndk",
        "android.hardware.media.bufferpool@2.0",
        "android.hardware.media.bufferpool2-V2-ndk",
        "android.hardware.media.c2-V1-ndk",
        "libbase",
        "libbinder_ndk",
        "libcutils",
        "libdl",
        "libdmabufheap",
        "libfmq",
        "libgralloctypes",
        "libhidlbase",
        "libion",
        "liblog",
        "libnativewindow",
        "libstagefright_foundation",
        "libstagefright_bufferpool@2.0.1",
        "libstagefright_aidl_bufferpool2",
        "libui",
        "libutils",
    ],

    cflags: [
        "-Werror",
        "-Wall",
    ],
}

// public dependency for statically linking to libcodec2_vndk for unit tests
cc_defaults {
    name: "libcodec2-static-defaults",

    defaults: [
        "libcodec2_hal_selection",
    ],

    static_libs: [
        "liblog",
        "libion",
        "libfmq",
        "libbase",
        "libutils",
        "libcutils",
        "libcodec2",
        "libhidlbase",
        "libdmabufheap",
        "libcodec2_vndk",
        "libnativewindow",
        "libcodec2_soft_common",
        "libsfplugin_ccodec_utils",
        "libstagefright_aidl_bufferpool2",
        "libstagefright_foundation",
        "libstagefright_bufferpool@2.0.1",
        "libgralloctypes",
        "android.hardware.graphics.mapper@2.0",
        "android.hardware.graphics.mapper@3.0",
        "android.hardware.media.bufferpool@2.0",
        "android.hardware.graphics.allocator@2.0",
        "android.hardware.graphics.allocator@3.0",
        "android.hardware.graphics.bufferqueue@2.0",
        "android.hardware.common-V2-ndk",
        "android.hardware.common.fmq-V1-ndk",
        "android.hardware.media.bufferpool2-V2-ndk",
        "android.hardware.media.c2-V1-ndk",
    ],

    shared_libs: [
        "libbinder",
        "libbinder_ndk",
        "libui",
        "libdl",
        "libvndksupport",
        "libprocessgroup",
    ],
}

// public dependency for implementing Codec 2 components
cc_defaults {
    name: "libcodec2-impl-defaults",
    cpp_std: "gnu++17",

    defaults: [
        "libcodec2_hal_selection",
    ],

    shared_libs: [
        "libbase", // for C2_LOG
        "liblog", // for ALOG
        "libcodec2",
        "libcodec2_hal_common",
        "libcodec2_vndk",
        "libutils",
    ],

    min_sdk_version: "29",
}

// public dependency for implementing Codec 2 framework utilities
// THIS IS ONLY FOR FRAMEWORK USE ONLY
cc_defaults {
    name: "libcodec2-internal-defaults",
    defaults: ["libcodec2-impl-defaults"],

    header_libs: [
        "libcodec2_internal",
    ],

    shared_libs: [
        "libcutils", // for properties
    ],

    // TODO: separate internal headers so they can be exposed here
}
