# Copyright (c) 2024-2025 Huawei Device Co., Ltd.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import("//build/ohos.gni")
import("../distributed_av_transport.gni")

config("av_pipeline_fwk_external_config") {
  include_dirs = [
    "${common_path}/include",
    "${dh_fwk_sdk_path}/include",
    "${interface_path}",
  ]
}

ohos_shared_library("distributed_av_pipeline_fwk") {
  sanitize = {
    cfi = true
    cfi_cross_dso = true
    cfi_no_nvcall = true
    cfi_vcall_icall_only = true
    debug = false
    boundary_sanitize = true
    integer_overflow = true
    ubsan = true
  }
  branch_protector_ret = "pac_ret"
  public_configs = [ ":av_pipeline_fwk_external_config" ]

  include_dirs = [
    "${dh_fwk_utils_path}/include",
    "${distributed_av_transport_path}/framework",
    "${distributed_av_transport_path}/framework/filter/include",
    "${distributed_av_transport_path}/framework/pipeline/include",
    "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_coder",
    "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_input",
    "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_output",
  ]

  sources = [
    "${common_path}/src/av_sync_utils.cpp",
    "${common_path}/src/av_trans_log.cpp",
    "${common_path}/src/softbus_channel_adapter.cpp",
    "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_coder/av_trans_audio_decoder_filter.cpp",
    "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_coder/av_trans_audio_encoder_filter.cpp",
    "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_input/av_trans_audio_input_filter.cpp",
    "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_output/daudio_output_filter.cpp",
    "${distributed_av_transport_path}/framework/filter/src/filter.cpp",
    "${distributed_av_transport_path}/framework/filter/src/filter_factory.cpp",
    "${distributed_av_transport_path}/framework/pipeline/src/pipeline.cpp",
  ]

  deps = [ "${dh_fwk_sdk_path}:libdhfwk_sdk" ]

  defines = [
    "HI_LOG_ENABLE",
    "DH_LOG_TAG=\"av_trans_fwk\"",
    "LOG_DOMAIN=0xD004101",
  ]

  external_deps = [
    "av_codec:av_codec_client",
    "av_codec:native_media_acodec",
    "bounds_checking_function:libsec_shared",
    "cJSON:cjson",
    "c_utils:utils",
    "dsoftbus:softbus_client",
    "graphic_surface:surface",
    "hilog:libhilog",
    "ipc:ipc_core",
    "media_foundation:media_foundation",
    "media_foundation:native_media_core",
  ]

  if (histreamer_compile_part) {
    external_deps += [ "media_foundation:media_foundation" ]
  }

  cflags = [
    "-fexceptions",
    "-fno-rtti",
    "-fPIC",
    "-O2",
    "-Wall",
    "-Wno-c++20-extensions",
    "-fstack-protector-strong",
  ]
  cflags_cc = cflags

  ldflags = [
    "-fpie",
    "-Wl,-z,relro",
    "-Wl,-z,now",
  ]

  part_name = "distributed_hardware_fwk"
  subsystem_name = "distributedhardware"
}