diff --git a/frameworks/native/avdemuxer/avdemuxer_impl.cpp b/frameworks/native/avdemuxer/avdemuxer_impl.cpp index c6e9ddddae57d30d97aa89b37550591356925be9..ea67553803906393f3160033a521304e25b3d517 100644 --- a/frameworks/native/avdemuxer/avdemuxer_impl.cpp +++ b/frameworks/native/avdemuxer/avdemuxer_impl.cpp @@ -26,7 +26,7 @@ #include "avcodec_errors.h" namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_DEMUXER_MUXER, "AVDemuxerImpl"}; + constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_DEMUXER, "AVDemuxerImpl"}; } namespace OHOS { diff --git a/frameworks/native/avmuxer/avmuxer_impl.cpp b/frameworks/native/avmuxer/avmuxer_impl.cpp index 4a9015baed6588b1b84f49bf15f40b27450c25c0..ad0e10484aef938023d7a00be9f457942cb6fb48 100644 --- a/frameworks/native/avmuxer/avmuxer_impl.cpp +++ b/frameworks/native/avmuxer/avmuxer_impl.cpp @@ -22,7 +22,7 @@ #include "avcodec_errors.h" namespace { -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_DEMUXER_MUXER, "AVMuxerImpl"}; +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_MUXER, "AVMuxerImpl"}; } namespace OHOS { diff --git a/frameworks/native/avsource/avsource_impl.cpp b/frameworks/native/avsource/avsource_impl.cpp index 230fca300539c40f4fe382fed4c34dc8a47b9043..723205b982a700ab3d876cea899d9e7491e92827 100644 --- a/frameworks/native/avsource/avsource_impl.cpp +++ b/frameworks/native/avsource/avsource_impl.cpp @@ -24,7 +24,7 @@ #include "common/status.h" namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_DEMUXER_MUXER, "AVSourceImpl"}; + constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_DEMUXER, "AVSourceImpl"}; } namespace OHOS { diff --git a/frameworks/native/capi/avdemuxer/native_avdemuxer.cpp b/frameworks/native/capi/avdemuxer/native_avdemuxer.cpp index 768d5c0201ed3d1a5bb5ac565ee00fba91949191..cfcc510758fe1f5ec0f8016c7169260494c6b18d 100644 --- a/frameworks/native/capi/avdemuxer/native_avdemuxer.cpp +++ b/frameworks/native/capi/avdemuxer/native_avdemuxer.cpp @@ -25,7 +25,7 @@ #include "native_object.h" #include "native_drm_common.h" namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_DEMUXER_MUXER, "NativeAVDemuxer"}; + constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_DEMUXER, "NativeAVDemuxer"}; } using namespace OHOS::MediaAVCodec; diff --git a/frameworks/native/capi/avmuxer/native_avmuxer.cpp b/frameworks/native/capi/avmuxer/native_avmuxer.cpp index 7de459db52992a93334bc0c7e2a1ea53ac4336cf..52834825328519c69a13816e5191222f8605ca15 100644 --- a/frameworks/native/capi/avmuxer/native_avmuxer.cpp +++ b/frameworks/native/capi/avmuxer/native_avmuxer.cpp @@ -21,7 +21,7 @@ #include "native_avmagic.h" namespace { -constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_DEMUXER_MUXER, "NativeAVMuxer"}; +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_MUXER, "NativeAVMuxer"}; } using namespace OHOS::Media; diff --git a/frameworks/native/capi/avsource/native_avsource.cpp b/frameworks/native/capi/avsource/native_avsource.cpp index a95ef1a4ef3e96aaa3339fa5391680b057982e0a..6acede7b371ebdd3bd80092585f91f62e3b0fb16 100644 --- a/frameworks/native/capi/avsource/native_avsource.cpp +++ b/frameworks/native/capi/avsource/native_avsource.cpp @@ -24,7 +24,7 @@ #include "avbuffer.h" namespace { - constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_DEMUXER_MUXER, "NativeAVSource"}; +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_DEMUXER, "NativeAVSource"}; } using namespace OHOS::MediaAVCodec; diff --git a/interfaces/inner_api/native/audio_sink.h b/interfaces/inner_api/native/audio_sink.h index 60480de507207fda13ecf61dec31ab0c7cd86b3b..d5cde55713a04450c5f049afc7d605fabebf7ffb 100644 --- a/interfaces/inner_api/native/audio_sink.h +++ b/interfaces/inner_api/native/audio_sink.h @@ -24,7 +24,6 @@ #include "buffer/avbuffer_queue_define.h" #include "plugin/audio_sink_plugin.h" #include "filter/filter.h" -#include "common/log.h" #include "plugin/plugin_time.h" namespace OHOS { diff --git a/interfaces/inner_api/native/subtitle_sink.h b/interfaces/inner_api/native/subtitle_sink.h index f13c4474392ffa98c7faff0be88fd6a5d708f2fd..7017755d5cc2d4e07ca003112b23955b0b444ac9 100644 --- a/interfaces/inner_api/native/subtitle_sink.h +++ b/interfaces/inner_api/native/subtitle_sink.h @@ -23,7 +23,6 @@ #include "buffer/avbuffer_queue.h" #include "buffer/avbuffer_queue_define.h" #include "filter/filter.h" -#include "common/log.h" namespace OHOS { namespace Media { diff --git a/interfaces/inner_api/native/surface_encoder_filter.h b/interfaces/inner_api/native/surface_encoder_filter.h index b92e3b9150590d6d2c178b326d340a51e9428c01..a408b49d557de0714d8ffd0bf1161243f52ae719 100644 --- a/interfaces/inner_api/native/surface_encoder_filter.h +++ b/interfaces/inner_api/native/surface_encoder_filter.h @@ -26,7 +26,6 @@ #include "buffer/avbuffer_queue_producer.h" #include "buffer/avbuffer_queue_consumer.h" #include "common/status.h" -#include "common/log.h" namespace OHOS { namespace Media { diff --git a/interfaces/inner_api/native/video_capture_filter.h b/interfaces/inner_api/native/video_capture_filter.h index c79a684fe9ff353fcea328c55f24e8abf143bd8a..80daf6516239722a8aa8738b21c75a9598417341 100644 --- a/interfaces/inner_api/native/video_capture_filter.h +++ b/interfaces/inner_api/native/video_capture_filter.h @@ -26,7 +26,6 @@ #include "buffer/avbuffer_queue_producer.h" #include "buffer/avbuffer_queue_consumer.h" #include "common/status.h" -#include "common/log.h" #define TIME_NONE ((int64_t) -1) diff --git a/services/dfx/include/avcodec_log.h b/services/dfx/include/avcodec_log.h index 63c91c4feb572fd870a698a9d0bd5fb9b0d15343..0455a9f0d686624391a39416f916063b732b5b01 100644 --- a/services/dfx/include/avcodec_log.h +++ b/services/dfx/include/avcodec_log.h @@ -28,8 +28,10 @@ namespace MediaAVCodec { #define LOG_DOMAIN_HCODEC 0xD002B32 #undef LOG_DOMAIN_TEST #define LOG_DOMAIN_TEST 0xD002B36 -#undef LOG_DOMAIN_DEMUXER_MUXER -#define LOG_DOMAIN_DEMUXER_MUXER 0xD002B3A +#undef LOG_DOMAIN_DEMUXER +#define LOG_DOMAIN_DEMUXER 0xD002B3A +#undef LOG_DOMAIN_MUXER +#define LOG_DOMAIN_MUXER 0xD002B3B #ifndef AVCODEC_LOG_USE_NO_DICT_LOG #define AVCODEC_LOG(level, fmt, args...) \ diff --git a/services/media_engine/filters/audio_capture_filter.cpp b/services/media_engine/filters/audio_capture_filter.cpp index d94fa49bb20856945e07366c33650d64f0bf5d29..84dc5167b107cf0500564273a4eb6c30179737c3 100644 --- a/services/media_engine/filters/audio_capture_filter.cpp +++ b/services/media_engine/filters/audio_capture_filter.cpp @@ -19,6 +19,10 @@ #include "source/audio_capture/audio_capture_module.h" #include "avcodec_trace.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Pipeline { @@ -261,7 +265,7 @@ void AudioCaptureFilter::SetParameter(const std::shared_ptr &meta) void AudioCaptureFilter::GetParameter(std::shared_ptr &meta) { MEDIA_LOG_I("GetParameter"); - MediaAVCodec::AVCodecTrace trace("AudioCaptureFilter::SetParameter"); + MediaAVCodec::AVCodecTrace trace("AudioCaptureFilter::GetParameter"); audioCaptureModule_->GetParameter(meta); } @@ -369,7 +373,7 @@ int32_t AudioCaptureFilter::GetMaxAmplitude() { MEDIA_LOG_I("GetMaxAmplitude"); if (audioCaptureModule_ == nullptr) { - MEDIA_LOG_E("audioCaptureModule_ is nullptr, cannot get audio capturer change info "); + MEDIA_LOG_E("audioCaptureModule_ is nullptr, cannot get audio capturer change info"); return (int32_t)Status::ERROR_INVALID_OPERATION; } return audioCaptureModule_->GetMaxAmplitude(); diff --git a/services/media_engine/filters/audio_data_source_filter.cpp b/services/media_engine/filters/audio_data_source_filter.cpp index f95f30b778f3ad26e9d0045dfdca51be9052f7c2..2b1454f2b549d12bf7f0e991102331c37547e497 100644 --- a/services/media_engine/filters/audio_data_source_filter.cpp +++ b/services/media_engine/filters/audio_data_source_filter.cpp @@ -16,6 +16,10 @@ #include "audio_data_source_filter.h" #include "common/log.h" #include "filter/filter_factory.h" + +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} namespace OHOS { namespace Media { diff --git a/services/media_engine/filters/audio_decoder_filter.cpp b/services/media_engine/filters/audio_decoder_filter.cpp index d59aca4cb09e17fb11d75601fc732909f79dce0b..fa62723049a38822adf57b09c03f928fc9686cfd 100644 --- a/services/media_engine/filters/audio_decoder_filter.cpp +++ b/services/media_engine/filters/audio_decoder_filter.cpp @@ -16,9 +16,14 @@ #include "audio_decoder_filter.h" #include "filter/filter_factory.h" +#include "common/log.h" #include "common/media_core.h" #include "avcodec_sysevent.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Pipeline { @@ -367,4 +372,4 @@ void AudioDecoderFilter::SetCallerInfo(uint64_t instanceId, const std::string& a } } // namespace Pipeline } // namespace MEDIA -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/services/media_engine/filters/audio_encoder_filter.cpp b/services/media_engine/filters/audio_encoder_filter.cpp index 2048373fbd354891caec5d564285b1d490429883..5894e74cea8ed19fbeaf7ce601e3de2370ec2a1f 100644 --- a/services/media_engine/filters/audio_encoder_filter.cpp +++ b/services/media_engine/filters/audio_encoder_filter.cpp @@ -14,10 +14,16 @@ */ #include "audio_encoder_filter.h" + +#include "common/log.h" #include "filter/filter_factory.h" #include "media_codec/media_codec.h" #include "avcodec_sysevent.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Pipeline { diff --git a/services/media_engine/filters/audio_sink_filter.cpp b/services/media_engine/filters/audio_sink_filter.cpp index 639efc3d2245e116cd8aba206aa4668454d58d0a..b6891a6bed369aa0fa7baba7efe3c78e7acca785 100644 --- a/services/media_engine/filters/audio_sink_filter.cpp +++ b/services/media_engine/filters/audio_sink_filter.cpp @@ -23,6 +23,10 @@ #include "media_core.h" #include "parameters.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Pipeline { @@ -137,7 +141,7 @@ Status AudioSinkFilter::DoResume() return Status::OK; } // only worked when state is paused - if (state_ == FilterState::PAUSED || state_ == FilterState::RUNNING) { + if (state_ == FilterState::PAUSED) { forceUpdateTimeAnchorNextTime_ = true; state_ = FilterState::RUNNING; if (frameCnt_ > 0) { diff --git a/services/media_engine/filters/codec_capability_adapter.cpp b/services/media_engine/filters/codec_capability_adapter.cpp index d803d8f0dc3b9ba8850240285702b6b3918fa116..e01c0237320be0f4ebc38de81db9095b8b53e772 100644 --- a/services/media_engine/filters/codec_capability_adapter.cpp +++ b/services/media_engine/filters/codec_capability_adapter.cpp @@ -16,6 +16,10 @@ #include "common/log.h" #include "codec_capability_adapter.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { diff --git a/services/media_engine/filters/decoder_surface_filter.cpp b/services/media_engine/filters/decoder_surface_filter.cpp index 2b28bd0f69e2fd5d285b9b4211865cde2bb4331e..3568d1439f34dfcc30b8761d251d5a37bebe4642 100644 --- a/services/media_engine/filters/decoder_surface_filter.cpp +++ b/services/media_engine/filters/decoder_surface_filter.cpp @@ -29,6 +29,10 @@ #include "osal/utils/util.h" #include "parameters.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Pipeline { diff --git a/services/media_engine/filters/demuxer_filter.cpp b/services/media_engine/filters/demuxer_filter.cpp index 076ba076041eddabcb57cdf36a5007943a2554cf..6fe845f84d6e2bfd19f824c0e306249226b326a4 100644 --- a/services/media_engine/filters/demuxer_filter.cpp +++ b/services/media_engine/filters/demuxer_filter.cpp @@ -26,6 +26,9 @@ #include "media_types.h" #include "avcodec_sysevent.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} namespace OHOS { namespace Media { diff --git a/services/media_engine/filters/muxer_filter.cpp b/services/media_engine/filters/muxer_filter.cpp index 363c9e8167525d0a22592840d529aa30670a0715..8d0d7a13fe598778682a26e078901b296610e677 100644 --- a/services/media_engine/filters/muxer_filter.cpp +++ b/services/media_engine/filters/muxer_filter.cpp @@ -23,6 +23,7 @@ #include "avcodec_sysevent.h" namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; static const std::unordered_map FORMAT_TABLE = { {OHOS::Media::Plugins::OutputFormat::DEFAULT, OHOS::Media::Plugins::MimeType::MEDIA_MP4}, {OHOS::Media::Plugins::OutputFormat::MPEG_4, OHOS::Media::Plugins::MimeType::MEDIA_MP4}, diff --git a/services/media_engine/filters/subtitle_sink_filter.cpp b/services/media_engine/filters/subtitle_sink_filter.cpp index a8526e00795b28435e2b2206c36a64859607ddb9..5c9df073e7620cd4c7462ebee4abbfa2459fcdda 100644 --- a/services/media_engine/filters/subtitle_sink_filter.cpp +++ b/services/media_engine/filters/subtitle_sink_filter.cpp @@ -22,6 +22,10 @@ #include "media_core.h" #include "parameters.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Pipeline { diff --git a/services/media_engine/filters/surface_decoder_adapter.cpp b/services/media_engine/filters/surface_decoder_adapter.cpp index 615e94dca15536ef61f24f3492b83d9bbd2a7709..8480af5e401b696175e52ca255ff32e128279ab5 100644 --- a/services/media_engine/filters/surface_decoder_adapter.cpp +++ b/services/media_engine/filters/surface_decoder_adapter.cpp @@ -21,6 +21,10 @@ #include "meta/format.h" #include "media_description.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_ONLY_PRERELEASE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { diff --git a/services/media_engine/filters/surface_decoder_filter.cpp b/services/media_engine/filters/surface_decoder_filter.cpp index b4d7a70ae504f041e0baf6f31defdb9f00c8bb8c..2eb494479c3071cfb7c8cc00e946ed8edbc09d90 100644 --- a/services/media_engine/filters/surface_decoder_filter.cpp +++ b/services/media_engine/filters/surface_decoder_filter.cpp @@ -19,6 +19,10 @@ #include "surface_decoder_adapter.h" #include "meta/format.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Pipeline { diff --git a/services/media_engine/filters/surface_encoder_adapter.cpp b/services/media_engine/filters/surface_encoder_adapter.cpp index 57e95d7d8a3875028ab5c4160ff3b0cc2f042419..06987ab2360ec92d60f0e07fd9ca91b21b4b0aad 100644 --- a/services/media_engine/filters/surface_encoder_adapter.cpp +++ b/services/media_engine/filters/surface_encoder_adapter.cpp @@ -24,6 +24,11 @@ #include "native_avcodec_base.h" #include "avcodec_trace.h" #include "avcodec_sysevent.h" +#include "common/log.h" + +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} constexpr uint32_t TIME_OUT_MS = 1000; constexpr uint32_t NS_PER_US = 1000; diff --git a/services/media_engine/filters/surface_encoder_adapter.h b/services/media_engine/filters/surface_encoder_adapter.h index b11b822a7d2d391d9c0f534a62f687af9e7b5bba..40ea08361973547de32ce5f8d6bd969f72a4161e 100644 --- a/services/media_engine/filters/surface_encoder_adapter.h +++ b/services/media_engine/filters/surface_encoder_adapter.h @@ -26,7 +26,6 @@ #include "buffer/avbuffer_queue_producer.h" #include "buffer/avbuffer_queue_consumer.h" #include "common/status.h" -#include "common/log.h" #include "osal/task/task.h" #include "avcodec_common.h" #include "osal/task/condition_variable.h" diff --git a/services/media_engine/filters/surface_encoder_filter.cpp b/services/media_engine/filters/surface_encoder_filter.cpp index 73552979bc58ecd4c9d0846fa1dd4e21e3e7cf71..848941e1ae42f2d21edd9cae3641a7b4839ab98f 100644 --- a/services/media_engine/filters/surface_encoder_filter.cpp +++ b/services/media_engine/filters/surface_encoder_filter.cpp @@ -13,12 +13,19 @@ * limitations under the License. */ +#include "surface_encoder_filter.h" + #include #include -#include "surface_encoder_filter.h" + +#include "common/log.h" #include "filter/filter_factory.h" #include "surface_encoder_adapter.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Pipeline { diff --git a/services/media_engine/filters/video_capture_filter.cpp b/services/media_engine/filters/video_capture_filter.cpp index adedea11d9929b98a80ed24d28110e58ae1a38d9..5f855c129efbcf41c66858d9ee5c7b7b81a7d05c 100644 --- a/services/media_engine/filters/video_capture_filter.cpp +++ b/services/media_engine/filters/video_capture_filter.cpp @@ -21,6 +21,11 @@ #include "avcodec_info.h" #include "avcodec_common.h" #include "avcodec_trace.h" +#include "common/log.h" + +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} namespace OHOS { namespace Media { diff --git a/services/media_engine/filters/video_decoder_adapter.cpp b/services/media_engine/filters/video_decoder_adapter.cpp index 683561de685c924f2331593d6f96a386b131fc1e..645b70475bee9a615652a7e8803fdbb6abdf03b6 100644 --- a/services/media_engine/filters/video_decoder_adapter.cpp +++ b/services/media_engine/filters/video_decoder_adapter.cpp @@ -31,6 +31,10 @@ #include "avcodec_sysevent.h" #include "media_core.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { using namespace MediaAVCodec; diff --git a/services/media_engine/filters/video_resize_filter.cpp b/services/media_engine/filters/video_resize_filter.cpp index 9f4250f13a2d61e410db9ffe824ff0e40c0d1ff6..df0e523aefc03a0dcd85547f1a7c2340f2bed814 100644 --- a/services/media_engine/filters/video_resize_filter.cpp +++ b/services/media_engine/filters/video_resize_filter.cpp @@ -22,6 +22,10 @@ #include "detail_enhancer_video_common.h" #endif +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { #ifdef USE_VIDEO_PROCESSING_ENGINE diff --git a/services/media_engine/modules/BUILD.gn b/services/media_engine/modules/BUILD.gn index 369d55b50872b02253916284d0a660f9b81c3a88..b06cc2aecb020a1a5dcedc4a3dfeeb7166a3a618 100644 --- a/services/media_engine/modules/BUILD.gn +++ b/services/media_engine/modules/BUILD.gn @@ -80,7 +80,10 @@ ohos_shared_library("av_codec_media_engine_modules") { "source/source.cpp", ] - deps = [ "$av_codec_root_dir/services/engine/base:av_codec_codec_base" ] + deps = [ + "$av_codec_root_dir/services/dfx:av_codec_service_dfx", + "$av_codec_root_dir/services/engine/base:av_codec_codec_base", + ] public_configs = [ "$audio_framework_root_dir/frameworks/native/audiocapturer:audio_capturer_config" ] diff --git a/services/media_engine/modules/demuxer/base_stream_demuxer.cpp b/services/media_engine/modules/demuxer/base_stream_demuxer.cpp index 14ce096a766754a2de9d5e02f124995aca45cf4a..46683eb92acc2ea96b6209fb014f10f854f50383 100644 --- a/services/media_engine/modules/demuxer/base_stream_demuxer.cpp +++ b/services/media_engine/modules/demuxer/base_stream_demuxer.cpp @@ -35,6 +35,10 @@ #include "plugin/plugin_info.h" #include "plugin/plugin_time.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { diff --git a/services/media_engine/modules/demuxer/demuxer_plugin_manager.cpp b/services/media_engine/modules/demuxer/demuxer_plugin_manager.cpp index c688a5099351d4bd8fae2674da1e238d50017755..c0949e1c893651eaa88cf179e239258070bf7e02 100644 --- a/services/media_engine/modules/demuxer/demuxer_plugin_manager.cpp +++ b/services/media_engine/modules/demuxer/demuxer_plugin_manager.cpp @@ -38,6 +38,10 @@ #include "base_stream_demuxer.h" #include "media_demuxer.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { diff --git a/services/media_engine/modules/demuxer/frame_detector.cpp b/services/media_engine/modules/demuxer/frame_detector.cpp index 2c297b9322715709af79962b470437b75e885f04..cb7d289f866c2d9c2f6821bbaf4a7c467e60f46e 100644 --- a/services/media_engine/modules/demuxer/frame_detector.cpp +++ b/services/media_engine/modules/demuxer/frame_detector.cpp @@ -18,8 +18,6 @@ #include #include -#include "common/log.h" - namespace OHOS { namespace Media { using namespace std; diff --git a/services/media_engine/modules/demuxer/media_demuxer.cpp b/services/media_engine/modules/demuxer/media_demuxer.cpp index e8b241bbf33428d19ad4632e1943fbc89288cde2..b8ee5a645f65a47f2857c97800a80485b6d04a90 100755 --- a/services/media_engine/modules/demuxer/media_demuxer.cpp +++ b/services/media_engine/modules/demuxer/media_demuxer.cpp @@ -41,6 +41,7 @@ #include "demuxer_plugin_manager.h" namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_DEMUXER, "HiStreamer" }; const std::string DUMP_PARAM = "a"; const std::string DUMP_DEMUXER_AUDIO_FILE_NAME = "player_demuxer_audio_output.es"; const std::string DUMP_DEMUXER_VIDEO_FILE_NAME = "player_demuxer_video_output.es"; diff --git a/services/media_engine/modules/demuxer/stream_demuxer.cpp b/services/media_engine/modules/demuxer/stream_demuxer.cpp index 40bf242290ef5eb13a60d5b739be805afa1e108d..52ec93b5df2d61df3c6d4c3f2e7e1085fff8a8f1 100644 --- a/services/media_engine/modules/demuxer/stream_demuxer.cpp +++ b/services/media_engine/modules/demuxer/stream_demuxer.cpp @@ -36,6 +36,10 @@ #include "plugin/plugin_time.h" #include "source/source.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { diff --git a/services/media_engine/modules/demuxer/type_finder.cpp b/services/media_engine/modules/demuxer/type_finder.cpp index c300321e545666e7341f6dee1324f2cb6c2c8419..f9129219033d7ad972e9c70d09d71ccbade7141f 100644 --- a/services/media_engine/modules/demuxer/type_finder.cpp +++ b/services/media_engine/modules/demuxer/type_finder.cpp @@ -25,6 +25,10 @@ #include "plugin/plugin_info.h" #include "plugin/plugin_manager_v2.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_DEMUXER, "HiStreamer" }; +} + namespace OHOS { namespace Media { using namespace Plugins; diff --git a/services/media_engine/modules/media_codec/media_codec.cpp b/services/media_engine/modules/media_codec/media_codec.cpp index 927409ab9b4e46d1bfd0d33464dbe46ab0d57f2a..f240dd986f69c65ba932ff7f8a65e314da33d7eb 100644 --- a/services/media_engine/modules/media_codec/media_codec.cpp +++ b/services/media_engine/modules/media_codec/media_codec.cpp @@ -19,8 +19,10 @@ #include "avcodec_trace.h" #include "plugin/plugin_manager_v2.h" #include "osal/utils/dump_buffer.h" +#include "avcodec_log.h" namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_AUDIO, "MediaCodec" }; const std::string INPUT_BUFFER_QUEUE_NAME = "MediaCodecInputBufferQueue"; constexpr int32_t DEFAULT_BUFFER_NUM = 8; constexpr int32_t TIME_OUT_MS = 500; @@ -78,12 +80,12 @@ int32_t MediaCodec::Init(const std::string &mime, bool isEncoder) { AutoLock lock(stateMutex_); MediaAVCodec::AVCodecTrace trace("MediaCodec::Init"); - MEDIA_LOG_I("Init enter, mime: " PUBLIC_LOG_S, mime.c_str()); + AVCODEC_LOGI("Init enter, mime: %{public}s", mime.c_str()); if (state_ != CodecState::UNINITIALIZED) { - MEDIA_LOG_E("Init failed, state = %{public}s .", StateToString(state_).data()); + AVCODEC_LOGE("Init failed, state = %{public}s .", StateToString(state_).data()); return (int32_t)Status::ERROR_INVALID_STATE; } - MEDIA_LOG_I("state from %{public}s to INITIALIZING", StateToString(state_).data()); + AVCODEC_LOGI("state from %{public}s to INITIALIZING", StateToString(state_).data()); state_ = CodecState::INITIALIZING; Plugins::PluginType type; if (isEncoder) { @@ -93,12 +95,12 @@ int32_t MediaCodec::Init(const std::string &mime, bool isEncoder) } codecPlugin_ = CreatePlugin(mime, type); if (codecPlugin_ != nullptr) { - MEDIA_LOG_I("codecPlugin_->Init()"); + AVCODEC_LOGI("codecPlugin_->Init()"); auto ret = codecPlugin_->Init(); - FALSE_RETURN_V_MSG_E(ret == Status::OK, (int32_t)ret, "pluign init failed"); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)ret, "pluign init failed"); state_ = CodecState::INITIALIZED; } else { - MEDIA_LOG_I("createPlugin failed"); + AVCODEC_LOGI("createPlugin failed"); return (int32_t)Status::ERROR_INVALID_PARAMETER; } return (int32_t)Status::OK; @@ -107,20 +109,20 @@ int32_t MediaCodec::Init(const std::string &mime, bool isEncoder) int32_t MediaCodec::Init(const std::string &name) { AutoLock lock(stateMutex_); - MEDIA_LOG_I("Init enter, name: " PUBLIC_LOG_S, name.c_str()); - MEDIA_LOG_I("MediaCodec::Init"); + AVCODEC_LOGI("Init enter, name: %{public}s", name.c_str()); + AVCODEC_LOGI("MediaCodec::Init"); MediaAVCodec::AVCodecTrace trace("MediaCodec::Init"); if (state_ != CodecState::UNINITIALIZED) { - MEDIA_LOG_E("Init failed, state = %{public}s .", StateToString(state_).data()); + AVCODEC_LOGE("Init failed, state = %{public}s .", StateToString(state_).data()); return (int32_t)Status::ERROR_INVALID_STATE; } - MEDIA_LOG_I("state from %{public}s to INITIALIZING", StateToString(state_).data()); + AVCODEC_LOGI("state from %{public}s to INITIALIZING", StateToString(state_).data()); state_ = CodecState::INITIALIZING; auto plugin = Plugins::PluginManagerV2::Instance().CreatePluginByName(name); - FALSE_RETURN_V_MSG_E(plugin != nullptr, (int32_t)Status::ERROR_INVALID_PARAMETER, "create pluign failed"); + CHECK_AND_RETURN_RET_LOG(plugin != nullptr, (int32_t)Status::ERROR_INVALID_PARAMETER, "create pluign failed"); codecPlugin_ = std::reinterpret_pointer_cast(plugin); Status ret = codecPlugin_->Init(); - FALSE_RETURN_V_MSG_E(ret == Status::OK, (int32_t)Status::ERROR_INVALID_PARAMETER, "pluign init failed"); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)Status::ERROR_INVALID_PARAMETER, "pluign init failed"); state_ = CodecState::INITIALIZED; return (int32_t)Status::OK; } @@ -136,14 +138,15 @@ std::shared_ptr MediaCodec::CreatePlugin(const std::string int32_t MediaCodec::Configure(const std::shared_ptr &meta) { - MEDIA_LOG_I("MediaCodec::configure in"); + AVCODEC_LOGI("MediaCodec::configure in"); AutoLock lock(stateMutex_); MediaAVCodec::AVCodecTrace trace("MediaCodec::Configure"); - FALSE_RETURN_V(state_ == CodecState::INITIALIZED, (int32_t)Status::ERROR_INVALID_STATE); + CHECK_AND_RETURN_RET_LOG(state_ == CodecState::INITIALIZED, (int32_t)Status::ERROR_INVALID_STATE, + "state is not INITIALIZED"); auto ret = codecPlugin_->SetParameter(meta); - FALSE_RETURN_V(ret == Status::OK, (int32_t)ret); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)ret, "SetParameter failed."); ret = codecPlugin_->SetDataCallback(this); - FALSE_RETURN_V(ret == Status::OK, (int32_t)ret); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)ret, "SetDataCallback failed."); state_ = CodecState::CONFIGURED; return (int32_t)Status::OK; } @@ -152,8 +155,8 @@ int32_t MediaCodec::SetOutputBufferQueue(const sptr &buff { AutoLock lock(stateMutex_); MediaAVCodec::AVCodecTrace trace("MediaCodec::SetOutputBufferQueue"); - FALSE_RETURN_V(state_ == CodecState::INITIALIZED || state_ == CodecState::CONFIGURED, - (int32_t)Status::ERROR_INVALID_STATE); + CHECK_AND_RETURN_RET_LOG(state_ == CodecState::INITIALIZED || state_ == CodecState::CONFIGURED, + (int32_t)Status::ERROR_INVALID_STATE, "state is not INITIALIZED or CONFIGURED"); outputBufferQueueProducer_ = bufferQueueProducer; isBufferMode_ = true; return (int32_t)Status::OK; @@ -162,22 +165,22 @@ int32_t MediaCodec::SetOutputBufferQueue(const sptr &buff int32_t MediaCodec::SetCodecCallback(const std::shared_ptr &codecCallback) { AutoLock lock(stateMutex_); - FALSE_RETURN_V(state_ == CodecState::INITIALIZED || state_ == CodecState::CONFIGURED, - (int32_t)Status::ERROR_INVALID_STATE); - FALSE_RETURN_V_MSG_E(codecCallback != nullptr, (int32_t)Status::ERROR_INVALID_PARAMETER, - "codecCallback is nullptr"); + CHECK_AND_RETURN_RET_LOG(state_ == CodecState::INITIALIZED || state_ == CodecState::CONFIGURED, + (int32_t)Status::ERROR_INVALID_STATE, "state != INITIALIZED and state != CONFIGURED"); + CHECK_AND_RETURN_RET_LOG(codecCallback != nullptr, (int32_t)Status::ERROR_INVALID_PARAMETER, + "codecCallback is nullptr"); codecCallback_ = codecCallback; auto ret = codecPlugin_->SetDataCallback(this); - FALSE_RETURN_V(ret == Status::OK, (int32_t)ret); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)ret, "ret != Status::OK"); return (int32_t)Status::OK; } int32_t MediaCodec::SetCodecCallback(const std::shared_ptr &codecCallback) { AutoLock lock(stateMutex_); - FALSE_RETURN_V(state_ == CodecState::INITIALIZED || state_ == CodecState::CONFIGURED, - (int32_t)Status::ERROR_INVALID_STATE); - FALSE_RETURN_V_MSG_E(codecCallback != nullptr, (int32_t)Status::ERROR_INVALID_PARAMETER, + CHECK_AND_RETURN_RET_LOG(state_ == CodecState::INITIALIZED || state_ == CodecState::CONFIGURED, + (int32_t)Status::ERROR_INVALID_STATE, "state != INITIALIZED and state != CONFIGURED"); + CHECK_AND_RETURN_RET_LOG(codecCallback != nullptr, (int32_t)Status::ERROR_INVALID_PARAMETER, "codecCallback is nullptr"); mediaCodecCallback_ = codecCallback; return (int32_t)Status::OK; @@ -186,44 +189,44 @@ int32_t MediaCodec::SetCodecCallback(const std::shared_ptr surface) { AutoLock lock(stateMutex_); - FALSE_RETURN_V(state_ == CodecState::INITIALIZED || state_ == CodecState::CONFIGURED, - (int32_t)Status::ERROR_INVALID_STATE); + CHECK_AND_RETURN_RET_LOG(state_ == CodecState::INITIALIZED || state_ == CodecState::CONFIGURED, + (int32_t)Status::ERROR_INVALID_STATE, "state != INITIALIZED and state != CONFIGURED"); isSurfaceMode_ = true; return (int32_t)Status::OK; } int32_t MediaCodec::Prepare() { - MEDIA_LOG_I("Prepare enter"); + AVCODEC_LOGI("Prepare enter"); AutoLock lock(stateMutex_); MediaAVCodec::AVCodecTrace trace("MediaCodec::Prepare"); - FALSE_RETURN_V(state_ != CodecState::PREPARED, (int32_t)Status::OK); - FALSE_RETURN_V(state_ == CodecState::CONFIGURED || state_ == CodecState::FLUSHED, - (int32_t)Status::ERROR_INVALID_STATE); + CHECK_AND_RETURN_RET_LOG(state_ != CodecState::PREPARED, (int32_t)Status::OK, "state != PREPARED"); + CHECK_AND_RETURN_RET_LOG(state_ == CodecState::CONFIGURED || state_ == CodecState::FLUSHED, + (int32_t)Status::ERROR_INVALID_STATE, "state != CONFIGURED and state != FLUSHED"); if (isBufferMode_ && isSurfaceMode_) { - MEDIA_LOG_E("state error"); + AVCODEC_LOGE("state error"); return (int32_t)Status::ERROR_UNKNOWN; } outputBufferCapacity_ = 0; auto ret = (int32_t)PrepareInputBufferQueue(); if (ret != (int32_t)Status::OK) { - MEDIA_LOG_E("PrepareInputBufferQueue failed"); + AVCODEC_LOGE("PrepareInputBufferQueue failed"); return (int32_t)ret; } ret = (int32_t)PrepareOutputBufferQueue(); if (ret != (int32_t)Status::OK) { - MEDIA_LOG_E("PrepareOutputBufferQueue failed"); + AVCODEC_LOGE("PrepareOutputBufferQueue failed"); return (int32_t)ret; } state_ = CodecState::PREPARED; - MEDIA_LOG_I("Prepare, ret = %{public}d", (int32_t)ret); + AVCODEC_LOGI("Prepare, ret = %{public}d", (int32_t)ret); return (int32_t)Status::OK; } sptr MediaCodec::GetInputBufferQueue() { AutoLock lock(stateMutex_); - FALSE_RETURN_V(state_ == CodecState::PREPARED, sptr()); + CHECK_AND_RETURN_RET_LOG(state_ == CodecState::PREPARED, sptr(), "state != PREPARED"); if (isSurfaceMode_) { return nullptr; } @@ -234,7 +237,7 @@ sptr MediaCodec::GetInputBufferQueue() sptr MediaCodec::GetInputSurface() { AutoLock lock(stateMutex_); - FALSE_RETURN_V(state_ == CodecState::PREPARED, nullptr); + CHECK_AND_RETURN_RET_LOG(state_ == CodecState::PREPARED, nullptr, "state != PREPARED"); if (isBufferMode_) { return nullptr; } @@ -245,14 +248,14 @@ sptr MediaCodec::GetInputSurface() int32_t MediaCodec::Start() { AutoLock lock(stateMutex_); - MEDIA_LOG_I("Start enter"); + AVCODEC_LOGI("Start enter"); MediaAVCodec::AVCodecTrace trace("MediaCodec::Start"); - FALSE_RETURN_V(state_ != CodecState::RUNNING, (int32_t)Status::OK); - FALSE_RETURN_V(state_ == CodecState::PREPARED || state_ == CodecState::FLUSHED, - (int32_t)Status::ERROR_INVALID_STATE); + CHECK_AND_RETURN_RET_LOG(state_ != CodecState::RUNNING, (int32_t)Status::OK, "state != RUNNING"); + CHECK_AND_RETURN_RET_LOG(state_ == CodecState::PREPARED || state_ == CodecState::FLUSHED, + (int32_t)Status::ERROR_INVALID_STATE, "state != PREPARED and state != FLUSHED"); state_ = CodecState::STARTING; auto ret = codecPlugin_->Start(); - FALSE_RETURN_V_MSG_E(ret == Status::OK, (int32_t)ret, "plugin start failed"); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)ret, "plugin start failed"); state_ = CodecState::RUNNING; return (int32_t)ret; } @@ -261,18 +264,18 @@ int32_t MediaCodec::Stop() { AutoLock lock(stateMutex_); MediaAVCodec::AVCodecTrace trace("MediaCodec::Stop"); - MEDIA_LOG_I("Stop enter"); - FALSE_RETURN_V(state_ != CodecState::PREPARED, (int32_t)Status::OK); + AVCODEC_LOGI("Stop enter"); + CHECK_AND_RETURN_RET_LOG(state_ != CodecState::PREPARED, (int32_t)Status::OK, "state != PREPARED"); if (state_ == CodecState::UNINITIALIZED || state_ == CodecState::STOPPING || state_ == CodecState::RELEASING) { - MEDIA_LOG_D("Stop, state_=%{public}s", StateToString(state_).data()); + AVCODEC_LOGD("Stop, state_=%{public}s", StateToString(state_).data()); return (int32_t)Status::OK; } - FALSE_RETURN_V(state_ == CodecState::RUNNING || state_ == CodecState::END_OF_STREAM || - state_ == CodecState::FLUSHED, (int32_t)Status::ERROR_INVALID_STATE); + CHECK_AND_RETURN_RET_LOG(state_ == CodecState::RUNNING || state_ == CodecState::END_OF_STREAM || + state_ == CodecState::FLUSHED, (int32_t)Status::ERROR_INVALID_STATE, "state != RUNNING, EOS or FLUSHED"); state_ = CodecState::STOPPING; auto ret = codecPlugin_->Stop(); - MEDIA_LOG_I("codec Stop, state from %{public}s to Stop", StateToString(state_).data()); - FALSE_RETURN_V_MSG_E(ret == Status::OK, (int32_t)ret, "plugin stop failed"); + AVCODEC_LOGI("codec Stop, state from %{public}s to Stop", StateToString(state_).data()); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)ret, "plugin stop failed"); ClearInputBuffer(); state_ = CodecState::PREPARED; return (int32_t)ret; @@ -281,20 +284,20 @@ int32_t MediaCodec::Stop() int32_t MediaCodec::Flush() { AutoLock lock(stateMutex_); - MEDIA_LOG_I("Flush enter"); + AVCODEC_LOGI("Flush enter"); if (state_ == CodecState::FLUSHED) { - MEDIA_LOG_W("Flush, state is already flushed, state_=%{public}s .", StateToString(state_).data()); + AVCODEC_LOGW("Flush, state is already flushed, state_=%{public}s .", StateToString(state_).data()); return (int32_t)Status::OK; } if (state_ != CodecState::RUNNING && state_ != CodecState::END_OF_STREAM) { - MEDIA_LOG_E("Flush failed, state =%{public}s", StateToString(state_).data()); + AVCODEC_LOGE("Flush failed, state =%{public}s", StateToString(state_).data()); return (int32_t)Status::ERROR_INVALID_STATE; } - MEDIA_LOG_I("Flush, state from %{public}s to FLUSHING", StateToString(state_).data()); + AVCODEC_LOGI("Flush, state from %{public}s to FLUSHING", StateToString(state_).data()); state_ = CodecState::FLUSHING; inputBufferQueueProducer_->Clear(); auto ret = codecPlugin_->Flush(); - FALSE_RETURN_V_MSG_E(ret == Status::OK, (int32_t)ret, "plugin flush failed"); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)ret, "plugin flush failed"); ClearInputBuffer(); state_ = CodecState::FLUSHED; return (int32_t)ret; @@ -304,18 +307,18 @@ int32_t MediaCodec::Reset() { AutoLock lock(stateMutex_); MediaAVCodec::AVCodecTrace trace("MediaCodec::Reset"); - MEDIA_LOG_I("Reset enter"); + AVCODEC_LOGI("Reset enter"); if (state_ == CodecState::UNINITIALIZED || state_ == CodecState::RELEASING) { - MEDIA_LOG_W("adapter reset, state is already released, state =%{public}s .", StateToString(state_).data()); + AVCODEC_LOGW("adapter reset, state is already released, state =%{public}s .", StateToString(state_).data()); return (int32_t)Status::OK; } if (state_ == CodecState::INITIALIZING) { - MEDIA_LOG_W("adapter reset, state is initialized, state =%{public}s .", StateToString(state_).data()); + AVCODEC_LOGW("adapter reset, state is initialized, state =%{public}s .", StateToString(state_).data()); state_ = CodecState::INITIALIZED; return (int32_t)Status::OK; } auto ret = codecPlugin_->Reset(); - FALSE_RETURN_V_MSG_E(ret == Status::OK, (int32_t)ret, "plugin reset failed"); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)ret, "plugin reset failed"); ClearInputBuffer(); state_ = CodecState::INITIALIZED; return (int32_t)ret; @@ -325,21 +328,23 @@ int32_t MediaCodec::Release() { AutoLock lock(stateMutex_); MediaAVCodec::AVCodecTrace trace("MediaCodec::Release"); - MEDIA_LOG_I("Release enter"); + AVCODEC_LOGI("Release enter"); if (state_ == CodecState::UNINITIALIZED || state_ == CodecState::RELEASING) { - MEDIA_LOG_W("codec Release, state isnot completely correct, state =%{public}s .", StateToString(state_).data()); + AVCODEC_LOGW("codec Release, state isnot completely correct, state =%{public}s .", + StateToString(state_).data()); return (int32_t)Status::OK; } if (state_ == CodecState::INITIALIZING) { - MEDIA_LOG_W("codec Release, state isnot completely correct, state =%{public}s .", StateToString(state_).data()); + AVCODEC_LOGW("codec Release, state isnot completely correct, state =%{public}s .", + StateToString(state_).data()); state_ = CodecState::RELEASING; return (int32_t)Status::OK; } - MEDIA_LOG_I("codec Release, state from %{public}s to RELEASING", StateToString(state_).data()); + AVCODEC_LOGI("codec Release, state from %{public}s to RELEASING", StateToString(state_).data()); state_ = CodecState::RELEASING; auto ret = codecPlugin_->Release(); - FALSE_RETURN_V_MSG_E(ret == Status::OK, (int32_t)ret, "plugin release failed"); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)ret, "plugin release failed"); codecPlugin_ = nullptr; ClearBufferQueue(); state_ = CodecState::UNINITIALIZED; @@ -349,8 +354,8 @@ int32_t MediaCodec::Release() int32_t MediaCodec::NotifyEos() { AutoLock lock(stateMutex_); - FALSE_RETURN_V(state_ != CodecState::END_OF_STREAM, (int32_t)Status::OK); - FALSE_RETURN_V(state_ == CodecState::RUNNING, (int32_t)Status::ERROR_INVALID_STATE); + CHECK_AND_RETURN_RET_LOG(state_ != CodecState::END_OF_STREAM, (int32_t)Status::OK, "state not EOS"); + CHECK_AND_RETURN_RET_LOG(state_ == CodecState::RUNNING, (int32_t)Status::ERROR_INVALID_STATE, "state not RUNNING"); state_ = CodecState::END_OF_STREAM; return (int32_t)Status::OK; } @@ -358,18 +363,18 @@ int32_t MediaCodec::NotifyEos() int32_t MediaCodec::SetParameter(const std::shared_ptr ¶meter) { AutoLock lock(stateMutex_); - FALSE_RETURN_V(parameter != nullptr, (int32_t)Status::ERROR_INVALID_PARAMETER); - FALSE_RETURN_V(state_ != CodecState::UNINITIALIZED && state_ != CodecState::INITIALIZED && - state_ != CodecState::PREPARED, (int32_t)Status::ERROR_INVALID_STATE); + CHECK_AND_RETURN_RET_LOG(parameter != nullptr, (int32_t)Status::ERROR_INVALID_PARAMETER, "parameter is nullptr"); + CHECK_AND_RETURN_RET_LOG(state_ != CodecState::UNINITIALIZED && state_ != CodecState::INITIALIZED && + state_ != CodecState::PREPARED, (int32_t)Status::ERROR_INVALID_STATE, "state is invalid"); auto ret = codecPlugin_->SetParameter(parameter); - FALSE_RETURN_V_MSG_E(ret == Status::OK, (int32_t)ret, "plugin set parameter failed"); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)ret, "plugin set parameter failed"); return (int32_t)ret; } void MediaCodec::SetDumpInfo(bool isDump, uint64_t instanceId) { if (isDump && instanceId == 0) { - MEDIA_LOG_W("Cannot dump with instanceId 0."); + AVCODEC_LOGW("Cannot dump with instanceId 0."); return; } dumpPrefix_ = std::to_string(instanceId); @@ -379,18 +384,18 @@ void MediaCodec::SetDumpInfo(bool isDump, uint64_t instanceId) int32_t MediaCodec::GetOutputFormat(std::shared_ptr ¶meter) { AutoLock lock(stateMutex_); - FALSE_RETURN_V_MSG_E(state_ != CodecState::UNINITIALIZED, (int32_t)Status::ERROR_INVALID_STATE, - "status incorrect,get output format failed."); - FALSE_RETURN_V(codecPlugin_ != nullptr, (int32_t)Status::ERROR_INVALID_STATE); - FALSE_RETURN_V(parameter != nullptr, (int32_t)Status::ERROR_INVALID_PARAMETER); + CHECK_AND_RETURN_RET_LOG(state_ != CodecState::UNINITIALIZED, (int32_t)Status::ERROR_INVALID_STATE, + "status incorrect,get output format failed."); + CHECK_AND_RETURN_RET_LOG(codecPlugin_ != nullptr, (int32_t)Status::ERROR_INVALID_STATE, "codecPlugin_ is nullptr"); + CHECK_AND_RETURN_RET_LOG(parameter != nullptr, (int32_t)Status::ERROR_INVALID_PARAMETER, "parameter is nullptr"); auto ret = codecPlugin_->GetParameter(parameter); - FALSE_RETURN_V_MSG_E(ret == Status::OK, (int32_t)ret, "plugin get parameter failed"); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)ret, "plugin get parameter failed"); return (int32_t)ret; } Status MediaCodec::AttachBufffer() { - MEDIA_LOG_I("AttachBufffer enter"); + AVCODEC_LOGI("AttachBufffer enter"); int inputBufferNum = DEFAULT_BUFFER_NUM; MemoryType memoryType; #ifndef MEDIA_OHOS @@ -401,34 +406,32 @@ Status MediaCodec::AttachBufffer() if (inputBufferQueue_ == nullptr) { inputBufferQueue_ = AVBufferQueue::Create(inputBufferNum, memoryType, INPUT_BUFFER_QUEUE_NAME); } - FALSE_RETURN_V_MSG_E(inputBufferQueue_ != nullptr, Status::ERROR_UNKNOWN, - "inputBufferQueue_ is nullptr"); + CHECK_AND_RETURN_RET_LOG(inputBufferQueue_ != nullptr, Status::ERROR_UNKNOWN, "inputBufferQueue_ is nullptr"); inputBufferQueueProducer_ = inputBufferQueue_->GetProducer(); std::shared_ptr inputBufferConfig = std::make_shared(); - FALSE_RETURN_V_MSG_E(codecPlugin_ != nullptr, Status::ERROR_UNKNOWN, "codecPlugin_ is nullptr"); + CHECK_AND_RETURN_RET_LOG(codecPlugin_ != nullptr, Status::ERROR_UNKNOWN, "codecPlugin_ is nullptr"); auto ret = codecPlugin_->GetParameter(inputBufferConfig); - FALSE_RETURN_V_MSG_E(ret == Status::OK, ret, "attachBufffer failed, plugin get param error"); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, ret, "attachBufffer failed, plugin get param error"); int32_t capacity = 0; - FALSE_RETURN_V_MSG_E(inputBufferConfig != nullptr, Status::ERROR_UNKNOWN, - "inputBufferConfig is nullptr"); - FALSE_RETURN_V(inputBufferConfig->Get(capacity), - Status::ERROR_INVALID_PARAMETER); + CHECK_AND_RETURN_RET_LOG(inputBufferConfig != nullptr, Status::ERROR_UNKNOWN, + "inputBufferConfig is nullptr"); + CHECK_AND_RETURN_RET_LOG(inputBufferConfig->Get(capacity), + Status::ERROR_INVALID_PARAMETER, "get AUDIO_MAX_INPUT_SIZE failed"); for (int i = 0; i < inputBufferNum; i++) { std::shared_ptr avAllocator; #ifndef MEDIA_OHOS - MEDIA_LOG_D("CreateVirtualAllocator,i=%{public}d capacity=%{public}d", i, capacity); + AVCODEC_LOGD("CreateVirtualAllocator,i=%{public}d capacity=%{public}d", i, capacity); avAllocator = AVAllocatorFactory::CreateVirtualAllocator(); #else - MEDIA_LOG_D("CreateSharedAllocator,i=%{public}d capacity=%{public}d", i, capacity); + AVCODEC_LOGD("CreateSharedAllocator,i=%{public}d capacity=%{public}d", i, capacity); avAllocator = AVAllocatorFactory::CreateSharedAllocator(MemoryFlag::MEMORY_READ_WRITE); #endif std::shared_ptr inputBuffer = AVBuffer::CreateAVBuffer(avAllocator, capacity); - FALSE_RETURN_V_MSG_E(inputBuffer != nullptr, Status::ERROR_UNKNOWN, - "inputBuffer is nullptr"); - FALSE_RETURN_V_MSG_E(inputBufferQueueProducer_ != nullptr, Status::ERROR_UNKNOWN, - "inputBufferQueueProducer_ is nullptr"); + CHECK_AND_RETURN_RET_LOG(inputBuffer != nullptr, Status::ERROR_UNKNOWN, "inputBuffer is nullptr"); + CHECK_AND_RETURN_RET_LOG(inputBufferQueueProducer_ != nullptr, Status::ERROR_UNKNOWN, + "inputBufferQueueProducer_ is nullptr"); inputBufferQueueProducer_->AttachBuffer(inputBuffer, false); - MEDIA_LOG_I("Attach intput buffer. index: %{public}d, bufferId: %{public}" PRIu64, + AVCODEC_LOGI("Attach intput buffer. index: %{public}d, bufferId: %{public}" PRIu64, i, inputBuffer->GetUniqueId()); inputBufferVector_.push_back(inputBuffer); } @@ -438,23 +441,23 @@ Status MediaCodec::AttachBufffer() Status MediaCodec::AttachDrmBufffer(std::shared_ptr &drmInbuf, std::shared_ptr &drmOutbuf, uint32_t size) { - MEDIA_LOG_D("AttachDrmBufffer"); + AVCODEC_LOGD("AttachDrmBufffer"); std::shared_ptr avAllocator; avAllocator = AVAllocatorFactory::CreateSharedAllocator(MemoryFlag::MEMORY_READ_WRITE); - FALSE_RETURN_V_MSG_E(avAllocator != nullptr, Status::ERROR_UNKNOWN, + CHECK_AND_RETURN_RET_LOG(avAllocator != nullptr, Status::ERROR_UNKNOWN, "avAllocator is nullptr"); drmInbuf = AVBuffer::CreateAVBuffer(avAllocator, size); - FALSE_RETURN_V_MSG_E(drmInbuf != nullptr, Status::ERROR_UNKNOWN, + CHECK_AND_RETURN_RET_LOG(drmInbuf != nullptr, Status::ERROR_UNKNOWN, "drmInbuf is nullptr"); - FALSE_RETURN_V_MSG_E(drmInbuf->memory_ != nullptr, Status::ERROR_UNKNOWN, + CHECK_AND_RETURN_RET_LOG(drmInbuf->memory_ != nullptr, Status::ERROR_UNKNOWN, "drmInbuf->memory_ is nullptr"); drmInbuf->memory_->SetSize(size); drmOutbuf = AVBuffer::CreateAVBuffer(avAllocator, size); - FALSE_RETURN_V_MSG_E(drmOutbuf != nullptr, Status::ERROR_UNKNOWN, + CHECK_AND_RETURN_RET_LOG(drmOutbuf != nullptr, Status::ERROR_UNKNOWN, "drmOutbuf is nullptr"); - FALSE_RETURN_V_MSG_E(drmOutbuf->memory_ != nullptr, Status::ERROR_UNKNOWN, + CHECK_AND_RETURN_RET_LOG(drmOutbuf->memory_ != nullptr, Status::ERROR_UNKNOWN, "drmOutbuf->memory_ is nullptr"); drmOutbuf->memory_->SetSize(size); return Status::OK; @@ -462,50 +465,50 @@ Status MediaCodec::AttachDrmBufffer(std::shared_ptr &drmInbuf, std::sh Status MediaCodec::DrmAudioCencDecrypt(std::shared_ptr &filledInputBuffer) { - MEDIA_LOG_D("DrmAudioCencDecrypt enter"); + AVCODEC_LOGD("DrmAudioCencDecrypt enter"); Status ret = Status::OK; // 1. allocate drm buffer uint32_t bufSize = static_cast(filledInputBuffer->memory_->GetSize()); if (bufSize == 0) { - MEDIA_LOG_D("MediaCodec DrmAudioCencDecrypt input buffer size equal 0"); + AVCODEC_LOGD("MediaCodec DrmAudioCencDecrypt input buffer size equal 0"); return ret; } std::shared_ptr drmInBuf; std::shared_ptr drmOutBuf; ret = AttachDrmBufffer(drmInBuf, drmOutBuf, bufSize); - FALSE_RETURN_V_MSG_E(ret == Status::OK, Status::ERROR_UNKNOWN, "AttachDrmBufffer failed"); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, Status::ERROR_UNKNOWN, "AttachDrmBufffer failed"); // 2. copy data to drm input buffer int32_t drmRes = memcpy_s(drmInBuf->memory_->GetAddr(), bufSize, filledInputBuffer->memory_->GetAddr(), bufSize); - FALSE_RETURN_V_MSG_E(drmRes == 0, Status::ERROR_UNKNOWN, "memcpy_s drmInBuf failed"); + CHECK_AND_RETURN_RET_LOG(drmRes == 0, Status::ERROR_UNKNOWN, "memcpy_s drmInBuf failed"); if (filledInputBuffer->meta_ != nullptr) { *(drmInBuf->meta_) = *(filledInputBuffer->meta_); } // 4. decrypt drmRes = drmDecryptor_->DrmAudioCencDecrypt(drmInBuf, drmOutBuf, bufSize); - FALSE_RETURN_V_MSG_E(drmRes == 0, Status::ERROR_UNKNOWN, "DrmAudioCencDecrypt return error"); + CHECK_AND_RETURN_RET_LOG(drmRes == 0, Status::ERROR_UNKNOWN, "DrmAudioCencDecrypt return error"); // 5. copy decrypted data from drm output buffer back drmRes = memcpy_s(filledInputBuffer->memory_->GetAddr(), bufSize, drmOutBuf->memory_->GetAddr(), bufSize); - FALSE_RETURN_V_MSG_E(drmRes == 0, Status::ERROR_UNKNOWN, "memcpy_s drmOutBuf failed"); + CHECK_AND_RETURN_RET_LOG(drmRes == 0, Status::ERROR_UNKNOWN, "memcpy_s drmOutBuf failed"); return Status::OK; } int32_t MediaCodec::PrepareInputBufferQueue() { - MEDIA_LOG_I("PrepareInputBufferQueue enter"); + AVCODEC_LOGI("PrepareInputBufferQueue enter"); std::vector> inputBuffers; MediaAVCodec::AVCodecTrace trace("MediaCodec::PrepareInputBufferQueue"); - FALSE_RETURN_V_MSG_E(codecPlugin_ != nullptr, (int32_t)Status::ERROR_UNKNOWN, "codecPlugin_ is nullptr"); + CHECK_AND_RETURN_RET_LOG(codecPlugin_ != nullptr, (int32_t)Status::ERROR_UNKNOWN, "codecPlugin_ is nullptr"); auto ret = codecPlugin_->GetInputBuffers(inputBuffers); - FALSE_RETURN_V_MSG_E(ret == Status::OK, (int32_t)ret, "pluign getInputBuffers failed"); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)ret, "pluign getInputBuffers failed"); if (inputBuffers.empty()) { ret = AttachBufffer(); if (ret != Status::OK) { - MEDIA_LOG_E("GetParameter failed"); + AVCODEC_LOGE("GetParameter failed"); return (int32_t)ret; } } else { @@ -513,49 +516,50 @@ int32_t MediaCodec::PrepareInputBufferQueue() inputBufferQueue_ = AVBufferQueue::Create(inputBuffers.size(), MemoryType::HARDWARE_MEMORY, INPUT_BUFFER_QUEUE_NAME); } - FALSE_RETURN_V_MSG_E(inputBufferQueue_ != nullptr, (int32_t)Status::ERROR_UNKNOWN, - "inputBufferQueue_ is nullptr"); + CHECK_AND_RETURN_RET_LOG(inputBufferQueue_ != nullptr, (int32_t)Status::ERROR_UNKNOWN, + "inputBufferQueue_ is nullptr"); inputBufferQueueProducer_ = inputBufferQueue_->GetProducer(); for (uint32_t i = 0; i < inputBuffers.size(); i++) { inputBufferQueueProducer_->AttachBuffer(inputBuffers[i], false); inputBufferVector_.push_back(inputBuffers[i]); } } - FALSE_RETURN_V_MSG_E(inputBufferQueue_ != nullptr, (int32_t)Status::ERROR_UNKNOWN, "inputBufferQueue_ is nullptr"); + CHECK_AND_RETURN_RET_LOG(inputBufferQueue_ != nullptr, (int32_t)Status::ERROR_UNKNOWN, + "inputBufferQueue_ is nullptr"); inputBufferQueueConsumer_ = inputBufferQueue_->GetConsumer(); sptr listener = new InputBufferAvailableListener(this); - FALSE_RETURN_V_MSG_E(inputBufferQueueConsumer_ != nullptr, (int32_t)Status::ERROR_UNKNOWN, - "inputBufferQueueConsumer_ is nullptr"); + CHECK_AND_RETURN_RET_LOG(inputBufferQueueConsumer_ != nullptr, (int32_t)Status::ERROR_UNKNOWN, + "inputBufferQueueConsumer_ is nullptr"); inputBufferQueueConsumer_->SetBufferAvailableListener(listener); return (int32_t)ret; } int32_t MediaCodec::PrepareOutputBufferQueue() { - MEDIA_LOG_I("PrepareOutputBufferQueue enter"); + AVCODEC_LOGI("PrepareOutputBufferQueue enter"); std::vector> outputBuffers; MediaAVCodec::AVCodecTrace trace("MediaCodec::PrepareOutputBufferQueue"); - FALSE_RETURN_V_MSG_E(codecPlugin_ != nullptr, (int32_t)Status::ERROR_INVALID_STATE, "codecPlugin_ is nullptr"); + CHECK_AND_RETURN_RET_LOG(codecPlugin_ != nullptr, (int32_t)Status::ERROR_INVALID_STATE, "codecPlugin_ is nullptr"); auto ret = codecPlugin_->GetOutputBuffers(outputBuffers); - FALSE_RETURN_V_MSG_E(ret == Status::OK, (int32_t)ret, "GetOutputBuffers failed"); - FALSE_RETURN_V_MSG_E(outputBufferQueueProducer_ != nullptr, (int32_t)Status::ERROR_INVALID_STATE, - "outputBufferQueueProducer_ is nullptr"); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)ret, "GetOutputBuffers failed"); + CHECK_AND_RETURN_RET_LOG(outputBufferQueueProducer_ != nullptr, (int32_t)Status::ERROR_INVALID_STATE, + "outputBufferQueueProducer_ is nullptr"); if (outputBuffers.empty()) { int outputBufferNum = 30; std::shared_ptr outputBufferConfig = std::make_shared(); ret = codecPlugin_->GetParameter(outputBufferConfig); - FALSE_RETURN_V_MSG_E(ret == Status::OK, (int32_t)ret, "GetParameter failed"); - FALSE_RETURN_V_MSG_E(outputBufferConfig != nullptr, (int32_t)Status::ERROR_INVALID_STATE, - "outputBufferConfig is nullptr"); - FALSE_RETURN_V(outputBufferConfig->Get(outputBufferCapacity_), - (int32_t)Status::ERROR_INVALID_PARAMETER); + CHECK_AND_RETURN_RET_LOG(ret == Status::OK, (int32_t)ret, "GetParameter failed"); + CHECK_AND_RETURN_RET_LOG(outputBufferConfig != nullptr, (int32_t)Status::ERROR_INVALID_STATE, + "outputBufferConfig is nullptr"); + CHECK_AND_RETURN_RET_LOG(outputBufferConfig->Get(outputBufferCapacity_), + (int32_t)Status::ERROR_INVALID_PARAMETER, "get AUDIO_MAX_OUTPUT_SIZE failed"); for (int i = 0; i < outputBufferNum; i++) { auto avAllocator = AVAllocatorFactory::CreateSharedAllocator(MemoryFlag::MEMORY_READ_WRITE); std::shared_ptr outputBuffer = AVBuffer::CreateAVBuffer(avAllocator, outputBufferCapacity_); - FALSE_RETURN_V_MSG_E(outputBuffer != nullptr, (int32_t)Status::ERROR_INVALID_STATE, - "outputBuffer is nullptr"); + CHECK_AND_RETURN_RET_LOG(outputBuffer != nullptr, (int32_t)Status::ERROR_INVALID_STATE, + "outputBuffer is nullptr"); if (outputBufferQueueProducer_->AttachBuffer(outputBuffer, false) == Status::OK) { - MEDIA_LOG_D("Attach output buffer. index: %{public}d, bufferId: %{public}" PRIu64, i, + AVCODEC_LOGD("Attach output buffer. index: %{public}d, bufferId: %{public}" PRIu64, i, outputBuffer->GetUniqueId()); outputBufferVector_.push_back(outputBuffer); } @@ -563,34 +567,34 @@ int32_t MediaCodec::PrepareOutputBufferQueue() } else { for (uint32_t i = 0; i < outputBuffers.size(); i++) { if (outputBufferQueueProducer_->AttachBuffer(outputBuffers[i], false) == Status::OK) { - MEDIA_LOG_D("Attach output buffer. index: %{public}d, bufferId: %{public}" PRIu64, i, + AVCODEC_LOGD("Attach output buffer. index: %{public}d, bufferId: %{public}" PRIu64, i, outputBuffers[i]->GetUniqueId()); outputBufferVector_.push_back(outputBuffers[i]); } } } - FALSE_RETURN_V_MSG_E(outputBufferVector_.size() > 0, (int32_t)Status::ERROR_INVALID_STATE, "Attach no buffer"); + CHECK_AND_RETURN_RET_LOG(outputBufferVector_.size() > 0, (int32_t)Status::ERROR_INVALID_STATE, "Attach no buffer"); return (int32_t)ret; } void MediaCodec::ProcessInputBuffer() { - MEDIA_LOG_D("ProcessInputBuffer enter"); + AVCODEC_LOGD("ProcessInputBuffer enter"); MediaAVCodec::AVCodecTrace trace("MediaCodec::ProcessInputBuffer"); Status ret; uint32_t eosStatus = 0; std::shared_ptr filledInputBuffer; if (state_ != CodecState::RUNNING) { - MEDIA_LOG_E("status changed, current status is not running in ProcessInputBuffer"); + AVCODEC_LOGE("status changed, current status is not running in ProcessInputBuffer"); return; } ret = inputBufferQueueConsumer_->AcquireBuffer(filledInputBuffer); if (ret != Status::OK) { - MEDIA_LOG_E("ProcessInputBuffer AcquireBuffer fail"); + AVCODEC_LOGE("ProcessInputBuffer AcquireBuffer fail"); return; } if (state_ != CodecState::RUNNING) { - MEDIA_LOG_D("ProcessInputBuffer ReleaseBuffer name:MediaCodecInputBufferQueue"); + AVCODEC_LOGD("ProcessInputBuffer ReleaseBuffer name:MediaCodecInputBufferQueue"); inputBufferQueueConsumer_->ReleaseBuffer(filledInputBuffer); return; } @@ -600,7 +604,7 @@ void MediaCodec::ProcessInputBuffer() if (drmDecryptor_ != nullptr) { ret = DrmAudioCencDecrypt(filledInputBuffer); if (ret != Status::OK) { - MEDIA_LOG_E("MediaCodec DrmAudioCencDecrypt failed."); + AVCODEC_LOGE("MediaCodec DrmAudioCencDecrypt failed."); break; } } @@ -614,7 +618,7 @@ void MediaCodec::ProcessInputBuffer() if (ret != Status::OK) { inputBufferQueueConsumer_->ReleaseBuffer(filledInputBuffer); - MEDIA_LOG_E("Plugin queueInputBuffer failed."); + AVCODEC_LOGE("Plugin queueInputBuffer failed."); return; } eosStatus = filledInputBuffer->flag_; @@ -627,11 +631,11 @@ void MediaCodec::ProcessInputBuffer() int32_t MediaCodec::SetAudioDecryptionConfig(const sptr &keySession, const bool svpFlag) { - MEDIA_LOG_I("MediaCodec::SetAudioDecryptionConfig"); + AVCODEC_LOGI("MediaCodec::SetAudioDecryptionConfig"); if (drmDecryptor_ == nullptr) { drmDecryptor_ = std::make_shared(); } - FALSE_RETURN_V_MSG_E(drmDecryptor_ != nullptr, (int32_t)Status::ERROR_NO_MEMORY, "drmDecryptor is nullptr"); + CHECK_AND_RETURN_RET_LOG(drmDecryptor_ != nullptr, (int32_t)Status::ERROR_NO_MEMORY, "drmDecryptor is nullptr"); drmDecryptor_->SetDecryptionConfig(keySession, svpFlag); return (int32_t)Status::OK; } @@ -639,7 +643,7 @@ int32_t MediaCodec::SetAudioDecryptionConfig(const sptr &keySession, const bool svpFlag) { - MEDIA_LOG_I("MediaCodec::SetAudioDecryptionConfig, Not support"); + AVCODEC_LOGI("MediaCodec::SetAudioDecryptionConfig, Not support"); (void)keySession; (void)svpFlag; return (int32_t)Status::OK; @@ -662,19 +666,19 @@ Status MediaCodec::ChangePlugin(const std::string &mime, bool isEncoder, const s codecPlugin_ = CreatePlugin(mime, type); if (codecPlugin_ != nullptr) { ret = codecPlugin_->SetParameter(meta); - MEDIA_LOG_I("codecPlugin SetParameter ret %{public}d", ret); + AVCODEC_LOGI("codecPlugin SetParameter ret %{public}d", ret); ret = codecPlugin_->Init(); - MEDIA_LOG_I("codecPlugin Init ret %{public}d", ret); + AVCODEC_LOGI("codecPlugin Init ret %{public}d", ret); ret = codecPlugin_->SetDataCallback(this); - MEDIA_LOG_I("codecPlugin SetDataCallback ret %{public}d", ret); + AVCODEC_LOGI("codecPlugin SetDataCallback ret %{public}d", ret); PrepareInputBufferQueue(); PrepareOutputBufferQueue(); if (state_ == CodecState::RUNNING) { ret = codecPlugin_->Start(); - MEDIA_LOG_I("codecPlugin Start ret %{public}d", ret); + AVCODEC_LOGI("codecPlugin Start ret %{public}d", ret); } } else { - MEDIA_LOG_I("createPlugin failed"); + AVCODEC_LOGI("createPlugin failed"); return Status::ERROR_INVALID_PARAMETER; } return ret; @@ -682,7 +686,7 @@ Status MediaCodec::ChangePlugin(const std::string &mime, bool isEncoder, const s Status MediaCodec::HandleOutputBuffer(uint32_t eosStatus) { - MEDIA_LOG_D("HandleOutputBuffer enter"); + AVCODEC_LOGD("HandleOutputBuffer enter"); Status ret = Status::OK; std::shared_ptr emptyOutputBuffer; AVBufferConfig avBufferConfig; @@ -699,14 +703,14 @@ Status MediaCodec::HandleOutputBuffer(uint32_t eosStatus) } ret = codecPlugin_->QueueOutputBuffer(emptyOutputBuffer); if (ret == Status::ERROR_NOT_ENOUGH_DATA) { - MEDIA_LOG_D("QueueOutputBuffer ERROR_NOT_ENOUGH_DATA"); + AVCODEC_LOGD("QueueOutputBuffer ERROR_NOT_ENOUGH_DATA"); outputBufferQueueProducer_->PushBuffer(emptyOutputBuffer, false); } else if (ret == Status::ERROR_AGAIN) { - MEDIA_LOG_D("The output data is not completely read, needs to be read again"); + AVCODEC_LOGD("The output data is not completely read, needs to be read again"); } else if (ret == Status::END_OF_STREAM) { - MEDIA_LOG_D("HandleOutputBuffer END_OF_STREAM"); + AVCODEC_LOGD("HandleOutputBuffer END_OF_STREAM"); } else if (ret != Status::OK) { - MEDIA_LOG_E("QueueOutputBuffer error"); + AVCODEC_LOGE("QueueOutputBuffer error"); outputBufferQueueProducer_->PushBuffer(emptyOutputBuffer, false); } return ret; @@ -716,9 +720,9 @@ void MediaCodec::OnInputBufferDone(const std::shared_ptr &inputBuffer) { MediaAVCodec::AVCodecTrace trace("MediaCodec::OnInputBufferDone"); Status ret = inputBufferQueueConsumer_->ReleaseBuffer(inputBuffer); - MEDIA_LOG_D("0x%{public}06" PRIXPTR " OnInputBufferDone, buffer->pts" PUBLIC_LOG_D64, + AVCODEC_LOGD("0x%{public}06" PRIXPTR " OnInputBufferDone, buffer->pts %{public}lld", FAKE_POINTER(this), inputBuffer->pts_); - FALSE_RETURN_MSG(ret == Status::OK, "OnInputBufferDone fail"); + CHECK_AND_RETURN_LOG(ret == Status::OK, "OnInputBufferDone fail"); } void MediaCodec::OnOutputBufferDone(const std::shared_ptr &outputBuffer) @@ -731,14 +735,14 @@ void MediaCodec::OnOutputBufferDone(const std::shared_ptr &outputBuffe if (mediaCodecCallback_) { mediaCodecCallback_->OnOutputBufferDone(outputBuffer); } - MEDIA_LOG_D("0x%{public}06" PRIXPTR " OnOutputBufferDone, buffer->pts" PUBLIC_LOG_D64, + AVCODEC_LOGD("0x%{public}06" PRIXPTR " OnOutputBufferDone, buffer->pts %{public}lld", FAKE_POINTER(this), outputBuffer->pts_); - FALSE_RETURN_MSG(ret == Status::OK, "OnOutputBufferDone fail"); + CHECK_AND_RETURN_LOG(ret == Status::OK, "OnOutputBufferDone fail"); } void MediaCodec::ClearBufferQueue() { - MEDIA_LOG_I("ClearBufferQueue called."); + AVCODEC_LOGI("ClearBufferQueue called."); if (inputBufferQueueProducer_ != nullptr) { for (auto &buffer : inputBufferVector_) { inputBufferQueueProducer_->DetachBuffer(buffer); @@ -758,7 +762,7 @@ void MediaCodec::ClearBufferQueue() void MediaCodec::ClearInputBuffer() { MediaAVCodec::AVCodecTrace trace("MediaCodec::ClearInputBuffer"); - MEDIA_LOG_D("ClearInputBuffer enter"); + AVCODEC_LOGD("ClearInputBuffer enter"); if (!inputBufferQueueConsumer_) { return; } @@ -767,7 +771,7 @@ void MediaCodec::ClearInputBuffer() while (ret == Status::OK) { ret = inputBufferQueueConsumer_->AcquireBuffer(filledInputBuffer); if (ret != Status::OK) { - MEDIA_LOG_I("clear input Buffer"); + AVCODEC_LOGI("clear input Buffer"); return; } inputBufferQueueConsumer_->ReleaseBuffer(filledInputBuffer); @@ -795,9 +799,9 @@ std::string MediaCodec::StateToString(CodecState state) void MediaCodec::OnDumpInfo(int32_t fd) { - MEDIA_LOG_D("MediaCodec::OnDumpInfo called."); + AVCODEC_LOGD("MediaCodec::OnDumpInfo called."); if (fd < 0) { - MEDIA_LOG_E("MediaCodec::OnDumpInfo fd is invalid."); + AVCODEC_LOGE("MediaCodec::OnDumpInfo fd is invalid."); return; } std::string dumpString; @@ -805,7 +809,7 @@ void MediaCodec::OnDumpInfo(int32_t fd) dumpString += "MediaCodec buffer size is:" + std::to_string(inputBufferQueue_->GetQueueSize()) + "\n"; int ret = write(fd, dumpString.c_str(), dumpString.size()); if (ret < 0) { - MEDIA_LOG_E("MediaCodec::OnDumpInfo write failed."); + AVCODEC_LOGE("MediaCodec::OnDumpInfo write failed."); return; } } diff --git a/services/media_engine/modules/media_codec/media_codec.h b/services/media_engine/modules/media_codec/media_codec.h index 08601fbdbcb267df535e15125e77e7ae01693b15..05f3a39826a388fe94592d82b44b0d6e42a5c7c0 100644 --- a/services/media_engine/modules/media_codec/media_codec.h +++ b/services/media_engine/modules/media_codec/media_codec.h @@ -25,7 +25,6 @@ #include "buffer/avbuffer_queue_producer.h" #include "buffer/avbuffer_queue_consumer.h" #include "common/status.h" -#include "common/log.h" #include "plugin/plugin_event.h" #include "plugin/codec_plugin.h" #include "osal/task/mutex.h" diff --git a/services/media_engine/modules/muxer/data_sink_fd.cpp b/services/media_engine/modules/muxer/data_sink_fd.cpp index 97642a5037d602dbeee1744f52aac17edbb05c43..8e8613e3abbfa8ffceab77fb039cb07f6e5800ba 100644 --- a/services/media_engine/modules/muxer/data_sink_fd.cpp +++ b/services/media_engine/modules/muxer/data_sink_fd.cpp @@ -20,6 +20,10 @@ #include #include "common/log.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_MUXER, "HiStreamer" }; +} + namespace OHOS { namespace Media { DataSinkFd::DataSinkFd(int32_t fd) : fd_(dup(fd)), pos_(0), end_(-1) diff --git a/services/media_engine/modules/muxer/data_sink_file.cpp b/services/media_engine/modules/muxer/data_sink_file.cpp index 95ccabef8ab9eadd867b0c5ea390a1594a4cc49e..94a4a3d297324570572bd87b7eaa0acd797ba6e4 100644 --- a/services/media_engine/modules/muxer/data_sink_file.cpp +++ b/services/media_engine/modules/muxer/data_sink_file.cpp @@ -19,6 +19,10 @@ #include #include "common/log.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_MUXER, "HiStreamer" }; +} + namespace OHOS { namespace Media { DataSinkFile::DataSinkFile(FILE *file) : file_(file), pos_(0), end_(-1), isCanRead_(true) diff --git a/services/media_engine/modules/muxer/media_muxer.cpp b/services/media_engine/modules/muxer/media_muxer.cpp index 53d7b65825fd23b3450487625319016064808566..bb3515f9b67c002f77a55fd49eb9efad965d7f5d 100644 --- a/services/media_engine/modules/muxer/media_muxer.cpp +++ b/services/media_engine/modules/muxer/media_muxer.cpp @@ -30,6 +30,10 @@ #include "data_sink_fd.h" #include "data_sink_file.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_MUXER, "HiStreamer" }; +} + namespace { using namespace OHOS::Media; using namespace Plugins; diff --git a/services/media_engine/modules/sink/audio_sink.cpp b/services/media_engine/modules/sink/audio_sink.cpp index 7998e30cca6dd2255f0e751c1fe1957321bf4705..b70b25814a3ebb5b3cf7b61dc1b898339987ea30 100644 --- a/services/media_engine/modules/sink/audio_sink.cpp +++ b/services/media_engine/modules/sink/audio_sink.cpp @@ -16,6 +16,11 @@ #include "audio_sink.h" #include "syspara/parameters.h" #include "plugin/plugin_manager_v2.h" +#include "common/log.h" + +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} namespace OHOS { namespace Media { diff --git a/services/media_engine/modules/sink/media_sync_manager.cpp b/services/media_engine/modules/sink/media_sync_manager.cpp index 6d57d21832fb450426cee804e7063b3c7ccc4805..f4394dc01a0dd64672dbadeb9ad0fafbd4b9bef3 100644 --- a/services/media_engine/modules/sink/media_sync_manager.cpp +++ b/services/media_engine/modules/sink/media_sync_manager.cpp @@ -22,6 +22,10 @@ #include "common/log.h" #include "osal/utils/steady_clock.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Pipeline { diff --git a/services/media_engine/modules/sink/media_synchronous_sink.cpp b/services/media_engine/modules/sink/media_synchronous_sink.cpp index 9f55c921e56d7479e96450fd7f6295bf9d3c15f5..2d666c44dbad43ac0bd27bfaad8bd65490b4b7de 100644 --- a/services/media_engine/modules/sink/media_synchronous_sink.cpp +++ b/services/media_engine/modules/sink/media_synchronous_sink.cpp @@ -18,6 +18,10 @@ #include "common/log.h" #include "plugin/plugin_time.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Pipeline { diff --git a/services/media_engine/modules/sink/subtitle_sink.cpp b/services/media_engine/modules/sink/subtitle_sink.cpp index 578d0f7e7bef7b7cc35883f767a8bb24327fc598..73502ce7bb06e2baac1186704bc5582bfa0ec872 100644 --- a/services/media_engine/modules/sink/subtitle_sink.cpp +++ b/services/media_engine/modules/sink/subtitle_sink.cpp @@ -14,9 +14,15 @@ */ #include "subtitle_sink.h" + +#include "common/log.h" #include "syspara/parameters.h" #include "meta/format.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace { diff --git a/services/media_engine/modules/sink/video_sink.cpp b/services/media_engine/modules/sink/video_sink.cpp index 3754f6db6b4dda92c9d5fe7e110e173290ce3731..64b7d9d5aa2102d3f93971afefae9fe4cc0170b8 100644 --- a/services/media_engine/modules/sink/video_sink.cpp +++ b/services/media_engine/modules/sink/video_sink.cpp @@ -22,6 +22,10 @@ #include "osal/task/jobutils.h" #include "syspara/parameters.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Pipeline { diff --git a/services/media_engine/modules/source/audio_capture/audio_capture_module.cpp b/services/media_engine/modules/source/audio_capture/audio_capture_module.cpp index f8d5730677da574e601da20fca85e0fa7fe90a4f..85bfb2d9e481d23b1a888ebecc4a0df50607f5a3 100644 --- a/services/media_engine/modules/source/audio_capture/audio_capture_module.cpp +++ b/services/media_engine/modules/source/audio_capture/audio_capture_module.cpp @@ -20,6 +20,10 @@ #include "audio_capturer.h" #include "avcodec_sysevent.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace AudioCaptureModule { diff --git a/services/media_engine/modules/source/source.cpp b/services/media_engine/modules/source/source.cpp index 91f11989d3e3cb8347a563a731ff75290c73f0e4..6c0e94bf0a2d9a2e01b4c18e2bff552eecf31d17 100644 --- a/services/media_engine/modules/source/source.cpp +++ b/services/media_engine/modules/source/source.cpp @@ -24,6 +24,10 @@ #include "plugin/plugin_manager_v2.h" #include "source.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { using namespace Plugins; diff --git a/services/media_engine/plugins/ffmpeg_adapter/audio_decoder/ffmpeg_decoder_plugin.cpp b/services/media_engine/plugins/ffmpeg_adapter/audio_decoder/ffmpeg_decoder_plugin.cpp index d71fca404917050bfdd2d57a4d1e845da8a5c5dd..a74266fe8f64a0b143e6a8a217d03bed3e661c23 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/audio_decoder/ffmpeg_decoder_plugin.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/audio_decoder/ffmpeg_decoder_plugin.cpp @@ -20,7 +20,6 @@ #include #include #include "osal/utils/util.h" -#include "common/log.h" #include "avcodec_log.h" #include "avcodec_codec_name.h" #include "meta/mime_type.h" @@ -85,7 +84,7 @@ void SetDefinition(size_t index, CodecPluginDef &definition, Capability &cap) AVCodecCodecName::AUDIO_DECODER_APE_NAME, definition, cap); break; default: - MEDIA_LOG_I("codec is not supported right now"); + AVCODEC_LOGI("codec is not supported right now"); } } diff --git a/services/media_engine/plugins/ffmpeg_adapter/audio_encoder/aac/ffmpeg_aac_encoder_plugin.cpp b/services/media_engine/plugins/ffmpeg_adapter/audio_encoder/aac/ffmpeg_aac_encoder_plugin.cpp index b9209e47c226b82cedc6bb0e9c8539904c7a2931..f73ba54887b35ed6fa039f93717e007dbdd277ff 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/audio_encoder/aac/ffmpeg_aac_encoder_plugin.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/audio_encoder/aac/ffmpeg_aac_encoder_plugin.cpp @@ -20,7 +20,6 @@ #include #include #include "avcodec_codec_name.h" -#include "common/log.h" #include "avcodec_log.h" #include "osal/utils/util.h" @@ -29,6 +28,8 @@ using namespace OHOS::Media; using namespace OHOS::Media::Plugins; using namespace Ffmpeg; +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_AUDIO, "FFmpegEncoderPlugin" }; + namespace { constexpr int32_t INPUT_BUFFER_SIZE_DEFAULT = 4 * 1024 * 8; constexpr int32_t OUTPUT_BUFFER_SIZE_DEFAULT = 8192; @@ -123,13 +124,12 @@ bool FFmpegAACEncoderPlugin::CheckSampleRate(const int sampleRate) bool FFmpegAACEncoderPlugin::CheckSampleFormat() { if (supportedSampleFormats.find(audioSampleFormat_) == supportedSampleFormats.end()) { - MEDIA_LOG_E("input sample format not supported,srcFmt_=%{public}d", (int32_t)srcFmt_); + AVCODEC_LOGE("input sample format not supported,srcFmt_=%{public}d", (int32_t)srcFmt_); return false; } AudioSampleFormat2AVSampleFormat(audioSampleFormat_, srcFmt_); - MEDIA_LOG_E("AUDIO_SAMPLE_FORMAT found,srcFmt:%{public}d to " - "ffmpeg-srcFmt_:%{public}d ", - (int32_t)audioSampleFormat_, (int32_t)srcFmt_); + AVCODEC_LOGE("AUDIO_SAMPLE_FORMAT found,srcFmt:%{public}d to ffmpeg-srcFmt_:%{public}d", + (int32_t)audioSampleFormat_, (int32_t)srcFmt_); needResample_ = CheckResample(); return true; } @@ -140,7 +140,7 @@ bool FFmpegAACEncoderPlugin::CheckChannelLayout() static_cast(srcLayout_)); // channel layout not available if (av_get_channel_layout_nb_channels(ffmpegChlayout) != channels_) { - MEDIA_LOG_E("channel layout channels mismatch"); + AVCODEC_LOGE("channel layout channels mismatch"); return false; } return true; @@ -149,7 +149,7 @@ bool FFmpegAACEncoderPlugin::CheckChannelLayout() bool FFmpegAACEncoderPlugin::CheckBitRate() const { if (bitRate_ < AAC_MIN_BIT_RATE || bitRate_ > AAC_MAX_BIT_RATE) { - MEDIA_LOG_E("parameter bit_rate illegal"); + AVCODEC_LOGE("parameter bit_rate illegal"); return false; } return true; @@ -158,27 +158,27 @@ bool FFmpegAACEncoderPlugin::CheckBitRate() const bool FFmpegAACEncoderPlugin::CheckFormat() { if (!CheckSampleFormat()) { - MEDIA_LOG_E("sampleFormat not supported"); + AVCODEC_LOGE("sampleFormat not supported"); return false; } if (!CheckBitRate()) { - MEDIA_LOG_E("bitRate not supported"); + AVCODEC_LOGE("bitRate not supported"); return false; } if (!CheckSampleRate(sampleRate_)) { - MEDIA_LOG_E("sample rate not supported"); + AVCODEC_LOGE("sample rate not supported"); return false; } if (channels_ < MIN_CHANNELS || channels_ > MAX_CHANNELS || channels_ == INVALID_CHANNELS) { - MEDIA_LOG_E("channels not supported"); + AVCODEC_LOGE("channels not supported"); return false; } if (!CheckChannelLayout()) { - MEDIA_LOG_E("channelLayout not supported"); + AVCODEC_LOGE("channelLayout not supported"); return false; } @@ -199,7 +199,7 @@ bool FFmpegAACEncoderPlugin::AudioSampleFormat2AVSampleFormat(const AudioSampleF }; // 使用迭代器遍历 unordered_map for (auto itM = formatTable.begin(); itM != formatTable.end(); ++itM) { - MEDIA_LOG_E("formatTable key:%{public}d Value:%{public}d ", (int32_t)itM->first, (int32_t)itM->second); + AVCODEC_LOGE("formatTable key:%{public}d Value:%{public}d ", (int32_t)itM->first, (int32_t)itM->second); } auto it = formatTable.find(audioFmt); @@ -207,44 +207,43 @@ bool FFmpegAACEncoderPlugin::AudioSampleFormat2AVSampleFormat(const AudioSampleF fmt = it->second; return true; } - MEDIA_LOG_E("AudioSampleFormat2AVSampleFormat fail, from fmt:%{public}d to " - "fmt:%{public}d", - (int32_t)audioFmt, (int32_t)fmt); + AVCODEC_LOGE("AudioSampleFormat2AVSampleFormat fail, from fmt:%{public}d to fmt:%{public}d", + (int32_t)audioFmt, (int32_t)fmt); return false; } Status FFmpegAACEncoderPlugin::Init() { - MEDIA_LOG_I("Init enter"); + AVCODEC_LOGI("Init enter"); return Status::OK; } Status FFmpegAACEncoderPlugin::Start() { - MEDIA_LOG_I("Start enter"); + AVCODEC_LOGI("Start enter"); Status status = AllocateContext("aac"); if (status != Status::OK) { - MEDIA_LOG_D("Allocat aac context failed, status = %{public}d", status); + AVCODEC_LOGD("Allocat aac context failed, status = %{public}d", status); return status; } if (!CheckFormat()) { - MEDIA_LOG_D("Format check failed."); + AVCODEC_LOGD("Format check failed."); return Status::ERROR_INVALID_PARAMETER; } status = InitContext(); if (status != Status::OK) { - MEDIA_LOG_D("Init context failed, status = %{public}d", status); + AVCODEC_LOGD("Init context failed, status = %{public}d", status); return status; } status = OpenContext(); if (status != Status::OK) { - MEDIA_LOG_D("Open context failed, status = %{public}d", status); + AVCODEC_LOGD("Open context failed, status = %{public}d", status); return status; } status = InitFrame(); if (status != Status::OK) { - MEDIA_LOG_D("Init frame failed, status = %{public}d", status); + AVCODEC_LOGD("Init frame failed, status = %{public}d", status); return status; } return Status::OK; @@ -257,7 +256,7 @@ Status FFmpegAACEncoderPlugin::QueueInputBuffer(const std::shared_ptr return Status::ERROR_INVALID_DATA; } if (memory->GetSize() == 0 && !(inputBuffer->flag_ & BUFFER_FLAG_EOS)) { - MEDIA_LOG_E("size is 0, but flag is not 1"); + AVCODEC_LOGE("size is 0, but flag is not 1"); return Status::ERROR_INVALID_DATA; } Status ret; @@ -270,7 +269,7 @@ Status FFmpegAACEncoderPlugin::QueueInputBuffer(const std::shared_ptr if (ret == Status::OK) { std::lock_guard l(bufferMetaMutex_); if (inputBuffer->meta_ == nullptr) { - MEDIA_LOG_E("encoder input buffer or meta is nullptr"); + AVCODEC_LOGE("encoder input buffer or meta is nullptr"); return Status::ERROR_INVALID_DATA; } bufferMeta_ = inputBuffer->meta_; @@ -284,7 +283,7 @@ Status FFmpegAACEncoderPlugin::QueueInputBuffer(const std::shared_ptr Status FFmpegAACEncoderPlugin::QueueOutputBuffer(std::shared_ptr &outputBuffer) { if (!outputBuffer) { - MEDIA_LOG_E("queue out buffer is nullptr."); + AVCODEC_LOGE("queue out buffer is nullptr."); return Status::ERROR_INVALID_PARAMETER; } std::lock_guard lock(avMutex_); @@ -303,25 +302,25 @@ Status FFmpegAACEncoderPlugin::ReceivePacketSucc(std::shared_ptr &outB std::string header; GetAdtsHeader(header, headerSize, avCodecContext_, avPacket_->size); if (headerSize == 0) { - MEDIA_LOG_E("Get header failed."); + AVCODEC_LOGE("Get header failed."); return Status::ERROR_UNKNOWN; } int32_t writeBytes = memory->Write( reinterpret_cast(const_cast(header.c_str())), headerSize, 0); if (writeBytes < headerSize) { - MEDIA_LOG_E("Write header failed"); + AVCODEC_LOGE("Write header failed"); return Status::ERROR_UNKNOWN; } int32_t outputSize = avPacket_->size + headerSize; if (memory->GetCapacity() < outputSize) { - MEDIA_LOG_E("Output buffer capacity is not enough"); + AVCODEC_LOGE("Output buffer capacity is not enough"); return Status::ERROR_NO_MEMORY; } auto len = memory->Write(avPacket_->data, avPacket_->size, headerSize); if (len < avPacket_->size) { - MEDIA_LOG_E("write packet data failed, len = %{public}d", len); + AVCODEC_LOGE("write packet data failed, len = %{public}d", len); return Status::ERROR_UNKNOWN; } @@ -337,23 +336,23 @@ Status FFmpegAACEncoderPlugin::ReceivePacketSucc(std::shared_ptr &outB Status FFmpegAACEncoderPlugin::ReceiveBuffer(std::shared_ptr &outBuffer) { - MEDIA_LOG_D("ReceiveBuffer enter"); + AVCODEC_LOGD("ReceiveBuffer enter"); (void)memset_s(avPacket_.get(), sizeof(AVPacket), 0, sizeof(AVPacket)); auto ret = avcodec_receive_packet(avCodecContext_.get(), avPacket_.get()); Status status; if (ret >= 0) { - MEDIA_LOG_D("receive one packet"); + AVCODEC_LOGD("receive one packet"); status = ReceivePacketSucc(outBuffer); } else if (ret == AVERROR_EOF) { outBuffer->flag_ = BUFFER_FLAG_EOS; avcodec_flush_buffers(avCodecContext_.get()); status = Status::END_OF_STREAM; - MEDIA_LOG_E("ReceiveBuffer EOF"); + AVCODEC_LOGE("ReceiveBuffer EOF"); } else if (ret == AVERROR(EAGAIN)) { status = Status::ERROR_NOT_ENOUGH_DATA; - MEDIA_LOG_E("ReceiveBuffer EAGAIN"); + AVCODEC_LOGE("ReceiveBuffer EAGAIN"); } else { - MEDIA_LOG_E("audio encoder receive unknow error: %{public}s", OSAL::AVStrError(ret).c_str()); + AVCODEC_LOGE("audio encoder receive unknow error: %{public}s", OSAL::AVStrError(ret).c_str()); status = Status::ERROR_UNKNOWN; } av_packet_unref(avPacket_.get()); @@ -364,7 +363,7 @@ Status FFmpegAACEncoderPlugin::SendOutputBuffer(std::shared_ptr &outpu { Status status = SendFrameToFfmpeg(); if (status == Status::ERROR_NOT_ENOUGH_DATA) { - MEDIA_LOG_D("SendFrameToFfmpeg no one frame data"); + AVCODEC_LOGD("SendFrameToFfmpeg no one frame data"); // last frame mark eos if (outputBuffer->flag_ & BUFFER_FLAG_EOS) { dataCallback_->OnOutputBufferDone(outBuffer_); @@ -377,7 +376,7 @@ Status FFmpegAACEncoderPlugin::SendOutputBuffer(std::shared_ptr &outpu { std::lock_guard l(bufferMetaMutex_); if (outBuffer_ == nullptr) { - MEDIA_LOG_E("SendOutputBuffer ERROR_NULL_POINTER"); + AVCODEC_LOGE("SendOutputBuffer ERROR_NULL_POINTER"); return Status::ERROR_NULL_POINTER; } outBuffer_->meta_ = bufferMeta_; @@ -385,21 +384,21 @@ Status FFmpegAACEncoderPlugin::SendOutputBuffer(std::shared_ptr &outpu int32_t fifoSize = av_audio_fifo_size(fifo_); if (fifoSize >= avCodecContext_->frame_size) { outputBuffer->flag_ = 0; // not eos - MEDIA_LOG_D("fifoSize:%{public}d need another encoder", fifoSize); + AVCODEC_LOGD("fifoSize:%{public}d need another encoder", fifoSize); dataCallback_->OnOutputBufferDone(outBuffer_); return Status::ERROR_AGAIN; } dataCallback_->OnOutputBufferDone(outBuffer_); return Status::OK; } else { - MEDIA_LOG_E("SendOutputBuffer-ReceiveBuffer error"); + AVCODEC_LOGE("SendOutputBuffer-ReceiveBuffer error"); } return status; } Status FFmpegAACEncoderPlugin::Reset() { - MEDIA_LOG_I("Reset enter"); + AVCODEC_LOGI("Reset enter"); std::lock_guard lock(avMutex_); auto ret = CloseCtxLocked(); avCodecContext_.reset(); @@ -409,7 +408,7 @@ Status FFmpegAACEncoderPlugin::Reset() Status FFmpegAACEncoderPlugin::Release() { - MEDIA_LOG_I("Release enter"); + AVCODEC_LOGI("Release enter"); std::lock_guard lock(avMutex_); auto ret = CloseCtxLocked(); avCodecContext_.reset(); @@ -418,7 +417,7 @@ Status FFmpegAACEncoderPlugin::Release() Status FFmpegAACEncoderPlugin::Flush() { - MEDIA_LOG_I("Flush enter"); + AVCODEC_LOGI("Flush enter"); std::lock_guard lock(avMutex_); if (avCodecContext_ != nullptr) { avcodec_flush_buffers(avCodecContext_.get()); @@ -433,7 +432,7 @@ Status FFmpegAACEncoderPlugin::Flush() Status FFmpegAACEncoderPlugin::ReAllocateContext() { if (!codecContextValid_) { - MEDIA_LOG_D("Old avcodec context not valid, no need to reallocate"); + AVCODEC_LOGD("Old avcodec context not valid, no need to reallocate"); return Status::OK; } @@ -451,7 +450,7 @@ Status FFmpegAACEncoderPlugin::ReAllocateContext() auto res = avcodec_open2(tmpContext.get(), avCodec_.get(), nullptr); if (res != 0) { - MEDIA_LOG_E("avcodec reopen error %{public}s", OSAL::AVStrError(res).c_str()); + AVCODEC_LOGE("avcodec reopen error %{public}s", OSAL::AVStrError(res).c_str()); return Status::ERROR_UNKNOWN; } avCodecContext_ = tmpContext; @@ -502,17 +501,16 @@ Status FFmpegAACEncoderPlugin::OpenContext() { { std::unique_lock lock(avMutex_); - MEDIA_LOG_I("avCodecContext_->channels " PUBLIC_LOG_D32, avCodecContext_->channels); - MEDIA_LOG_I("avCodecContext_->sample_rate " PUBLIC_LOG_D32, avCodecContext_->sample_rate); - MEDIA_LOG_I("avCodecContext_->bit_rate " PUBLIC_LOG_D64, avCodecContext_->bit_rate); - MEDIA_LOG_I("avCodecContext_->channel_layout " PUBLIC_LOG_D64, avCodecContext_->channel_layout); - MEDIA_LOG_I("avCodecContext_->sample_fmt " PUBLIC_LOG_D32, - static_cast(*(avCodec_.get()->sample_fmts))); - MEDIA_LOG_I("avCodecContext_ old srcFmt_ " PUBLIC_LOG_D32, static_cast(srcFmt_)); - MEDIA_LOG_I("avCodecContext_->codec_id " PUBLIC_LOG_D32, static_cast(avCodec_.get()->id)); + AVCODEC_LOGI("avCodecContext_->channels %{public}d", avCodecContext_->channels); + AVCODEC_LOGI("avCodecContext_->sample_rate %{public}d", avCodecContext_->sample_rate); + AVCODEC_LOGI("avCodecContext_->bit_rate %{public}lld", avCodecContext_->bit_rate); + AVCODEC_LOGI("avCodecContext_->channel_layout %{public}lld", avCodecContext_->channel_layout); + AVCODEC_LOGI("avCodecContext_->sample_fmt %{public}d", static_cast(*(avCodec_.get()->sample_fmts))); + AVCODEC_LOGI("avCodecContext_ old srcFmt_ %{public}d", static_cast(srcFmt_)); + AVCODEC_LOGI("avCodecContext_->codec_id %{public}d", static_cast(avCodec_.get()->id)); auto res = avcodec_open2(avCodecContext_.get(), avCodec_.get(), nullptr); if (res != 0) { - MEDIA_LOG_E("avcodec open error %{public}s", OSAL::AVStrError(res).c_str()); + AVCODEC_LOGE("avcodec open error %{public}s", OSAL::AVStrError(res).c_str()); return Status::ERROR_UNKNOWN; } av_log_set_level(AV_LOG_DEBUG); @@ -520,7 +518,7 @@ Status FFmpegAACEncoderPlugin::OpenContext() codecContextValid_ = true; } if (avCodecContext_->frame_size <= 0) { - MEDIA_LOG_E("frame size invalid"); + AVCODEC_LOGE("frame size invalid"); } int32_t destSamplesPerFrame = (avCodecContext_->frame_size > (avCodecContext_->sample_rate / FRAMES_PER_SECOND)) ? avCodecContext_->frame_size : (avCodecContext_->sample_rate / FRAMES_PER_SECOND); @@ -536,7 +534,7 @@ Status FFmpegAACEncoderPlugin::OpenContext() }; resample_ = std::make_shared(); if (resample_->Init(resamplePara) != Status::OK) { - MEDIA_LOG_E("Resmaple init failed."); + AVCODEC_LOGE("Resmaple init failed."); return Status::ERROR_UNKNOWN; } } @@ -553,49 +551,49 @@ bool FFmpegAACEncoderPlugin::CheckResample() const return false; } } - MEDIA_LOG_I("CheckResample need resample"); + AVCODEC_LOGI("CheckResample need resample"); return true; } Status FFmpegAACEncoderPlugin::GetMetaData(const std::shared_ptr &meta) { int32_t type; - MEDIA_LOG_I("GetMetaData enter"); + AVCODEC_LOGI("GetMetaData enter"); if (meta->Get(type)) { aacName_ = (type == 1 ? "aac" : "aac_latm"); } if (meta->Get(channels_)) { if (channels_ < MIN_CHANNELS || channels_ > MAX_CHANNELS) { - MEDIA_LOG_E("AUDIO_CHANNEL_COUNT error"); + AVCODEC_LOGE("AUDIO_CHANNEL_COUNT error"); return Status::ERROR_INVALID_PARAMETER; } } else { - MEDIA_LOG_E("no AUDIO_CHANNEL_COUNT"); + AVCODEC_LOGE("no AUDIO_CHANNEL_COUNT"); return Status::ERROR_INVALID_PARAMETER; } if (!meta->Get(sampleRate_)) { - MEDIA_LOG_E("no AUDIO_SAMPLE_RATE"); + AVCODEC_LOGE("no AUDIO_SAMPLE_RATE"); return Status::ERROR_INVALID_PARAMETER; } if (!meta->Get(bitRate_)) { - MEDIA_LOG_E("no MEDIA_BITRATE, set to 32k"); + AVCODEC_LOGE("no MEDIA_BITRATE, set to 32k"); bitRate_ = AAC_DEFAULT_BIT_RATE; } if (meta->Get(audioSampleFormat_)) { - MEDIA_LOG_D("AUDIO_SAMPLE_FORMAT found, srcFmt:%{public}d", audioSampleFormat_); + AVCODEC_LOGD("AUDIO_SAMPLE_FORMAT found, srcFmt:%{public}d", audioSampleFormat_); } else { - MEDIA_LOG_E("no AUDIO_SAMPLE_FORMAT"); + AVCODEC_LOGE("no AUDIO_SAMPLE_FORMAT"); return Status::ERROR_INVALID_PARAMETER; } if (meta->Get(maxInputSize_)) { - MEDIA_LOG_I("maxInputSize: %{public}d", maxInputSize_); + AVCODEC_LOGI("maxInputSize: %{public}d", maxInputSize_); } if (meta->Get(srcLayout_)) { - MEDIA_LOG_I("srcLayout_: " PUBLIC_LOG_U64, srcLayout_); + AVCODEC_LOGI("srcLayout_: %{public}llu", srcLayout_); } else { auto iter = channelLayoutMap.find(channels_); if (iter == channelLayoutMap.end()) { - MEDIA_LOG_E("channel layout not found, channels: %{public}d", channels_); + AVCODEC_LOGE("channel layout not found, channels: %{public}d", channels_); return Status::ERROR_UNKNOWN; } else { srcLayout_ = static_cast(iter->second); @@ -606,11 +604,11 @@ Status FFmpegAACEncoderPlugin::GetMetaData(const std::shared_ptr &meta) Status FFmpegAACEncoderPlugin::SetParameter(const std::shared_ptr &meta) { - MEDIA_LOG_I("SetParameter enter"); + AVCODEC_LOGI("SetParameter enter"); std::lock_guard lock(parameterMutex_); Status ret = GetMetaData(meta); if (!CheckFormat()) { - MEDIA_LOG_E("CheckFormat fail"); + AVCODEC_LOGE("CheckFormat fail"); return Status::ERROR_INVALID_PARAMETER; } audioParameter_ = *meta; @@ -624,7 +622,7 @@ Status FFmpegAACEncoderPlugin::GetParameter(std::shared_ptr &meta) maxInputSize_ = INPUT_BUFFER_SIZE_DEFAULT; } maxOutputSize_ = OUTPUT_BUFFER_SIZE_DEFAULT; - MEDIA_LOG_I("GetParameter maxInputSize_: %{public}d", maxInputSize_); + AVCODEC_LOGI("GetParameter maxInputSize_: %{public}d", maxInputSize_); // add codec meta audioParameter_.Set(maxInputSize_); audioParameter_.Set(maxOutputSize_); @@ -634,20 +632,20 @@ Status FFmpegAACEncoderPlugin::GetParameter(std::shared_ptr &meta) Status FFmpegAACEncoderPlugin::InitFrame() { - MEDIA_LOG_I("InitFrame enter"); + AVCODEC_LOGI("InitFrame enter"); cachedFrame_->nb_samples = avCodecContext_->frame_size; cachedFrame_->format = avCodecContext_->sample_fmt; cachedFrame_->channel_layout = avCodecContext_->channel_layout; cachedFrame_->channels = avCodecContext_->channels; int ret = av_frame_get_buffer(cachedFrame_.get(), 0); if (ret < 0) { - MEDIA_LOG_E("Get frame buffer failed: %{public}s", OSAL::AVStrError(ret).c_str()); + AVCODEC_LOGE("Get frame buffer failed: %{public}s", OSAL::AVStrError(ret).c_str()); return Status::ERROR_NO_MEMORY; } if (!(fifo_ = av_audio_fifo_alloc(avCodecContext_->sample_fmt, avCodecContext_->channels, cachedFrame_->nb_samples))) { - MEDIA_LOG_E("Could not allocate FIFO"); + AVCODEC_LOGE("Could not allocate FIFO"); } return Status::OK; } @@ -656,18 +654,17 @@ Status FFmpegAACEncoderPlugin::SendEncoder(const std::shared_ptr &inpu { auto memory = inputBuffer->memory_; if (memory->GetSize() < 0) { - MEDIA_LOG_E("SendEncoder buffer size is less than 0. size : %{public}d", memory->GetSize()); + AVCODEC_LOGE("SendEncoder buffer size is less than 0. size : %{public}d", memory->GetSize()); return Status::ERROR_UNKNOWN; } if (memory->GetSize() > memory->GetCapacity()) { - MEDIA_LOG_E("send input buffer is > allocate size. size : " - "%{public}d, allocate size : %{public}d", - memory->GetSize(), memory->GetCapacity()); + AVCODEC_LOGE("send input buffer is > allocate size. size : %{public}d, allocate size : %{public}d", + memory->GetSize(), memory->GetCapacity()); return Status::ERROR_UNKNOWN; } auto errCode = PcmFillFrame(inputBuffer); if (errCode != Status::OK) { - MEDIA_LOG_E("SendEncoder PcmFillFrame error"); + AVCODEC_LOGE("SendEncoder PcmFillFrame error"); return errCode; } return Status::OK; @@ -676,33 +673,33 @@ Status FFmpegAACEncoderPlugin::SendEncoder(const std::shared_ptr &inpu Status FFmpegAACEncoderPlugin::PushInFifo(const std::shared_ptr &inputBuffer) { if (!inputBuffer) { - MEDIA_LOG_D("inputBuffer is nullptr"); + AVCODEC_LOGD("inputBuffer is nullptr"); return Status::ERROR_INVALID_PARAMETER; } int ret = av_frame_make_writable(cachedFrame_.get()); if (ret != 0) { - MEDIA_LOG_D("Frame make writable failed: %{public}s", OSAL::AVStrError(ret).c_str()); + AVCODEC_LOGD("Frame make writable failed: %{public}s", OSAL::AVStrError(ret).c_str()); return Status::ERROR_UNKNOWN; } bool isEos = inputBuffer->flag_ & BUFFER_FLAG_EOS; if (!isEos) { auto status = SendEncoder(inputBuffer); if (status != Status::OK) { - MEDIA_LOG_E("input push in fifo fail"); + AVCODEC_LOGE("input push in fifo fail"); return status; } } else { - MEDIA_LOG_I("input eos"); + AVCODEC_LOGI("input eos"); } return Status::OK; } Status FFmpegAACEncoderPlugin::SendFrameToFfmpeg() { - MEDIA_LOG_D("SendFrameToFfmpeg enter"); + AVCODEC_LOGD("SendFrameToFfmpeg enter"); int32_t fifoSize = av_audio_fifo_size(fifo_); if (fifoSize < avCodecContext_->frame_size) { - MEDIA_LOG_D("fifoSize:%{public}d not enough", fifoSize); + AVCODEC_LOGD("fifoSize:%{public}d not enough", fifoSize); return Status::ERROR_NOT_ENOUGH_DATA; } cachedFrame_->nb_samples = avCodecContext_->frame_size; @@ -715,7 +712,7 @@ Status FFmpegAACEncoderPlugin::SendFrameToFfmpeg() int readRet = av_audio_fifo_read(fifo_, reinterpret_cast(cachedFrame_->data), avCodecContext_->frame_size); if (readRet < 0) { - MEDIA_LOG_E("fifo read error"); + AVCODEC_LOGE("fifo read error"); return Status::ERROR_UNKNOWN; } cachedFrame_->linesize[0] = readRet * av_get_bytes_per_sample(avCodecContext_->sample_fmt); @@ -723,20 +720,20 @@ Status FFmpegAACEncoderPlugin::SendFrameToFfmpeg() if (ret == 0) { return Status::OK; } else if (ret == AVERROR(EAGAIN)) { - MEDIA_LOG_E("skip this frame because data not enough, msg:%{public}s", OSAL::AVStrError(ret).data()); + AVCODEC_LOGE("skip this frame because data not enough, msg:%{public}s", OSAL::AVStrError(ret).data()); return Status::ERROR_NOT_ENOUGH_DATA; } else if (ret == AVERROR_EOF) { - MEDIA_LOG_D("eos send frame, msg:%{public}s", OSAL::AVStrError(ret).data()); + AVCODEC_LOGD("eos send frame, msg:%{public}s", OSAL::AVStrError(ret).data()); return Status::END_OF_STREAM; } else { - MEDIA_LOG_D("Send frame unknown error: %{public}s", OSAL::AVStrError(ret).c_str()); + AVCODEC_LOGD("Send frame unknown error: %{public}s", OSAL::AVStrError(ret).c_str()); return Status::ERROR_UNKNOWN; } } Status FFmpegAACEncoderPlugin::PcmFillFrame(const std::shared_ptr &inputBuffer) { - MEDIA_LOG_D("PcmFillFrame enter, buffer->pts" PUBLIC_LOG_D64, inputBuffer->pts_); + AVCODEC_LOGD("PcmFillFrame enter, buffer->pts %{public}lld", inputBuffer->pts_); auto memory = inputBuffer->memory_; auto bytesPerSample = av_get_bytes_per_sample(avCodecContext_->sample_fmt); const uint8_t *srcBuffer = memory->GetAddr(); @@ -745,15 +742,14 @@ Status FFmpegAACEncoderPlugin::PcmFillFrame(const std::shared_ptr &inp size_t destBufferSize = srcBufferSize; if (needResample_ && resample_ != nullptr) { if (resample_->Convert(srcBuffer, srcBufferSize, destBuffer, destBufferSize) != Status::OK) { - MEDIA_LOG_E("Convert sample format failed"); + AVCODEC_LOGE("Convert sample format failed"); } } cachedFrame_->nb_samples = static_cast(destBufferSize) / (bytesPerSample * avCodecContext_->channels); if (!(inputBuffer->flag_ & BUFFER_FLAG_EOS) && cachedFrame_->nb_samples != avCodecContext_->frame_size) { - MEDIA_LOG_D("Input frame size not match, input samples: %{public}d, " - "frame_size: %{public}d", - cachedFrame_->nb_samples, avCodecContext_->frame_size); + AVCODEC_LOGD("Input frame size not match, input samples: %{public}d, frame_size: %{public}d", + cachedFrame_->nb_samples, avCodecContext_->frame_size); } int32_t destSamplesPerFrame = (avCodecContext_->frame_size > (avCodecContext_->sample_rate / FRAMES_PER_SECOND)) ? avCodecContext_->frame_size : (avCodecContext_->sample_rate / FRAMES_PER_SECOND); @@ -768,14 +764,14 @@ Status FFmpegAACEncoderPlugin::PcmFillFrame(const std::shared_ptr &inp int32_t cacheSize = av_audio_fifo_size(fifo_); int32_t ret = av_audio_fifo_realloc(fifo_, cacheSize + cachedFrame_->nb_samples); if (ret < 0) { - MEDIA_LOG_E("realloc ret: %{public}d, cacheSize: %{public}d", ret, cacheSize); + AVCODEC_LOGE("realloc ret: %{public}d, cacheSize: %{public}d", ret, cacheSize); } - MEDIA_LOG_D("realloc nb_samples:%{public}d cacheSize:%{public}d channels:%{public}d", + AVCODEC_LOGD("realloc nb_samples:%{public}d cacheSize:%{public}d channels:%{public}d", cachedFrame_->nb_samples, cacheSize, avCodecContext_->channels); int32_t writeSamples = av_audio_fifo_write(fifo_, reinterpret_cast(cachedFrame_->data), cachedFrame_->nb_samples); if (writeSamples < cachedFrame_->nb_samples) { - MEDIA_LOG_E("write smaples: %{public}d, nb_samples: %{public}d", writeSamples, cachedFrame_->nb_samples); + AVCODEC_LOGE("write smaples: %{public}d, nb_samples: %{public}d", writeSamples, cachedFrame_->nb_samples); } return Status::OK; } @@ -795,7 +791,7 @@ Status FFmpegAACEncoderPlugin::Stop() outBuffer_.reset(); outBuffer_ = nullptr; } - MEDIA_LOG_I("Stop"); + AVCODEC_LOGI("Stop"); return ret; } @@ -814,7 +810,7 @@ Status FFmpegAACEncoderPlugin::CloseCtxLocked() if (avCodecContext_ != nullptr) { auto res = avcodec_close(avCodecContext_.get()); if (res != 0) { - MEDIA_LOG_E("avcodec close failed: %{public}s", OSAL::AVStrError(res).c_str()); + AVCODEC_LOGE("avcodec close failed: %{public}s", OSAL::AVStrError(res).c_str()); return Status::ERROR_UNKNOWN; } } diff --git a/services/media_engine/plugins/ffmpeg_adapter/audio_encoder/ffmpeg_encoder_plugin.cpp b/services/media_engine/plugins/ffmpeg_adapter/audio_encoder/ffmpeg_encoder_plugin.cpp index 3cb0834cad809389379b19ce4d9f542c734e426b..8c3f22f972740413694b1cd98b9b1be04f566e62 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/audio_encoder/ffmpeg_encoder_plugin.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/audio_encoder/ffmpeg_encoder_plugin.cpp @@ -21,7 +21,6 @@ #include #include #include "osal/utils/util.h" -#include "common/log.h" #include "avcodec_log.h" #include "avcodec_codec_name.h" #include "meta/mime_type.h" @@ -59,7 +58,7 @@ void SetDefinition(size_t index, CodecPluginDef &definition, Capability &cap) }); break; default: - MEDIA_LOG_I("codec is not supported right now"); + AVCODEC_LOGI("codec is not supported right now"); } } diff --git a/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_convert.cpp b/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_convert.cpp index a4dace18f229868c80ff6f8ff5e6e612a30e7005..01ea23066af79fc08e6eb1a0f33e2e17f4767411 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_convert.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_convert.cpp @@ -13,9 +13,16 @@ * limitations under the License. */ #include "ffmpeg_convert.h" -#include "common/log.h" + +#include + +#include "avcodec_log.h" #include "securec.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_AUDIO, "FFmpegConvert"}; +} + namespace OHOS { namespace Media { namespace Plugins { @@ -34,18 +41,18 @@ Status Resample::Init(const ResamplePara &resamplePara) resamplePara_.destSamplesPerFrame, resamplePara_.destFmt, 0); auto swrContext = swr_alloc(); if (swrContext == nullptr) { - MEDIA_LOG_E("cannot allocate swr context"); + AVCODEC_LOGE("cannot allocate swr context"); return Status::ERROR_NO_MEMORY; } int32_t error = swr_alloc_set_opts2(&swrContext, &resamplePara_.channelLayout, resamplePara_.destFmt, resamplePara_.sampleRate, &resamplePara_.channelLayout, resamplePara_.srcFfFmt, resamplePara_.sampleRate, 0, nullptr); if (error < 0) { - MEDIA_LOG_E("swr init error"); + AVCODEC_LOGE("swr init error"); return Status::ERROR_UNKNOWN; } if (swr_init(swrContext) != 0) { - MEDIA_LOG_E("swr init error"); + AVCODEC_LOGE("swr init error"); return Status::ERROR_UNKNOWN; } swrCtx_ = std::shared_ptr(swrContext, [](SwrContext *ptr) { @@ -63,18 +70,18 @@ Status Resample::InitSwrContext(const ResamplePara &resamplePara) resamplePara_ = resamplePara; auto swrContext = swr_alloc(); if (swrContext == nullptr) { - MEDIA_LOG_E("cannot allocate swr context"); + AVCODEC_LOGE("cannot allocate swr context"); return Status::ERROR_NO_MEMORY; } int32_t error = swr_alloc_set_opts2(&swrContext, &resamplePara_.channelLayout, resamplePara_.destFmt, resamplePara_.sampleRate, &resamplePara_.channelLayout, resamplePara_.srcFfFmt, resamplePara_.sampleRate, 0, nullptr); if (error < 0) { - MEDIA_LOG_E("swr init error"); + AVCODEC_LOGE("swr init error"); return Status::ERROR_UNKNOWN; } if (swr_init(swrContext) != 0) { - MEDIA_LOG_E("swr init error"); + AVCODEC_LOGE("swr init error"); return Status::ERROR_UNKNOWN; } swrCtx_ = std::shared_ptr(swrContext, [](SwrContext *ptr) { @@ -89,26 +96,28 @@ Status Resample::Convert(const uint8_t *srcBuffer, const size_t srcLength, uint8 { #if defined(_WIN32) || !defined(OHOS_LITE) if (resamplePara_.bitsPerSample == 8) { // 8 - FALSE_RETURN_V_MSG(resamplePara_.destFmt == AV_SAMPLE_FMT_S16, Status::ERROR_UNIMPLEMENTED, - "resample 8bit to other format can not support"); + CHECK_AND_RETURN_RET_LOG(resamplePara_.destFmt == AV_SAMPLE_FMT_S16, Status::ERROR_UNIMPLEMENTED, + "resample 8bit to other format can not support"); destLength = srcLength * 2; // 2 resampleCache_.reserve(destLength); resampleCache_.assign(destLength, 0); for (size_t i{0}; i < destLength / 2; i++) { // 2 auto resCode = memcpy_s(&resampleCache_[0] + i * 2 + 1, sizeof(uint8_t), srcBuffer + i, 1); // 0 2 1 - FALSE_RETURN_V_MSG_E(resCode == EOK, Status::ERROR_INVALID_OPERATION, "Memcpy failed at 8 bits/sample."); + CHECK_AND_RETURN_RET_LOG(resCode == EOK, Status::ERROR_INVALID_OPERATION, + "Memcpy failed at 8 bits/sample."); *(&resampleCache_[0] + i * 2 + 1) += 0x80; // 2 0x80 } destBuffer = resampleCache_.data(); } else if (resamplePara_.bitsPerSample == 24) { // 24 - FALSE_RETURN_V_MSG(resamplePara_.destFmt == AV_SAMPLE_FMT_S16, Status::ERROR_UNIMPLEMENTED, - "resample 24bit to other format can not support"); + CHECK_AND_RETURN_RET_LOG(resamplePara_.destFmt == AV_SAMPLE_FMT_S16, Status::ERROR_UNIMPLEMENTED, + "resample 24bit to other format can not support"); destLength = srcLength / 3 * 2; // 3 2 resampleCache_.reserve(destLength); resampleCache_.assign(destLength, 0); for (size_t i = 0; i < destLength / 2; i++) { // 2 auto resCode = memcpy_s(&resampleCache_[0] + i * 2, sizeof(uint8_t) * 2, srcBuffer + i * 3 + 1, 2); // 2 3 1 - FALSE_RETURN_V_MSG_E(resCode == EOK, Status::ERROR_INVALID_OPERATION, "Memcpy failed at 24 bits/sample."); + CHECK_AND_RETURN_RET_LOG(resCode == EOK, Status::ERROR_INVALID_OPERATION, + "Memcpy failed at 24 bits/sample."); } destBuffer = resampleCache_.data(); } else { @@ -124,7 +133,7 @@ Status Resample::Convert(const uint8_t *srcBuffer, const size_t srcLength, uint8 auto res = swr_convert(swrCtx_.get(), resampleChannelAddr_.data(), resamplePara_.destSamplesPerFrame, tmpInput.data(), samples); if (res < 0) { - MEDIA_LOG_E("resample input failed"); + AVCODEC_LOGE("resample input failed"); destLength = 0; } else { destBuffer = resampleCache_.data(); @@ -146,7 +155,7 @@ static std::string AVStrError(int errnum) Status Resample::ConvertFrame(AVFrame *outputFrame, const AVFrame *inputFrame) { if (outputFrame == nullptr || inputFrame == nullptr) { - MEDIA_LOG_E("Frame null pointer"); + AVCODEC_LOGE("Frame null pointer"); return Status::ERROR_NO_MEMORY; } @@ -156,7 +165,7 @@ Status Resample::ConvertFrame(AVFrame *outputFrame, const AVFrame *inputFrame) auto ret = swr_convert_frame(swrCtx_.get(), outputFrame, inputFrame); if (ret < 0) { - MEDIA_LOG_E("convert frame failed, %{public}s", AVStrError(ret).c_str()); + AVCODEC_LOGE("convert frame failed, %{public}s", AVStrError(ret).c_str()); return Status::ERROR_UNKNOWN; } return Status::OK; @@ -172,7 +181,7 @@ Status Scale::Init(const ScalePara &scalePara, uint8_t **dstData, int32_t *dstLi auto swsContext = sws_getContext(scalePara_.srcWidth, scalePara_.srcHeight, scalePara_.srcFfFmt, scalePara_.dstWidth, scalePara_.dstHeight, scalePara_.dstFfFmt, SWS_FAST_BILINEAR, nullptr, nullptr, nullptr); - FALSE_RETURN_V_MSG_E(swsContext != nullptr, Status::ERROR_UNKNOWN, "sws_getContext fail"); + CHECK_AND_RETURN_RET_LOG(swsContext != nullptr, Status::ERROR_UNKNOWN, "sws_getContext fail"); swsCtx_ = std::shared_ptr(swsContext, [](struct SwsContext *ptr) { if (ptr != nullptr) { sws_freeContext(ptr); @@ -180,14 +189,13 @@ Status Scale::Init(const ScalePara &scalePara, uint8_t **dstData, int32_t *dstLi }); auto ret = av_image_alloc(dstData, dstLineSize, scalePara_.dstWidth, scalePara_.dstHeight, scalePara_.dstFfFmt, scalePara_.align); - FALSE_RETURN_V_MSG_E(ret >= 0, Status::ERROR_UNKNOWN, "could not allocate destination image" PUBLIC_LOG_D32, ret); - MEDIA_LOG_D("av_image_alloc call, ret: " PUBLIC_LOG_U32 "dstPixelFormat_: " PUBLIC_LOG_U32, ret, - scalePara_.dstFfFmt); + CHECK_AND_RETURN_RET_LOG(ret >= 0, Status::ERROR_UNKNOWN, "could not allocate destination image %{public}d", ret); + AVCODEC_LOGD("av_image_alloc call, ret: %{public}ud dstPixelFormat_: %{public}ud", ret, scalePara_.dstFfFmt); // av_image_alloc can make sure that dstLineSize last element is 0 for (int32_t i = 0; dstLineSize[i] > 0; i++) { - MEDIA_LOG_D("dstLineSize[" PUBLIC_LOG_D32 "]: " PUBLIC_LOG_D32, i, dstLineSize[i]); + AVCODEC_LOGD("dstLineSize[%{public}d]: %{public}d", i, dstLineSize[i]); if (dstData[i] && !dstLineSize[i]) { - MEDIA_LOG_E("scale frame is broken, i: " PUBLIC_LOG_D32, i); + AVCODEC_LOGE("scale frame is broken, i: %{public}d", i); return Status::ERROR_UNKNOWN; } } @@ -197,7 +205,7 @@ Status Scale::Init(const ScalePara &scalePara, uint8_t **dstData, int32_t *dstLi Status Scale::Convert(uint8_t **srcData, const int32_t *srcLineSize, uint8_t **dstData, int32_t *dstLineSize) { auto res = sws_scale(swsCtx_.get(), srcData, srcLineSize, 0, scalePara_.srcHeight, dstData, dstLineSize); - FALSE_RETURN_V_MSG_E(res >= 0, Status::ERROR_UNKNOWN, "sws_scale fail: " PUBLIC_LOG_D32, res); + CHECK_AND_RETURN_RET_LOG(res >= 0, Status::ERROR_UNKNOWN, "sws_scale fail: %{public}d", res); return Status::OK; } #endif diff --git a/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_converter.cpp b/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_converter.cpp index 47b8ec8cfe5cf5e2c4976c7ce4f7fdd4724b4907..82fc00bccdc37761cbe7da0a801157069f0cd2b3 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_converter.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_converter.cpp @@ -21,6 +21,7 @@ #include "ffmpeg_converter.h" namespace { constexpr int US_PER_SECOND = 1000000; +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_DEMUXER, "FFmpegConverter"}; } namespace OHOS { namespace Media { diff --git a/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_utils.cpp b/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_utils.cpp index 4615ae612007e47f78fbf29d80adc8c1a43b1b28..386298597fbf423a3ae950efdc15160120edea68 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_utils.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/common/ffmpeg_utils.cpp @@ -23,6 +23,10 @@ #include "meta/audio_types.h" #include "ffmpeg_utils.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + #define AV_CODEC_TIME_BASE (static_cast(1)) #define AV_CODEC_NSECOND AV_CODEC_TIME_BASE #define AV_CODEC_USECOND (static_cast(1000) * AV_CODEC_NSECOND) diff --git a/services/media_engine/plugins/ffmpeg_adapter/common/reference_parser_manager.cpp b/services/media_engine/plugins/ffmpeg_adapter/common/reference_parser_manager.cpp index dc4038590c238a289b8e6beb1e463cdb1f92d015..96a64f40c023db9be6f582ac3a161bb197995af6 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/common/reference_parser_manager.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/common/reference_parser_manager.cpp @@ -21,6 +21,7 @@ namespace { const std::string REFERENCE_LIB_PATH = "libav_codec_reference_parser.z.so"; +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_DEMUXER, "HiStreamer"}; } namespace OHOS { diff --git a/services/media_engine/plugins/ffmpeg_adapter/common/stream_parser_manager.cpp b/services/media_engine/plugins/ffmpeg_adapter/common/stream_parser_manager.cpp index 97bcd70b8ae6629af6f052cc581f243c2577d402..c2bcc3fdef06be74392dc94b290677886c1092df 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/common/stream_parser_manager.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/common/stream_parser_manager.cpp @@ -21,6 +21,7 @@ namespace { const std::string HEVC_LIB_PATH = "libav_codec_hevc_parser.z.so"; +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_DEMUXER, "HiStreamer" }; } namespace OHOS { diff --git a/services/media_engine/plugins/ffmpeg_adapter/demuxer/block_queue.h b/services/media_engine/plugins/ffmpeg_adapter/demuxer/block_queue.h index 5b525ddc57e3fd1d28510a59ad0cd81d00bcef43..38d33fcd5d04d53c4255498e6a12a8e26669e0bd 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/demuxer/block_queue.h +++ b/services/media_engine/plugins/ffmpeg_adapter/demuxer/block_queue.h @@ -19,7 +19,6 @@ #include #include #include -#include "common/log.h" namespace OHOS { namespace Media { @@ -81,7 +80,8 @@ public: if (que_.empty() && !isActive_) { MEDIA_LOG_D("block queue " PUBLIC_LOG_S " is inactive for Pop.", name_.c_str()); return {}; - } else if (que_.empty() && isActive_) { + } + if (que_.empty() && isActive_) { MEDIA_LOG_D("block queue " PUBLIC_LOG_S " is empty, please waiting for Push.", name_.c_str()); condEmpty_.wait(lock, [this] { return !isActive_ || !que_.empty(); }); } @@ -104,7 +104,8 @@ public: if (que_.empty() && !isActive_) { MEDIA_LOG_D("block queue " PUBLIC_LOG_S " is inactive for Front.", name_.c_str()); return {}; - } else if (que_.empty() && isActive_) { + } + if (que_.empty() && isActive_) { MEDIA_LOG_D("block queue " PUBLIC_LOG_S " is empty, please waiting for Push.", name_.c_str()); condEmpty_.wait(lock, [this] { return !isActive_ || !que_.empty(); }); } @@ -126,7 +127,8 @@ public: if (que_.empty() && !isActive_) { MEDIA_LOG_D("block queue " PUBLIC_LOG_S " is inactive for Back.", name_.c_str()); return {}; - } else if (que_.empty() && isActive_) { + } + if (que_.empty() && isActive_) { MEDIA_LOG_D("block queue " PUBLIC_LOG_S " is empty, please waiting for Push.", name_.c_str()); condEmpty_.wait(lock, [this] { return !isActive_ || !que_.empty(); }); } @@ -161,6 +163,7 @@ public: } private: + static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_ONLY_PRERELEASE, LOG_DOMAIN_FOUNDATION, "HiStreamer" }; void ClearUnprotected() { if (que_.empty()) { diff --git a/services/media_engine/plugins/ffmpeg_adapter/demuxer/block_queue_pool.cpp b/services/media_engine/plugins/ffmpeg_adapter/demuxer/block_queue_pool.cpp index 5c9be52c68b85d9aa5d1a001ce7c769b73f57d06..bdb8a6578d39fa2e2c61c7774de17d3491919f64 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/demuxer/block_queue_pool.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/demuxer/block_queue_pool.cpp @@ -18,6 +18,9 @@ #include "common/log.h" #include "block_queue_pool.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_DEMUXER, "HiStreamer" }; +} namespace OHOS { namespace Media { diff --git a/services/media_engine/plugins/ffmpeg_adapter/demuxer/ffmpeg_demuxer_plugin.cpp b/services/media_engine/plugins/ffmpeg_adapter/demuxer/ffmpeg_demuxer_plugin.cpp index eae65988b834ec7321537e85eb342392b25ead56..86fd0a2856ca23896ecc06c1f7911a0d3026ee92 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/demuxer/ffmpeg_demuxer_plugin.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/demuxer/ffmpeg_demuxer_plugin.cpp @@ -35,6 +35,10 @@ #include "ffmpeg_demuxer_plugin.h" #include "meta/format.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_DEMUXER, "HiStreamer" }; +} + #define AV_CODEC_TIME_BASE (static_cast(1)) #define AV_CODEC_NSECOND AV_CODEC_TIME_BASE #define AV_CODEC_USECOND (static_cast(1000) * AV_CODEC_NSECOND) diff --git a/services/media_engine/plugins/ffmpeg_adapter/demuxer/ffmpeg_format_helper.cpp b/services/media_engine/plugins/ffmpeg_adapter/demuxer/ffmpeg_format_helper.cpp index 1bbd15e5d4f112db832c96ea4bb06c68ed26f7b7..0818671b7de435aa858b61b014390a6048ea26f1 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/demuxer/ffmpeg_format_helper.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/demuxer/ffmpeg_format_helper.cpp @@ -40,6 +40,10 @@ extern "C" { #define TERMINAL_PROVIDE_CODE (static_cast(4)) #define TERMINAL_PROVIDE_ORIENTED_CODE (static_cast(5)) +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Plugins { diff --git a/services/media_engine/plugins/ffmpeg_adapter/muxer/ffmpeg_muxer_plugin.cpp b/services/media_engine/plugins/ffmpeg_adapter/muxer/ffmpeg_muxer_plugin.cpp index b112551136221668fa60c14cdb8c6ceb4de5f9d0..b80ed94b5b36ef88a4a708dd92049504452f4c3a 100644 --- a/services/media_engine/plugins/ffmpeg_adapter/muxer/ffmpeg_muxer_plugin.cpp +++ b/services/media_engine/plugins/ffmpeg_adapter/muxer/ffmpeg_muxer_plugin.cpp @@ -26,6 +26,8 @@ #include "meta/mime_type.h" namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_MUXER, "HiStreamer"}; + using namespace OHOS::Media; using namespace OHOS::Media::Plugins; using namespace Ffmpeg; diff --git a/services/media_engine/plugins/sink/audio_server_sink_plugin.cpp b/services/media_engine/plugins/sink/audio_server_sink_plugin.cpp index 7c8599f4c2bcc2aac229a730b4c208affa990a00..7080e3aa0043dac8a45246533ca02f84732a2200 100644 --- a/services/media_engine/plugins/sink/audio_server_sink_plugin.cpp +++ b/services/media_engine/plugins/sink/audio_server_sink_plugin.cpp @@ -35,6 +35,7 @@ namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; using namespace OHOS::Media::Plugins; constexpr int TUPLE_SECOND_ITEM_INDEX = 2; constexpr int32_t DEFAULT_BUFFER_NUM = 8; diff --git a/services/media_engine/plugins/source/data_stream_source_plugin.cpp b/services/media_engine/plugins/source/data_stream_source_plugin.cpp index 34b18730662458e1dbbf46bf2bf34453effbc4f7..c9e4fcf28e7f48c9a52e47b74de1c0c3ef350633 100644 --- a/services/media_engine/plugins/source/data_stream_source_plugin.cpp +++ b/services/media_engine/plugins/source/data_stream_source_plugin.cpp @@ -21,6 +21,10 @@ #include "common/media_core.h" #include "osal/utils/util.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Plugin { diff --git a/services/media_engine/plugins/source/file_fd_source_plugin.cpp b/services/media_engine/plugins/source/file_fd_source_plugin.cpp index 19181185d7955031f6132bf5291e9dd2350938ee..0b3c5842a21e81b02d79d1c66703dd2f144dbfc2 100644 --- a/services/media_engine/plugins/source/file_fd_source_plugin.cpp +++ b/services/media_engine/plugins/source/file_fd_source_plugin.cpp @@ -31,6 +31,10 @@ #include "file_fd_source_plugin.h" #include "common/media_core.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Plugins { diff --git a/services/media_engine/plugins/source/file_source_plugin.cpp b/services/media_engine/plugins/source/file_source_plugin.cpp index 1b9748fcd56c58288566e3cadde8bd8934041b78..62d717f6bd41ef346f664580c1d35098a5e9af7e 100644 --- a/services/media_engine/plugins/source/file_source_plugin.cpp +++ b/services/media_engine/plugins/source/file_source_plugin.cpp @@ -19,6 +19,10 @@ #include #include "common/log.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Plugins { diff --git a/services/media_engine/plugins/source/http_source/base64/base64_utils.cpp b/services/media_engine/plugins/source/http_source/base64/base64_utils.cpp index b09ae670385bad7eff288ff2626fd24febfd4607..e0f69955f44b9f4a7f7131e738e06071f52a3792 100644 --- a/services/media_engine/plugins/source/http_source/base64/base64_utils.cpp +++ b/services/media_engine/plugins/source/http_source/base64/base64_utils.cpp @@ -16,6 +16,10 @@ #include "base64_utils.h" #include "common/log.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_STREAM_SOURCE, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Plugins { diff --git a/services/media_engine/plugins/source/http_source/dash/dash_segment_downloader.cpp b/services/media_engine/plugins/source/http_source/dash/dash_segment_downloader.cpp index 49f7c11f0d591bb14a9502fe96d00c3f8697357c..6036115b8f7cac7ca9364193be596edee94fb7de 100644 --- a/services/media_engine/plugins/source/http_source/dash/dash_segment_downloader.cpp +++ b/services/media_engine/plugins/source/http_source/dash/dash_segment_downloader.cpp @@ -18,7 +18,6 @@ #include #include #include "dash_mpd_util.h" -#include "common/log.h" namespace OHOS { namespace Media { diff --git a/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_parser.cpp b/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_parser.cpp index 7c02ffea1eca9c282a289a19b2ebddc494fb7e56..56c1932e46952eb073d0c9ea26718c8dc867f464 100644 --- a/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_parser.cpp +++ b/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_parser.cpp @@ -21,6 +21,10 @@ #include "dash_mpd_util.h" #include "utils/time_utils.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_STREAM_SOURCE, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Plugins { diff --git a/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_prefer_audio_util.cpp b/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_prefer_audio_util.cpp index 5843ebceb3c7ce93c219e6f71ac9e25d1f63c9d0..bbac9edb694147adda56af5a8fc9a1ff993b58cd 100644 --- a/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_prefer_audio_util.cpp +++ b/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_prefer_audio_util.cpp @@ -19,6 +19,10 @@ #include "dash_mpd_def.h" #include "common/log.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_STREAM_SOURCE, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Plugins { diff --git a/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_util.cpp b/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_util.cpp index bd61d01c5cbec079d5b426bab7862d78ba981f99..611a31b50bdda426e41d99c6bdc89d682f2c1bb5 100644 --- a/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_util.cpp +++ b/services/media_engine/plugins/source/http_source/dash/mpd_parser/dash_mpd_util.cpp @@ -20,6 +20,10 @@ #include "dash_mpd_util.h" #include "utils/time_utils.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_STREAM_SOURCE, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Plugins { diff --git a/services/media_engine/plugins/source/http_source/dash/mpd_parser/sidx_box_parser.cpp b/services/media_engine/plugins/source/http_source/dash/mpd_parser/sidx_box_parser.cpp index f1a2a7c69a63b8790a9474f8296db3dcdee0cb38..ce6bc9a098b05aabcc7c12417e9221f3b53fb915 100644 --- a/services/media_engine/plugins/source/http_source/dash/mpd_parser/sidx_box_parser.cpp +++ b/services/media_engine/plugins/source/http_source/dash/mpd_parser/sidx_box_parser.cpp @@ -18,6 +18,10 @@ #include "sidx_box_parser.h" #include "common/log.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_STREAM_SOURCE, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Plugins { diff --git a/services/media_engine/plugins/source/http_source/download/downloader.h b/services/media_engine/plugins/source/http_source/download/downloader.h index 89efa7bd70ea15f9a60601933be506074d4a4746..3a6864ec5591008c90634ffb898cc98d866f543b 100644 --- a/services/media_engine/plugins/source/http_source/download/downloader.h +++ b/services/media_engine/plugins/source/http_source/download/downloader.h @@ -27,6 +27,10 @@ #include #include "securec.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_STREAM_SOURCE, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Plugins { diff --git a/services/media_engine/plugins/source/http_source/download/http_curl_client.cpp b/services/media_engine/plugins/source/http_source/download/http_curl_client.cpp index 70fe35461933df55c9426845fb1b92360e5481b9..50da78ed5efb1686fe1c326c29ee57658c7a9996 100644 --- a/services/media_engine/plugins/source/http_source/download/http_curl_client.cpp +++ b/services/media_engine/plugins/source/http_source/download/http_curl_client.cpp @@ -18,10 +18,14 @@ #include #include #include -#include "common/log.h" #include "osal/task/autolock.h" #include "securec.h" #include "net_conn_client.h" +#include "common/log.h" + +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_STREAM_SOURCE, "HiStreamer" }; +} namespace OHOS { namespace Media { diff --git a/services/media_engine/plugins/source/http_source/hls/m3u8.cpp b/services/media_engine/plugins/source/http_source/hls/m3u8.cpp index 2d11809889d0f342fe4a0170c69bde6713f364f6..557fbe1bd265d0bcfb34b0385f187351b84aebf6 100644 --- a/services/media_engine/plugins/source/http_source/hls/m3u8.cpp +++ b/services/media_engine/plugins/source/http_source/hls/m3u8.cpp @@ -17,7 +17,6 @@ #include #include #include -#include "common/log.h" #include "m3u8.h" namespace OHOS { diff --git a/services/media_engine/plugins/source/http_source/hls/playlist_downloader.cpp b/services/media_engine/plugins/source/http_source/hls/playlist_downloader.cpp index c667939fd36874b8912821a68dbd4d9a77ba2f7d..bbc6f1ace1b2b810b721fd758aa5166c6a5747ef 100644 --- a/services/media_engine/plugins/source/http_source/hls/playlist_downloader.cpp +++ b/services/media_engine/plugins/source/http_source/hls/playlist_downloader.cpp @@ -99,9 +99,8 @@ void PlayListDownloader::DoOpenNative(const std::string& url) if (ret < 0) { MEDIA_LOG_E("Failed to read, errno " PUBLIC_LOG_D32, static_cast(errno)); return; - } else { - MEDIA_LOG_I("Read success."); } + MEDIA_LOG_I("Read success."); playList_ = m3u8; ParseManifest(playList_); } diff --git a/services/media_engine/plugins/source/http_source/media_downloader.h b/services/media_engine/plugins/source/http_source/media_downloader.h index d127a17871f62cf6989b21846eddd4a0656ca35a..4b7f5b2778f0ff8d364f398269e0776ae2a389c7 100644 --- a/services/media_engine/plugins/source/http_source/media_downloader.h +++ b/services/media_engine/plugins/source/http_source/media_downloader.h @@ -36,6 +36,7 @@ struct ReadDataInfo { class MediaDownloader { public: + static constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_STREAM_SOURCE, "HiStreamer" }; virtual ~MediaDownloader() = default; virtual bool Open(const std::string& url, const std::map& httpHeader) = 0; virtual void Close(bool isAsync) = 0; diff --git a/services/media_engine/plugins/source/http_source/utils/media_cached_buffer.cpp b/services/media_engine/plugins/source/http_source/utils/media_cached_buffer.cpp index 73240d3fc72694b7ca9d92f6b6f3b22dd4b230dc..fcbac34e24a013ef31c2471ebdc9c4718e85ad4b 100644 --- a/services/media_engine/plugins/source/http_source/utils/media_cached_buffer.cpp +++ b/services/media_engine/plugins/source/http_source/utils/media_cached_buffer.cpp @@ -24,6 +24,10 @@ #include "avcodec_log.h" #include "avcodec_errors.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_STREAM_SOURCE, "HiStreamer" }; +} + namespace OHOS { namespace Media { diff --git a/services/media_engine/plugins/source/http_source/utils/media_cached_buffer.h b/services/media_engine/plugins/source/http_source/utils/media_cached_buffer.h index 97bd90c13deedf7768b38551b5a6c9017dbce7cb..6a342ce6221bfbc64976158e8c776d97bccb0854 100644 --- a/services/media_engine/plugins/source/http_source/utils/media_cached_buffer.h +++ b/services/media_engine/plugins/source/http_source/utils/media_cached_buffer.h @@ -22,8 +22,6 @@ #include #include -#include "common/log.h" - namespace OHOS { namespace Media { constexpr uint32_t CHUNK_SIZE = 16 * 1024; diff --git a/services/media_engine/plugins/source/http_source/xml/xml_parser.cpp b/services/media_engine/plugins/source/http_source/xml/xml_parser.cpp index b85648b609bacd906a9268e9d8d02c591bc15608..9f841a1015054164202c2688c182680b698c1454 100644 --- a/services/media_engine/plugins/source/http_source/xml/xml_parser.cpp +++ b/services/media_engine/plugins/source/http_source/xml/xml_parser.cpp @@ -16,6 +16,10 @@ #include "xml/xml_parser.h" #include "common/log.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_STREAM_SOURCE, "HiStreamer" }; +} + namespace OHOS { namespace Media { namespace Plugins { diff --git a/services/utils/include/block_queue.h b/services/utils/include/block_queue.h index f51bf651f17ba6cff2b90dc69601033c5690cb12..b69c8d0185256205cf4c1065a1ad4cc1d2785414 100644 --- a/services/utils/include/block_queue.h +++ b/services/utils/include/block_queue.h @@ -161,7 +161,7 @@ private: std::string name_; const size_t capacity_; std::atomic isActive_; - const OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_DEMUXER_MUXER, "BlockQueue"}; + const OHOS::HiviewDFX::HiLogLabel LABEL = {LOG_CORE, LOG_DOMAIN_DEMUXER, "BlockQueue"}; }; } // namespace MediaAVCodec } // namespace OHOS diff --git a/test/unittest/media_sink_test/audio_sink_test.cpp b/test/unittest/media_sink_test/audio_sink_test.cpp index ebc50e25018e0d261bf1737426574b39f7c02d78..9c0394b44f6b6015f858d4da252c837ef7b915b6 100644 --- a/test/unittest/media_sink_test/audio_sink_test.cpp +++ b/test/unittest/media_sink_test/audio_sink_test.cpp @@ -19,6 +19,10 @@ #include "filter/filter.h" #include "common/log.h" +namespace { +constexpr OHOS::HiviewDFX::HiLogLabel LABEL = { LOG_CORE, LOG_DOMAIN_SYSTEM_PLAYER, "HiStreamer" }; +} + using namespace testing::ext; namespace OHOS { diff --git a/test/unittest/sa_avcodec_test/mock/include/mem_mgr_client.h b/test/unittest/sa_avcodec_test/mock/include/mem_mgr_client.h index 448da4a4288d78d528dcb99116757ab3ab3d7b04..bc4749642f3308c1b2740a4210db11fdf26032eb 100644 --- a/test/unittest/sa_avcodec_test/mock/include/mem_mgr_client.h +++ b/test/unittest/sa_avcodec_test/mock/include/mem_mgr_client.h @@ -20,7 +20,6 @@ #include #include #include "avcodec_errors.h" -#include "hilog/log.h" #include "ipc/av_codec_service_ipc_interface_code.h" #include "iremote_broker.h" #include "iremote_object.h" diff --git a/test/unittest/sa_avcodec_test/mock/include/system_ability.h b/test/unittest/sa_avcodec_test/mock/include/system_ability.h index 7844d4e6510f2cb913b799c03f794e3ff91cae59..4ada35844c2c91d187d41727c3c51c6de7dd4760 100644 --- a/test/unittest/sa_avcodec_test/mock/include/system_ability.h +++ b/test/unittest/sa_avcodec_test/mock/include/system_ability.h @@ -19,7 +19,6 @@ #include #include #include -#include "hilog/log.h" #include "iremote_object.h" #include "iservice_registry.h"