package {
    default_applicable_licenses: ["frameworks_av_media_libstagefright_license"],
}

// Added automatically by a large-scale-change
// See: http://go/android-license-faq
license {
    name: "frameworks_av_media_libstagefright_license",
    visibility: [":__subpackages__"],
    license_kinds: [
        "SPDX-license-identifier-Apache-2.0",
    ],
    license_text: [
        "NOTICE",
    ],
}

cc_library_headers {
    name: "libstagefright_headers",
    export_include_dirs: ["include"],
    vendor_available: true,
    apex_available: [
        "//apex_available:platform",
        "com.android.media",
        "com.android.media.swcodec",
    ],
    min_sdk_version: "29",
    host_supported: true,
    target: {
        darwin: {
            enabled: false,
        },
    },
}

cc_library_shared {
    name: "libstagefright_codecbase",

    export_include_dirs: ["include"],

    srcs: [
        "CodecBase.cpp",
        "DataConverter.cpp",
        "FrameRenderTracker.cpp",
        "MediaCodecListWriter.cpp",
        "SkipCutBuffer.cpp",
    ],

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

    header_libs: [
        "libmediadrm_headers",
        "media_ndk_headers",
    ],

    shared_libs: [
        "android.hardware.cas.native@1.0",
        "android.hardware.drm@1.0",
        "libaudioutils",
        "libgui",
        "libhidlallocatorutils",
        "liblog",
        "libmedia_codeclist",
        "libmedia_omx",
        "libstagefright_foundation",
        "libui",
        "libutils",
    ],

    sanitize: {
        cfi: true,
        misc_undefined: [
            "signed-integer-overflow",
            "unsigned-integer-overflow",
        ],
    },
}

cc_library_static {
    name: "libstagefright_mpeg2extractor",
    apex_available: [
        "//apex_available:platform",
        "com.android.media",
    ],
    min_sdk_version: "29",

    srcs: [
        "HevcUtils.cpp",
        "MediaSource.cpp",
        "Utils.cpp",
    ],

    shared_libs: [
        "liblog",
    ],

    static_libs: [
        "libstagefright_esds",
        "android.media.extractor.flags-aconfig-cc",
    ],

    export_include_dirs: [
        "include",
    ],

    header_libs: [
        "libaudioclient_headers",
        "libbase_headers",
        "libmedia_datasource_headers",
        "media_ndk_headers",
        "media_plugin_headers",
    ],

    cflags: [
        "-Wall",
        "-Werror",
        "-Wno-error=deprecated-declarations",
        "-Wno-multichar",
    ],

    sanitize: {
        cfi: true,
        misc_undefined: [
            "signed-integer-overflow",
            "unsigned-integer-overflow",
        ],
    },

    host_supported: true,
    target: {
        darwin: {
            enabled: false,
        },
        linux: {
            cflags: [
                "-DDISABLE_AUDIO_SYSTEM_OFFLOAD",
            ],
        },
    },
}

cc_library_shared {
    name: "libstagefright_framecapture_utils",

    srcs: [
        "FrameCaptureLayer.cpp",
        "FrameCaptureProcessor.cpp",
    ],

    shared_libs: [
        "libEGL",
        "libGLESv1_CM",
        "libGLESv2",
        "libbase",
        "libcutils",
        "libgui",
        "liblog",
        "libprocessgroup",
        "libstagefright_foundation",
        "libsync",
        "libui",
        "libutils",
        "libvulkan",
    ],

    static_libs: [
        "librenderfright",
    ],

    export_include_dirs: [
        "include",
    ],

    cflags: [
        "-Wall",
        "-Werror",
        "-Wno-error=deprecated-declarations",
        "-Wno-multichar",
    ],

    sanitize: {
        // TODO: re-enabled cfi for this lib after b/139945549 fixed
        cfi: false,
        misc_undefined: [
            "signed-integer-overflow",
            "unsigned-integer-overflow",
        ],
    },
}

cc_library_shared {
    name: "libstagefright_surface_utils",

    srcs: [
        "SurfaceUtils.cpp",
    ],

    shared_libs: [
        "libgui",
        "liblog",
        "libui",
        "libutils",
    ],

    export_include_dirs: [
        "include",
    ],

    cflags: [
        "-Wall",
        "-Werror",
        "-Wno-multichar",
    ],

    sanitize: {
        cfi: true,
        misc_undefined: [
            "signed-integer-overflow",
            "unsigned-integer-overflow",
        ],
    },
}

