# Copyright (C) 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/config/features.gni")
import("//build/ohos.gni")
import("//build/test.gni")
module_output_path = "av_codec/av_codec"
MEDIA_ROOT_DIR = "//foundation/multimedia/av_codec/"
import("//foundation/multimedia/av_codec/config.gni")

##############################fuzztest##########################################
ohos_fuzztest("PluginSinkFuzzTest") {
  module_out_path = module_output_path
  fuzz_config_file =
      "$MEDIA_ROOT_DIR/test/fuzztest/pluginsink_fuzzer"
  include_dirs = [
    "$MEDIA_ROOT_DIR/test/fuzztest/pluginsink_fuzzer",
    "$av_codec_root_dir/interfaces",
    "$av_codec_root_dir/interfaces/inner_api/native",
    "$av_codec_root_dir/services/media_engine/plugins/ffmpeg_adapter/common",
    "$av_codec_root_dir/services/media_engine/plugins/sink",
    "//foundation/multimedia/av_codec/test/fuzztest/http_plugin_fuzztest/common",
  ]
  cflags = [
    "-O2",
    "-fPIC",
    "-Wall",
    "-fexceptions",
    "-fno-rtti",
    "-Wno-unused-but-set-variable",
    "-Wno-format",
  ]
  sources = [
    "$av_codec_root_dir/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_convert.cpp",
    "$av_codec_root_dir/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_utils.cpp",
    "$av_codec_root_dir/services/media_engine/plugins/sink/audio_server_sink_plugin.cpp",
    "sink_fuzzer.cpp",
  ]
  external_deps = [
    "audio_framework:audio_client",
    "audio_framework:audio_foundation",
    "audio_framework:audio_renderer",
    "c_utils:utils",
    "ffmpeg:libohosffmpeg",
    "graphic_surface:surface",
    "graphic_surface:sync_fence",
    "hilog:libhilog",
    "hitrace:hitrace_meter",
    "init:libbegetutil",
    "ipc:ipc_single",
    "media_foundation:media_foundation",
    "safwk:system_ability_fwk",
  ]
  deps = [ "$av_codec_root_dir/services/dfx:av_codec_service_dfx" ]
  configs = [
    "$av_codec_root_dir/services/media_engine/plugins/sink:audio_server_sink_plugin_config",
    "$av_codec_root_dir/services/dfx:av_codec_service_log_dfx_public_config",
  ]
}

###############################################################################
group("fuzztest") {
  testonly = true
  deps = []
  deps += [
    # deps file
    ":PluginSinkFuzzTest",
  ]
}
###############################################################################