1# Copyright (c) 2021-2021 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13# 14import("//foundation/multimedia/media_foundation/config.gni") 15 16if (!hst_is_lite_sys) { 17 ohos_kernel_type = "" 18} 19 20group("plugin_ffmpeg_adapter") { 21 deps = [] 22 if (ohos_kernel_type != "liteos_m") { 23 deps += [ 24 ":histreamer_plugin_FFmpegAudioDecoders", 25 ":histreamer_plugin_FFmpegDemuxer", 26 ] 27 if (media_foundation_enable_video) { 28 deps += [ ":histreamer_plugin_FFmpegVideoDecoders" ] 29 } 30 } 31 if (!hst_is_lite_sys && media_foundation_enable_recorder) { 32 deps += [ 33 ":histreamer_plugin_FFmpegAudioEncoders", 34 ":histreamer_plugin_FFmpegMuxers", 35 ] 36 if (media_foundation_enable_video) { 37 deps += [ ":histreamer_plugin_FFmpegVideoEncoders" ] 38 } 39 } 40} 41config("plugin_ffmpeg_adapter_config") { 42 include_dirs = [ 43 "//foundation/multimedia/media_foundation/engine/include/", 44 "//foundation/multimedia/media_foundation/engine/plugin/", 45 "//third_party/ffmpeg", 46 ] 47} 48 49ohos_source_set("ffmpeg_adapter_common") { 50 subsystem_name = "multimedia" 51 part_name = "media_foundation" 52 sources = [ "utils/ffmpeg_utils.cpp" ] 53 public_configs = [ 54 ":plugin_ffmpeg_adapter_config", 55 "//foundation/multimedia/media_foundation:histreamer_presets", 56 ] 57 public_deps = [ 58 "//foundation/multimedia/media_foundation/engine/foundation:histreamer_foundation", 59 "//foundation/multimedia/media_foundation/engine/plugin:histreamer_plugin_base", 60 ] 61 if (!hst_is_lite_sys) { 62 external_deps = [ "graphic_surface:surface" ] 63 } 64 if (hst_is_lite_sys) { 65 print("histreamer audio encoder plugin only supports standard system") 66 } else { 67 public_deps += [ "//third_party/ffmpeg:libohosffmpeg" ] 68 } 69} 70 71ohos_source_set("ffmpeg_audio_decoders") { 72 subsystem_name = "multimedia" 73 part_name = "media_foundation" 74 sources = [ "audio_decoder/audio_ffmpeg_decoder_plugin.cpp" ] 75 public_configs = [ 76 ":plugin_ffmpeg_adapter_config", 77 "//foundation/multimedia/media_foundation:histreamer_presets", 78 ] 79 public_deps = [ 80 "//foundation/multimedia/media_foundation/engine/foundation:histreamer_foundation", 81 "//foundation/multimedia/media_foundation/engine/plugin:histreamer_plugin_base", 82 ] 83 if (!hst_is_lite_sys) { 84 external_deps = [ "graphic_surface:surface" ] 85 } 86 if (hst_is_lite_sys) { 87 # deps on lite 88 } else { 89 public_deps += [ "//third_party/ffmpeg:libohosffmpeg" ] 90 } 91} 92ohos_source_set("ffmpeg_demuxers") { 93 subsystem_name = "multimedia" 94 part_name = "media_foundation" 95 sources = [ 96 "demuxer/ffmpeg_demuxer_plugin.cpp", 97 "demuxer/ffmpeg_track_meta.cpp", 98 "utils/aac_audio_config_parser.cpp", 99 "utils/bit_reader.cpp", 100 ] 101 if (media_foundation_enable_video) { 102 sources += [ "utils/avc_config_data_parser.cpp" ] 103 } 104 public_configs = [ 105 ":plugin_ffmpeg_adapter_config", 106 "//foundation/multimedia/media_foundation:histreamer_presets", 107 ] 108 public_deps = [ 109 "//foundation/multimedia/media_foundation/engine/foundation:histreamer_foundation", 110 "//foundation/multimedia/media_foundation/engine/plugin:histreamer_plugin_base", 111 ] 112 if (!hst_is_lite_sys) { 113 external_deps = [ "graphic_surface:surface" ] 114 } 115 116 if (hst_is_lite_sys) { 117 # deps on lite 118 } else { 119 public_deps += [ "//third_party/ffmpeg:libohosffmpeg" ] 120 } 121} 122 123ohos_source_set("ffmpeg_audio_encoders") { 124 subsystem_name = "multimedia" 125 part_name = "media_foundation" 126 sources = [ 127 "audio_encoder/audio_ffmpeg_encoder_plugin.cpp", 128 "audio_encoder/ffmpeg_au_enc_config.cpp", 129 ] 130 public_configs = [ 131 ":plugin_ffmpeg_adapter_config", 132 "//foundation/multimedia/media_foundation:histreamer_presets", 133 ] 134 public_deps = [ 135 "//foundation/multimedia/media_foundation/engine/foundation:histreamer_foundation", 136 "//foundation/multimedia/media_foundation/engine/plugin:histreamer_ffmpeg_convert", 137 "//foundation/multimedia/media_foundation/engine/plugin:histreamer_plugin_base", 138 ] 139 if (!hst_is_lite_sys) { 140 external_deps = [ "graphic_surface:surface" ] 141 } 142 if (hst_is_lite_sys) { 143 print("histreamer audio encoder plugin only supports standard system") 144 } else { 145 public_deps += [ "//third_party/ffmpeg:libohosffmpeg" ] 146 } 147} 148 149ohos_source_set("ffmpeg_video_decoders") { 150 subsystem_name = "multimedia" 151 part_name = "media_foundation" 152 sources = [ "video_decoder/video_ffmpeg_decoder_plugin.cpp" ] 153 public_configs = [ 154 ":plugin_ffmpeg_adapter_config", 155 "//foundation/multimedia/media_foundation:histreamer_presets", 156 ] 157 public_deps = [ 158 "//foundation/multimedia/media_foundation/engine/foundation:histreamer_foundation", 159 "//foundation/multimedia/media_foundation/engine/plugin:histreamer_ffmpeg_convert", 160 "//foundation/multimedia/media_foundation/engine/plugin:histreamer_plugin_base", 161 ] 162 if (!hst_is_lite_sys) { 163 external_deps = [ "graphic_surface:surface" ] 164 } 165 if (hst_is_lite_sys) { 166 print("histreamer video decoder plugin only supports standard system") 167 } else { 168 public_deps += [ "//third_party/ffmpeg:libohosffmpeg" ] 169 } 170} 171 172ohos_source_set("ffmpeg_video_encoders") { 173 subsystem_name = "multimedia" 174 part_name = "media_foundation" 175 sources = [ 176 "video_encoder/ffmpeg_vid_enc_config.cpp", 177 "video_encoder/video_ffmpeg_encoder_plugin.cpp", 178 ] 179 public_configs = [ 180 ":plugin_ffmpeg_adapter_config", 181 "//foundation/multimedia/media_foundation:histreamer_presets", 182 ] 183 public_deps = [ 184 "//foundation/multimedia/media_foundation/engine/foundation:histreamer_foundation", 185 "//foundation/multimedia/media_foundation/engine/plugin:histreamer_plugin_base", 186 ] 187 if (!hst_is_lite_sys) { 188 external_deps = [ "graphic_surface:surface" ] 189 } 190 if (hst_is_lite_sys) { 191 print("histreamer video encoder plugin only supports standard system") 192 } else { 193 public_deps += [ "//third_party/ffmpeg:libohosffmpeg" ] 194 } 195} 196 197ohos_source_set("ffmpeg_muxers") { 198 subsystem_name = "multimedia" 199 part_name = "media_foundation" 200 sources = [ 201 "muxer/ffmpeg_muxer_plugin.cpp", 202 "utils/ffmpeg_codec_map.cpp", 203 ] 204 public_configs = [ 205 ":plugin_ffmpeg_adapter_config", 206 "//foundation/multimedia/media_foundation:histreamer_presets", 207 ] 208 public_deps = [ 209 "//foundation/multimedia/media_foundation/engine/foundation:histreamer_foundation", 210 "//foundation/multimedia/media_foundation/engine/plugin:histreamer_plugin_base", 211 ] 212 if (!hst_is_lite_sys) { 213 external_deps = [ "graphic_surface:surface" ] 214 } 215 if (hst_is_lite_sys) { 216 print("histreamer ffmpeg muxer plugin only supports standard system") 217 } else { 218 public_deps += [ "//third_party/ffmpeg:libohosffmpeg" ] 219 } 220} 221 222if (hst_is_lite_sys) { 223 # lite 224 import("//build/lite/config/component/lite_component.gni") 225 if (ohos_kernel_type == "liteos_m") { 226 # plugin is not need on this platform 227 } else { 228 lite_library("histreamer_plugin_FFmpegAudioDecoders") { 229 target_type = "shared_library" 230 sources = [] 231 deps = [ 232 ":ffmpeg_adapter_common", 233 ":ffmpeg_audio_decoders", 234 ] 235 ldflags = [ 236 "-lavcodec", 237 "-lswresample", 238 ] 239 } 240 lite_library("histreamer_plugin_FFmpegDemuxer") { 241 target_type = "shared_library" 242 sources = [] 243 deps = [ 244 ":ffmpeg_adapter_common", 245 ":ffmpeg_demuxers", 246 ] 247 ldflags = [ 248 "-lavformat", 249 "-lavcodec", 250 ] 251 } 252 } 253} else { 254 # standard 255 import("//build/ohos.gni") 256 ohos_shared_library("histreamer_plugin_FFmpegAudioDecoders") { 257 sanitize = { 258 cfi = true 259 cfi_cross_dso = true 260 debug = false 261 integer_overflow = true 262 } 263 deps = [ 264 ":ffmpeg_adapter_common", 265 ":ffmpeg_audio_decoders", 266 ] 267 external_deps = [ "hilog:libhilog" ] 268 relative_install_dir = "media/histreamer_plugins" 269 subsystem_name = "multimedia" 270 part_name = "media_foundation" 271 } 272 ohos_shared_library("histreamer_plugin_FFmpegVideoDecoders") { 273 sanitize = { 274 cfi = true 275 cfi_cross_dso = true 276 debug = false 277 integer_overflow = true 278 } 279 deps = [ 280 ":ffmpeg_adapter_common", 281 ":ffmpeg_video_decoders", 282 ] 283 external_deps = [ "hilog:libhilog" ] 284 relative_install_dir = "media/histreamer_plugins" 285 subsystem_name = "multimedia" 286 part_name = "media_foundation" 287 } 288 ohos_shared_library("histreamer_plugin_FFmpegDemuxer") { 289 sanitize = { 290 cfi = true 291 cfi_cross_dso = true 292 debug = false 293 integer_overflow = true 294 } 295 deps = [ 296 ":ffmpeg_adapter_common", 297 ":ffmpeg_demuxers", 298 ] 299 external_deps = [ "hilog:libhilog" ] 300 relative_install_dir = "media/histreamer_plugins" 301 subsystem_name = "multimedia" 302 part_name = "media_foundation" 303 } 304 ohos_shared_library("histreamer_plugin_FFmpegAudioEncoders") { 305 sanitize = { 306 cfi = true 307 cfi_cross_dso = true 308 debug = false 309 integer_overflow = true 310 } 311 deps = [ 312 ":ffmpeg_adapter_common", 313 ":ffmpeg_audio_encoders", 314 ] 315 external_deps = [ "hilog:libhilog" ] 316 relative_install_dir = "media/histreamer_plugins" 317 subsystem_name = "multimedia" 318 part_name = "media_foundation" 319 } 320 ohos_shared_library("histreamer_plugin_FFmpegVideoEncoders") { 321 sanitize = { 322 cfi = true 323 cfi_cross_dso = true 324 debug = false 325 integer_overflow = true 326 } 327 deps = [ 328 ":ffmpeg_adapter_common", 329 ":ffmpeg_video_encoders", 330 ] 331 external_deps = [ "hilog:libhilog" ] 332 relative_install_dir = "media/histreamer_plugins" 333 subsystem_name = "multimedia" 334 part_name = "media_foundation" 335 } 336 ohos_shared_library("histreamer_plugin_FFmpegMuxers") { 337 sanitize = { 338 cfi = true 339 cfi_cross_dso = true 340 debug = false 341 integer_overflow = true 342 } 343 deps = [ 344 ":ffmpeg_adapter_common", 345 ":ffmpeg_muxers", 346 ] 347 external_deps = [ "hilog:libhilog" ] 348 relative_install_dir = "media/histreamer_plugins" 349 subsystem_name = "multimedia" 350 part_name = "media_foundation" 351 } 352} 353