cc_library {
    name: "libstagefright",

    srcs: [
        "AACWriter.cpp",
        "ACodec.cpp",
        "ACodecBufferChannel.cpp",
        "AHierarchicalStateMachine.cpp",
        "AMRWriter.cpp",
        "AudioSource.cpp",
        "BufferImpl.cpp",
        "CallbackDataSource.cpp",
        "CallbackMediaSource.cpp",
        "CameraSource.cpp",
        "CameraSourceTimeLapse.cpp",
        "CodecErrorLog.cpp",
        "CryptoAsync.cpp",
        "FrameDecoder.cpp",
        "HevcUtils.cpp",
        "InterfaceUtils.cpp",
        "JPEGSource.cpp",
        "MPEG2TSWriter.cpp",
        "MPEG4Writer.cpp",
        "MediaAdapter.cpp",
        "MediaAppender.cpp",
        "MediaClock.cpp",
        "MediaCodec.cpp",
        "MediaCodecList.cpp",
        "MediaCodecListOverrides.cpp",
        "MediaCodecSource.cpp",
        "MediaExtractor.cpp",
        "MediaExtractorFactory.cpp",
        "MediaMuxer.cpp",
        "MediaSource.cpp",
        "MediaSync.cpp",
        "MediaTrack.cpp",
        "NuMediaExtractor.cpp",
        "OMXClient.cpp",
        "OggWriter.cpp",
        "OmxInfoBuilder.cpp",
        "RemoteMediaExtractor.cpp",
        "RemoteMediaSource.cpp",
        "SimpleDecodingSource.cpp",
        "StagefrightMediaScanner.cpp",
        "SurfaceUtils.cpp",
        "ThrottledSource.cpp",
        "Utils.cpp",
        "VideoFrameScheduler.cpp",
        "VideoFrameSchedulerBase.cpp",
        "VideoRenderQualityTracker.cpp",
    ],

    shared_libs: [
        "aconfig_mediacodec_flags_c_lib",
        "android.hardware.cas.native@1.0",
        "android.hardware.drm@1.0",
        "android.hardware.media.omx@1.0",
        "android.hidl.allocator@1.0",
        "framework-permission-aidl-cpp",
        "libaconfig_storage_read_api_cc",
        "libaudioclient",
        "libaudioclient_aidl_conversion",
        "libaudiofoundation",
        "libaudioutils",
        "libbase",
        "libbinder",
        "libbinder_ndk",
        "libcamera_client",
        "libcodec2",
        "libcodec2_vndk",
        "libcutils",
        "libdatasource",
        "libdl",
        "libdl_android",
        "libgui",
        "libhidlallocatorutils",
        "libhidlbase",
        "libhidlmemory",
        "liblog",
        "libmedia",
        "libmedia_codeclist",
        "libmedia_helper",
        "libmedia_omx",
        "libmedia_omx_client",
        "libmediametrics",
        "libsfplugin_ccodec",
        "libsfplugin_ccodec_utils",
        "libstagefright_codecbase",
        "libstagefright_foundation",
        "libstagefright_framecapture_utils",
        "libstagefright_omx_utils",
        "libui",
        "libutils",
        "packagemanager_aidl-cpp",
        "server_configurable_flags",
        "libaconfig_storage_read_api_cc",
        "aconfig_mediacodec_flags_c_lib",
        "camera_platform_flags_c_lib",
    ],

    static_libs: [
        "android.media.codec-aconfig-cc",
        "android.media.extractor.flags-aconfig-cc",
        "com.android.media.flags.editing-aconfig-cc",
        "framework-permission-aidl-cpp",
        "libmedia_ndkformatpriv",
        "libmediandk_format",
        "libogg",
        "libstagefright_color_conversion",
        "libstagefright_esds",
        "libstagefright_id3",
        "libstagefright_timedtext",
        "libstagefright_webm",
        "libyuv",
    ],

    header_libs: [
        "libmediadrm_headers",
        "libmediaformatshaper_headers",
        "libnativeloader-headers",
        "libstagefright_xmlparser_headers",
        "media_ndk_headers",
    ],

    export_shared_lib_headers: [
        "android.hidl.allocator@1.0",
        "framework-permission-aidl-cpp",
        "libgui",
        "libhidlmemory",
        "libmedia",
    ],

    export_include_dirs: [
        "include",
    ],

    cflags: [
        "-Wall",
        "-Werror",
        "-Wno-error=deprecated-declarations",
        "-Wno-multichar",
    ],

    version_script: "exports.lds",

    product_variables: {
        debuggable: {
            // enable experiments only in userdebug and eng builds
            cflags: ["-DENABLE_STAGEFRIGHT_EXPERIMENTS"],
        },
    },

    sanitize: {
        cfi: true,
        misc_undefined: [
            "signed-integer-overflow",
            "unsigned-integer-overflow",
        ],
    },
}
