From b2c7ee79601ba256897c56db0976a34cc9effab9 Mon Sep 17 00:00:00 2001 From: gaoziyu Date: Thu, 27 Apr 2023 11:19:29 +0800 Subject: [PATCH 1/2] log change, print delete Signed-off-by: gaoziyu --- .../codec/audio/audio_ffmpeg_adapter.cpp | 4 ++-- .../decoder/audio_ffmpeg_decoder_plugin.cpp | 20 +------------------ .../audio_ffmpeg_mp3_decoder_plugin.cpp | 4 ---- 3 files changed, 3 insertions(+), 25 deletions(-) diff --git a/services/engine/codec/audio/audio_ffmpeg_adapter.cpp b/services/engine/codec/audio/audio_ffmpeg_adapter.cpp index bb21f7a5d..7734f6a5a 100644 --- a/services/engine/codec/audio/audio_ffmpeg_adapter.cpp +++ b/services/engine/codec/audio/audio_ffmpeg_adapter.cpp @@ -94,12 +94,12 @@ int32_t AudioFFMpegAdapter::Start() { AVCODEC_LOGD("Start enter"); if (!callback_) { - AVCODEC_LOGE("ffmpeg adapter start error, callback not initlized ."); + AVCODEC_LOGE("adapter start error, callback not initlized ."); return AVCodecServiceErrCode::AVCS_ERR_UNKNOWN; } if (!audioCodec) { - AVCODEC_LOGE("ffmpeg adapter start error, audio codec not initlized ."); + AVCODEC_LOGE("adapter start error, audio codec not initlized ."); return AVCodecServiceErrCode::AVCS_ERR_UNKNOWN; } diff --git a/services/engine/codec/audio/decoder/audio_ffmpeg_decoder_plugin.cpp b/services/engine/codec/audio/decoder/audio_ffmpeg_decoder_plugin.cpp index 307576b1c..e2fb5685e 100644 --- a/services/engine/codec/audio/decoder/audio_ffmpeg_decoder_plugin.cpp +++ b/services/engine/codec/audio/decoder/audio_ffmpeg_decoder_plugin.cpp @@ -40,9 +40,6 @@ AudioFfmpegDecoderPlugin::~AudioFfmpegDecoderPlugin() int32_t AudioFfmpegDecoderPlugin::ProcessSendData(const std::shared_ptr &inputBuffer) { - AVCodecTrace trace(std::string(__FUNCTION__)); - AVCODEC_LOGD("ffmpeg Plugin ProcessSendData enter"); - AVCODEC_LOGD("Plugin ProcessSendData enter"); int32_t ret = AVCodecServiceErrCode::AVCS_ERR_OK; { std::unique_lock lock(avMutext_); @@ -64,9 +61,6 @@ std::string AVStrError(int errnum) int32_t AudioFfmpegDecoderPlugin::SendBuffer(const std::shared_ptr &inputBuffer) { - AVCodecTrace trace(std::string(__FUNCTION__)); - AVCODEC_LOGD("ffmpeg Plugin SendBuffer enter"); - AVCODEC_LOGD("Plugin SendBuffer enter"); if (!inputBuffer) { AVCODEC_LOGE("inputBuffer is nullptr"); return AVCodecServiceErrCode::AVCS_ERR_INVALID_VAL; @@ -101,7 +95,6 @@ int32_t AudioFfmpegDecoderPlugin::SendBuffer(const std::shared_ptr &outBuffer) { - AVCodecTrace trace(std::string(__FUNCTION__)); if (!outBuffer) { AVCODEC_LOGE("outBuffer is nullptr"); return AVCodecServiceErrCode::AVCS_ERR_INVALID_VAL; @@ -120,8 +113,6 @@ int32_t AudioFfmpegDecoderPlugin::ProcessRecieveData(std::shared_ptr &outBuffer) { - AVCodecTrace trace(std::string(__FUNCTION__)); - AVCODEC_LOGD("Plugin receiveBuffer enter"); auto ret = avcodec_receive_frame(avCodecContext_.get(), cachedFrame_.get()); int32_t status; if (ret >= 0) { @@ -165,8 +156,6 @@ int32_t AudioFfmpegDecoderPlugin::ReceiveBuffer(std::shared_ptr int32_t AudioFfmpegDecoderPlugin::ReceiveFrameSucc(std::shared_ptr &outBuffer) { - AVCodecTrace trace(std::string(__FUNCTION__)); - AVCODEC_LOGD("Plugin ReceiveFrameSucc enter"); int32_t channels = cachedFrame_->channels; int32_t samples = cachedFrame_->nb_samples; auto sampleFormat = static_cast(cachedFrame_->format); @@ -209,19 +198,15 @@ int32_t AudioFfmpegDecoderPlugin::Release() int32_t AudioFfmpegDecoderPlugin::Flush() { - AVCodecTrace trace(std::string(__FUNCTION__)); std::unique_lock lock(avMutext_); if (avCodecContext_ != nullptr) { avcodec_flush_buffers(avCodecContext_.get()); } - AVCODEC_LOGD("Flush exit."); return AVCodecServiceErrCode::AVCS_ERR_OK; } int32_t AudioFfmpegDecoderPlugin::AllocateContext(const std::string &name) { - AVCodecTrace trace(std::string(__FUNCTION__)); - AVCODEC_LOGD("Plugin AllocateContext enter"); { std::unique_lock lock(avMutext_); avCodec_ = std::shared_ptr(const_cast(avcodec_find_decoder_by_name(name.c_str())), @@ -229,6 +214,7 @@ int32_t AudioFfmpegDecoderPlugin::AllocateContext(const std::string &name) cachedFrame_ = std::shared_ptr(av_frame_alloc(), [](AVFrame *fp) { av_frame_free(&fp); }); } if (avCodec_ == nullptr) { + AVCODEC_LOGD("AllocateContext fail,parameter avcodec is nullptr."); return AVCodecServiceErrCode::AVCS_ERR_UNSUPPORT_PROTOCOL_TYPE; } @@ -248,7 +234,6 @@ int32_t AudioFfmpegDecoderPlugin::AllocateContext(const std::string &name) int32_t AudioFfmpegDecoderPlugin::InitContext(const Format &format) { - AVCODEC_LOGD("Plugin InitContext enter"); format.GetIntValue(CHANNEL_COUNT_KEY, avCodecContext_->channels); format.GetIntValue(SAMPLE_RATE_KEY, avCodecContext_->sample_rate); format.GetLongValue(BITS_RATE_KEY, avCodecContext_->bit_rate); @@ -264,8 +249,6 @@ int32_t AudioFfmpegDecoderPlugin::InitContext(const Format &format) int32_t AudioFfmpegDecoderPlugin::OpenContext() { - AVCodecTrace trace(std::string(__FUNCTION__)); - AVCODEC_LOGD("Plugin OpenContext enter"); avPacket_ = std::shared_ptr(av_packet_alloc(), [](AVPacket *ptr) { av_packet_free(&ptr); }); { std::unique_lock lock(avMutext_); @@ -300,7 +283,6 @@ std::shared_ptr AudioFfmpegDecoderPlugin::GetCodecCacheFrame() const no int32_t AudioFfmpegDecoderPlugin::CloseCtxLocked() { - AVCodecTrace trace(std::string(__FUNCTION__)); if (avCodecContext_ != nullptr) { auto res = avcodec_close(avCodecContext_.get()); if (res != 0) { diff --git a/services/engine/codec/audio/decoder/audio_ffmpeg_mp3_decoder_plugin.cpp b/services/engine/codec/audio/decoder/audio_ffmpeg_mp3_decoder_plugin.cpp index a0c34df99..ad772c6de 100644 --- a/services/engine/codec/audio/decoder/audio_ffmpeg_mp3_decoder_plugin.cpp +++ b/services/engine/codec/audio/decoder/audio_ffmpeg_mp3_decoder_plugin.cpp @@ -37,12 +37,10 @@ int32_t AudioFFMpegMp3DecoderPlugin::init(const Format &format) return checkresult; } if (ret != AVCodecServiceErrCode::AVCS_ERR_OK) { - // std::cout << "init 1 OH error:" << ret << "\n"; return ret; } ret = basePlugin->InitContext(format); if (ret != AVCodecServiceErrCode::AVCS_ERR_OK) { - // std::cout << "init 2 OH error:" << ret << "\n"; return ret; } return basePlugin->OpenContext(); @@ -77,14 +75,12 @@ uint32_t AudioFFMpegMp3DecoderPlugin::getInputBufferSize() const { uint32_t size = int(bit_rate / 150); - // printf("in size %d \n", size); return size; } uint32_t AudioFFMpegMp3DecoderPlugin::getOutputBufferSize() const { uint32_t size = (int(sample_rate / 31) + 128) * channels * sizeof(short); - // printf("out size %d %d\n", size, sample_rate); return size; } From 3f708e0dc35dcd3672a91f5fd7f4a5546f9156ec Mon Sep 17 00:00:00 2001 From: peng <12329789+peng5233@user.noreply.gitee.com> Date: Thu, 27 Apr 2023 11:54:33 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E8=AF=B4?= =?UTF-8?q?=E6=98=8E=E3=80=91=E4=BF=AE=E6=94=B9=E9=9F=B3=E9=A2=91=E4=BB=A3?= =?UTF-8?q?=E7=A0=81gn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: peng --- services/engine/base/BUILD.gn | 14 +++++----- services/engine/codec/audio/BUILD.gn | 38 +++++++++++++--------------- services/engine/common/BUILD.gn | 23 +++++------------ 3 files changed, 30 insertions(+), 45 deletions(-) diff --git a/services/engine/base/BUILD.gn b/services/engine/base/BUILD.gn index 55cb8fa56..fafcc8c8c 100644 --- a/services/engine/base/BUILD.gn +++ b/services/engine/base/BUILD.gn @@ -1,22 +1,20 @@ import("//build/ohos.gni") import("//foundation/multimedia/av_codec/config.gni") -AV_CODEC_ROOT_DIR = "//foundation/multimedia/av_codec" - ohos_static_library("av_codec_codec_base"){ include_dirs=[ "//foundation/graphic/graphic_2d/frameworks/surface/include", - "$AV_CODEC_ROOT_DIR/services/engine/base/include", - "$AV_CODEC_ROOT_DIR/services/engine/common/include", - "$AV_CODEC_ROOT_DIR/interfaces/inner_api/native", - "$AV_CODEC_ROOT_DIR/interfaces/kits/c", - "$AV_CODEC_ROOT_DIR/services/dfx/include", + "$av_codec_root_dir/services/engine/base/include", + "$av_codec_root_dir/services/engine/common/include", + "$av_codec_root_dir/interfaces/inner_api/native", + "$av_codec_root_dir/interfaces/kits/c", + "$av_codec_root_dir/services/dfx/include", "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/ffmpeg", ] sources=[ - "$AV_CODEC_ROOT_DIR/services/engine/base/codecbase.cpp" + "$av_codec_root_dir/services/engine/base/codecbase.cpp" ] deps=[ diff --git a/services/engine/codec/audio/BUILD.gn b/services/engine/codec/audio/BUILD.gn index ddf1ec44f..7a60d81a5 100644 --- a/services/engine/codec/audio/BUILD.gn +++ b/services/engine/codec/audio/BUILD.gn @@ -1,35 +1,33 @@ import("//build/ohos.gni") import("//foundation/multimedia/av_codec/config.gni") -AV_CODEC_ROOT_DIR = "//foundation/multimedia/av_codec" - ohos_static_library("av_codec_audio_ffmpeg_codec"){ include_dirs=[ "//foundation/graphic/graphic_2d/frameworks/surface/include", "//commonlibrary/c_utils/base/include", - "$AV_CODEC_ROOT_DIR/services/engine/base/include", - "$AV_CODEC_ROOT_DIR/services/engine/common/include", - "$AV_CODEC_ROOT_DIR/services/engine/factory", - "$AV_CODEC_ROOT_DIR/services/utils/include", - "$AV_CODEC_ROOT_DIR/services/engine/codec/include/audio", - "$AV_CODEC_ROOT_DIR/services/engine/codec/include/audio/decoder", - "$AV_CODEC_ROOT_DIR/interfaces/inner_api/native", - "$AV_CODEC_ROOT_DIR/interfaces/kits/c", - "$AV_CODEC_ROOT_DIR/services/dfx/include", + "$av_codec_root_dir/services/engine/base/include", + "$av_codec_root_dir/services/engine/common/include", + "$av_codec_root_dir/services/engine/factory", + "$av_codec_root_dir/services/utils/include", + "$av_codec_root_dir/services/engine/codec/include/audio", + "$av_codec_root_dir/services/engine/codec/include/audio/decoder", + "$av_codec_root_dir/interfaces/inner_api/native", + "$av_codec_root_dir/interfaces/kits/c", + "$av_codec_root_dir/services/dfx/include", "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//third_party/ffmpeg", ] sources=[ - "$AV_CODEC_ROOT_DIR/services/engine/codec/audio/audio_buffer_info.cpp", - "$AV_CODEC_ROOT_DIR/services/engine/codec/audio/audio_buffers_manager.cpp", - "$AV_CODEC_ROOT_DIR/services/engine/codec/audio/audio_codec_worker.cpp", - "$AV_CODEC_ROOT_DIR/services/engine/codec/audio/audio_ffmpeg_adapter.cpp", - "$AV_CODEC_ROOT_DIR/services/engine/codec/audio/decoder/audio_ffmpeg_decoder_plugin.cpp", - "$AV_CODEC_ROOT_DIR/services/engine/codec/audio/decoder/audio_ffmpeg_aac_decoder_plugin.cpp", - "$AV_CODEC_ROOT_DIR/services/engine/codec/audio/decoder/audio_ffmpeg_flac_decoder_plugin.cpp", - "$AV_CODEC_ROOT_DIR/services/engine/codec/audio/decoder/audio_ffmpeg_mp3_decoder_plugin.cpp", - "$AV_CODEC_ROOT_DIR/services/engine/codec/audio/decoder/audio_ffmpeg_vorbis_decoder_plugin.cpp", + "$av_codec_root_dir/services/engine/codec/audio/audio_buffer_info.cpp", + "$av_codec_root_dir/services/engine/codec/audio/audio_buffers_manager.cpp", + "$av_codec_root_dir/services/engine/codec/audio/audio_codec_worker.cpp", + "$av_codec_root_dir/services/engine/codec/audio/audio_ffmpeg_adapter.cpp", + "$av_codec_root_dir/services/engine/codec/audio/decoder/audio_ffmpeg_decoder_plugin.cpp", + "$av_codec_root_dir/services/engine/codec/audio/decoder/audio_ffmpeg_aac_decoder_plugin.cpp", + "$av_codec_root_dir/services/engine/codec/audio/decoder/audio_ffmpeg_flac_decoder_plugin.cpp", + "$av_codec_root_dir/services/engine/codec/audio/decoder/audio_ffmpeg_mp3_decoder_plugin.cpp", + "$av_codec_root_dir/services/engine/codec/audio/decoder/audio_ffmpeg_vorbis_decoder_plugin.cpp", ] deps=[ diff --git a/services/engine/common/BUILD.gn b/services/engine/common/BUILD.gn index 5e9a7bf85..7e1d76851 100644 --- a/services/engine/common/BUILD.gn +++ b/services/engine/common/BUILD.gn @@ -1,29 +1,18 @@ import("//build/ohos.gni") import("//foundation/multimedia/av_codec/config.gni") -AV_CODEC_ROOT_DIR = "//foundation/multimedia/av_codec" - -config("av_codec_engine_common_config"){ - -} -ohos_shared_library("av_codec_engine_common"){ - install_enable = true - +ohos_static_library("av_codec_engine_common"){ include_dirs=[ "//base/hiviewdfx/hisysevent/interfaces/native/innerkits/hisysevent/include", "//commonlibrary/c_utils/base/include", - "$AV_CODEC_ROOT_DIR/services/engine/common/include", - "$AV_CODEC_ROOT_DIR/services/utils/include", - "$AV_CODEC_ROOT_DIR/interfaces/inner_api/native", - "$AV_CODEC_ROOT_DIR/services/dfx/include", + "$av_codec_root_dir/services/engine/common/include", + "$av_codec_root_dir/services/utils/include", + "$av_codec_root_dir/interfaces/inner_api/native", + "$av_codec_root_dir/services/dfx/include", ] sources=[ - "$AV_CODEC_ROOT_DIR/services/engine/common/share_memory.cpp", - ] - - configs = [ - ":av_codec_engine_common_config" + "$av_codec_root_dir/services/engine/common/share_memory.cpp", ] public_deps= [