From 70cdd624137ec2913ab4397d4f9966aa9095c27d Mon Sep 17 00:00:00 2001 From: liqiao49 Date: Mon, 26 Jun 2023 16:18:05 +0800 Subject: [PATCH 1/8] add filter and plugin Signed-off-by: liqiao49 --- av_transport/av_trans_engine/filters/BUILD.gn | 54 ++ .../av_transport_input_filter.cpp | 571 ++++++++++++++++++ .../av_transport_input_filter.h | 79 +++ .../av_transport_output_filter.cpp | 367 +++++++++++ .../av_transport_output_filter.h | 74 +++ .../plugin/core/avtrans_input.cpp | 31 + .../plugin/core/avtrans_input.h | 47 ++ .../plugin/core/avtrans_output.cpp | 31 + .../plugin/core/avtrans_output.h | 47 ++ .../plugin/interface/avtrans_input_plugin.h | 51 ++ .../plugin/interface/avtrans_output_plugin.h | 51 ++ .../av_trans_input/daudio_input/BUILD.gn | 8 +- .../daudio_input/daudio_input_plugin.cpp | 26 +- .../daudio_input/daudio_input_plugin.h | 1 - .../av_trans_input/dscreen_input/BUILD.gn | 8 +- .../dscreen_input/dscreen_input_plugin.cpp | 27 +- .../dscreen_input/dscreen_input_plugin.h | 0 .../av_trans_input/dsoftbus_input/BUILD.gn | 8 +- .../dsoftbus_input/dsoftbus_input_plugin.cpp | 26 +- .../dsoftbus_input/dsoftbus_input_plugin.h | 0 .../dsoftbus_input_audio/BUILD.gn | 8 +- .../dsoftbus_input_audio_plugin.cpp | 26 +- .../dsoftbus_input_audio_plugin.h | 0 .../av_trans_output/daudio_output/BUILD.gn | 8 +- .../daudio_output/daudio_output_plugin.cpp | 26 +- .../daudio_output/daudio_output_plugin.h | 0 .../av_trans_output/dscreen_output/BUILD.gn | 8 +- .../dscreen_output/dscreen_output_plugin.cpp | 26 +- .../dscreen_output/dscreen_output_plugin.h | 0 .../av_trans_output/dsoftbus_output/BUILD.gn | 8 +- .../dsoftbus_output_plugin.cpp | 31 +- .../dsoftbus_output/dsoftbus_output_plugin.h | 0 .../dsoftbus_output_audio/BUILD.gn | 8 +- .../dsoftbus_output_audio_plugin.cpp | 27 +- .../dsoftbus_output_audio_plugin.h | 0 35 files changed, 1546 insertions(+), 137 deletions(-) create mode 100644 av_transport/av_trans_engine/filters/BUILD.gn create mode 100644 av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp create mode 100644 av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.h create mode 100644 av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp create mode 100644 av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.h create mode 100644 av_transport/av_trans_engine/plugin/core/avtrans_input.cpp create mode 100644 av_transport/av_trans_engine/plugin/core/avtrans_input.h create mode 100644 av_transport/av_trans_engine/plugin/core/avtrans_output.cpp create mode 100644 av_transport/av_trans_engine/plugin/core/avtrans_output.h create mode 100644 av_transport/av_trans_engine/plugin/interface/avtrans_input_plugin.h create mode 100644 av_transport/av_trans_engine/plugin/interface/avtrans_output_plugin.h rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_input/daudio_input/BUILD.gn (90%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp (88%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_input/daudio_input/daudio_input_plugin.h (98%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_input/dscreen_input/BUILD.gn (91%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp (86%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.h (100%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_input/dsoftbus_input/BUILD.gn (90%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp (92%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.h (100%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn (90%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp (89%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.h (100%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_output/daudio_output/BUILD.gn (91%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp (95%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_output/daudio_output/daudio_output_plugin.h (100%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_output/dscreen_output/BUILD.gn (90%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp (92%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.h (100%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_output/dsoftbus_output/BUILD.gn (90%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp (92%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.h (100%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn (90%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp (90%) rename av_transport/av_trans_engine/{ => plugin}/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.h (100%) diff --git a/av_transport/av_trans_engine/filters/BUILD.gn b/av_transport/av_trans_engine/filters/BUILD.gn new file mode 100644 index 00000000..c51b391d --- /dev/null +++ b/av_transport/av_trans_engine/filters/BUILD.gn @@ -0,0 +1,54 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +source_set("avtrans_input_filter") { + include_dirs = [ + "${plugin_path}/core", + "${plugin_path}/interface" + ] + + sources = [ + "av_transport_input/av_transport_input_filter.cpp", + "${plugin_path}/core/avtrans_input.cpp" + ] + + public_deps = [ + "${histreamer_path}/foundation:histreamer_foundation", + "${histreamer_path}/pipeline:histreamer_base", + "${plugin_path}/plugins/av_trans_input/daudio_input:plugin_AVTransDaudioInput", + "${plugin_path}/plugins/av_trans_input/dscreen_input:plugin_AVTransDscreenInput", + "${plugin_path}/plugins/av_trans_input/dsoftbus_input:plugin_AVTransDsoftbusInput", + "${plugin_path}/plugins/av_trans_input/dsoftbus_input_audio:plugin_AVTransDsoftbusInputAudio", + ] +} + +source_set("avtrans_output_filter") { + include_dirs = [ + "${plugin_path}/core", + "${plugin_path}/interface" + ] + + sources = [ + "av_transport_output/av_transport_output_filter.cpp", + "${plugin_path}/core/avtrans_output.cpp" + ] + + public_deps = [ + "${histreamer_path}/foundation:histreamer_foundation", + "${histreamer_path}/pipeline:histreamer_base", + "${plugin_path}/plugins/av_trans_output/daudio_output:plugin_AVTransDaudioOutput", + "${plugin_path}/plugins/av_trans_output/dscreen_output:plugin_AVTransDscreenOutput", + "${plugin_path}/plugins/av_trans_output/dsoftbus_output:plugin_AVTransDsoftbusOutput", + "${plugin_path}/plugins/av_trans_output/dsoftbus_output_audio:plugin_AVTransDsoftbusOutputAudio", + ] +} \ No newline at end of file diff --git a/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp b/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp new file mode 100644 index 00000000..5955cf1d --- /dev/null +++ b/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp @@ -0,0 +1,571 @@ +/* + * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define HST_LOG_TAG "AVInputFilter" +#include "av_transport_input_filter.h" +#include "pipeline/filters/common/plugin_utils.h" +#include "foundation/log.h" +#include "pipeline/factory/filter_factory.h" +#include "plugin/common/plugin_attr_desc.h" + +namespace OHOS { +namespace DistributedHardware { + +static AutoRegisterFilter g_registerFilterHelper("builtin.avtransport.avinput"); + +AVInputFilter::AVInputFilter(const std::string& name) : FilterBase(name), plugin_(nullptr), pluginInfo_(nullptr) +{ + MEDIA_LOG_I("ctor called"); +} + +AVInputFilter::~AVInputFilter() +{ + MEDIA_LOG_I("dtor called"); + OSAL::ScopedLock lock(inputFilterMutex_); + if (plugin_ != nullptr) { + plugin_->Deinit(); + } +} + +std::vector AVInputFilter::GetWorkModes() +{ + return {WorkMode::PUSH}; +} + +ErrorCode AVInputFilter::SetParameter(int32_t key, const Any& value) +{ + Tag tag; + if (!TranslateIntoParameter(key, tag)) { + MEDIA_LOG_E("This key is invalid!"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + { + OSAL::ScopedLock lock(inputFilterMutex_); + paramsMap_[tag] = value; + } + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::GetParameter(int32_t key, Any& value) +{ + Tag tag; + if (!TranslateIntoParameter(key, tag)) { + MEDIA_LOG_E("This key is invalid!"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + { + OSAL::ScopedLock lock(inputFilterMutex_); + value = paramsMap_[tag]; + } + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::Prepare() +{ + MEDIA_LOG_I("Prepare entered."); + if (state_ != FilterState::INITIALIZED) { + MEDIA_LOG_E("The current state is invalid"); + return ErrorCode::ERROR_INVALID_STATE; + } + state_ = FilterState::PREPARING; + ErrorCode err = FindPlugin(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Find plugin fail"); + state_ = FilterState::INITIALIZED; + return err; + } + err = DoConfigure(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Configure downStream fail"); + state_ = FilterState::INITIALIZED; + return err; + } + err = PreparePlugin(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Prepare plugin fail"); + state_ = FilterState::INITIALIZED; + return err; + } + state_ = FilterState::READY; + MEDIA_LOG_I("Prepare end."); + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::Start() +{ + MEDIA_LOG_I("Start"); + OSAL::ScopedLock lock(inputFilterMutex_); + if (state_ != FilterState::READY && state_ != FilterState::PAUSED) { + MEDIA_LOG_E("The current state is invalid"); + return ErrorCode::ERROR_INVALID_STATE; + } + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_NULL_POINTER; + } + if (TranslatePluginStatus(plugin_->Start()) != ErrorCode::SUCCESS) { + MEDIA_LOG_E("The plugin start fail!"); + return ErrorCode::ERROR_INVALID_OPERATION; + } + state_ = FilterState::RUNNING; + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::Stop() +{ + MEDIA_LOG_I("Stop"); + OSAL::ScopedLock lock(inputFilterMutex_); + if (state_ != FilterState::RUNNING) { + MEDIA_LOG_E("The current state is invalid"); + return ErrorCode::ERROR_INVALID_STATE; + } + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_NULL_POINTER; + } + if (TranslatePluginStatus(plugin_->Stop()) != ErrorCode::SUCCESS) { + MEDIA_LOG_E("The plugin stop fail!"); + return ErrorCode::ERROR_INVALID_OPERATION; + } + state_ = FilterState::READY; + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::Pause() +{ + MEDIA_LOG_I("Pause"); + OSAL::ScopedLock lock(inputFilterMutex_); + if (state_ != FilterState::RUNNING) { + MEDIA_LOG_E("The current state is invalid"); + return ErrorCode::ERROR_INVALID_STATE; + } + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_NULL_POINTER; + } + if (TranslatePluginStatus(plugin_->Stop()) != ErrorCode::SUCCESS) { + MEDIA_LOG_E("The plugin stop fail!"); + return ErrorCode::ERROR_INVALID_OPERATION; + } + state_ = FilterState::PAUSED; + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::Resume() +{ + MEDIA_LOG_I("Resume"); + return ErrorCode::SUCCESS; +} + +void AVInputFilter::InitPorts() +{ + MEDIA_LOG_I("InitPorts"); + auto outPort = std::make_shared(this); + { + OSAL::ScopedLock lock(inputFilterMutex_); + outPorts_.push_back(outPort); + } +} + +ErrorCode AVInputFilter::FindPlugin() +{ + OSAL::ScopedLock lock(inputFilterMutex_); + std::string mime; + if (paramsMap_.find(Tag::MIME) == paramsMap_.end() || + !paramsMap_[Tag::MIME].SameTypeWith(typeid(std::string))) { + MEDIA_LOG_E("Must set mime correctly first"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + mime = Plugin::AnyCast(paramsMap_[Tag::MIME]); + auto nameList = PluginManager::Instance().ListPlugins(PluginType::AVTRANS_INPUT); + for (const std::string& name : nameList) { + auto info = PluginManager::Instance().GetPluginInfo(PluginType::AVTRANS_INPUT, name); + if (mime != info->outCaps[0].mime) { + continue; + } + if (DoNegotiate(info->outCaps) && CreatePlugin(info) == ErrorCode::SUCCESS) { + MEDIA_LOG_I("CreatePlugin " PUBLIC_LOG_S " success", name_.c_str()); + return ErrorCode::SUCCESS; + } + } + MEDIA_LOG_I("Cannot find any plugin"); + return ErrorCode::ERROR_UNSUPPORTED_FORMAT; +} + +bool AVInputFilter::DoNegotiate(const CapabilitySet& outCaps) +{ + MEDIA_LOG_I("DoNegotiate start"); + if (outCaps.empty()) { + MEDIA_LOG_E("Input plugin must have out caps"); + return false; + } + for (const auto& outCap : outCaps) { + auto thisOutCap = std::make_shared(outCap); + MEDIA_LOG_I("thisOutCap " PUBLIC_LOG_S, thisOutCap->mime.c_str()); + Meta upstreamParams; + Meta downstreamParams; + if (outPorts_.size() == 0 || outPorts_[0] == nullptr) { + MEDIA_LOG_E("outPorts is empty or invalid!"); + return false; + } + if (outPorts_[0]->Negotiate(thisOutCap, capNegWithDownstream_, upstreamParams, downstreamParams)) { + MEDIA_LOG_I("Negotiate success"); + return true; + } + } + MEDIA_LOG_I("DoNegotiate end"); + return false; +} + +ErrorCode AVInputFilter::CreatePlugin(const std::shared_ptr& selectedInfo) +{ + MEDIA_LOG_I("CreatePlugin"); + if (selectedInfo == nullptr || selectedInfo->name.empty()) { + MEDIA_LOG_E("selectedInfo is nullptr or pluginName is invalid!"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + if ((plugin_ != nullptr) && (pluginInfo_ != nullptr)) { + if (selectedInfo->name == pluginInfo_->name && TranslatePluginStatus(plugin_->Reset()) == ErrorCode::SUCCESS) { + MEDIA_LOG_I("Reuse last plugin: " PUBLIC_LOG_S, selectedInfo->name.c_str()); + return ErrorCode::SUCCESS; + } + if (TranslatePluginStatus(plugin_->Deinit()) != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Deinit last plugin: " PUBLIC_LOG_S " error", pluginInfo_->name.c_str()); + } + } + plugin_ = PluginManager::Instance().CreateAvTransInputPlugin(selectedInfo->name); + if (plugin_ == nullptr) { + MEDIA_LOG_E("PluginManager CreatePlugin " PUBLIC_LOG_S " fail", selectedInfo->name.c_str()); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + pluginInfo_ = selectedInfo; + MEDIA_LOG_I("Create new plugin: " PUBLIC_LOG_S " success", pluginInfo_->name.c_str()); + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::DoConfigure() +{ + Plugin::Meta emptyMeta; + Plugin::Meta targetMeta; + if (MergeMeta(emptyMeta, targetMeta) != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Merge Meta fail!"); + return ErrorCode::ERROR_INVALID_OPERATION; + } + if (ConfigMeta(targetMeta) != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Config Meta fail!"); + return ErrorCode::ERROR_INVALID_OPERATION; + } + if (ConfigDownStream(targetMeta) != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Config DownStream fail!"); + return ErrorCode::ERROR_INVALID_OPERATION; + } + auto err = InitPlugin(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Init plugin fail"); + state_ = FilterState::INITIALIZED; + return ErrorCode::ERROR_INVALID_OPERATION; + } + err = ConfigPlugin(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Configure plugin fail"); + state_ = FilterState::INITIALIZED; + return ErrorCode::ERROR_INVALID_OPERATION; + } + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::MergeMeta(const Plugin::Meta& meta, Plugin::Meta& targetMeta) +{ + OSAL::ScopedLock lock(inputFilterMutex_); + if (!MergeMetaWithCapability(meta, capNegWithDownstream_, targetMeta)) { + MEDIA_LOG_E("cannot find available capability of plugin " PUBLIC_LOG_S, pluginInfo_->name.c_str()); + return ErrorCode::ERROR_INVALID_OPERATION; + } + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::ConfigMeta(Plugin::Meta& meta) +{ + MEDIA_LOG_I("ConfigMeta start!"); + OSAL::ScopedLock lock(inputFilterMutex_); + if (paramsMap_.find(Tag::MEDIA_TYPE) == paramsMap_.end() || + !paramsMap_[Tag::MEDIA_TYPE].SameTypeWith(typeid(Plugin::MediaType))) { + MEDIA_LOG_E("MEDIA_TYPE in ParamsMap is not exist!"); + return ErrorCode::ERROR_NOT_EXISTED; + } + auto mediaType = Plugin::AnyCast(paramsMap_[Tag::MEDIA_TYPE]); + if (mediaType == MediaType::VIDEO) { + ConfigVideoMeta(meta); + } else { + ConfigAudioMeta(meta); + } + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::ConfigVideoMeta(Plugin::Meta& meta) +{ + MEDIA_LOG_I("ConfigVideoMeta start!"); + if (paramsMap_.find(Tag::VIDEO_WIDTH) != paramsMap_.end() && + paramsMap_[Tag::VIDEO_WIDTH].SameTypeWith(typeid(int))) { + uint32_t width = Plugin::AnyCast(paramsMap_[Tag::VIDEO_WIDTH]); + MEDIA_LOG_I("ConfigVideoMeta: VIDEO_WIDTH is " PUBLIC_LOG_U32, width); + meta.Set(width); + } + if (paramsMap_.find(Tag::VIDEO_HEIGHT) != paramsMap_.end() && + paramsMap_[Tag::VIDEO_HEIGHT].SameTypeWith(typeid(int))) { + uint32_t height = Plugin::AnyCast(paramsMap_[Tag::VIDEO_HEIGHT]); + MEDIA_LOG_I("ConfigVideoMeta: VIDEO_HEIGHT is " PUBLIC_LOG_U32, height); + meta.Set(height); + } + if (paramsMap_.find(Tag::MEDIA_BITRATE) != paramsMap_.end() && + paramsMap_[Tag::MEDIA_BITRATE].SameTypeWith(typeid(int))) { + int64_t mediaBitRate = Plugin::AnyCast(paramsMap_[Tag::MEDIA_BITRATE]); + MEDIA_LOG_I("ConfigVideoMeta: MEDIA_BITRATE is " PUBLIC_LOG_D64, mediaBitRate); + meta.Set(mediaBitRate); + } + if (paramsMap_.find(Tag::VIDEO_FRAME_RATE) != paramsMap_.end() && + paramsMap_[Tag::VIDEO_FRAME_RATE].SameTypeWith(typeid(int))) { + uint32_t videoFrameRate = Plugin::AnyCast(paramsMap_[Tag::VIDEO_FRAME_RATE]); + MEDIA_LOG_I("ConfigVideoMeta: VIDEO_FRAME_RATE is " PUBLIC_LOG_U32, videoFrameRate); + meta.Set(videoFrameRate); + } + if (paramsMap_.find(Tag::VIDEO_BIT_STREAM_FORMAT) != paramsMap_.end() && + paramsMap_[Tag::VIDEO_BIT_STREAM_FORMAT].SameTypeWith(typeid(VideoBitStreamFormat))) { + auto videoBitStreamFormat = Plugin::AnyCast(paramsMap_[Tag::VIDEO_BIT_STREAM_FORMAT]); + MEDIA_LOG_I("ConfigVideoMeta: VIDEO_BIT_STREAM_FORMAT is " PUBLIC_LOG_U32, videoBitStreamFormat); + meta.Set(std::vector{videoBitStreamFormat}); + } + if (paramsMap_.find(Tag::VIDEO_PIXEL_FORMAT) != paramsMap_.end() && + paramsMap_[Tag::VIDEO_PIXEL_FORMAT].SameTypeWith(typeid(VideoPixelFormat))) { + auto videoPixelFormat = Plugin::AnyCast(paramsMap_[Tag::VIDEO_PIXEL_FORMAT]); + MEDIA_LOG_I("ConfigVideoMeta: VIDEO_PIXEL_FORMAT is " PUBLIC_LOG_U32, videoPixelFormat); + meta.Set(videoPixelFormat); + } + return ErrorCode::SUCCESS; +} + +OHOS::Media::Plugin::AudioChannelLayout AVInputFilter::TransAudioChannelLayout(int layoutPtr) +{ + const static std::pair mapArray[] = { + {1, OHOS::Media::Plugin::AudioChannelLayout::MONO}, + {2, OHOS::Media::Plugin::AudioChannelLayout::STEREO}, + }; + for (const auto& item : mapArray) { + if (item.first == layoutPtr) { + return item.second; + } + } + return OHOS::Media::Plugin::AudioChannelLayout::UNKNOWN; +} + +OHOS::Media::Plugin::AudioSampleFormat AVInputFilter::TransAudioSampleFormat(int sampleFormat) +{ + const static std::pair mapArray[] = { + {0, OHOS::Media::Plugin::AudioSampleFormat::U8}, + {1, OHOS::Media::Plugin::AudioSampleFormat::S16}, + {2, OHOS::Media::Plugin::AudioSampleFormat::S24}, + {3, OHOS::Media::Plugin::AudioSampleFormat::S32}, + {4, OHOS::Media::Plugin::AudioSampleFormat::F32P}, + {-1, OHOS::Media::Plugin::AudioSampleFormat::NONE}, + }; + for (const auto& item : mapArray) { + if (item.first == sampleFormat) { + return item.second; + } + } + return OHOS::Media::Plugin::AudioSampleFormat::NONE; +} + +ErrorCode AVInputFilter::ConfigAudioMeta(Plugin::Meta& meta) +{ + MEDIA_LOG_I("ConfigAudioMeta start"); + if (paramsMap_.find(Tag::AUDIO_CHANNELS) != paramsMap_.end() && + paramsMap_[Tag::AUDIO_CHANNELS].SameTypeWith(typeid(int))) { + uint32_t audioChannel = Plugin::AnyCast(paramsMap_[Tag::AUDIO_CHANNELS]); + MEDIA_LOG_I("ConfigAudioMeta: AUDIO_CHANNELS is " PUBLIC_LOG_U32, audioChannel); + meta.Set(audioChannel); + } + if (paramsMap_.find(Tag::AUDIO_SAMPLE_RATE) != paramsMap_.end() && + paramsMap_[Tag::AUDIO_SAMPLE_RATE].SameTypeWith(typeid(int))) { + uint32_t sampleRate = Plugin::AnyCast(paramsMap_[Tag::AUDIO_SAMPLE_RATE]); + MEDIA_LOG_I("ConfigAudioMeta: AUDIO_SAMPLE_RATE is " PUBLIC_LOG_U32, sampleRate); + meta.Set(sampleRate); + } + if (paramsMap_.find(Tag::MEDIA_BITRATE) != paramsMap_.end() && + paramsMap_[Tag::MEDIA_BITRATE].SameTypeWith(typeid(int))) { + int64_t mediaBitRate = Plugin::AnyCast(paramsMap_[Tag::MEDIA_BITRATE]); + MEDIA_LOG_I("ConfigAudioMeta: MEDIA_BITRATE is " PUBLIC_LOG_D64, mediaBitRate); + meta.Set(mediaBitRate); + } + if (paramsMap_.find(Tag::AUDIO_SAMPLE_FORMAT) != paramsMap_.end() && + paramsMap_[Tag::AUDIO_SAMPLE_FORMAT].SameTypeWith(typeid(int))) { + auto audioSampleFmtPtr = Plugin::AnyCast(paramsMap_[Tag::AUDIO_SAMPLE_FORMAT]); + MEDIA_LOG_I("ConfigAudioMeta: AUDIO_SAMPLE_FORMAT is " PUBLIC_LOG_U32, audioSampleFmtPtr); + meta.Set(TransAudioSampleFormat(audioSampleFmtPtr)); + } + if (paramsMap_.find(Tag::AUDIO_CHANNEL_LAYOUT) != paramsMap_.end() && + paramsMap_[Tag::AUDIO_CHANNEL_LAYOUT].SameTypeWith(typeid(int))) { + auto layoutPtr = Plugin::AnyCast(paramsMap_[Tag::AUDIO_CHANNEL_LAYOUT]); + MEDIA_LOG_I("ConfigAudioMeta: AUDIO_CHANNEL_LAYOUT is " PUBLIC_LOG_U32, layoutPtr); + meta.Set(TransAudioChannelLayout(layoutPtr)); + } + if (paramsMap_.find(Tag::AUDIO_SAMPLE_PER_FRAME) != paramsMap_.end() && + paramsMap_[Tag::AUDIO_SAMPLE_PER_FRAME].SameTypeWith(typeid(int))) { + uint32_t samplePerFrame = Plugin::AnyCast(paramsMap_[Tag::AUDIO_SAMPLE_PER_FRAME]); + MEDIA_LOG_I("ConfigAudioMeta: AUDIO_SAMPLE_PER_FRAME is " PUBLIC_LOG_U32, samplePerFrame); + meta.Set(samplePerFrame); + } + if (paramsMap_.find(Tag::AUDIO_AAC_LEVEL) != paramsMap_.end() && + paramsMap_[Tag::AUDIO_AAC_LEVEL].SameTypeWith(typeid(int))) { + uint32_t aacLevel = Plugin::AnyCast(paramsMap_[Tag::AUDIO_AAC_LEVEL]); + MEDIA_LOG_I("ConfigAudioMeta: AUDIO_AAC_LEVEL is " PUBLIC_LOG_U32, aacLevel); + meta.Set(aacLevel); + } + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::ConfigDownStream(const Plugin::Meta& meta) +{ + Meta upstreamParams; + Meta downstreamParams; + OSAL::ScopedLock lock(inputFilterMutex_); + if (outPorts_.size() == 0 || outPorts_[0] == nullptr) { + MEDIA_LOG_E("outPorts is empty or invalid!"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + if (!outPorts_[0]->Configure(std::make_shared(meta), upstreamParams, downstreamParams)) { + MEDIA_LOG_E("Configure downstream fail"); + return ErrorCode::ERROR_INVALID_OPERATION; + } + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::InitPlugin() +{ + MEDIA_LOG_I("InitPlugin"); + OSAL::ScopedLock lock(inputFilterMutex_); + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + return TranslatePluginStatus(plugin_->Init()); +} + +ErrorCode AVInputFilter::ConfigPlugin() +{ + MEDIA_LOG_I("Configure"); + ErrorCode err = SetPluginParams(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Set Plugin fail!"); + return err; + } + err = SetEventCallBack(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Plugin SetEventCallBack fail!"); + return err; + } + err = SetDataCallBack(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Plugin SetDataCallBack fail!"); + return err; + } + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::SetPluginParams() +{ + OSAL::ScopedLock lock(inputFilterMutex_); + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_NULL_POINTER; + } + if (paramsMap_.find(Tag::MEDIA_DESCRIPTION) != paramsMap_.end()) { + plugin_->SetParameter(Tag::MEDIA_DESCRIPTION, paramsMap_[Tag::MEDIA_DESCRIPTION]); + } + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::PreparePlugin() +{ + OSAL::ScopedLock lock(inputFilterMutex_); + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_NULL_POINTER; + } + return TranslatePluginStatus(plugin_->Prepare()); +} + +ErrorCode AVInputFilter::PushData(const std::string& inPort, const AVBufferPtr& buffer, int64_t offset) +{ + OSAL::ScopedLock lock(inputFilterMutex_); + if (name_.compare(inPort) != 0) { + MEDIA_LOG_E("FilterName is not targetName!"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + if (buffer == nullptr || plugin_ == nullptr) { + MEDIA_LOG_E("buffer or plugin is nullptr!"); + return ErrorCode::ERROR_NULL_POINTER; + } + MEDIA_LOG_I("PushData to plugin"); + if (TranslatePluginStatus(plugin_->PushData(inPort, buffer, offset)) != ErrorCode::SUCCESS) { + MEDIA_LOG_E("PushData to plugin fail!"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + MEDIA_LOG_I("PushData from plugin"); + if (outPorts_.size() == 0 || outPorts_[0] == nullptr) { + MEDIA_LOG_E("outPorts is empty or invalid!"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + MEDIA_LOG_I("PushData to next filter plugin!"); + outPorts_[0]->PushData(buffer, 0); + return ErrorCode::SUCCESS; +} + +ErrorCode AVInputFilter::SetEventCallBack() +{ + OSAL::ScopedLock lock(inputFilterMutex_); + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_NULL_POINTER ; + } + return TranslatePluginStatus(plugin_->SetCallback(this)); +} + +ErrorCode AVInputFilter::SetDataCallBack() +{ + OSAL::ScopedLock lock(inputFilterMutex_); + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_NULL_POINTER; + } + return TranslatePluginStatus(plugin_->SetDataCallback(std::bind(&AVInputFilter::OnDataCallback, this, + std::placeholders::_1))); +} + +void AVInputFilter::OnDataCallback(std::shared_ptr buffer) +{ + OSAL::ScopedLock lock(inputFilterMutex_); + if (buffer == nullptr) { + MEDIA_LOG_E("buffer is nullptr!"); + return; + } + if (outPorts_.size() == 0 || outPorts_[0] == nullptr) { + MEDIA_LOG_E("outPorts is invalid!"); + return; + } + outPorts_[0]->PushData(buffer, 0); +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.h b/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.h new file mode 100644 index 00000000..44ff8bfb --- /dev/null +++ b/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.h @@ -0,0 +1,79 @@ +/* + * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MEDIA_PIPELINE_INPUT_FILTER_H +#define MEDIA_PIPELINE_INPUT_FILTER_H + +#include +#include + +#include "foundation/osal/utils/util.h" +#include "foundation/utils/constants.h" +#include "pipeline/core/error_code.h" +#include "pipeline/core/filter_base.h" +#include "plugin/common/plugin_video_tags.h" +#include "plugin/core/plugin_manager.h" +#include "pipeline/core/type_define.h" +#include "../../plugin/interface/avtrans_input_plugin.h" +#include "../../plugin/core/avtrans_input.h" + +namespace OHOS { +namespace DistributedHardware { + +class AVInputFilter : public FilterBase { +public: + explicit AVInputFilter(const std::string& name); + ~AVInputFilter() override; + + std::vector GetWorkModes() override; + ErrorCode SetParameter(int32_t key, const Plugin::Any& value) override; + ErrorCode GetParameter(int32_t key, Plugin::Any& value) override; + ErrorCode Prepare() override; + ErrorCode Start() override; + ErrorCode Stop() override; + ErrorCode Pause() override; + ErrorCode Resume() override; + ErrorCode PushData(const std::string& inPort, const AVBufferPtr& buffer, int64_t offset) override; + +private: + void InitPorts() override; + ErrorCode FindPlugin(); + bool DoNegotiate(const CapabilitySet& outCaps); + ErrorCode CreatePlugin(const std::shared_ptr& selectedInfo); + ErrorCode DoConfigure(); + ErrorCode MergeMeta(const Plugin::Meta& meta, Plugin::Meta& targetMeta); + ErrorCode ConfigMeta(Plugin::Meta& meta); + ErrorCode ConfigVideoMeta(Plugin::Meta& meta); + ErrorCode ConfigAudioMeta(Plugin::Meta& meta); + ErrorCode ConfigDownStream(const Plugin::Meta& meta); + ErrorCode InitPlugin(); + ErrorCode ConfigPlugin(); + ErrorCode PreparePlugin(); + ErrorCode SetEventCallBack(); + ErrorCode SetDataCallBack(); + ErrorCode SetPluginParams(); + void OnDataCallback(std::shared_ptr buffer); + OHOS::Media::Plugin::AudioChannelLayout TransAudioChannelLayout(int layoutPtr); + OHOS::Media::Plugin::AudioSampleFormat TransAudioSampleFormat(int sampleFormat); + + std::shared_ptr plugin_ {nullptr}; + std::shared_ptr pluginInfo_ {nullptr}; + Capability capNegWithDownstream_ {}; + std::unordered_map paramsMap_; + OSAL::Mutex inputFilterMutex_ {}; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif \ No newline at end of file diff --git a/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp b/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp new file mode 100644 index 00000000..c640f745 --- /dev/null +++ b/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp @@ -0,0 +1,367 @@ +/* + * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#define HST_LOG_TAG "AVOutputFilter" +#include "av_transport_output_filter.h" +#include "pipeline/filters/common/plugin_utils.h" +#include "foundation/log.h" +#include "pipeline/factory/filter_factory.h" +#include "plugin/common/plugin_attr_desc.h" + +namespace OHOS { +namespace DistributedHardware { + +static AutoRegisterFilter g_registerFilterHelper("builtin.avtransport.avoutput"); + +AVOutputFilter::AVOutputFilter(const std::string& name) : FilterBase(name), plugin_(nullptr), pluginInfo_(nullptr) +{ + MEDIA_LOG_I("ctor called"); +} + +AVOutputFilter::~AVOutputFilter() +{ + MEDIA_LOG_I("dtor called"); + OSAL::ScopedLock lock(outputFilterMutex_); + if (plugin_ != nullptr) { + plugin_->Deinit(); + } +} + +std::vector AVOutputFilter::GetWorkModes() +{ + return {WorkMode::PUSH}; +} + +ErrorCode AVOutputFilter::SetParameter(int32_t key, const Any& value) +{ + MEDIA_LOG_I("SetParameter key " PUBLIC_LOG_D32, key); + Tag tag; + if (!TranslateIntoParameter(key, tag)) { + MEDIA_LOG_E("This key is invalid!"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + { + OSAL::ScopedLock lock(outputFilterMutex_); + paramsMap_[tag] = value; + } + return ErrorCode::SUCCESS; +} + +ErrorCode AVOutputFilter::GetParameter(int32_t key, Any& value) +{ + Tag tag; + if (!TranslateIntoParameter(key, tag)) { + MEDIA_LOG_E("This key is invalid!"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + { + OSAL::ScopedLock lock(outputFilterMutex_); + value = paramsMap_[tag]; + } + return ErrorCode::SUCCESS; +} + +ErrorCode AVOutputFilter::Prepare() +{ + MEDIA_LOG_I("Prepare entered."); + if (state_ != FilterState::INITIALIZED) { + MEDIA_LOG_E("The current state is invalid"); + return ErrorCode::ERROR_INVALID_STATE; + } + state_ = FilterState::PREPARING; + ErrorCode err = FindPlugin(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Find plugin fail"); + state_ = FilterState::INITIALIZED; + return err; + } + err = InitPlugin(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Init plugin fail"); + state_ = FilterState::INITIALIZED; + return err; + } + err = ConfigPlugin(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Configure downStream fail"); + state_ = FilterState::INITIALIZED; + return err; + } + err = PreparePlugin(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Prepare plugin fail"); + state_ = FilterState::INITIALIZED; + return err; + } + state_ = FilterState::READY; + MEDIA_LOG_I("Prepare end."); + return err; +} + +ErrorCode AVOutputFilter::Start() +{ + MEDIA_LOG_I("Start"); + OSAL::ScopedLock lock(outputFilterMutex_); + if (state_ != FilterState::READY && state_ != FilterState::PAUSED) { + MEDIA_LOG_E("The current state is invalid"); + return ErrorCode::ERROR_INVALID_STATE; + } + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_NULL_POINTER; + } + if (TranslatePluginStatus(plugin_->Start()) != ErrorCode::SUCCESS) { + MEDIA_LOG_E("The plugin start fail!"); + return ErrorCode::ERROR_INVALID_OPERATION; + } + state_ = FilterState::RUNNING; + return ErrorCode::SUCCESS; +} + +ErrorCode AVOutputFilter::Stop() +{ + MEDIA_LOG_I("Stop"); + OSAL::ScopedLock lock(outputFilterMutex_); + if (state_ != FilterState::RUNNING) { + MEDIA_LOG_E("The current state is invalid"); + return ErrorCode::ERROR_INVALID_STATE; + } + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_NULL_POINTER; + } + if (TranslatePluginStatus(plugin_->Stop()) != ErrorCode::SUCCESS) { + MEDIA_LOG_E("The plugin stop fail!"); + return ErrorCode::ERROR_INVALID_OPERATION; + } + state_ = FilterState::READY; + return ErrorCode::SUCCESS; +} + +ErrorCode AVOutputFilter::Pause() +{ + MEDIA_LOG_I("Pause"); + OSAL::ScopedLock lock(outputFilterMutex_); + if (state_ != FilterState::RUNNING) { + MEDIA_LOG_E("The current state is invalid"); + return ErrorCode::ERROR_INVALID_STATE; + } + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_NULL_POINTER; + } + if (TranslatePluginStatus(plugin_->Stop()) != ErrorCode::SUCCESS) { + MEDIA_LOG_E("The plugin stop fail!"); + return ErrorCode::ERROR_INVALID_OPERATION; + } + state_ = FilterState::PAUSED; + return ErrorCode::SUCCESS; +} + +ErrorCode AVOutputFilter::Resume() +{ + MEDIA_LOG_I("Resume"); + return ErrorCode::SUCCESS; +} + +void AVOutputFilter::InitPorts() +{ + MEDIA_LOG_I("InitPorts"); + auto inPort = std::make_shared(this); + { + OSAL::ScopedLock lock(outputFilterMutex_); + inPorts_.push_back(inPort); + } +} + +ErrorCode AVOutputFilter::FindPlugin() +{ + OSAL::ScopedLock lock(outputFilterMutex_); + std::string mime; + if (paramsMap_.find(Tag::MIME) == paramsMap_.end() || + !paramsMap_[Tag::MIME].SameTypeWith(typeid(std::string))) { + MEDIA_LOG_E("Must set mime correctly first"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + mime = Plugin::AnyCast(paramsMap_[Tag::MIME]); + auto nameList = PluginManager::Instance().ListPlugins(PluginType::AVTRANS_OUTPUT); + for (const std::string& name : nameList) { + auto info = PluginManager::Instance().GetPluginInfo(PluginType::AVTRANS_OUTPUT, name); + if (mime != info->inCaps[0].mime) { + continue; + } + if (CreatePlugin(info) == ErrorCode::SUCCESS) { + MEDIA_LOG_I("CreatePlugin " PUBLIC_LOG_S " success", name_.c_str()); + return ErrorCode::SUCCESS; + } + } + MEDIA_LOG_I("Cannot find any plugin"); + return ErrorCode::ERROR_UNSUPPORTED_FORMAT; +} + +bool AVOutputFilter::Negotiate(const std::string& inPort, const std::shared_ptr& upstreamCap, + Plugin::Capability& negotiatedCap, const Plugin::Meta& upstreamParams, Plugin::Meta& downstreamParams) +{ + MEDIA_LOG_I("Negotiate"); + if (pluginInfo_ == nullptr) { + MEDIA_LOG_E("pluginInfo_ is nullptr"); + return false; + } + negotiatedCap = pluginInfo_->inCaps[0]; + return true; +} + +ErrorCode AVOutputFilter::CreatePlugin(const std::shared_ptr& selectedInfo) +{ + MEDIA_LOG_I("CreatePlugin"); + if (selectedInfo == nullptr || selectedInfo->name.empty()) { + MEDIA_LOG_E("selectedInfo is nullptr or pluginName is invalid!"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + if ((plugin_ != nullptr) && (pluginInfo_ != nullptr)) { + if (selectedInfo->name == pluginInfo_->name && TranslatePluginStatus(plugin_->Reset()) == ErrorCode::SUCCESS) { + MEDIA_LOG_I("Reuse last plugin: " PUBLIC_LOG_S, selectedInfo->name.c_str()); + return ErrorCode::SUCCESS; + } + if (TranslatePluginStatus(plugin_->Deinit()) != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Deinit last plugin: " PUBLIC_LOG_S " error", pluginInfo_->name.c_str()); + } + } + plugin_ = PluginManager::Instance().CreateAvTransOutputPlugin(selectedInfo->name); + if (plugin_ == nullptr) { + MEDIA_LOG_E("PluginManager CreatePlugin " PUBLIC_LOG_S " fail", selectedInfo->name.c_str()); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + pluginInfo_ = selectedInfo; + MEDIA_LOG_I("Create new plugin: " PUBLIC_LOG_S " success", pluginInfo_->name.c_str()); + return ErrorCode::SUCCESS; +} + +bool AVOutputFilter::Configure(const std::string& inPort, const std::shared_ptr& upstreamMeta, + Plugin::Meta& upstreamParams, Plugin::Meta& downstreamParams) +{ + MEDIA_LOG_I("DoConfigure"); + return true; +} + +ErrorCode AVOutputFilter::InitPlugin() +{ + MEDIA_LOG_I("InitPlugin"); + OSAL::ScopedLock lock(outputFilterMutex_); + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + return TranslatePluginStatus(plugin_->Init()); +} + +ErrorCode AVOutputFilter::ConfigPlugin() +{ + MEDIA_LOG_I("Configure"); + ErrorCode err = SetPluginParams(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Set Plugin fail!"); + return err; + } + err = SetEventCallBack(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Plugin SetEventCallBack fail!"); + return err; + } + err = SetDataCallBack(); + if (err != ErrorCode::SUCCESS) { + MEDIA_LOG_E("Plugin SetDataCallBack fail!"); + return err; + } + return ErrorCode::SUCCESS; +} + +ErrorCode AVOutputFilter::PreparePlugin() +{ + OSAL::ScopedLock lock(outputFilterMutex_); + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_INVALID_PARAMETER_TYPE; + } + return TranslatePluginStatus(plugin_->Prepare()); +} + +ErrorCode AVOutputFilter::PushData(const std::string& inPort, const AVBufferPtr& buffer, int64_t offset) +{ + OSAL::ScopedLock lock(outputFilterMutex_); + if (buffer == nullptr || plugin_ == nullptr) { + MEDIA_LOG_E("buffer or plugin is nullptr!"); + return ErrorCode::ERROR_INVALID_PARAMETER_TYPE; + } + plugin_->PushData(inPort, buffer, offset); + MEDIA_LOG_E("push buffer to plugin."); + return ErrorCode::SUCCESS; +} + +ErrorCode AVOutputFilter::SetPluginParams() +{ + OSAL::ScopedLock lock(outputFilterMutex_); + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_NULL_POINTER; + } + if (paramsMap_.find(Tag::MEDIA_DESCRIPTION) != paramsMap_.end()) { + plugin_->SetParameter(Tag::MEDIA_DESCRIPTION, paramsMap_[Tag::MEDIA_DESCRIPTION]); + } + if (paramsMap_.find(Tag::AUDIO_CHANNELS) != paramsMap_.end()) { + plugin_->SetParameter(Tag::AUDIO_CHANNELS, paramsMap_[Tag::AUDIO_CHANNELS]); + } + if (paramsMap_.find(Tag::AUDIO_SAMPLE_RATE) != paramsMap_.end()) { + plugin_->SetParameter(Tag::AUDIO_SAMPLE_RATE, paramsMap_[Tag::AUDIO_SAMPLE_RATE]); + } + if (paramsMap_.find(Tag::AUDIO_CHANNEL_LAYOUT) != paramsMap_.end()) { + plugin_->SetParameter(Tag::AUDIO_CHANNEL_LAYOUT, paramsMap_[Tag::AUDIO_CHANNEL_LAYOUT]); + } + return ErrorCode::SUCCESS; +} + +ErrorCode AVOutputFilter::SetEventCallBack() +{ + OSAL::ScopedLock lock(outputFilterMutex_); + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + plugin_->SetCallback(this); + return ErrorCode::SUCCESS; +} + +ErrorCode AVOutputFilter::SetDataCallBack() +{ + OSAL::ScopedLock lock(outputFilterMutex_); + if (plugin_ == nullptr) { + MEDIA_LOG_E("plugin is nullptr!"); + return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; + } + plugin_->SetDataCallback(std::bind(&AVOutputFilter::OnDataCallback, this, std::placeholders::_1)); + return ErrorCode::SUCCESS; +} + +void AVOutputFilter::OnDataCallback(std::shared_ptr buffer) +{ + OSAL::ScopedLock lock(outputFilterMutex_); + if (buffer == nullptr) { + MEDIA_LOG_E("buffer is nullptr!"); + return; + } + OnEvent(Event{name_, EventType::EVENT_BUFFER_PROGRESS, buffer}); +} +} // namespace DistributedHardware +} // namespace OHOS \ No newline at end of file diff --git a/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.h b/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.h new file mode 100644 index 00000000..7cd2fc81 --- /dev/null +++ b/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.h @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MEDIA_PIPELINE_OUTPUT_FILTER_H +#define MEDIA_PIPELINE_OUTPUT_FILTER_H + +#include +#include + +#include "foundation/osal/utils/util.h" +#include "foundation/utils/constants.h" +#include "pipeline/core/error_code.h" +#include "pipeline/core/filter_base.h" +#include "plugin/common/plugin_video_tags.h" +#include "plugin/core/plugin_manager.h" +#include "pipeline/core/type_define.h" +#include "../../plugin/interface/avtrans_output_plugin.h" +#include "../../plugin/core/avtrans_output.h" + +namespace OHOS { +namespace DistributedHardware { + +class AVOutputFilter : public FilterBase { +public: + explicit AVOutputFilter(const std::string& name); + ~AVOutputFilter() override; + + std::vector GetWorkModes() override; + ErrorCode SetParameter(int32_t key, const Plugin::Any& value) override; + ErrorCode GetParameter(int32_t key, Plugin::Any& value) override; + ErrorCode Prepare() override; + ErrorCode Start() override; + ErrorCode Stop() override; + ErrorCode Pause() override; + ErrorCode Resume() override; + ErrorCode PushData(const std::string& inPort, const AVBufferPtr& buffer, int64_t offset) override; + bool Negotiate(const std::string& inPort, const std::shared_ptr& upstreamCap, + Plugin::Capability& negotiatedCap, const Plugin::Meta& upstreamParams, + Plugin::Meta& downstreamParams) override; + bool Configure(const std::string& inPort, const std::shared_ptr& upstreamMeta, + Plugin::Meta& upstreamParams, Plugin::Meta& downstreamParams) override; + +private: + void InitPorts() override; + ErrorCode FindPlugin(); + ErrorCode CreatePlugin(const std::shared_ptr& selectedInfo); + ErrorCode InitPlugin(); + ErrorCode ConfigPlugin(); + ErrorCode PreparePlugin(); + ErrorCode SetEventCallBack(); + ErrorCode SetDataCallBack(); + ErrorCode SetPluginParams(); + void OnDataCallback(std::shared_ptr buffer); + + std::shared_ptr plugin_ {nullptr}; + std::shared_ptr pluginInfo_ {nullptr}; + std::unordered_map paramsMap_; + OSAL::Mutex outputFilterMutex_ {}; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif \ No newline at end of file diff --git a/av_transport/av_trans_engine/plugin/core/avtrans_input.cpp b/av_transport/av_trans_engine/plugin/core/avtrans_input.cpp new file mode 100644 index 00000000..d1e19f2f --- /dev/null +++ b/av_transport/av_trans_engine/plugin/core/avtrans_input.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "avtrans_input.h" + +#include "../interface/avtrans_input_plugin.h" + +AvTransInput::AvTransInput(uint32_t pkgVer, uint32_t apiVer, std::shared_ptr plugin) + : Base(pkgVer, apiVer, plugin), AvTransInputPlugin_(std::move(plugin)) {} + +Status AvTransInput::PushData(const std::string& inPort, std::shared_ptr buffer, int32_t offset) +{ + return AvTransInputPlugin_->PushData(inPort, buffer, offset); +} + +Status AvTransInput::SetDataCallback(std::function)> callback) +{ + return AvTransInputPlugin_->SetDataCallback(callback); +} \ No newline at end of file diff --git a/av_transport/av_trans_engine/plugin/core/avtrans_input.h b/av_transport/av_trans_engine/plugin/core/avtrans_input.h new file mode 100644 index 00000000..1740c9b2 --- /dev/null +++ b/av_transport/av_trans_engine/plugin/core/avtrans_input.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HISTREAMER_PLUGIN_CORE_AVTRANS_INPUT_H +#define HISTREAMER_PLUGIN_CORE_AVTRANS_INPUT_H + +#include +#include +#include + +#include "plugin/core/base.h" +#include "plugin/common/plugin_types.h" + +namespace OHOS { +namespace DistributedHardware { +struct AvTransInputPlugin; + +class AvTransInput : public Base { +public: + AvTransInput(const AvTransInput &) = delete; + AvTransInput operator=(const AvTransInput &) = delete; + ~AvTransInput() override = default; + + Status PushData(const std::string& inPort, std::shared_ptr buffer, int32_t offset); + + Status SetDataCallback(std::function)> callback); + + AvTransInput(uint32_t pkgVer, uint32_t apiVer, std::shared_ptr plugin); + +private: + std::shared_ptr AvTransInputPlugin_; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // HISTREAMER_PLUGIN_CORE_AVTRANS_INPUT_H \ No newline at end of file diff --git a/av_transport/av_trans_engine/plugin/core/avtrans_output.cpp b/av_transport/av_trans_engine/plugin/core/avtrans_output.cpp new file mode 100644 index 00000000..91d76054 --- /dev/null +++ b/av_transport/av_trans_engine/plugin/core/avtrans_output.cpp @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include "avtrans_output.h"\ + +#include "../interface/avtrans_output_plugin.h" + +AvTransOutput::AvTransOutput(uint32_t pkgVer, uint32_t apiVer, std::shared_ptr plugin) + : Base(pkgVer, apiVer, plugin), AvTransOutputPlugin_(std::move(plugin)) {} + +Status AvTransOutput::PushData(const std::string& inPort, std::shared_ptr buffer, int32_t offset) +{ + return AvTransOutputPlugin_->PushData(inPort, buffer, offset); +} + +Status AvTransOutput::SetDataCallback(std::function)> callback) +{ + return AvTransOutputPlugin_->SetDataCallback(callback); +} \ No newline at end of file diff --git a/av_transport/av_trans_engine/plugin/core/avtrans_output.h b/av_transport/av_trans_engine/plugin/core/avtrans_output.h new file mode 100644 index 00000000..292884a4 --- /dev/null +++ b/av_transport/av_trans_engine/plugin/core/avtrans_output.h @@ -0,0 +1,47 @@ +/* + * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HISTREAMER_PLUGIN_CORE_AVTRANS_OUTPUT_H +#define HISTREAMER_PLUGIN_CORE_AVTRANS_OUTPUT_H + +#include +#include +#include + +#include "plugin/core/base.h" +#include "plugin/common/plugin_types.h" + +namespace OHOS { +namespace DistributedHardware { +struct AvTransOutputPlugin; + +class AvTransOutput : public Base { +public: + AvTransOutput(const AvTransOutput &) = delete; + AvTransOutput operator=(const AvTransOutput &) = delete; + ~AvTransOutput() override = default; + + Status PushData(const std::string& inPort, std::shared_ptr buffer, int32_t offset); + + Status SetDataCallback(std::function)> callback); + + AvTransOutput(uint32_t pkgVer, uint32_t apiVer, std::shared_ptr plugin); + +private: + std::shared_ptr AvTransOutputPlugin_; +}; +} // namespace DistributedHardware +} // namespace OHOS +#endif // HISTREAMER_PLUGIN_CORE_AVTRANS_OUTPUT_H \ No newline at end of file diff --git a/av_transport/av_trans_engine/plugin/interface/avtrans_input_plugin.h b/av_transport/av_trans_engine/plugin/interface/avtrans_input_plugin.h new file mode 100644 index 00000000..f50f2e07 --- /dev/null +++ b/av_transport/av_trans_engine/plugin/interface/avtrans_input_plugin.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HISTREAMER_PLUGIN_INTF_AVTRANS_INPUT_PLUGIN_H +#define HISTREAMER_PLUGIN_INTF_AVTRANS_INPUT_PLUGIN_H + +#include +#include + +#include "plugin/common/media_source.h" +#include "plugin/common/plugin_source_tags.h" +#include "plugin/common/plugin_buffer.h" +#include "plugin/common/plugin_caps.h" +#include "plugin/interface/plugin_base.h" +#include "plugin/interface/plugin_definition.h" + +namespace OHOS { +namespace DistributedHardware { +struct AvTransInputPlugin : public PluginBase { +explicit AvTransInputPlugin(std::string name): PluginBase(std::move(name)) {} + +virtual OHOS::Media::Plugin::Status PushData(const std::string& inPort, std::shared_ptr buffer, + int32_t offset) = 0; + +virtual OHOS::Media::Plugin::Status SetDataCallback(std::function)> callback) = 0; +}; + +/// Avtrans input plugin api major number. +#define AVTRANS_INPUT_API_VERSION_MAJOR (1) + +/// Avtrans input plugin api minor number +#define AVTRANS_INPUT_API_VERSION_MINOR (0) + +/// Avtrans input plugin version +#define AVTRANS_INPUT_API_VERSION MAKE_VERSION(AVTRANS_INPUT_API_VERSION_MAJOR, AVTRANS_INPUT_API_VERSION_MINOR) + +} // namespace DistributedHardware +} // namespace OHOS +#endif \ No newline at end of file diff --git a/av_transport/av_trans_engine/plugin/interface/avtrans_output_plugin.h b/av_transport/av_trans_engine/plugin/interface/avtrans_output_plugin.h new file mode 100644 index 00000000..e646a113 --- /dev/null +++ b/av_transport/av_trans_engine/plugin/interface/avtrans_output_plugin.h @@ -0,0 +1,51 @@ +/* + * Copyright (c) 2023-2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef HISTREAMER_PLUGIN_INTF_AVTRANS_OUTPUT_PLUGIN_H +#define HISTREAMER_PLUGIN_INTF_AVTRANS_OUTPUT_PLUGIN_H + +#include +#include + +#include "plugin/common/media_source.h" +#include "plugin/common/plugin_source_tags.h" +#include "plugin/common/plugin_buffer.h" +#include "plugin/common/plugin_caps.h" +#include "plugin_base.h" +#include "plugin_definition.h" + +namespace OHOS { +namespace DistributedHardware { +struct AvTransOutputPlugin : public PluginBase { +explicit AvTransOutputPlugin(std::string name): PluginBase(std::move(name)) {} + +virtual OHOS::Media::Plugin::Status PushData(const std::string& inPort, std::shared_ptr buffer, + int32_t offset) = 0; + +virtual OHOS::Media::Plugin::Status SetDataCallback(std::function)> callback) = 0; +}; + +/// Avtrans output plugin api major number. +#define AVTRANS_OUTPUT_API_VERSION_MAJOR (1) + +/// Avtrans output plugin api minor number +#define AVTRANS_OUTPUT_API_VERSION_MINOR (0) + +/// Avtrans output plugin version +#define AVTRANS_OUTPUT_API_VERSION MAKE_VERSION(AVTRANS_OUTPUT_API_VERSION_MAJOR, AVTRANS_OUTPUT_API_VERSION_MINOR) + +} // namespace DistributedHardware +} // namespace OHOS +#endif \ No newline at end of file diff --git a/av_transport/av_trans_engine/plugins/av_trans_input/daudio_input/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn similarity index 90% rename from av_transport/av_trans_engine/plugins/av_trans_input/daudio_input/BUILD.gn rename to av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn index 7da1939c..7165b5b7 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_input/daudio_input/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -ohos_shared_library("histreamer_plugin_AVTransDaudioInput") { +source_set("plugin_AVTransDaudioInput") { include_dirs = [ "${common_path}/include", "${histreamer_path}/foundation/osal/thread", @@ -48,10 +48,4 @@ ohos_shared_library("histreamer_plugin_AVTransDaudioInput") { "DH_LOG_TAG=\"daudio_input_plugin\"", "LOG_DOMAIN=0xD004100", ] - - relative_install_dir = "media/histreamer_plugins" - - subsystem_name = "multimedia" - - part_name = "histreamer" } diff --git a/av_transport/av_trans_engine/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp similarity index 88% rename from av_transport/av_trans_engine/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp rename to av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp index fda9811e..0b25fb7c 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp @@ -17,23 +17,26 @@ #include "foundation/utils/constants.h" #include "plugin/common/plugin_caps_builder.h" +#include "plugin/factory/plugin_factory.h" +#include "plugin/interface/generic_plugin.h" namespace OHOS { namespace DistributedHardware { -std::shared_ptr DaudioInputPluginCreator(const std::string& name) +GenericPluginDef CreateDaudioInputPluginDef() { - return std::make_shared(name); -} - -Status DaudioInputRegister(const std::shared_ptr& reg) -{ - AvTransInputPluginDef definition; + DHLOGI("DaudioInputPlugin registered."); + GenericPluginDef definition; definition.name = "AVTransDaudioInputPlugin"; + definition.pkgName = "AVTransDaudioInputPlugin"; definition.description = "Audio transport from daudio service"; definition.rank = PLUGIN_RANK; - definition.creator = DaudioInputPluginCreator; - definition.pluginType = PluginType::AVTRANS_INPUT; + definition.creator = [] (const std::string& name) -> std::shared_ptr { + return std::make_shared(name); + } + + definition.pkgVersion = AVTRANS_INPUT_API_VERSION; + definition.license = LicenseType::APACHE_V2; CapabilityBuilder capBuilder; capBuilder.SetMime(OHOS::Media::MEDIA_MIME_AUDIO_RAW); @@ -41,12 +44,9 @@ Status DaudioInputRegister(const std::shared_ptr& reg) 22050, 24000, 32000, 44100, 48000, 64000, 96000}; capBuilder.SetAudioSampleRateList(values); definition.outCaps.push_back(capBuilder.Build()); - - return reg->AddPlugin(definition); + return definition; } -PLUGIN_DEFINITION(AVTransDaudioInput, LicenseType::APACHE_V2, DaudioInputRegister, [] {}); - DaudioInputPlugin::DaudioInputPlugin(std::string name) : AvTransInputPlugin(std::move(name)) { diff --git a/av_transport/av_trans_engine/plugins/av_trans_input/daudio_input/daudio_input_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.h similarity index 98% rename from av_transport/av_trans_engine/plugins/av_trans_input/daudio_input/daudio_input_plugin.h rename to av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.h index 0e0174a9..f637f083 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_input/daudio_input/daudio_input_plugin.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.h @@ -21,7 +21,6 @@ #include #include -#include "av_sync_utils.h" #include "av_trans_buffer.h" #include "av_trans_constants.h" #include "av_trans_log.h" diff --git a/av_transport/av_trans_engine/plugins/av_trans_input/dscreen_input/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn similarity index 91% rename from av_transport/av_trans_engine/plugins/av_trans_input/dscreen_input/BUILD.gn rename to av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn index 143fb45d..f9d7d286 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_input/dscreen_input/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -ohos_shared_library("histreamer_plugin_AVTransDscreenInput") { +source_set("plugin_AVTransDscreenInput") { include_dirs = [ "${common_path}/include", "${plugin_path}/interface", @@ -55,10 +55,4 @@ ohos_shared_library("histreamer_plugin_AVTransDscreenInput") { "ipc:ipc_core", "samgr:samgr_proxy", ] - - relative_install_dir = "media/histreamer_plugins" - - subsystem_name = "multimedia" - - part_name = "histreamer" } diff --git a/av_transport/av_trans_engine/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp similarity index 86% rename from av_transport/av_trans_engine/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp rename to av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp index aeb9d238..2ae35707 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp @@ -17,34 +17,35 @@ #include "av_trans_utils.h" #include "foundation/utils/constants.h" #include "nlohmann/json.hpp" +#include "plugin/factory/plugin_factory.h" +#include "plugin/interface/generic_plugin.h" namespace OHOS { namespace DistributedHardware { using json = nlohmann::json; -std::shared_ptr DscreenInputPluginCreator(const std::string &name) +GenericPluginDef CreateDscreenInputPluginDef() { - return std::make_shared(name); -} - -Status DscreenInputRegister(const std::shared_ptr ®) -{ - AvTransInputPluginDef definition; + DHLOGI("DscreenInputPlugin registered."); + GenericPluginDef definition; definition.name = "AVTransDscreenInputPlugin"; - definition.description = "Video transport from dsrceen service"; + definition.pkgName = "AVTransDscreenInputPlugin"; + definition.description = "Video transport from dscreen service"; definition.rank = PLUGIN_RANK; - definition.pluginType = PluginType::AVTRANS_INPUT; - definition.creator = DscreenInputPluginCreator; + definition.creator = [] (const std::string& name) -> std::shared_ptr { + return std::make_shared(name); + } + + definition.pkgVersion = AVTRANS_INPUT_API_VERSION; + definition.license = LicenseType::APACHE_V2; Capability outCap(Media::MEDIA_MIME_VIDEO_RAW); outCap.AppendDiscreteKeys( Capability::Key::VIDEO_PIXEL_FORMAT, {VideoPixelFormat::RGBA}); definition.outCaps.push_back(outCap); - return reg->AddPlugin(definition); + return definition; } -PLUGIN_DEFINITION(AVTransDscreenInput, LicenseType::APACHE_V2, DscreenInputRegister, [] {}); - DscreenInputPlugin::DscreenInputPlugin(std::string name) : AvTransInputPlugin(std::move(name)) { diff --git a/av_transport/av_trans_engine/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.h similarity index 100% rename from av_transport/av_trans_engine/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.h rename to av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.h diff --git a/av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn similarity index 90% rename from av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input/BUILD.gn rename to av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn index 05d87100..5718da56 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -ohos_shared_library("histreamer_plugin_AVTransDsoftbusInput") { +source_set("plugin_AVTransDsoftbusInput") { include_dirs = [ "${common_path}/include", "${plugin_path}/interface", @@ -50,10 +50,4 @@ ohos_shared_library("histreamer_plugin_AVTransDsoftbusInput") { ] external_deps = [ "dsoftbus:softbus_client" ] - - relative_install_dir = "media/histreamer_plugins" - - subsystem_name = "multimedia" - - part_name = "histreamer" } diff --git a/av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp similarity index 92% rename from av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp rename to av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp index 5e76d5cb..a240532b 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp @@ -18,39 +18,43 @@ #include "foundation/utils/constants.h" #include "plugin/common/share_memory.h" #include "plugin/common/plugin_caps_builder.h" +#include "plugin/factory/plugin_factory.h" +#include "plugin/interface/generic_plugin.h" namespace OHOS { namespace DistributedHardware { -std::shared_ptr DsoftbusInputPluginCreator(const std::string &name) -{ - return std::make_shared(name); -} -Status DsoftbusInputRegister(const std::shared_ptr ®) +GenericPluginDef CreateDsoftbusInputPluginDef() { int32_t capNum = 2; + std::vector definitionList; for (int i = 0; i < capNum; i++) { + DHLOGI("DsoftbusInputPlugin_H264 registered."); AvTransInputPluginDef definition; definition.name = "AVTransDsoftbusInputPlugin_H264"; + definition.pkgName = "AVTransDsoftbusInputPlugin"; definition.description = "Video transport from dsoftbus"; definition.rank = PLUGIN_RANK; - definition.pluginType = PluginType::AVTRANS_INPUT; - definition.creator = DsoftbusInputPluginCreator; + definition.creator = [] (const std::string& name) -> std::shared_ptr { + return std::make_shared(name); + } + + definition.pkgVersion = AVTRANS_INPUT_API_VERSION; + definition.license = LicenseType::APACHE_V2; CapabilityBuilder capBuilder; capBuilder.SetMime(Media::MEDIA_MIME_VIDEO_H264); if (i == 1) { + DHLOGI("DsoftbusInputPlugin_H265 registered."); definition.name = "AVTransDsoftbusInputPlugin_H265"; capBuilder.SetMime(Media::MEDIA_MIME_VIDEO_H265); } definition.outCaps.push_back(capBuilder.Build()); - reg->AddPlugin(definition); + definitionList.push_back(definition); } - return Status::OK; + return definitionList; } -PLUGIN_DEFINITION(AVTransDsoftbusInput, LicenseType::APACHE_V2, DsoftbusInputRegister, [] {}); - DsoftbusInputPlugin::DsoftbusInputPlugin(std::string name) : AvTransInputPlugin(std::move(name)) { diff --git a/av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.h similarity index 100% rename from av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.h rename to av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.h diff --git a/av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn similarity index 90% rename from av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn rename to av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn index e7ccc5f7..61a9d23e 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -ohos_shared_library("histreamer_plugin_AVTransDsoftbusInputAudio") { +source_set("plugin_AVTransDsoftbusInputAudio") { include_dirs = [ "${common_path}/include", "${plugin_path}/interface", @@ -50,10 +50,4 @@ ohos_shared_library("histreamer_plugin_AVTransDsoftbusInputAudio") { ] external_deps = [ "dsoftbus:softbus_client" ] - - relative_install_dir = "media/histreamer_plugins" - - subsystem_name = "multimedia" - - part_name = "histreamer" } diff --git a/av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp similarity index 89% rename from av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp rename to av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp index 6663bef9..56704c2b 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp @@ -18,12 +18,34 @@ #include "foundation/utils/constants.h" #include "plugin/common/share_memory.h" #include "plugin/common/plugin_caps_builder.h" +#include "plugin/factory/plugin_factory.h" +#include "plugin/interface/generic_plugin.h" namespace OHOS { namespace DistributedHardware { -std::shared_ptr DsoftbusInputAudioPluginCreator(const std::string &name) + +GenericPluginDef CreateDsoftbusInputAudioPluginDef() { - return std::make_shared(name); + DHLOGI("DsoftbusInputAudioPlugin registered."); + GenericPluginDef definition; + definition.name = "AVTransDsoftbusInputAudioPlugin"; + definition.pkgName = "AVTransDsoftbusInputAudioPlugin"; + definition.description = "Audio transport from dsoftbus"; + definition.rank = PLUGIN_RANK; + definition.creator = [] (const std::string& name) -> std::shared_ptr { + return std::make_shared(name); + } + + definition.pkgVersion = AVTRANS_INPUT_API_VERSION; + definition.license = LicenseType::APACHE_V2; + + CapabilityBuilder capBuilder; + capBuilder.SetMime(OHOS::Media::MEDIA_MIME_AUDIO_AAC); + DiscreteCapability values = {8000, 11025, 12000, 16000, + 22050, 24000, 32000, 44100, 48000, 64000, 96000}; + capBuilder.SetAudioSampleRateList(values); + definition.outCaps.push_back(capBuilder.Build()); + return definition; } Status DsoftbusInputAudioRegister(const std::shared_ptr ®) diff --git a/av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.h similarity index 100% rename from av_transport/av_trans_engine/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.h rename to av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.h diff --git a/av_transport/av_trans_engine/plugins/av_trans_output/daudio_output/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn similarity index 91% rename from av_transport/av_trans_engine/plugins/av_trans_output/daudio_output/BUILD.gn rename to av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn index aeabb7bc..3c5ccf78 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_output/daudio_output/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -ohos_shared_library("histreamer_plugin_AVTransDaudioOutput") { +source_set("plugin_AVTransDaudioOutput") { include_dirs = [ "${common_path}/include", "${histreamer_path}/foundation/osal/thread", @@ -51,10 +51,4 @@ ohos_shared_library("histreamer_plugin_AVTransDaudioOutput") { "DH_LOG_TAG=\"daudio_output_plugin\"", "LOG_DOMAIN=0xD004100", ] - - relative_install_dir = "media/histreamer_plugins" - - subsystem_name = "multimedia" - - part_name = "histreamer" } diff --git a/av_transport/av_trans_engine/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp similarity index 95% rename from av_transport/av_trans_engine/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp rename to av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp index 5768f462..8202c717 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp @@ -17,23 +17,26 @@ #include "foundation/utils/constants.h" #include "plugin/common/plugin_caps_builder.h" +#include "plugin/factory/plugin_factory.h" +#include "plugin/interface/generic_plugin.h" namespace OHOS { namespace DistributedHardware { -std::shared_ptr DaudioOutputPluginCreator(const std::string& name) +GenericPluginDef CreateDaudioOutputPluginDef() { - return std::make_shared(name); -} - -Status DaudioOutputRegister(const std::shared_ptr ®) -{ - AvTransOutputPluginDef definition; + DHLOGI("DaudioOutputPlugin registered."); + GenericPluginDef definition; definition.name = "AVTransDaudioOutputPlugin"; + definition.pkgName = "AVTransDaudioOutputPlugin"; definition.description = "Send audio playback and frame rate control."; definition.rank = PLUGIN_RANK; - definition.creator = DaudioOutputPluginCreator; - definition.pluginType = PluginType::AVTRANS_OUTPUT; + definition.creator = [] (const std::string& name) -> std::shared_ptr { + return std::make_shared(name); + } + + definition.pkgVersion = AVTRANS_OUTPUT_API_VERSION; + definition.license = LicenseType::APACHE_V2; CapabilityBuilder capBuilder; capBuilder.SetMime(OHOS::Media::MEDIA_MIME_AUDIO_RAW); @@ -43,12 +46,9 @@ Status DaudioOutputRegister(const std::shared_ptr ®) DiscreteCapability valuesSampleFormat = {AudioSampleFormat::F32P}; capBuilder.SetAudioSampleFormatList(valuesSampleFormat); definition.inCaps.push_back(capBuilder.Build()); - - return reg->AddPlugin(definition); + return definition; } -PLUGIN_DEFINITION(AVTransDaudioOutput, LicenseType::APACHE_V2, DaudioOutputRegister, [] {}); - DaudioOutputPlugin::DaudioOutputPlugin(std::string name) : AvTransOutputPlugin(std::move(name)) { diff --git a/av_transport/av_trans_engine/plugins/av_trans_output/daudio_output/daudio_output_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.h similarity index 100% rename from av_transport/av_trans_engine/plugins/av_trans_output/daudio_output/daudio_output_plugin.h rename to av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.h diff --git a/av_transport/av_trans_engine/plugins/av_trans_output/dscreen_output/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn similarity index 90% rename from av_transport/av_trans_engine/plugins/av_trans_output/dscreen_output/BUILD.gn rename to av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn index a18192af..aaaac352 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_output/dscreen_output/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -ohos_shared_library("histreamer_plugin_AVTransDscreenOutput") { +source_set("plugin_AVTransDscreenOutput") { include_dirs = [ "${common_path}/include", "${plugin_path}/interface", @@ -48,10 +48,4 @@ ohos_shared_library("histreamer_plugin_AVTransDscreenOutput") { "DH_LOG_TAG=\"dscreen_output_plugin\"", "LOG_DOMAIN=0xD004100", ] - - relative_install_dir = "media/histreamer_plugins" - - subsystem_name = "multimedia" - - part_name = "histreamer" } diff --git a/av_transport/av_trans_engine/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp similarity index 92% rename from av_transport/av_trans_engine/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp rename to av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp index 2da45da4..edd1a0da 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp @@ -16,32 +16,34 @@ #include "dscreen_output_plugin.h" #include "foundation/utils/constants.h" +#include "plugin/factory/plugin_factory.h" +#include "plugin/interface/generic_plugin.h" namespace OHOS { namespace DistributedHardware { -std::shared_ptr DscreenOutputPluginCreator(const std::string &name) -{ - return std::make_shared(name); -} -Status DscreenOutputRegister(const std::shared_ptr ®) +GenericPluginDef CreateDscreenOutputPluginDef() { - AvTransOutputPluginDef definition; - definition.name = "AVTranseDscreenOutputPlugin"; + DHLOGI("DscreenOutputPlugin registered."); + GenericPluginDef definition; + definition.name = "AVTransDscreenOutputPlugin"; + definition.pkgName = "AVTransDscreenOutputPlugin"; definition.description = "Send video display and frame rate control."; definition.rank = PLUGIN_RANK; - definition.pluginType = PluginType::AVTRANS_OUTPUT; - definition.creator = DscreenOutputPluginCreator; + definition.creator = [] (const std::string& name) -> std::shared_ptr { + return std::make_shared(name); + } + + definition.pkgVersion = AVTRANS_OUTPUT_API_VERSION; + definition.license = LicenseType::APACHE_V2; Capability inCap(Media::MEDIA_MIME_VIDEO_RAW); inCap.AppendDiscreteKeys( Capability::Key::VIDEO_PIXEL_FORMAT, {VideoPixelFormat::RGBA}); definition.inCaps.push_back(inCap); - return reg->AddPlugin(definition); + return definition; } -PLUGIN_DEFINITION(AVTransDscreenOutput, LicenseType::APACHE_V2, DscreenOutputRegister, [] {}); - DscreenOutputPlugin::DscreenOutputPlugin(std::string name) : AvTransOutputPlugin(std::move(name)) { diff --git a/av_transport/av_trans_engine/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.h similarity index 100% rename from av_transport/av_trans_engine/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.h rename to av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.h diff --git a/av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn similarity index 90% rename from av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output/BUILD.gn rename to av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn index 92051654..89bb1355 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -ohos_shared_library("histreamer_plugin_AVTransDsoftbusOutput") { +source_set("plugin_AVTransDsoftbusOutput") { include_dirs = [ "${common_path}/include", "${plugin_path}/interface", @@ -50,10 +50,4 @@ ohos_shared_library("histreamer_plugin_AVTransDsoftbusOutput") { ] external_deps = [ "dsoftbus:softbus_client" ] - - relative_install_dir = "media/histreamer_plugins" - - subsystem_name = "multimedia" - - part_name = "histreamer" } diff --git a/av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp similarity index 92% rename from av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp rename to av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp index 8c9c2491..229f0d9e 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp @@ -16,40 +16,43 @@ #include "foundation/utils/constants.h" #include "plugin/common/plugin_caps_builder.h" +#include "plugin/factory/plugin_factory.h" +#include "plugin/interface/generic_plugin.h" namespace OHOS { namespace DistributedHardware { -std::shared_ptr DsoftbusOutputPluginCreator(const std::string &name) -{ - return std::make_shared(name); -} - -Status DsoftbusOutputRegister(const std::shared_ptr ®) +GenericPluginDef CreateDsoftbusOutputPluginDef() { int32_t capNum = 2; + std::vector definitionList; for (int i = 0; i < capNum; i++) { - AvTransOutputPluginDef definition; + DHLOGI("DsoftbusOutputPlugin_H264 registered."); + AvTransInputPluginDef definition; definition.name = "AVTransDsoftbusOutputPlugin_H264"; + definition.pkgName = "AVTransDsoftbusOutputPlugin"; definition.description = "Video transport to dsoftbus"; definition.rank = PLUGIN_RANK; - definition.pluginType = PluginType::AVTRANS_OUTPUT; - definition.creator = DsoftbusOutputPluginCreator; + definition.creator = [] (const std::string& name) -> std::shared_ptr { + return std::make_shared(name); + } + + definition.pkgVersion = AVTRANS_OUTPUT_API_VERSION; + definition.license = LicenseType::APACHE_V2; CapabilityBuilder capBuilder; capBuilder.SetMime(Media::MEDIA_MIME_VIDEO_H264); if (i == 1) { + DHLOGI("DsoftbusOutputPlugin_H265 registered."); definition.name = "AVTransDsoftbusOutputPlugin_H265"; capBuilder.SetMime(Media::MEDIA_MIME_VIDEO_H265); } - definition.inCaps.push_back(capBuilder.Build()); - reg->AddPlugin(definition); + definition.outCaps.push_back(capBuilder.Build()); + definitionList.push_back(definition); } - return Status::OK; + return definitionList; } -PLUGIN_DEFINITION(AVTransDsoftbusOutput, LicenseType::APACHE_V2, DsoftbusOutputRegister, [] {}); - DsoftbusOutputPlugin::DsoftbusOutputPlugin(std::string name) : AvTransOutputPlugin(std::move(name)) { diff --git a/av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.h similarity index 100% rename from av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.h rename to av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.h diff --git a/av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn similarity index 90% rename from av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn rename to av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn index 330ae6df..746b4fd9 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn @@ -15,7 +15,7 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -ohos_shared_library("histreamer_plugin_AVTransDsoftbusOutputAudio") { +source_set("plugin_AVTransDsoftbusOutputAudio") { include_dirs = [ "${common_path}/include", "${plugin_path}/interface", @@ -50,10 +50,4 @@ ohos_shared_library("histreamer_plugin_AVTransDsoftbusOutputAudio") { ] external_deps = [ "dsoftbus:softbus_client" ] - - relative_install_dir = "media/histreamer_plugins" - - subsystem_name = "multimedia" - - part_name = "histreamer" } diff --git a/av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp similarity index 90% rename from av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp rename to av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp index 0edaaf77..f194d213 100644 --- a/av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp @@ -16,13 +16,36 @@ #include "foundation/utils/constants.h" #include "plugin/common/plugin_caps_builder.h" +#include "plugin/factory/plugin_factory.h" +#include "plugin/interface/generic_plugin.h" namespace OHOS { namespace DistributedHardware { -std::shared_ptr DsoftbusOutputAudioPluginCreator(const std::string &name) +GenericPluginDef CreateDsoftbusOutputAudioPluginDef() { - return std::make_shared(name); + DHLOGI("DsoftbusOutputAudioPlugin registered."); + GenericPluginDef definition; + definition.name = "AVTransDsoftbusOutputAudioPlugin"; + definition.pkgName = "AVTransDsoftbusOutputAudioPlugin"; + definition.description = "Audio transport to dsoftbus"; + definition.rank = PLUGIN_RANK; + definition.creator = [] (const std::string& name) -> std::shared_ptr { + return std::make_shared(name); + } + + definition.pkgVersion = AVTRANS_OUTPUT_API_VERSION; + definition.license = LicenseType::APACHE_V2; + + CapabilityBuilder capBuilder; + capBuilder.SetMime(OHOS::Media::MEDIA_MIME_AUDIO_AAC); + DiscreteCapability valuesSampleRate = {8000, 11025, 12000, 16000, + 22050, 24000, 32000, 44100, 48000, 64000, 96000}; + capBuilder.SetAudioSampleRateList(valuesSampleRate); + DiscreteCapability valuesSampleFormat = {AudioSampleFormat::S16}; + capBuilder.SetAudioSampleFormatList(valuesSampleFormat); + definition.inCaps.push_back(capBuilder.Build()); + return definition; } Status DsoftbusOutputAudioRegister(const std::shared_ptr ®) diff --git a/av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.h similarity index 100% rename from av_transport/av_trans_engine/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.h rename to av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.h -- Gitee From bee955b62f1e88fd01c19b31ea5ade6ce87bfc18 Mon Sep 17 00:00:00 2001 From: liqiao49 Date: Mon, 26 Jun 2023 18:10:19 +0800 Subject: [PATCH 2/8] add code Signed-off-by: liqiao49 --- .../av_trans_engine/av_receiver/BUILD.gn | 10 ++++---- .../av_receiver/include/av_receiver_engine.h | 8 +++--- .../av_trans_engine/av_sender/BUILD.gn | 10 ++++---- .../av_sender/include/av_sender_engine.h | 8 +++--- av_transport/av_trans_engine/filters/BUILD.gn | 20 +++++++++------ .../av_transport_input_filter.cpp | 8 +++--- .../av_transport_input_filter.h | 5 +++- .../av_transport_output_filter.cpp | 8 +++--- .../av_transport_output_filter.h | 5 +++- .../plugin/core/avtrans_input.cpp | 5 ++++ .../plugin/core/avtrans_input.h | 3 +++ .../plugin/core/avtrans_output.cpp | 7 +++++- .../plugin/core/avtrans_output.h | 3 +++ .../plugin/interface/avtrans_input_plugin.h | 4 +++ .../plugin/interface/avtrans_output_plugin.h | 8 ++++-- .../av_trans_input/daudio_input/BUILD.gn | 14 +++-------- .../daudio_input/daudio_input_plugin.cpp | 4 ++- .../daudio_input/daudio_input_plugin.h | 2 +- .../av_trans_input/dscreen_input/BUILD.gn | 17 ++----------- .../dscreen_input/dscreen_input_plugin.cpp | 4 ++- .../dscreen_input/dscreen_input_plugin.h | 1 - .../av_trans_input/dsoftbus_input/BUILD.gn | 15 ++++------- .../dsoftbus_input/dsoftbus_input_plugin.cpp | 8 +++--- .../dsoftbus_input_audio/BUILD.gn | 15 ++++------- .../dsoftbus_input_audio_plugin.cpp | 23 ++--------------- .../av_trans_output/daudio_output/BUILD.gn | 13 +++------- .../daudio_output/daudio_output_plugin.cpp | 4 ++- .../daudio_output/daudio_output_plugin.h | 2 -- .../av_trans_output/dscreen_output/BUILD.gn | 10 ++------ .../dscreen_output/dscreen_output_plugin.cpp | 4 ++- .../dscreen_output/dscreen_output_plugin.h | 3 +-- .../av_trans_output/dsoftbus_output/BUILD.gn | 15 ++++------- .../dsoftbus_output_plugin.cpp | 12 +++++---- .../dsoftbus_output_audio/BUILD.gn | 15 ++++------- .../dsoftbus_output_audio_plugin.cpp | 25 ++----------------- 35 files changed, 134 insertions(+), 184 deletions(-) diff --git a/av_transport/av_trans_engine/av_receiver/BUILD.gn b/av_transport/av_trans_engine/av_receiver/BUILD.gn index 3b2e6c69..ed1dbcce 100644 --- a/av_transport/av_trans_engine/av_receiver/BUILD.gn +++ b/av_transport/av_trans_engine/av_receiver/BUILD.gn @@ -38,12 +38,11 @@ ohos_shared_library("distributed_av_receiver") { "${histreamer_path}/include/pipeline/filters", "${histreamer_path}/include/pipeline/filters/codec/audio_decoder", "${histreamer_path}/include/pipeline/filters/codec/video_decoder", - "${histreamer_path}/include/pipeline/filters/source/av_transport_input", - "${histreamer_path}/include/pipeline/filters/sink/av_transport_output", - "${histreamer_path}/include/plugin", "${histreamer_path}/include/plugin/common", "${histreamer_path}/include/scene/standard", "${histreamer_path}/pipeline/filters/codec", + "${filters_path}/av_transport_input", + "${filters_path}/av_transport_output", ] sources = [ @@ -59,8 +58,9 @@ ohos_shared_library("distributed_av_receiver") { deps = [ "${control_center_path}/inner_kits:avtranscenter_sdk", - "${histreamer_path}/pipeline:histreamer_pipeline", - "${histreamer_path}/pipeline:histreamer_pipeline_base", + "${histreamer_path}/pipeline/filters/codec:codec_filters, + "${filters_path}/avtrans_input_filter", + "${filters_path}/avtrans_output_filter", ] defines = [ diff --git a/av_transport/av_trans_engine/av_receiver/include/av_receiver_engine.h b/av_transport/av_trans_engine/av_receiver/include/av_receiver_engine.h index 3d9aae64..c0f442ff 100644 --- a/av_transport/av_trans_engine/av_receiver/include/av_receiver_engine.h +++ b/av_transport/av_trans_engine/av_receiver/include/av_receiver_engine.h @@ -27,6 +27,8 @@ #include "softbus_channel_adapter.h" #include "av_trans_control_center_kit.h" #include "av_trans_control_center_callback.h" +#include "av_transport_input_filter.h" +#include "av_transport_output_filter.h" // follwing head files depends on histreamer #include "error_code.h" @@ -36,8 +38,6 @@ #include "pipeline_core.h" #include "audio_decoder_filter.h" #include "video_decoder_filter.h" -#include "av_transport_input_filter.h" -#include "av_transport_output_filter.h" #include "async_mode.h" namespace OHOS { @@ -106,8 +106,8 @@ private: std::shared_ptr receiverCallback_ = nullptr; std::shared_ptr pipeline_ = nullptr; - std::shared_ptr avInput_; - std::shared_ptr avOutput_; + std::shared_ptr avInput_; + std::shared_ptr avOutput_; std::shared_ptr audioDecoder_; std::shared_ptr videoDecoder_; }; diff --git a/av_transport/av_trans_engine/av_sender/BUILD.gn b/av_transport/av_trans_engine/av_sender/BUILD.gn index 568c98d5..cbec6c86 100644 --- a/av_transport/av_trans_engine/av_sender/BUILD.gn +++ b/av_transport/av_trans_engine/av_sender/BUILD.gn @@ -38,11 +38,10 @@ ohos_shared_library("distributed_av_sender") { "${histreamer_path}/include/pipeline/filters", "${histreamer_path}/include/pipeline/filters/codec/audio_encoder", "${histreamer_path}/include/pipeline/filters/codec/video_encoder", - "${histreamer_path}/include/pipeline/filters/source/av_transport_input", - "${histreamer_path}/include/pipeline/filters/sink/av_transport_output", - "${histreamer_path}/include/plugin", "${histreamer_path}/include/plugin/common", "${histreamer_path}/include/scene/standard", + "${filters_path}/av_transport_input", + "${filters_path}/av_transport_output", ] sources = [ @@ -58,8 +57,9 @@ ohos_shared_library("distributed_av_sender") { deps = [ "${control_center_path}/inner_kits:avtranscenter_sdk", - "${histreamer_path}/pipeline:histreamer_pipeline", - "${histreamer_path}/pipeline:histreamer_pipeline_base", + "${histreamer_path}/pipeline/filters/codec:codec_filters, + "${filters_path}/avtrans_input_filter", + "${filters_path}/avtrans_output_filter", ] defines = [ diff --git a/av_transport/av_trans_engine/av_sender/include/av_sender_engine.h b/av_transport/av_trans_engine/av_sender/include/av_sender_engine.h index b4a1d2f1..c9ac7d44 100644 --- a/av_transport/av_trans_engine/av_sender/include/av_sender_engine.h +++ b/av_transport/av_trans_engine/av_sender/include/av_sender_engine.h @@ -27,6 +27,8 @@ #include "softbus_channel_adapter.h" #include "av_trans_control_center_kit.h" #include "av_trans_control_center_callback.h" +#include "av_transport_input_filter.h" +#include "av_transport_output_filter.h" // follwing head files depends on histreamer #include "error_code.h" @@ -35,8 +37,6 @@ #include "pipeline_core.h" #include "audio_encoder_filter.h" #include "video_encoder_filter.h" -#include "av_transport_input_filter.h" -#include "av_transport_output_filter.h" namespace OHOS { namespace DistributedHardware { @@ -106,8 +106,8 @@ private: std::shared_ptr senderCallback_ = nullptr; std::shared_ptr pipeline_ = nullptr; - std::shared_ptr avInput_ = nullptr; - std::shared_ptr avOutput_ = nullptr; + std::shared_ptr avInput_ = nullptr; + std::shared_ptr avOutput_ = nullptr; std::shared_ptr audioEncoder_ = nullptr; std::shared_ptr videoEncoder_ = nullptr; }; diff --git a/av_transport/av_trans_engine/filters/BUILD.gn b/av_transport/av_trans_engine/filters/BUILD.gn index c51b391d..254447c4 100644 --- a/av_transport/av_trans_engine/filters/BUILD.gn +++ b/av_transport/av_trans_engine/filters/BUILD.gn @@ -11,18 +11,22 @@ # See the License for the specific language governing permissions and # limitations under the License. +import("//build/ohos.gni") +import( + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") + source_set("avtrans_input_filter") { include_dirs = [ "${plugin_path}/core", - "${plugin_path}/interface" + "${plugin_path}/interface", ] - sources = [ + sources = [ "av_transport_input/av_transport_input_filter.cpp", - "${plugin_path}/core/avtrans_input.cpp" + "${plugin_path}/core/avtrans_input.cpp", ] - public_deps = [ + public_deps = [ "${histreamer_path}/foundation:histreamer_foundation", "${histreamer_path}/pipeline:histreamer_base", "${plugin_path}/plugins/av_trans_input/daudio_input:plugin_AVTransDaudioInput", @@ -35,15 +39,15 @@ source_set("avtrans_input_filter") { source_set("avtrans_output_filter") { include_dirs = [ "${plugin_path}/core", - "${plugin_path}/interface" + "${plugin_path}/interface", ] - sources = [ + sources = [ "av_transport_output/av_transport_output_filter.cpp", - "${plugin_path}/core/avtrans_output.cpp" + "${plugin_path}/core/avtrans_output.cpp", ] - public_deps = [ + public_deps = [ "${histreamer_path}/foundation:histreamer_foundation", "${histreamer_path}/pipeline:histreamer_base", "${plugin_path}/plugins/av_trans_output/daudio_output:plugin_AVTransDaudioOutput", diff --git a/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp b/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp index 5955cf1d..2c792601 100644 --- a/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp +++ b/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp @@ -189,10 +189,10 @@ ErrorCode AVInputFilter::FindPlugin() return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } mime = Plugin::AnyCast(paramsMap_[Tag::MIME]); - auto nameList = PluginManager::Instance().ListPlugins(PluginType::AVTRANS_INPUT); + auto nameList = PluginManager::Instance().ListPlugins(PluginType::GENERIC_PLUGIN); for (const std::string& name : nameList) { - auto info = PluginManager::Instance().GetPluginInfo(PluginType::AVTRANS_INPUT, name); - if (mime != info->outCaps[0].mime) { + auto info = PluginManager::Instance().GetPluginInfo(PluginType::GENERIC_PLUGIN, name); + if (info->outCaps.empty() || mime != info->outCaps[0].mime) { continue; } if (DoNegotiate(info->outCaps) && CreatePlugin(info) == ErrorCode::SUCCESS) { @@ -245,7 +245,7 @@ ErrorCode AVInputFilter::CreatePlugin(const std::shared_ptr& selecte MEDIA_LOG_E("Deinit last plugin: " PUBLIC_LOG_S " error", pluginInfo_->name.c_str()); } } - plugin_ = PluginManager::Instance().CreateAvTransInputPlugin(selectedInfo->name); + plugin_ = PluginManager::Instance().CreateGenericPlugin(selectedInfo->name); if (plugin_ == nullptr) { MEDIA_LOG_E("PluginManager CreatePlugin " PUBLIC_LOG_S " fail", selectedInfo->name.c_str()); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; diff --git a/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.h b/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.h index 44ff8bfb..8debcd5f 100644 --- a/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.h +++ b/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.h @@ -32,6 +32,9 @@ namespace OHOS { namespace DistributedHardware { +using namespace OHOS::Media; +using namespace OHOS::Media::Pipeline; + class AVInputFilter : public FilterBase { public: explicit AVInputFilter(const std::string& name); @@ -68,7 +71,7 @@ private: OHOS::Media::Plugin::AudioChannelLayout TransAudioChannelLayout(int layoutPtr); OHOS::Media::Plugin::AudioSampleFormat TransAudioSampleFormat(int sampleFormat); - std::shared_ptr plugin_ {nullptr}; + std::shared_ptr plugin_ {nullptr}; std::shared_ptr pluginInfo_ {nullptr}; Capability capNegWithDownstream_ {}; std::unordered_map paramsMap_; diff --git a/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp b/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp index c640f745..ad23e982 100644 --- a/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp +++ b/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp @@ -196,10 +196,10 @@ ErrorCode AVOutputFilter::FindPlugin() return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } mime = Plugin::AnyCast(paramsMap_[Tag::MIME]); - auto nameList = PluginManager::Instance().ListPlugins(PluginType::AVTRANS_OUTPUT); + auto nameList = PluginManager::Instance().ListPlugins(PluginType::GENERIC_PLUGIN); for (const std::string& name : nameList) { - auto info = PluginManager::Instance().GetPluginInfo(PluginType::AVTRANS_OUTPUT, name); - if (mime != info->inCaps[0].mime) { + auto info = PluginManager::Instance().GetPluginInfo(PluginType::GENERIC_PLUGIN, name); + if (info->inCaps.empty() || mime != info->inCaps[0].mime) { continue; } if (CreatePlugin(info) == ErrorCode::SUCCESS) { @@ -239,7 +239,7 @@ ErrorCode AVOutputFilter::CreatePlugin(const std::shared_ptr& select MEDIA_LOG_E("Deinit last plugin: " PUBLIC_LOG_S " error", pluginInfo_->name.c_str()); } } - plugin_ = PluginManager::Instance().CreateAvTransOutputPlugin(selectedInfo->name); + plugin_ = PluginManager::Instance().CreateGenericPlugin(selectedInfo->name); if (plugin_ == nullptr) { MEDIA_LOG_E("PluginManager CreatePlugin " PUBLIC_LOG_S " fail", selectedInfo->name.c_str()); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; diff --git a/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.h b/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.h index 7cd2fc81..5390ae79 100644 --- a/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.h +++ b/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.h @@ -32,6 +32,9 @@ namespace OHOS { namespace DistributedHardware { +using namespace OHOS::Media; +using namespace OHOS::Media::Pipeline; + class AVOutputFilter : public FilterBase { public: explicit AVOutputFilter(const std::string& name); @@ -64,7 +67,7 @@ private: ErrorCode SetPluginParams(); void OnDataCallback(std::shared_ptr buffer); - std::shared_ptr plugin_ {nullptr}; + std::shared_ptr plugin_ {nullptr}; std::shared_ptr pluginInfo_ {nullptr}; std::unordered_map paramsMap_; OSAL::Mutex outputFilterMutex_ {}; diff --git a/av_transport/av_trans_engine/plugin/core/avtrans_input.cpp b/av_transport/av_trans_engine/plugin/core/avtrans_input.cpp index d1e19f2f..258ca24d 100644 --- a/av_transport/av_trans_engine/plugin/core/avtrans_input.cpp +++ b/av_transport/av_trans_engine/plugin/core/avtrans_input.cpp @@ -17,6 +17,9 @@ #include "../interface/avtrans_input_plugin.h" +namespace OHOS { +namespace DistributedHardware { + AvTransInput::AvTransInput(uint32_t pkgVer, uint32_t apiVer, std::shared_ptr plugin) : Base(pkgVer, apiVer, plugin), AvTransInputPlugin_(std::move(plugin)) {} @@ -28,4 +31,6 @@ Status AvTransInput::PushData(const std::string& inPort, std::shared_ptr)> callback) { return AvTransInputPlugin_->SetDataCallback(callback); +} +} } \ No newline at end of file diff --git a/av_transport/av_trans_engine/plugin/core/avtrans_input.h b/av_transport/av_trans_engine/plugin/core/avtrans_input.h index 1740c9b2..796409a7 100644 --- a/av_transport/av_trans_engine/plugin/core/avtrans_input.h +++ b/av_transport/av_trans_engine/plugin/core/avtrans_input.h @@ -27,6 +27,9 @@ namespace OHOS { namespace DistributedHardware { struct AvTransInputPlugin; +using namespace OHOS::Media; +using namespace OHOS::Media::Pipeline; + class AvTransInput : public Base { public: AvTransInput(const AvTransInput &) = delete; diff --git a/av_transport/av_trans_engine/plugin/core/avtrans_output.cpp b/av_transport/av_trans_engine/plugin/core/avtrans_output.cpp index 91d76054..d5de623c 100644 --- a/av_transport/av_trans_engine/plugin/core/avtrans_output.cpp +++ b/av_transport/av_trans_engine/plugin/core/avtrans_output.cpp @@ -13,10 +13,13 @@ * limitations under the License. */ -#include "avtrans_output.h"\ +#include "avtrans_output.h" #include "../interface/avtrans_output_plugin.h" +namespace OHOS { +namespace DistributedHardware { + AvTransOutput::AvTransOutput(uint32_t pkgVer, uint32_t apiVer, std::shared_ptr plugin) : Base(pkgVer, apiVer, plugin), AvTransOutputPlugin_(std::move(plugin)) {} @@ -28,4 +31,6 @@ Status AvTransOutput::PushData(const std::string& inPort, std::shared_ptr)> callback) { return AvTransOutputPlugin_->SetDataCallback(callback); +} +} } \ No newline at end of file diff --git a/av_transport/av_trans_engine/plugin/core/avtrans_output.h b/av_transport/av_trans_engine/plugin/core/avtrans_output.h index 292884a4..786125b4 100644 --- a/av_transport/av_trans_engine/plugin/core/avtrans_output.h +++ b/av_transport/av_trans_engine/plugin/core/avtrans_output.h @@ -27,6 +27,9 @@ namespace OHOS { namespace DistributedHardware { struct AvTransOutputPlugin; +using namespace OHOS::Media; +using namespace OHOS::Media::Pipeline; + class AvTransOutput : public Base { public: AvTransOutput(const AvTransOutput &) = delete; diff --git a/av_transport/av_trans_engine/plugin/interface/avtrans_input_plugin.h b/av_transport/av_trans_engine/plugin/interface/avtrans_input_plugin.h index f50f2e07..aca6d9d1 100644 --- a/av_transport/av_trans_engine/plugin/interface/avtrans_input_plugin.h +++ b/av_transport/av_trans_engine/plugin/interface/avtrans_input_plugin.h @@ -28,6 +28,10 @@ namespace OHOS { namespace DistributedHardware { + +using namespace OHOS::Media; +using namespace OHOS::Media::Pipeline; + struct AvTransInputPlugin : public PluginBase { explicit AvTransInputPlugin(std::string name): PluginBase(std::move(name)) {} diff --git a/av_transport/av_trans_engine/plugin/interface/avtrans_output_plugin.h b/av_transport/av_trans_engine/plugin/interface/avtrans_output_plugin.h index e646a113..9e82c8d2 100644 --- a/av_transport/av_trans_engine/plugin/interface/avtrans_output_plugin.h +++ b/av_transport/av_trans_engine/plugin/interface/avtrans_output_plugin.h @@ -23,11 +23,15 @@ #include "plugin/common/plugin_source_tags.h" #include "plugin/common/plugin_buffer.h" #include "plugin/common/plugin_caps.h" -#include "plugin_base.h" -#include "plugin_definition.h" +#include "plugin/interface/plugin_base.h" +#include "plugin/interface/plugin_definition.h" namespace OHOS { namespace DistributedHardware { + +using namespace OHOS::Media; +using namespace OHOS::Media::Pipeline; + struct AvTransOutputPlugin : public PluginBase { explicit AvTransOutputPlugin(std::string name): PluginBase(std::move(name)) {} diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn index 7165b5b7..b2932e3a 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn @@ -21,26 +21,20 @@ source_set("plugin_AVTransDaudioInput") { "${histreamer_path}/foundation/osal/thread", "${histreamer_path}/include/pipeline/core", "${histreamer_path}/include/plugin/common", + "${histreamer_path}/include/plugin/core", + "${histreamer_path}/plugin/core", "${histreamer_path}/include/plugin/interface", "${histreamer_path}/foundation/utils", - "${histreamer_path}/plugin/core", "${plugin_path}/interface", "//third_party/json/include", ] - sources = [ - "${common_path}/src/av_sync_utils.cpp", - "${common_path}/src/av_trans_buffer.cpp", - "${common_path}/src/av_trans_log.cpp", - "${common_path}/src/av_trans_meta.cpp", - "${common_path}/src/av_trans_utils.cpp", - "daudio_input_plugin.cpp", - ] + sources = [ "daudio_input_plugin.cpp" ] deps = [ "${histreamer_path}/foundation:histreamer_foundation", "${histreamer_path}/plugin:histreamer_plugin_core", - "${histreamer_path}/plugin:histreamer_plugin_intf", + "${histreamer_path}/plugin:histreamer_plugin_intf" ] defines = [ diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp index 0b25fb7c..71ba62cf 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp @@ -33,7 +33,7 @@ GenericPluginDef CreateDaudioInputPluginDef() definition.rank = PLUGIN_RANK; definition.creator = [] (const std::string& name) -> std::shared_ptr { return std::make_shared(name); - } + }; definition.pkgVersion = AVTRANS_INPUT_API_VERSION; definition.license = LicenseType::APACHE_V2; @@ -47,6 +47,8 @@ GenericPluginDef CreateDaudioInputPluginDef() return definition; } +static AutoRegisterPlugin g_registerPluginHelper(CreateDaudioInputPluginDef()); + DaudioInputPlugin::DaudioInputPlugin(std::string name) : AvTransInputPlugin(std::move(name)) { diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.h index f637f083..bdf2061f 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.h @@ -44,7 +44,7 @@ using namespace OHOS::Media::Plugin; using json = nlohmann::json; using AVDataCallback = std::function)>; -class DaudioInputPlugin : public Media::Plugin::AvTransInputPlugin { +class DaudioInputPlugin : public AvTransInputPlugin { public: explicit DaudioInputPlugin(std::string name); ~DaudioInputPlugin(); diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn index f9d7d286..4bf984ca 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn @@ -22,20 +22,14 @@ source_set("plugin_AVTransDscreenInput") { "${histreamer_path}/include/pipeline/core", "${histreamer_path}/include/plugin/interface", "${histreamer_path}/include/plugin/common", + "${histreamer_path}/include/plugin/core", "${histreamer_path}/plugin/core", "${histreamer_path}/include/foundation/osal/thread", "${histreamer_path}/foundation/utils", "//third_party/json/include", ] - sources = [ - "${common_path}/src/av_sync_utils.cpp", - "${common_path}/src/av_trans_buffer.cpp", - "${common_path}/src/av_trans_log.cpp", - "${common_path}/src/av_trans_meta.cpp", - "${common_path}/src/av_trans_utils.cpp", - "dscreen_input_plugin.cpp", - ] + sources = [ "dscreen_input_plugin.cpp" ] deps = [ "${histreamer_path}/foundation:histreamer_foundation", @@ -48,11 +42,4 @@ source_set("plugin_AVTransDscreenInput") { "DH_LOG_TAG=\"dscreen_input_plugin\"", "LOG_DOMAIN=0xD004100", ] - - external_deps = [ - "c_utils:utils", - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "samgr:samgr_proxy", - ] } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp index 2ae35707..6badfead 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp @@ -34,7 +34,7 @@ GenericPluginDef CreateDscreenInputPluginDef() definition.rank = PLUGIN_RANK; definition.creator = [] (const std::string& name) -> std::shared_ptr { return std::make_shared(name); - } + }; definition.pkgVersion = AVTRANS_INPUT_API_VERSION; definition.license = LicenseType::APACHE_V2; @@ -46,6 +46,8 @@ GenericPluginDef CreateDscreenInputPluginDef() return definition; } +static AutoRegisterPlugin g_registerPluginHelper(CreateDscreenInputPluginDef()); + DscreenInputPlugin::DscreenInputPlugin(std::string name) : AvTransInputPlugin(std::move(name)) { diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.h index 3f8b1e4c..14184213 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.h @@ -21,7 +21,6 @@ #include #include -#include "av_sync_utils.h" #include "av_trans_buffer.h" #include "av_trans_errno.h" #include "av_trans_constants.h" diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn index 5718da56..13fe83d3 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn @@ -22,20 +22,17 @@ source_set("plugin_AVTransDsoftbusInput") { "${histreamer_path}/include/pipeline/core", "${histreamer_path}/include/plugin/interface", "${histreamer_path}/include/plugin/common", + "${histreamer_path}/include/plugin/core", "${histreamer_path}/plugin/core", "${histreamer_path}/include/foundation/osal/thread", "${histreamer_path}/foundation/utils", + "${dsoftbus_path}/interface/kits/transport", + "${dsoftbus_path}/interface/kits/bus_center", + "${dsoftbus_path}/interface/kits/common", "//third_party/json/include", ] - sources = [ - "${common_path}/src/av_trans_buffer.cpp", - "${common_path}/src/av_trans_log.cpp", - "${common_path}/src/av_trans_meta.cpp", - "${common_path}/src/av_trans_utils.cpp", - "${common_path}/src/softbus_channel_adapter.cpp", - "dsoftbus_input_plugin.cpp", - ] + sources = [ "dsoftbus_input_plugin.cpp" ] deps = [ "${histreamer_path}/foundation:histreamer_foundation", @@ -48,6 +45,4 @@ source_set("plugin_AVTransDsoftbusInput") { "DH_LOG_TAG=\"dsoftbus_input_plugin\"", "LOG_DOMAIN=0xD004100", ] - - external_deps = [ "dsoftbus:softbus_client" ] } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp index a240532b..4ae05521 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp @@ -24,20 +24,20 @@ namespace OHOS { namespace DistributedHardware { -GenericPluginDef CreateDsoftbusInputPluginDef() +std::vector CreateDsoftbusInputPluginDef() { int32_t capNum = 2; std::vector definitionList; for (int i = 0; i < capNum; i++) { DHLOGI("DsoftbusInputPlugin_H264 registered."); - AvTransInputPluginDef definition; + GenericPluginDef definition; definition.name = "AVTransDsoftbusInputPlugin_H264"; definition.pkgName = "AVTransDsoftbusInputPlugin"; definition.description = "Video transport from dsoftbus"; definition.rank = PLUGIN_RANK; definition.creator = [] (const std::string& name) -> std::shared_ptr { return std::make_shared(name); - } + }; definition.pkgVersion = AVTRANS_INPUT_API_VERSION; definition.license = LicenseType::APACHE_V2; @@ -55,6 +55,8 @@ GenericPluginDef CreateDsoftbusInputPluginDef() return definitionList; } +static AutoRegisterPlugin g_registerPluginHelper(CreateDsoftbusInputPluginDef()); + DsoftbusInputPlugin::DsoftbusInputPlugin(std::string name) : AvTransInputPlugin(std::move(name)) { diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn index 61a9d23e..ede3c9a3 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn @@ -22,20 +22,17 @@ source_set("plugin_AVTransDsoftbusInputAudio") { "${histreamer_path}/include/pipeline/core", "${histreamer_path}/include/plugin/interface", "${histreamer_path}/include/plugin/common", + "${histreamer_path}/include/plugin/core", "${histreamer_path}/plugin/core", "${histreamer_path}/include/foundation/osal/thread", "${histreamer_path}/foundation/utils", + "${dsoftbus_path}/interface/kits/transport", + "${dsoftbus_path}/interface/kits/bus_center", + "${dsoftbus_path}/interface/kits/common", "//third_party/json/include", ] - sources = [ - "${common_path}/src/av_trans_buffer.cpp", - "${common_path}/src/av_trans_log.cpp", - "${common_path}/src/av_trans_meta.cpp", - "${common_path}/src/av_trans_utils.cpp", - "${common_path}/src/softbus_channel_adapter.cpp", - "dsoftbus_input_audio_plugin.cpp", - ] + sources = [ "dsoftbus_input_audio_plugin.cpp" ] deps = [ "${histreamer_path}/foundation:histreamer_foundation", @@ -48,6 +45,4 @@ source_set("plugin_AVTransDsoftbusInputAudio") { "DH_LOG_TAG=\"dsoftbus_input_audio_plugin\"", "LOG_DOMAIN=0xD004100", ] - - external_deps = [ "dsoftbus:softbus_client" ] } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp index 56704c2b..880ddad6 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp @@ -34,7 +34,7 @@ GenericPluginDef CreateDsoftbusInputAudioPluginDef() definition.rank = PLUGIN_RANK; definition.creator = [] (const std::string& name) -> std::shared_ptr { return std::make_shared(name); - } + }; definition.pkgVersion = AVTRANS_INPUT_API_VERSION; definition.license = LicenseType::APACHE_V2; @@ -48,26 +48,7 @@ GenericPluginDef CreateDsoftbusInputAudioPluginDef() return definition; } -Status DsoftbusInputAudioRegister(const std::shared_ptr ®) -{ - AvTransInputPluginDef definition; - definition.name = "AVTransDsoftbusInputAudioPlugin"; - definition.description = "Audio transport from dsoftbus"; - definition.rank = PLUGIN_RANK; - definition.pluginType = PluginType::AVTRANS_INPUT; - definition.creator = DsoftbusInputAudioPluginCreator; - - CapabilityBuilder capBuilder; - capBuilder.SetMime(OHOS::Media::MEDIA_MIME_AUDIO_AAC); - DiscreteCapability values = {8000, 11025, 12000, 16000, - 22050, 24000, 32000, 44100, 48000, 64000, 96000}; - capBuilder.SetAudioSampleRateList(values); - definition.outCaps.push_back(capBuilder.Build()); - - return reg->AddPlugin(definition); -} - -PLUGIN_DEFINITION(AVTransDsoftbusInputAudio, LicenseType::APACHE_V2, DsoftbusInputAudioRegister, [] {}); +static AutoRegisterPlugin g_registerPluginHelper(CreateDsoftbusInputAudioPluginDef()); DsoftbusInputAudioPlugin::DsoftbusInputAudioPlugin(std::string name) : AvTransInputPlugin(std::move(name)) diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn index 3c5ccf78..3438ba86 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn @@ -22,22 +22,15 @@ source_set("plugin_AVTransDaudioOutput") { "${histreamer_path}/include/pipeline/core", "${histreamer_path}/include/plugin/common", "${histreamer_path}/include/plugin/interface", - "${histreamer_path}/foundation/utils", + "${histreamer_path}/include/plugin/core", "${histreamer_path}/plugin/core", + "${histreamer_path}/foundation/utils", "${plugin_path}/interface", "//third_party/json/include", "//third_party/ffmpeg", ] - sources = [ - "${common_path}/src/av_sync_utils.cpp", - "${common_path}/src/av_trans_buffer.cpp", - "${common_path}/src/av_trans_log.cpp", - "${common_path}/src/av_trans_meta.cpp", - "${common_path}/src/av_trans_utils.cpp", - "${histreamer_path}/plugin/plugins/ffmpeg_adapter/utils/ffmpeg_utils.cpp", - "daudio_output_plugin.cpp", - ] + sources = [ "daudio_output_plugin.cpp" ] deps = [ "${histreamer_path}/foundation:histreamer_foundation", diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp index 8202c717..9ee02f20 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp @@ -33,7 +33,7 @@ GenericPluginDef CreateDaudioOutputPluginDef() definition.rank = PLUGIN_RANK; definition.creator = [] (const std::string& name) -> std::shared_ptr { return std::make_shared(name); - } + }; definition.pkgVersion = AVTRANS_OUTPUT_API_VERSION; definition.license = LicenseType::APACHE_V2; @@ -49,6 +49,8 @@ GenericPluginDef CreateDaudioOutputPluginDef() return definition; } +static AutoRegisterPlugin g_registerPluginHelper(CreateDaudioOutputPluginDef()); + DaudioOutputPlugin::DaudioOutputPlugin(std::string name) : AvTransOutputPlugin(std::move(name)) { diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.h index f2d5960e..75a31e72 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.h @@ -22,10 +22,8 @@ #include #include -#include "av_sync_utils.h" #include "av_trans_buffer.h" #include "av_trans_constants.h" -#include "av_trans_errno.h" #include "av_trans_log.h" #include "av_trans_meta.h" #include "av_trans_types.h" diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn index aaaac352..4bd5d2cf 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn @@ -22,20 +22,14 @@ source_set("plugin_AVTransDscreenOutput") { "${histreamer_path}/include/pipeline/core", "${histreamer_path}/include/plugin/interface", "${histreamer_path}/include/plugin/common", + "${histreamer_path}/include/plugin/core", "${histreamer_path}/plugin/core", "${histreamer_path}/include/foundation/osal/thread", "${histreamer_path}/foundation/utils", "//third_party/json/include", ] - sources = [ - "${common_path}/src/av_sync_utils.cpp", - "${common_path}/src/av_trans_buffer.cpp", - "${common_path}/src/av_trans_log.cpp", - "${common_path}/src/av_trans_meta.cpp", - "${common_path}/src/av_trans_utils.cpp", - "dscreen_output_plugin.cpp", - ] + sources = [ "dscreen_output_plugin.cpp" ] deps = [ "${histreamer_path}/foundation:histreamer_foundation", diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp index edd1a0da..5ebec7e0 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp @@ -32,7 +32,7 @@ GenericPluginDef CreateDscreenOutputPluginDef() definition.rank = PLUGIN_RANK; definition.creator = [] (const std::string& name) -> std::shared_ptr { return std::make_shared(name); - } + }; definition.pkgVersion = AVTRANS_OUTPUT_API_VERSION; definition.license = LicenseType::APACHE_V2; @@ -44,6 +44,8 @@ GenericPluginDef CreateDscreenOutputPluginDef() return definition; } +static AutoRegisterPlugin g_registerPluginHelper(CreateDscreenOutputPluginDef()); + DscreenOutputPlugin::DscreenOutputPlugin(std::string name) : AvTransOutputPlugin(std::move(name)) { diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.h index 53b951fd..e14ac7c6 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.h @@ -22,7 +22,6 @@ #include #include -#include "av_sync_utils.h" #include "av_trans_buffer.h" #include "av_trans_errno.h" #include "av_trans_constants.h" @@ -45,7 +44,7 @@ using namespace OHOS::Media::Plugin; using json = nlohmann::json; using AVDataCallback = std::function)>; -class DscreenOutputPlugin : public Media::Plugin::AvTransOutputPlugin { +class DscreenOutputPlugin : public AvTransOutputPlugin { public: explicit DscreenOutputPlugin(std::string name); ~DscreenOutputPlugin(); diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn index 89bb1355..65f91f93 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn @@ -22,20 +22,17 @@ source_set("plugin_AVTransDsoftbusOutput") { "${histreamer_path}/include/pipeline/core", "${histreamer_path}/include/plugin/interface", "${histreamer_path}/include/plugin/common", + "${histreamer_path}/include/plugin/core", "${histreamer_path}/plugin/core", "${histreamer_path}/include/foundation/osal/thread", "${histreamer_path}/foundation/utils", + "${dsoftbus_path}/interface/kits/transport", + "${dsoftbus_path}/interface/kits/bus_center", + "${dsoftbus_path}/interface/kits/common", "//third_party/json/include", ] - sources = [ - "${common_path}/src/av_trans_buffer.cpp", - "${common_path}/src/av_trans_log.cpp", - "${common_path}/src/av_trans_meta.cpp", - "${common_path}/src/av_trans_utils.cpp", - "${common_path}/src/softbus_channel_adapter.cpp", - "dsoftbus_output_plugin.cpp", - ] + sources = [ "dsoftbus_output_plugin.cpp" ] deps = [ "${histreamer_path}/foundation:histreamer_foundation", @@ -48,6 +45,4 @@ source_set("plugin_AVTransDsoftbusOutput") { "DH_LOG_TAG=\"dsoftbus_output_plugin\"", "LOG_DOMAIN=0xD004100", ] - - external_deps = [ "dsoftbus:softbus_client" ] } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp index 229f0d9e..ef25c82b 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp @@ -22,20 +22,20 @@ namespace OHOS { namespace DistributedHardware { -GenericPluginDef CreateDsoftbusOutputPluginDef() +std::vector CreateDsoftbusOutputPluginDef() { int32_t capNum = 2; std::vector definitionList; for (int i = 0; i < capNum; i++) { DHLOGI("DsoftbusOutputPlugin_H264 registered."); - AvTransInputPluginDef definition; + GenericPluginDef definition; definition.name = "AVTransDsoftbusOutputPlugin_H264"; definition.pkgName = "AVTransDsoftbusOutputPlugin"; definition.description = "Video transport to dsoftbus"; definition.rank = PLUGIN_RANK; definition.creator = [] (const std::string& name) -> std::shared_ptr { - return std::make_shared(name); - } + return std::make_shared(name); + }; definition.pkgVersion = AVTRANS_OUTPUT_API_VERSION; definition.license = LicenseType::APACHE_V2; @@ -47,12 +47,14 @@ GenericPluginDef CreateDsoftbusOutputPluginDef() definition.name = "AVTransDsoftbusOutputPlugin_H265"; capBuilder.SetMime(Media::MEDIA_MIME_VIDEO_H265); } - definition.outCaps.push_back(capBuilder.Build()); + definition.inCaps.push_back(capBuilder.Build()); definitionList.push_back(definition); } return definitionList; } +static AutoRegisterPlugin g_registerPluginHelper(CreateDsoftbusOutputPluginDef()); + DsoftbusOutputPlugin::DsoftbusOutputPlugin(std::string name) : AvTransOutputPlugin(std::move(name)) { diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn index 746b4fd9..a4110680 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn @@ -22,20 +22,17 @@ source_set("plugin_AVTransDsoftbusOutputAudio") { "${histreamer_path}/include/pipeline/core", "${histreamer_path}/include/plugin/interface", "${histreamer_path}/include/plugin/common", + "${histreamer_path}/include/plugin/core", "${histreamer_path}/plugin/core", "${histreamer_path}/include/foundation/osal/thread", "${histreamer_path}/foundation/utils", + "${dsoftbus_path}/interface/kits/transport", + "${dsoftbus_path}/interface/kits/bus_center", + "${dsoftbus_path}/interface/kits/common", "//third_party/json/include", ] - sources = [ - "${common_path}/src/av_trans_buffer.cpp", - "${common_path}/src/av_trans_log.cpp", - "${common_path}/src/av_trans_meta.cpp", - "${common_path}/src/av_trans_utils.cpp", - "${common_path}/src/softbus_channel_adapter.cpp", - "dsoftbus_output_audio_plugin.cpp", - ] + sources = [ "dsoftbus_output_audio_plugin.cpp" ] deps = [ "${histreamer_path}/foundation:histreamer_foundation", @@ -48,6 +45,4 @@ source_set("plugin_AVTransDsoftbusOutputAudio") { "DH_LOG_TAG=\"dsoftbus_output_audio_plugin\"", "LOG_DOMAIN=0xD004100", ] - - external_deps = [ "dsoftbus:softbus_client" ] } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp index f194d213..2e19eb48 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp @@ -32,7 +32,7 @@ GenericPluginDef CreateDsoftbusOutputAudioPluginDef() definition.rank = PLUGIN_RANK; definition.creator = [] (const std::string& name) -> std::shared_ptr { return std::make_shared(name); - } + }; definition.pkgVersion = AVTRANS_OUTPUT_API_VERSION; definition.license = LicenseType::APACHE_V2; @@ -48,28 +48,7 @@ GenericPluginDef CreateDsoftbusOutputAudioPluginDef() return definition; } -Status DsoftbusOutputAudioRegister(const std::shared_ptr ®) -{ - AvTransOutputPluginDef definition; - definition.name = "AVTransDsoftbusOutputAudioPlugin"; - definition.description = "Audio transport to dsoftbus"; - definition.rank = PLUGIN_RANK; - definition.pluginType = PluginType::AVTRANS_OUTPUT; - definition.creator = DsoftbusOutputAudioPluginCreator; - - CapabilityBuilder capBuilder; - capBuilder.SetMime(OHOS::Media::MEDIA_MIME_AUDIO_AAC); - DiscreteCapability valuesSampleRate = {8000, 11025, 12000, 16000, - 22050, 24000, 32000, 44100, 48000, 64000, 96000}; - capBuilder.SetAudioSampleRateList(valuesSampleRate); - DiscreteCapability valuesSampleFormat = {AudioSampleFormat::S16}; - capBuilder.SetAudioSampleFormatList(valuesSampleFormat); - definition.inCaps.push_back(capBuilder.Build()); - - return reg->AddPlugin(definition); -} - -PLUGIN_DEFINITION(AVTransDsoftbusOutputAudio, LicenseType::APACHE_V2, DsoftbusOutputAudioRegister, [] {}); +static AutoRegisterPlugin g_registerPluginHelper(CreateDsoftbusOutputAudioPluginDef()); DsoftbusOutputAudioPlugin::DsoftbusOutputAudioPlugin(std::string name) : AvTransOutputPlugin(std::move(name)) -- Gitee From 93bee2e327feeb589cb11f0e4b80810206d576d1 Mon Sep 17 00:00:00 2001 From: liqiao49 Date: Tue, 27 Jun 2023 09:20:17 +0800 Subject: [PATCH 3/8] fix code Signed-off-by: liqiao49 --- av_transport/av_trans_engine/av_receiver/BUILD.gn | 8 ++++---- av_transport/av_trans_engine/av_sender/BUILD.gn | 8 ++++---- av_transport/av_trans_engine/plugin/core/avtrans_input.h | 2 +- av_transport/av_trans_engine/plugin/core/avtrans_output.h | 2 +- .../plugin/interface/avtrans_input_plugin.h | 2 +- .../plugin/interface/avtrans_output_plugin.h | 2 +- .../plugin/plugins/av_trans_input/daudio_input/BUILD.gn | 2 +- .../plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn | 6 +++--- .../plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn | 6 +++--- .../plugin/plugins/av_trans_output/daudio_output/BUILD.gn | 2 +- .../plugins/av_trans_output/dsoftbus_output/BUILD.gn | 6 +++--- .../av_trans_output/dsoftbus_output_audio/BUILD.gn | 6 +++--- 12 files changed, 26 insertions(+), 26 deletions(-) diff --git a/av_transport/av_trans_engine/av_receiver/BUILD.gn b/av_transport/av_trans_engine/av_receiver/BUILD.gn index ed1dbcce..73a61890 100644 --- a/av_transport/av_trans_engine/av_receiver/BUILD.gn +++ b/av_transport/av_trans_engine/av_receiver/BUILD.gn @@ -59,8 +59,8 @@ ohos_shared_library("distributed_av_receiver") { deps = [ "${control_center_path}/inner_kits:avtranscenter_sdk", "${histreamer_path}/pipeline/filters/codec:codec_filters, - "${filters_path}/avtrans_input_filter", - "${filters_path}/avtrans_output_filter", + "${filters_path}:avtrans_input_filter", + "${filters_path}:avtrans_output_filter", ] defines = [ @@ -101,6 +101,6 @@ ohos_shared_library("distributed_av_receiver") { ] cflags_cc = cflags - part_name = "histreamer" - subsystem_name = "multimedia" + part_name = "distributed_hardware_fwk" + subsystem_name = "distributedhardware" } diff --git a/av_transport/av_trans_engine/av_sender/BUILD.gn b/av_transport/av_trans_engine/av_sender/BUILD.gn index cbec6c86..cc5aeabc 100644 --- a/av_transport/av_trans_engine/av_sender/BUILD.gn +++ b/av_transport/av_trans_engine/av_sender/BUILD.gn @@ -58,8 +58,8 @@ ohos_shared_library("distributed_av_sender") { deps = [ "${control_center_path}/inner_kits:avtranscenter_sdk", "${histreamer_path}/pipeline/filters/codec:codec_filters, - "${filters_path}/avtrans_input_filter", - "${filters_path}/avtrans_output_filter", + "${filters_path}:avtrans_input_filter", + "${filters_path}:avtrans_output_filter", ] defines = [ @@ -100,6 +100,6 @@ ohos_shared_library("distributed_av_sender") { ] cflags_cc = cflags - part_name = "histreamer" - subsystem_name = "multimedia" + part_name = "distributed_hardware_fwk" + subsystem_name = "distributedhardware" } diff --git a/av_transport/av_trans_engine/plugin/core/avtrans_input.h b/av_transport/av_trans_engine/plugin/core/avtrans_input.h index 796409a7..26190d5e 100644 --- a/av_transport/av_trans_engine/plugin/core/avtrans_input.h +++ b/av_transport/av_trans_engine/plugin/core/avtrans_input.h @@ -28,7 +28,7 @@ namespace DistributedHardware { struct AvTransInputPlugin; using namespace OHOS::Media; -using namespace OHOS::Media::Pipeline; +using namespace OHOS::Media::Plugin; class AvTransInput : public Base { public: diff --git a/av_transport/av_trans_engine/plugin/core/avtrans_output.h b/av_transport/av_trans_engine/plugin/core/avtrans_output.h index 786125b4..7c3f1689 100644 --- a/av_transport/av_trans_engine/plugin/core/avtrans_output.h +++ b/av_transport/av_trans_engine/plugin/core/avtrans_output.h @@ -28,7 +28,7 @@ namespace DistributedHardware { struct AvTransOutputPlugin; using namespace OHOS::Media; -using namespace OHOS::Media::Pipeline; +using namespace OHOS::Media::Plugin; class AvTransOutput : public Base { public: diff --git a/av_transport/av_trans_engine/plugin/interface/avtrans_input_plugin.h b/av_transport/av_trans_engine/plugin/interface/avtrans_input_plugin.h index aca6d9d1..2d259ee2 100644 --- a/av_transport/av_trans_engine/plugin/interface/avtrans_input_plugin.h +++ b/av_transport/av_trans_engine/plugin/interface/avtrans_input_plugin.h @@ -30,7 +30,7 @@ namespace OHOS { namespace DistributedHardware { using namespace OHOS::Media; -using namespace OHOS::Media::Pipeline; +using namespace OHOS::Media::Plugin; struct AvTransInputPlugin : public PluginBase { explicit AvTransInputPlugin(std::string name): PluginBase(std::move(name)) {} diff --git a/av_transport/av_trans_engine/plugin/interface/avtrans_output_plugin.h b/av_transport/av_trans_engine/plugin/interface/avtrans_output_plugin.h index 9e82c8d2..ae8301bb 100644 --- a/av_transport/av_trans_engine/plugin/interface/avtrans_output_plugin.h +++ b/av_transport/av_trans_engine/plugin/interface/avtrans_output_plugin.h @@ -30,7 +30,7 @@ namespace OHOS { namespace DistributedHardware { using namespace OHOS::Media; -using namespace OHOS::Media::Pipeline; +using namespace OHOS::Media::Plugin; struct AvTransOutputPlugin : public PluginBase { explicit AvTransOutputPlugin(std::string name): PluginBase(std::move(name)) {} diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn index b2932e3a..c0961452 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn @@ -22,9 +22,9 @@ source_set("plugin_AVTransDaudioInput") { "${histreamer_path}/include/pipeline/core", "${histreamer_path}/include/plugin/common", "${histreamer_path}/include/plugin/core", - "${histreamer_path}/plugin/core", "${histreamer_path}/include/plugin/interface", "${histreamer_path}/foundation/utils", + "${histreamer_path}/plugin/core", "${plugin_path}/interface", "//third_party/json/include", ] diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn index 13fe83d3..ee156295 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn @@ -26,9 +26,9 @@ source_set("plugin_AVTransDsoftbusInput") { "${histreamer_path}/plugin/core", "${histreamer_path}/include/foundation/osal/thread", "${histreamer_path}/foundation/utils", - "${dsoftbus_path}/interface/kits/transport", - "${dsoftbus_path}/interface/kits/bus_center", - "${dsoftbus_path}/interface/kits/common", + "${dsoftbus_path}/interfaces/kits/transport", + "${dsoftbus_path}/interfaces/kits/bus_center", + "${dsoftbus_path}/interfaces/kits/common", "//third_party/json/include", ] diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn index ede3c9a3..3b809638 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn @@ -26,9 +26,9 @@ source_set("plugin_AVTransDsoftbusInputAudio") { "${histreamer_path}/plugin/core", "${histreamer_path}/include/foundation/osal/thread", "${histreamer_path}/foundation/utils", - "${dsoftbus_path}/interface/kits/transport", - "${dsoftbus_path}/interface/kits/bus_center", - "${dsoftbus_path}/interface/kits/common", + "${dsoftbus_path}/interfaces/kits/transport", + "${dsoftbus_path}/interfaces/kits/bus_center", + "${dsoftbus_path}/interfaces/kits/common", "//third_party/json/include", ] diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn index 3438ba86..2eff6b34 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn @@ -23,8 +23,8 @@ source_set("plugin_AVTransDaudioOutput") { "${histreamer_path}/include/plugin/common", "${histreamer_path}/include/plugin/interface", "${histreamer_path}/include/plugin/core", - "${histreamer_path}/plugin/core", "${histreamer_path}/foundation/utils", + "${histreamer_path}/plugin/core", "${plugin_path}/interface", "//third_party/json/include", "//third_party/ffmpeg", diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn index 65f91f93..aed7eabe 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn @@ -26,9 +26,9 @@ source_set("plugin_AVTransDsoftbusOutput") { "${histreamer_path}/plugin/core", "${histreamer_path}/include/foundation/osal/thread", "${histreamer_path}/foundation/utils", - "${dsoftbus_path}/interface/kits/transport", - "${dsoftbus_path}/interface/kits/bus_center", - "${dsoftbus_path}/interface/kits/common", + "${dsoftbus_path}/interfaces/kits/transport", + "${dsoftbus_path}/interfaces/kits/bus_center", + "${dsoftbus_path}/interfaces/kits/common", "//third_party/json/include", ] diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn index a4110680..90d0b404 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn @@ -26,9 +26,9 @@ source_set("plugin_AVTransDsoftbusOutputAudio") { "${histreamer_path}/plugin/core", "${histreamer_path}/include/foundation/osal/thread", "${histreamer_path}/foundation/utils", - "${dsoftbus_path}/interface/kits/transport", - "${dsoftbus_path}/interface/kits/bus_center", - "${dsoftbus_path}/interface/kits/common", + "${dsoftbus_path}/interfaces/kits/transport", + "${dsoftbus_path}/interfaces/kits/bus_center", + "${dsoftbus_path}/interfaces/kits/common", "//third_party/json/include", ] -- Gitee From 47ff68342dfc05202fd7fd74ec5f8d5209e214be Mon Sep 17 00:00:00 2001 From: liqiao49 Date: Tue, 27 Jun 2023 20:56:27 +0800 Subject: [PATCH 4/8] put on build Signed-off-by: liqiao49 --- .../inner_kits/BUILD.gn | 3 +- .../av_trans_engine/av_receiver/BUILD.gn | 29 +-- .../av_receiver/include/av_receiver_engine.h | 1 - .../av_receiver/src/av_receiver_engine.cpp | 8 +- .../av_trans_engine/av_sender/BUILD.gn | 27 +-- av_transport/av_trans_engine/filters/BUILD.gn | 70 ++++++- .../av_transport_input_filter.cpp | 183 +++++++++--------- .../av_transport_output_filter.cpp | 105 +++++----- .../av_trans_engine/plugin/plugins/BUILD.gn | 25 +++ .../av_trans_input/daudio_input/BUILD.gn | 24 +-- .../daudio_input/daudio_input_plugin.cpp | 2 +- .../daudio_input/daudio_input_plugin.h | 1 + .../av_trans_input/dscreen_input/BUILD.gn | 24 +-- .../dscreen_input/dscreen_input_plugin.cpp | 2 +- .../dscreen_input/dscreen_input_plugin.h | 1 + .../av_trans_input/dsoftbus_input/BUILD.gn | 24 +-- .../dsoftbus_input/dsoftbus_input_plugin.cpp | 4 +- .../dsoftbus_input_audio/BUILD.gn | 24 +-- .../dsoftbus_input_audio_plugin.cpp | 2 +- .../av_trans_output/daudio_output/BUILD.gn | 25 ++- .../daudio_output/daudio_output_plugin.cpp | 2 +- .../daudio_output/daudio_output_plugin.h | 4 +- .../av_trans_output/dscreen_output/BUILD.gn | 24 +-- .../dscreen_output/dscreen_output_plugin.cpp | 2 +- .../dscreen_output/dscreen_output_plugin.h | 1 + .../av_trans_output/dsoftbus_output/BUILD.gn | 24 +-- .../dsoftbus_output_plugin.cpp | 4 +- .../dsoftbus_output_audio/BUILD.gn | 24 +-- .../dsoftbus_output_audio_plugin.cpp | 2 +- av_transport/common/include/av_sync_utils.h | 1 - av_transport/distributed_av_transport.gni | 6 +- bundle.json | 21 +- distributedhardwarefwk.gni | 2 - 33 files changed, 392 insertions(+), 309 deletions(-) create mode 100644 av_transport/av_trans_engine/plugin/plugins/BUILD.gn diff --git a/av_transport/av_trans_control_center/inner_kits/BUILD.gn b/av_transport/av_trans_control_center/inner_kits/BUILD.gn index 191394dc..23ea976f 100644 --- a/av_transport/av_trans_control_center/inner_kits/BUILD.gn +++ b/av_transport/av_trans_control_center/inner_kits/BUILD.gn @@ -50,6 +50,7 @@ ohos_shared_library("avtranscenter_sdk") { "samgr:samgr_proxy", ] - part_name = "distributed_hardware_fwk" subsystem_name = "distributedhardware" + + part_name = "distributed_hardware_fwk" } diff --git a/av_transport/av_trans_engine/av_receiver/BUILD.gn b/av_transport/av_trans_engine/av_receiver/BUILD.gn index 73a61890..4a966ee1 100644 --- a/av_transport/av_trans_engine/av_receiver/BUILD.gn +++ b/av_transport/av_trans_engine/av_receiver/BUILD.gn @@ -15,32 +15,30 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") +config("sender_external_config") { + include_dirs = [ + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/common/include", + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_sender/include", + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_receiver/include", + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/interface", + ] +} + + ohos_shared_library("distributed_av_receiver") { include_dirs = [ "${drivers_disaplay_path}/interfaces/include", "${media_standard_path}/interfaces/inner_api/native", "//third_party/json/include", - "${common_path}/include", "${engine_path}", "${engine_path}/av_sender/include", "${engine_path}/av_receiver/include", "${interface_path}", "${dh_fwk_utils_path}/include", + "${dh_fwk_utils_path}/include", "${control_center_path}/inner_kits/include", "${control_center_path}/inner_kits/include/ipc", - - "${histreamer_path}/include", - "${histreamer_path}/include/foundation", - "${histreamer_path}/include/pipeline", - "${histreamer_path}/include/pipeline/core", - "${histreamer_path}/include/pipeline/factory", - "${histreamer_path}/include/pipeline/filters", - "${histreamer_path}/include/pipeline/filters/codec/audio_decoder", - "${histreamer_path}/include/pipeline/filters/codec/video_decoder", - "${histreamer_path}/include/plugin/common", - "${histreamer_path}/include/scene/standard", - "${histreamer_path}/pipeline/filters/codec", "${filters_path}/av_transport_input", "${filters_path}/av_transport_output", ] @@ -58,7 +56,6 @@ ohos_shared_library("distributed_av_receiver") { deps = [ "${control_center_path}/inner_kits:avtranscenter_sdk", - "${histreamer_path}/pipeline/filters/codec:codec_filters, "${filters_path}:avtrans_input_filter", "${filters_path}:avtrans_output_filter", ] @@ -86,6 +83,10 @@ ohos_shared_library("distributed_av_receiver") { "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_plugin_base", + "histreamer:histreamer_ffmpeg_convert", ] remove_configs = [ diff --git a/av_transport/av_trans_engine/av_receiver/include/av_receiver_engine.h b/av_transport/av_trans_engine/av_receiver/include/av_receiver_engine.h index c0f442ff..e22705cc 100644 --- a/av_transport/av_trans_engine/av_receiver/include/av_receiver_engine.h +++ b/av_transport/av_trans_engine/av_receiver/include/av_receiver_engine.h @@ -38,7 +38,6 @@ #include "pipeline_core.h" #include "audio_decoder_filter.h" #include "video_decoder_filter.h" -#include "async_mode.h" namespace OHOS { namespace DistributedHardware { diff --git a/av_transport/av_trans_engine/av_receiver/src/av_receiver_engine.cpp b/av_transport/av_trans_engine/av_receiver/src/av_receiver_engine.cpp index 151f035e..4d4808a1 100644 --- a/av_transport/av_trans_engine/av_receiver/src/av_receiver_engine.cpp +++ b/av_transport/av_trans_engine/av_receiver/src/av_receiver_engine.cpp @@ -68,12 +68,10 @@ int32_t AVReceiverEngine::InitPipeline() avOutput_ = FilterFactory::Instance().CreateFilterWithType(AVOUTPUT_NAME, "avoutput"); TRUE_RETURN_V_MSG_E(avOutput_ == nullptr, ERR_DH_AVT_NULL_POINTER, "create av output filter failed"); - std::shared_ptr vCodecMode = std::make_shared("videoDec"); - videoDecoder_ = std::make_shared(VDECODER_NAME, vCodecMode); + videoDecoder_ = FilterFactory::Instance().CreateFilterWithType(VDECODER_NAME, "videoDec"); TRUE_RETURN_V_MSG_E(videoDecoder_ == nullptr, ERR_DH_AVT_NULL_POINTER, "create av video decoder filter failed"); - - std::shared_ptr aCodecMode = std::make_shared("audioDec"); - audioDecoder_ = std::make_shared(ADECODER_NAME, aCodecMode); + + audioDecoder_ = FilterFactory::Instance().CreateFilterWithType(ADECODER_NAME, "audioDec"); TRUE_RETURN_V_MSG_E(audioDecoder_ == nullptr, ERR_DH_AVT_NULL_POINTER, "create av audio decoder filter failed"); ErrorCode ret; diff --git a/av_transport/av_trans_engine/av_sender/BUILD.gn b/av_transport/av_trans_engine/av_sender/BUILD.gn index cc5aeabc..6047cb62 100644 --- a/av_transport/av_trans_engine/av_sender/BUILD.gn +++ b/av_transport/av_trans_engine/av_sender/BUILD.gn @@ -15,7 +15,18 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") +config("sender_external_config") { + include_dirs = [ + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/common/include", + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_sender/include", + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_receiver/include", + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/interface", + ] +} + ohos_shared_library("distributed_av_sender") { + public_configs = [ ":sender_external_config" ] + include_dirs = [ "${drivers_disaplay_path}/interfaces/include", "${media_standard_path}/interfaces/inner_api/native", @@ -29,17 +40,6 @@ ohos_shared_library("distributed_av_sender") { "${dh_fwk_utils_path}/include", "${control_center_path}/inner_kits/include", "${control_center_path}/inner_kits/include/ipc", - - "${histreamer_path}/include", - "${histreamer_path}/include/foundation", - "${histreamer_path}/include/pipeline", - "${histreamer_path}/include/pipeline/core", - "${histreamer_path}/include/pipeline/factory", - "${histreamer_path}/include/pipeline/filters", - "${histreamer_path}/include/pipeline/filters/codec/audio_encoder", - "${histreamer_path}/include/pipeline/filters/codec/video_encoder", - "${histreamer_path}/include/plugin/common", - "${histreamer_path}/include/scene/standard", "${filters_path}/av_transport_input", "${filters_path}/av_transport_output", ] @@ -57,7 +57,6 @@ ohos_shared_library("distributed_av_sender") { deps = [ "${control_center_path}/inner_kits:avtranscenter_sdk", - "${histreamer_path}/pipeline/filters/codec:codec_filters, "${filters_path}:avtrans_input_filter", "${filters_path}:avtrans_output_filter", ] @@ -85,6 +84,10 @@ ohos_shared_library("distributed_av_sender") { "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_plugin_base", + "histreamer:histreamer_ffmpeg_convert", ] remove_configs = [ diff --git a/av_transport/av_trans_engine/filters/BUILD.gn b/av_transport/av_trans_engine/filters/BUILD.gn index 254447c4..3b5417e1 100644 --- a/av_transport/av_trans_engine/filters/BUILD.gn +++ b/av_transport/av_trans_engine/filters/BUILD.gn @@ -15,31 +15,58 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -source_set("avtrans_input_filter") { +ohos_source_set("avtrans_input_filter") { include_dirs = [ "${plugin_path}/core", "${plugin_path}/interface", + "${common_path}/include", ] sources = [ "av_transport_input/av_transport_input_filter.cpp", "${plugin_path}/core/avtrans_input.cpp", - ] + ] + + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_plugin_base", + "histreamer:histreamer_ffmpeg_convert", + ] public_deps = [ - "${histreamer_path}/foundation:histreamer_foundation", - "${histreamer_path}/pipeline:histreamer_base", "${plugin_path}/plugins/av_trans_input/daudio_input:plugin_AVTransDaudioInput", "${plugin_path}/plugins/av_trans_input/dscreen_input:plugin_AVTransDscreenInput", "${plugin_path}/plugins/av_trans_input/dsoftbus_input:plugin_AVTransDsoftbusInput", "${plugin_path}/plugins/av_trans_input/dsoftbus_input_audio:plugin_AVTransDsoftbusInputAudio", - ] + ] + + cflags = [ + "-O2", + "-fPIC", + "-Wall", + "-frtti", + "-fexceptions", + "-Wno-unused-but-set-variable", + "-Wno-format", + ] + cflags_cc = cflags + part_name = "distributed_hardware_fwk" + subsystem_name = "distributedhardware" + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"av_transport_input_filter\"", + "LOG_DOMAIN=0xD004100", + ] } -source_set("avtrans_output_filter") { +ohos_source_set("avtrans_output_filter") { include_dirs = [ "${plugin_path}/core", "${plugin_path}/interface", + "${common_path}/include", ] sources = [ @@ -47,12 +74,37 @@ source_set("avtrans_output_filter") { "${plugin_path}/core/avtrans_output.cpp", ] + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_plugin_base", + "histreamer:histreamer_ffmpeg_convert", + ] + public_deps = [ - "${histreamer_path}/foundation:histreamer_foundation", - "${histreamer_path}/pipeline:histreamer_base", "${plugin_path}/plugins/av_trans_output/daudio_output:plugin_AVTransDaudioOutput", "${plugin_path}/plugins/av_trans_output/dscreen_output:plugin_AVTransDscreenOutput", "${plugin_path}/plugins/av_trans_output/dsoftbus_output:plugin_AVTransDsoftbusOutput", "${plugin_path}/plugins/av_trans_output/dsoftbus_output_audio:plugin_AVTransDsoftbusOutputAudio", - ] + ] + + cflags = [ + "-O2", + "-fPIC", + "-Wall", + "-frtti", + "-fexceptions", + "-Wno-unused-but-set-variable", + "-Wno-format", + ] + cflags_cc = cflags + part_name = "distributed_hardware_fwk" + subsystem_name = "distributedhardware" + + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"av_transport_output_filter\"", + "LOG_DOMAIN=0xD004100", + ] } \ No newline at end of file diff --git a/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp b/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp index 2c792601..b337e414 100644 --- a/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp +++ b/av_transport/av_trans_engine/filters/av_transport_input/av_transport_input_filter.cpp @@ -15,8 +15,9 @@ #define HST_LOG_TAG "AVInputFilter" #include "av_transport_input_filter.h" +#include "av_trans_log.h" +#include "av_trans_constants.h" #include "pipeline/filters/common/plugin_utils.h" -#include "foundation/log.h" #include "pipeline/factory/filter_factory.h" #include "plugin/common/plugin_attr_desc.h" @@ -27,12 +28,12 @@ static AutoRegisterFilter g_registerFilterHelper("builtin.avtrans AVInputFilter::AVInputFilter(const std::string& name) : FilterBase(name), plugin_(nullptr), pluginInfo_(nullptr) { - MEDIA_LOG_I("ctor called"); + AVTRANS_LOGI("ctor called"); } AVInputFilter::~AVInputFilter() { - MEDIA_LOG_I("dtor called"); + AVTRANS_LOGI("dtor called"); OSAL::ScopedLock lock(inputFilterMutex_); if (plugin_ != nullptr) { plugin_->Deinit(); @@ -48,7 +49,7 @@ ErrorCode AVInputFilter::SetParameter(int32_t key, const Any& value) { Tag tag; if (!TranslateIntoParameter(key, tag)) { - MEDIA_LOG_E("This key is invalid!"); + AVTRANS_LOGE("This key is invalid!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } { @@ -62,7 +63,7 @@ ErrorCode AVInputFilter::GetParameter(int32_t key, Any& value) { Tag tag; if (!TranslateIntoParameter(key, tag)) { - MEDIA_LOG_E("This key is invalid!"); + AVTRANS_LOGE("This key is invalid!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } { @@ -74,49 +75,49 @@ ErrorCode AVInputFilter::GetParameter(int32_t key, Any& value) ErrorCode AVInputFilter::Prepare() { - MEDIA_LOG_I("Prepare entered."); + AVTRANS_LOGI("Prepare entered."); if (state_ != FilterState::INITIALIZED) { - MEDIA_LOG_E("The current state is invalid"); + AVTRANS_LOGE("The current state is invalid"); return ErrorCode::ERROR_INVALID_STATE; } state_ = FilterState::PREPARING; ErrorCode err = FindPlugin(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Find plugin fail"); + AVTRANS_LOGE("Find plugin fail"); state_ = FilterState::INITIALIZED; return err; } err = DoConfigure(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Configure downStream fail"); + AVTRANS_LOGE("Configure downStream fail"); state_ = FilterState::INITIALIZED; return err; } err = PreparePlugin(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Prepare plugin fail"); + AVTRANS_LOGE("Prepare plugin fail"); state_ = FilterState::INITIALIZED; return err; } state_ = FilterState::READY; - MEDIA_LOG_I("Prepare end."); + AVTRANS_LOGI("Prepare end."); return ErrorCode::SUCCESS; } ErrorCode AVInputFilter::Start() { - MEDIA_LOG_I("Start"); + AVTRANS_LOGI("Start"); OSAL::ScopedLock lock(inputFilterMutex_); if (state_ != FilterState::READY && state_ != FilterState::PAUSED) { - MEDIA_LOG_E("The current state is invalid"); + AVTRANS_LOGE("The current state is invalid"); return ErrorCode::ERROR_INVALID_STATE; } if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_NULL_POINTER; } if (TranslatePluginStatus(plugin_->Start()) != ErrorCode::SUCCESS) { - MEDIA_LOG_E("The plugin start fail!"); + AVTRANS_LOGE("The plugin start fail!"); return ErrorCode::ERROR_INVALID_OPERATION; } state_ = FilterState::RUNNING; @@ -125,18 +126,18 @@ ErrorCode AVInputFilter::Start() ErrorCode AVInputFilter::Stop() { - MEDIA_LOG_I("Stop"); + AVTRANS_LOGI("Stop"); OSAL::ScopedLock lock(inputFilterMutex_); if (state_ != FilterState::RUNNING) { - MEDIA_LOG_E("The current state is invalid"); + AVTRANS_LOGE("The current state is invalid"); return ErrorCode::ERROR_INVALID_STATE; } if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_NULL_POINTER; } if (TranslatePluginStatus(plugin_->Stop()) != ErrorCode::SUCCESS) { - MEDIA_LOG_E("The plugin stop fail!"); + AVTRANS_LOGE("The plugin stop fail!"); return ErrorCode::ERROR_INVALID_OPERATION; } state_ = FilterState::READY; @@ -145,18 +146,18 @@ ErrorCode AVInputFilter::Stop() ErrorCode AVInputFilter::Pause() { - MEDIA_LOG_I("Pause"); + AVTRANS_LOGI("Pause"); OSAL::ScopedLock lock(inputFilterMutex_); if (state_ != FilterState::RUNNING) { - MEDIA_LOG_E("The current state is invalid"); + AVTRANS_LOGE("The current state is invalid"); return ErrorCode::ERROR_INVALID_STATE; } if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_NULL_POINTER; } if (TranslatePluginStatus(plugin_->Stop()) != ErrorCode::SUCCESS) { - MEDIA_LOG_E("The plugin stop fail!"); + AVTRANS_LOGE("The plugin stop fail!"); return ErrorCode::ERROR_INVALID_OPERATION; } state_ = FilterState::PAUSED; @@ -165,13 +166,13 @@ ErrorCode AVInputFilter::Pause() ErrorCode AVInputFilter::Resume() { - MEDIA_LOG_I("Resume"); + AVTRANS_LOGI("Resume"); return ErrorCode::SUCCESS; } void AVInputFilter::InitPorts() { - MEDIA_LOG_I("InitPorts"); + AVTRANS_LOGI("InitPorts"); auto outPort = std::make_shared(this); { OSAL::ScopedLock lock(inputFilterMutex_); @@ -185,7 +186,7 @@ ErrorCode AVInputFilter::FindPlugin() std::string mime; if (paramsMap_.find(Tag::MIME) == paramsMap_.end() || !paramsMap_[Tag::MIME].SameTypeWith(typeid(std::string))) { - MEDIA_LOG_E("Must set mime correctly first"); + AVTRANS_LOGE("Must set mime correctly first"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } mime = Plugin::AnyCast(paramsMap_[Tag::MIME]); @@ -196,62 +197,62 @@ ErrorCode AVInputFilter::FindPlugin() continue; } if (DoNegotiate(info->outCaps) && CreatePlugin(info) == ErrorCode::SUCCESS) { - MEDIA_LOG_I("CreatePlugin " PUBLIC_LOG_S " success", name_.c_str()); + AVTRANS_LOGI("CreatePlugin %s success", name_.c_str()); return ErrorCode::SUCCESS; } } - MEDIA_LOG_I("Cannot find any plugin"); + AVTRANS_LOGI("Cannot find any plugin"); return ErrorCode::ERROR_UNSUPPORTED_FORMAT; } bool AVInputFilter::DoNegotiate(const CapabilitySet& outCaps) { - MEDIA_LOG_I("DoNegotiate start"); + AVTRANS_LOGI("DoNegotiate start"); if (outCaps.empty()) { - MEDIA_LOG_E("Input plugin must have out caps"); + AVTRANS_LOGE("Input plugin must have out caps"); return false; } for (const auto& outCap : outCaps) { auto thisOutCap = std::make_shared(outCap); - MEDIA_LOG_I("thisOutCap " PUBLIC_LOG_S, thisOutCap->mime.c_str()); + AVTRANS_LOGI("thisOutCap %s", thisOutCap->mime.c_str()); Meta upstreamParams; Meta downstreamParams; if (outPorts_.size() == 0 || outPorts_[0] == nullptr) { - MEDIA_LOG_E("outPorts is empty or invalid!"); + AVTRANS_LOGE("outPorts is empty or invalid!"); return false; } if (outPorts_[0]->Negotiate(thisOutCap, capNegWithDownstream_, upstreamParams, downstreamParams)) { - MEDIA_LOG_I("Negotiate success"); + AVTRANS_LOGI("Negotiate success"); return true; } } - MEDIA_LOG_I("DoNegotiate end"); + AVTRANS_LOGI("DoNegotiate end"); return false; } ErrorCode AVInputFilter::CreatePlugin(const std::shared_ptr& selectedInfo) { - MEDIA_LOG_I("CreatePlugin"); + AVTRANS_LOGI("CreatePlugin"); if (selectedInfo == nullptr || selectedInfo->name.empty()) { - MEDIA_LOG_E("selectedInfo is nullptr or pluginName is invalid!"); + AVTRANS_LOGE("selectedInfo is nullptr or pluginName is invalid!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } if ((plugin_ != nullptr) && (pluginInfo_ != nullptr)) { if (selectedInfo->name == pluginInfo_->name && TranslatePluginStatus(plugin_->Reset()) == ErrorCode::SUCCESS) { - MEDIA_LOG_I("Reuse last plugin: " PUBLIC_LOG_S, selectedInfo->name.c_str()); + AVTRANS_LOGI("Reuse last plugin: %s", selectedInfo->name.c_str()); return ErrorCode::SUCCESS; } if (TranslatePluginStatus(plugin_->Deinit()) != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Deinit last plugin: " PUBLIC_LOG_S " error", pluginInfo_->name.c_str()); + AVTRANS_LOGE("Deinit last plugin: %s error", pluginInfo_->name.c_str()); } } plugin_ = PluginManager::Instance().CreateGenericPlugin(selectedInfo->name); if (plugin_ == nullptr) { - MEDIA_LOG_E("PluginManager CreatePlugin " PUBLIC_LOG_S " fail", selectedInfo->name.c_str()); + AVTRANS_LOGE("PluginManager CreatePlugin %s fail", selectedInfo->name.c_str()); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } pluginInfo_ = selectedInfo; - MEDIA_LOG_I("Create new plugin: " PUBLIC_LOG_S " success", pluginInfo_->name.c_str()); + AVTRANS_LOGI("Create new plugin: %s success", pluginInfo_->name.c_str()); return ErrorCode::SUCCESS; } @@ -260,26 +261,26 @@ ErrorCode AVInputFilter::DoConfigure() Plugin::Meta emptyMeta; Plugin::Meta targetMeta; if (MergeMeta(emptyMeta, targetMeta) != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Merge Meta fail!"); + AVTRANS_LOGE("Merge Meta fail!"); return ErrorCode::ERROR_INVALID_OPERATION; } if (ConfigMeta(targetMeta) != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Config Meta fail!"); + AVTRANS_LOGE("Config Meta fail!"); return ErrorCode::ERROR_INVALID_OPERATION; } if (ConfigDownStream(targetMeta) != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Config DownStream fail!"); + AVTRANS_LOGE("Config DownStream fail!"); return ErrorCode::ERROR_INVALID_OPERATION; } auto err = InitPlugin(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Init plugin fail"); + AVTRANS_LOGE("Init plugin fail"); state_ = FilterState::INITIALIZED; return ErrorCode::ERROR_INVALID_OPERATION; } err = ConfigPlugin(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Configure plugin fail"); + AVTRANS_LOGE("Configure plugin fail"); state_ = FilterState::INITIALIZED; return ErrorCode::ERROR_INVALID_OPERATION; } @@ -290,7 +291,7 @@ ErrorCode AVInputFilter::MergeMeta(const Plugin::Meta& meta, Plugin::Meta& targe { OSAL::ScopedLock lock(inputFilterMutex_); if (!MergeMetaWithCapability(meta, capNegWithDownstream_, targetMeta)) { - MEDIA_LOG_E("cannot find available capability of plugin " PUBLIC_LOG_S, pluginInfo_->name.c_str()); + AVTRANS_LOGE("cannot find available capability of plugin %s", pluginInfo_->name.c_str()); return ErrorCode::ERROR_INVALID_OPERATION; } return ErrorCode::SUCCESS; @@ -298,11 +299,11 @@ ErrorCode AVInputFilter::MergeMeta(const Plugin::Meta& meta, Plugin::Meta& targe ErrorCode AVInputFilter::ConfigMeta(Plugin::Meta& meta) { - MEDIA_LOG_I("ConfigMeta start!"); + AVTRANS_LOGI("ConfigMeta start!"); OSAL::ScopedLock lock(inputFilterMutex_); if (paramsMap_.find(Tag::MEDIA_TYPE) == paramsMap_.end() || !paramsMap_[Tag::MEDIA_TYPE].SameTypeWith(typeid(Plugin::MediaType))) { - MEDIA_LOG_E("MEDIA_TYPE in ParamsMap is not exist!"); + AVTRANS_LOGE("MEDIA_TYPE in ParamsMap is not exist!"); return ErrorCode::ERROR_NOT_EXISTED; } auto mediaType = Plugin::AnyCast(paramsMap_[Tag::MEDIA_TYPE]); @@ -316,41 +317,41 @@ ErrorCode AVInputFilter::ConfigMeta(Plugin::Meta& meta) ErrorCode AVInputFilter::ConfigVideoMeta(Plugin::Meta& meta) { - MEDIA_LOG_I("ConfigVideoMeta start!"); + AVTRANS_LOGI("ConfigVideoMeta start!"); if (paramsMap_.find(Tag::VIDEO_WIDTH) != paramsMap_.end() && paramsMap_[Tag::VIDEO_WIDTH].SameTypeWith(typeid(int))) { - uint32_t width = Plugin::AnyCast(paramsMap_[Tag::VIDEO_WIDTH]); - MEDIA_LOG_I("ConfigVideoMeta: VIDEO_WIDTH is " PUBLIC_LOG_U32, width); + uint32_t width = static_cast(Plugin::AnyCast(paramsMap_[Tag::VIDEO_WIDTH])); + AVTRANS_LOGI("ConfigVideoMeta: VIDEO_WIDTH is %d", width); meta.Set(width); } if (paramsMap_.find(Tag::VIDEO_HEIGHT) != paramsMap_.end() && paramsMap_[Tag::VIDEO_HEIGHT].SameTypeWith(typeid(int))) { - uint32_t height = Plugin::AnyCast(paramsMap_[Tag::VIDEO_HEIGHT]); - MEDIA_LOG_I("ConfigVideoMeta: VIDEO_HEIGHT is " PUBLIC_LOG_U32, height); + uint32_t height = static_cast(Plugin::AnyCast(paramsMap_[Tag::VIDEO_HEIGHT])); + AVTRANS_LOGI("ConfigVideoMeta: VIDEO_HEIGHT is %d", height); meta.Set(height); } if (paramsMap_.find(Tag::MEDIA_BITRATE) != paramsMap_.end() && paramsMap_[Tag::MEDIA_BITRATE].SameTypeWith(typeid(int))) { int64_t mediaBitRate = Plugin::AnyCast(paramsMap_[Tag::MEDIA_BITRATE]); - MEDIA_LOG_I("ConfigVideoMeta: MEDIA_BITRATE is " PUBLIC_LOG_D64, mediaBitRate); + AVTRANS_LOGI("ConfigVideoMeta: MEDIA_BITRATE is %ld", mediaBitRate); meta.Set(mediaBitRate); } if (paramsMap_.find(Tag::VIDEO_FRAME_RATE) != paramsMap_.end() && paramsMap_[Tag::VIDEO_FRAME_RATE].SameTypeWith(typeid(int))) { - uint32_t videoFrameRate = Plugin::AnyCast(paramsMap_[Tag::VIDEO_FRAME_RATE]); - MEDIA_LOG_I("ConfigVideoMeta: VIDEO_FRAME_RATE is " PUBLIC_LOG_U32, videoFrameRate); + uint32_t videoFrameRate = static_cast(Plugin::AnyCast(paramsMap_[Tag::VIDEO_FRAME_RATE])); + AVTRANS_LOGI("ConfigVideoMeta: VIDEO_FRAME_RATE is %d", videoFrameRate); meta.Set(videoFrameRate); } if (paramsMap_.find(Tag::VIDEO_BIT_STREAM_FORMAT) != paramsMap_.end() && paramsMap_[Tag::VIDEO_BIT_STREAM_FORMAT].SameTypeWith(typeid(VideoBitStreamFormat))) { auto videoBitStreamFormat = Plugin::AnyCast(paramsMap_[Tag::VIDEO_BIT_STREAM_FORMAT]); - MEDIA_LOG_I("ConfigVideoMeta: VIDEO_BIT_STREAM_FORMAT is " PUBLIC_LOG_U32, videoBitStreamFormat); + AVTRANS_LOGI("ConfigVideoMeta: VIDEO_BIT_STREAM_FORMAT is %d", videoBitStreamFormat); meta.Set(std::vector{videoBitStreamFormat}); } if (paramsMap_.find(Tag::VIDEO_PIXEL_FORMAT) != paramsMap_.end() && paramsMap_[Tag::VIDEO_PIXEL_FORMAT].SameTypeWith(typeid(VideoPixelFormat))) { auto videoPixelFormat = Plugin::AnyCast(paramsMap_[Tag::VIDEO_PIXEL_FORMAT]); - MEDIA_LOG_I("ConfigVideoMeta: VIDEO_PIXEL_FORMAT is " PUBLIC_LOG_U32, videoPixelFormat); + AVTRANS_LOGI("ConfigVideoMeta: VIDEO_PIXEL_FORMAT is %d", videoPixelFormat); meta.Set(videoPixelFormat); } return ErrorCode::SUCCESS; @@ -390,47 +391,47 @@ OHOS::Media::Plugin::AudioSampleFormat AVInputFilter::TransAudioSampleFormat(int ErrorCode AVInputFilter::ConfigAudioMeta(Plugin::Meta& meta) { - MEDIA_LOG_I("ConfigAudioMeta start"); + AVTRANS_LOGI("ConfigAudioMeta start"); if (paramsMap_.find(Tag::AUDIO_CHANNELS) != paramsMap_.end() && paramsMap_[Tag::AUDIO_CHANNELS].SameTypeWith(typeid(int))) { - uint32_t audioChannel = Plugin::AnyCast(paramsMap_[Tag::AUDIO_CHANNELS]); - MEDIA_LOG_I("ConfigAudioMeta: AUDIO_CHANNELS is " PUBLIC_LOG_U32, audioChannel); + uint32_t audioChannel = static_cast(Plugin::AnyCast(paramsMap_[Tag::AUDIO_CHANNELS])); + AVTRANS_LOGI("ConfigAudioMeta: AUDIO_CHANNELS is %d", audioChannel); meta.Set(audioChannel); } if (paramsMap_.find(Tag::AUDIO_SAMPLE_RATE) != paramsMap_.end() && paramsMap_[Tag::AUDIO_SAMPLE_RATE].SameTypeWith(typeid(int))) { - uint32_t sampleRate = Plugin::AnyCast(paramsMap_[Tag::AUDIO_SAMPLE_RATE]); - MEDIA_LOG_I("ConfigAudioMeta: AUDIO_SAMPLE_RATE is " PUBLIC_LOG_U32, sampleRate); + uint32_t sampleRate = static_cast(Plugin::AnyCast(paramsMap_[Tag::AUDIO_SAMPLE_RATE])); + AVTRANS_LOGI("ConfigAudioMeta: AUDIO_SAMPLE_RATE is %d", sampleRate); meta.Set(sampleRate); } if (paramsMap_.find(Tag::MEDIA_BITRATE) != paramsMap_.end() && paramsMap_[Tag::MEDIA_BITRATE].SameTypeWith(typeid(int))) { int64_t mediaBitRate = Plugin::AnyCast(paramsMap_[Tag::MEDIA_BITRATE]); - MEDIA_LOG_I("ConfigAudioMeta: MEDIA_BITRATE is " PUBLIC_LOG_D64, mediaBitRate); + AVTRANS_LOGI("ConfigAudioMeta: MEDIA_BITRATE is %ld", mediaBitRate); meta.Set(mediaBitRate); } if (paramsMap_.find(Tag::AUDIO_SAMPLE_FORMAT) != paramsMap_.end() && paramsMap_[Tag::AUDIO_SAMPLE_FORMAT].SameTypeWith(typeid(int))) { auto audioSampleFmtPtr = Plugin::AnyCast(paramsMap_[Tag::AUDIO_SAMPLE_FORMAT]); - MEDIA_LOG_I("ConfigAudioMeta: AUDIO_SAMPLE_FORMAT is " PUBLIC_LOG_U32, audioSampleFmtPtr); + AVTRANS_LOGI("ConfigAudioMeta: AUDIO_SAMPLE_FORMAT is %d", audioSampleFmtPtr); meta.Set(TransAudioSampleFormat(audioSampleFmtPtr)); } if (paramsMap_.find(Tag::AUDIO_CHANNEL_LAYOUT) != paramsMap_.end() && paramsMap_[Tag::AUDIO_CHANNEL_LAYOUT].SameTypeWith(typeid(int))) { auto layoutPtr = Plugin::AnyCast(paramsMap_[Tag::AUDIO_CHANNEL_LAYOUT]); - MEDIA_LOG_I("ConfigAudioMeta: AUDIO_CHANNEL_LAYOUT is " PUBLIC_LOG_U32, layoutPtr); + AVTRANS_LOGI("ConfigAudioMeta: AUDIO_CHANNEL_LAYOUT is %d", layoutPtr); meta.Set(TransAudioChannelLayout(layoutPtr)); } if (paramsMap_.find(Tag::AUDIO_SAMPLE_PER_FRAME) != paramsMap_.end() && paramsMap_[Tag::AUDIO_SAMPLE_PER_FRAME].SameTypeWith(typeid(int))) { - uint32_t samplePerFrame = Plugin::AnyCast(paramsMap_[Tag::AUDIO_SAMPLE_PER_FRAME]); - MEDIA_LOG_I("ConfigAudioMeta: AUDIO_SAMPLE_PER_FRAME is " PUBLIC_LOG_U32, samplePerFrame); + uint32_t samplePerFrame = static_cast(Plugin::AnyCast(paramsMap_[Tag::AUDIO_SAMPLE_PER_FRAME])); + AVTRANS_LOGI("ConfigAudioMeta: AUDIO_SAMPLE_PER_FRAME is %d", samplePerFrame); meta.Set(samplePerFrame); } if (paramsMap_.find(Tag::AUDIO_AAC_LEVEL) != paramsMap_.end() && paramsMap_[Tag::AUDIO_AAC_LEVEL].SameTypeWith(typeid(int))) { - uint32_t aacLevel = Plugin::AnyCast(paramsMap_[Tag::AUDIO_AAC_LEVEL]); - MEDIA_LOG_I("ConfigAudioMeta: AUDIO_AAC_LEVEL is " PUBLIC_LOG_U32, aacLevel); + uint32_t aacLevel = static_cast(Plugin::AnyCast(paramsMap_[Tag::AUDIO_AAC_LEVEL])); + AVTRANS_LOGI("ConfigAudioMeta: AUDIO_AAC_LEVEL is %d", aacLevel); meta.Set(aacLevel); } return ErrorCode::SUCCESS; @@ -442,11 +443,11 @@ ErrorCode AVInputFilter::ConfigDownStream(const Plugin::Meta& meta) Meta downstreamParams; OSAL::ScopedLock lock(inputFilterMutex_); if (outPorts_.size() == 0 || outPorts_[0] == nullptr) { - MEDIA_LOG_E("outPorts is empty or invalid!"); + AVTRANS_LOGE("outPorts is empty or invalid!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } if (!outPorts_[0]->Configure(std::make_shared(meta), upstreamParams, downstreamParams)) { - MEDIA_LOG_E("Configure downstream fail"); + AVTRANS_LOGE("Configure downstream fail"); return ErrorCode::ERROR_INVALID_OPERATION; } return ErrorCode::SUCCESS; @@ -454,10 +455,10 @@ ErrorCode AVInputFilter::ConfigDownStream(const Plugin::Meta& meta) ErrorCode AVInputFilter::InitPlugin() { - MEDIA_LOG_I("InitPlugin"); + AVTRANS_LOGI("InitPlugin"); OSAL::ScopedLock lock(inputFilterMutex_); if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } return TranslatePluginStatus(plugin_->Init()); @@ -465,20 +466,20 @@ ErrorCode AVInputFilter::InitPlugin() ErrorCode AVInputFilter::ConfigPlugin() { - MEDIA_LOG_I("Configure"); + AVTRANS_LOGI("Configure"); ErrorCode err = SetPluginParams(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Set Plugin fail!"); + AVTRANS_LOGE("Set Plugin fail!"); return err; } err = SetEventCallBack(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Plugin SetEventCallBack fail!"); + AVTRANS_LOGE("Plugin SetEventCallBack fail!"); return err; } err = SetDataCallBack(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Plugin SetDataCallBack fail!"); + AVTRANS_LOGE("Plugin SetDataCallBack fail!"); return err; } return ErrorCode::SUCCESS; @@ -488,7 +489,7 @@ ErrorCode AVInputFilter::SetPluginParams() { OSAL::ScopedLock lock(inputFilterMutex_); if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_NULL_POINTER; } if (paramsMap_.find(Tag::MEDIA_DESCRIPTION) != paramsMap_.end()) { @@ -501,7 +502,7 @@ ErrorCode AVInputFilter::PreparePlugin() { OSAL::ScopedLock lock(inputFilterMutex_); if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_NULL_POINTER; } return TranslatePluginStatus(plugin_->Prepare()); @@ -511,24 +512,24 @@ ErrorCode AVInputFilter::PushData(const std::string& inPort, const AVBufferPtr& { OSAL::ScopedLock lock(inputFilterMutex_); if (name_.compare(inPort) != 0) { - MEDIA_LOG_E("FilterName is not targetName!"); + AVTRANS_LOGE("FilterName is not targetName!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } if (buffer == nullptr || plugin_ == nullptr) { - MEDIA_LOG_E("buffer or plugin is nullptr!"); + AVTRANS_LOGE("buffer or plugin is nullptr!"); return ErrorCode::ERROR_NULL_POINTER; } - MEDIA_LOG_I("PushData to plugin"); + AVTRANS_LOGI("PushData to plugin"); if (TranslatePluginStatus(plugin_->PushData(inPort, buffer, offset)) != ErrorCode::SUCCESS) { - MEDIA_LOG_E("PushData to plugin fail!"); + AVTRANS_LOGE("PushData to plugin fail!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } - MEDIA_LOG_I("PushData from plugin"); + AVTRANS_LOGI("PushData from plugin"); if (outPorts_.size() == 0 || outPorts_[0] == nullptr) { - MEDIA_LOG_E("outPorts is empty or invalid!"); + AVTRANS_LOGE("outPorts is empty or invalid!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } - MEDIA_LOG_I("PushData to next filter plugin!"); + AVTRANS_LOGI("PushData to next filter plugin!"); outPorts_[0]->PushData(buffer, 0); return ErrorCode::SUCCESS; } @@ -537,7 +538,7 @@ ErrorCode AVInputFilter::SetEventCallBack() { OSAL::ScopedLock lock(inputFilterMutex_); if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_NULL_POINTER ; } return TranslatePluginStatus(plugin_->SetCallback(this)); @@ -547,7 +548,7 @@ ErrorCode AVInputFilter::SetDataCallBack() { OSAL::ScopedLock lock(inputFilterMutex_); if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_NULL_POINTER; } return TranslatePluginStatus(plugin_->SetDataCallback(std::bind(&AVInputFilter::OnDataCallback, this, @@ -558,11 +559,11 @@ void AVInputFilter::OnDataCallback(std::shared_ptr buffer) { OSAL::ScopedLock lock(inputFilterMutex_); if (buffer == nullptr) { - MEDIA_LOG_E("buffer is nullptr!"); + AVTRANS_LOGE("buffer is nullptr!"); return; } if (outPorts_.size() == 0 || outPorts_[0] == nullptr) { - MEDIA_LOG_E("outPorts is invalid!"); + AVTRANS_LOGE("outPorts is invalid!"); return; } outPorts_[0]->PushData(buffer, 0); diff --git a/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp b/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp index ad23e982..b7a2005e 100644 --- a/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp +++ b/av_transport/av_trans_engine/filters/av_transport_output/av_transport_output_filter.cpp @@ -15,8 +15,9 @@ #define HST_LOG_TAG "AVOutputFilter" #include "av_transport_output_filter.h" +#include "av_trans_log.h" +#include "av_trans_constants.h" #include "pipeline/filters/common/plugin_utils.h" -#include "foundation/log.h" #include "pipeline/factory/filter_factory.h" #include "plugin/common/plugin_attr_desc.h" @@ -27,12 +28,12 @@ static AutoRegisterFilter g_registerFilterHelper("builtin.avtran AVOutputFilter::AVOutputFilter(const std::string& name) : FilterBase(name), plugin_(nullptr), pluginInfo_(nullptr) { - MEDIA_LOG_I("ctor called"); + AVTRANS_LOGI("ctor called"); } AVOutputFilter::~AVOutputFilter() { - MEDIA_LOG_I("dtor called"); + AVTRANS_LOGI("dtor called"); OSAL::ScopedLock lock(outputFilterMutex_); if (plugin_ != nullptr) { plugin_->Deinit(); @@ -46,10 +47,10 @@ std::vector AVOutputFilter::GetWorkModes() ErrorCode AVOutputFilter::SetParameter(int32_t key, const Any& value) { - MEDIA_LOG_I("SetParameter key " PUBLIC_LOG_D32, key); + AVTRANS_LOGI("SetParameter key %d", key); Tag tag; if (!TranslateIntoParameter(key, tag)) { - MEDIA_LOG_E("This key is invalid!"); + AVTRANS_LOGE("This key is invalid!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } { @@ -63,7 +64,7 @@ ErrorCode AVOutputFilter::GetParameter(int32_t key, Any& value) { Tag tag; if (!TranslateIntoParameter(key, tag)) { - MEDIA_LOG_E("This key is invalid!"); + AVTRANS_LOGE("This key is invalid!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } { @@ -75,55 +76,55 @@ ErrorCode AVOutputFilter::GetParameter(int32_t key, Any& value) ErrorCode AVOutputFilter::Prepare() { - MEDIA_LOG_I("Prepare entered."); + AVTRANS_LOGI("Prepare entered."); if (state_ != FilterState::INITIALIZED) { - MEDIA_LOG_E("The current state is invalid"); + AVTRANS_LOGE("The current state is invalid"); return ErrorCode::ERROR_INVALID_STATE; } state_ = FilterState::PREPARING; ErrorCode err = FindPlugin(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Find plugin fail"); + AVTRANS_LOGE("Find plugin fail"); state_ = FilterState::INITIALIZED; return err; } err = InitPlugin(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Init plugin fail"); + AVTRANS_LOGE("Init plugin fail"); state_ = FilterState::INITIALIZED; return err; } err = ConfigPlugin(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Configure downStream fail"); + AVTRANS_LOGE("Configure downStream fail"); state_ = FilterState::INITIALIZED; return err; } err = PreparePlugin(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Prepare plugin fail"); + AVTRANS_LOGE("Prepare plugin fail"); state_ = FilterState::INITIALIZED; return err; } state_ = FilterState::READY; - MEDIA_LOG_I("Prepare end."); + AVTRANS_LOGI("Prepare end."); return err; } ErrorCode AVOutputFilter::Start() { - MEDIA_LOG_I("Start"); + AVTRANS_LOGI("Start"); OSAL::ScopedLock lock(outputFilterMutex_); if (state_ != FilterState::READY && state_ != FilterState::PAUSED) { - MEDIA_LOG_E("The current state is invalid"); + AVTRANS_LOGE("The current state is invalid"); return ErrorCode::ERROR_INVALID_STATE; } if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_NULL_POINTER; } if (TranslatePluginStatus(plugin_->Start()) != ErrorCode::SUCCESS) { - MEDIA_LOG_E("The plugin start fail!"); + AVTRANS_LOGE("The plugin start fail!"); return ErrorCode::ERROR_INVALID_OPERATION; } state_ = FilterState::RUNNING; @@ -132,18 +133,18 @@ ErrorCode AVOutputFilter::Start() ErrorCode AVOutputFilter::Stop() { - MEDIA_LOG_I("Stop"); + AVTRANS_LOGI("Stop"); OSAL::ScopedLock lock(outputFilterMutex_); if (state_ != FilterState::RUNNING) { - MEDIA_LOG_E("The current state is invalid"); + AVTRANS_LOGE("The current state is invalid"); return ErrorCode::ERROR_INVALID_STATE; } if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_NULL_POINTER; } if (TranslatePluginStatus(plugin_->Stop()) != ErrorCode::SUCCESS) { - MEDIA_LOG_E("The plugin stop fail!"); + AVTRANS_LOGE("The plugin stop fail!"); return ErrorCode::ERROR_INVALID_OPERATION; } state_ = FilterState::READY; @@ -152,18 +153,18 @@ ErrorCode AVOutputFilter::Stop() ErrorCode AVOutputFilter::Pause() { - MEDIA_LOG_I("Pause"); + AVTRANS_LOGI("Pause"); OSAL::ScopedLock lock(outputFilterMutex_); if (state_ != FilterState::RUNNING) { - MEDIA_LOG_E("The current state is invalid"); + AVTRANS_LOGE("The current state is invalid"); return ErrorCode::ERROR_INVALID_STATE; } if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_NULL_POINTER; } if (TranslatePluginStatus(plugin_->Stop()) != ErrorCode::SUCCESS) { - MEDIA_LOG_E("The plugin stop fail!"); + AVTRANS_LOGE("The plugin stop fail!"); return ErrorCode::ERROR_INVALID_OPERATION; } state_ = FilterState::PAUSED; @@ -172,13 +173,13 @@ ErrorCode AVOutputFilter::Pause() ErrorCode AVOutputFilter::Resume() { - MEDIA_LOG_I("Resume"); + AVTRANS_LOGI("Resume"); return ErrorCode::SUCCESS; } void AVOutputFilter::InitPorts() { - MEDIA_LOG_I("InitPorts"); + AVTRANS_LOGI("InitPorts"); auto inPort = std::make_shared(this); { OSAL::ScopedLock lock(outputFilterMutex_); @@ -192,7 +193,7 @@ ErrorCode AVOutputFilter::FindPlugin() std::string mime; if (paramsMap_.find(Tag::MIME) == paramsMap_.end() || !paramsMap_[Tag::MIME].SameTypeWith(typeid(std::string))) { - MEDIA_LOG_E("Must set mime correctly first"); + AVTRANS_LOGE("Must set mime correctly first"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } mime = Plugin::AnyCast(paramsMap_[Tag::MIME]); @@ -203,20 +204,20 @@ ErrorCode AVOutputFilter::FindPlugin() continue; } if (CreatePlugin(info) == ErrorCode::SUCCESS) { - MEDIA_LOG_I("CreatePlugin " PUBLIC_LOG_S " success", name_.c_str()); + AVTRANS_LOGI("CreatePlugin %s success", name_.c_str()); return ErrorCode::SUCCESS; } } - MEDIA_LOG_I("Cannot find any plugin"); + AVTRANS_LOGI("Cannot find any plugin"); return ErrorCode::ERROR_UNSUPPORTED_FORMAT; } bool AVOutputFilter::Negotiate(const std::string& inPort, const std::shared_ptr& upstreamCap, Plugin::Capability& negotiatedCap, const Plugin::Meta& upstreamParams, Plugin::Meta& downstreamParams) { - MEDIA_LOG_I("Negotiate"); + AVTRANS_LOGI("Negotiate"); if (pluginInfo_ == nullptr) { - MEDIA_LOG_E("pluginInfo_ is nullptr"); + AVTRANS_LOGE("pluginInfo_ is nullptr"); return false; } negotiatedCap = pluginInfo_->inCaps[0]; @@ -225,43 +226,43 @@ bool AVOutputFilter::Negotiate(const std::string& inPort, const std::shared_ptr< ErrorCode AVOutputFilter::CreatePlugin(const std::shared_ptr& selectedInfo) { - MEDIA_LOG_I("CreatePlugin"); + AVTRANS_LOGI("CreatePlugin"); if (selectedInfo == nullptr || selectedInfo->name.empty()) { - MEDIA_LOG_E("selectedInfo is nullptr or pluginName is invalid!"); + AVTRANS_LOGE("selectedInfo is nullptr or pluginName is invalid!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } if ((plugin_ != nullptr) && (pluginInfo_ != nullptr)) { if (selectedInfo->name == pluginInfo_->name && TranslatePluginStatus(plugin_->Reset()) == ErrorCode::SUCCESS) { - MEDIA_LOG_I("Reuse last plugin: " PUBLIC_LOG_S, selectedInfo->name.c_str()); + AVTRANS_LOGI("Reuse last plugin: %s", selectedInfo->name.c_str()); return ErrorCode::SUCCESS; } if (TranslatePluginStatus(plugin_->Deinit()) != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Deinit last plugin: " PUBLIC_LOG_S " error", pluginInfo_->name.c_str()); + AVTRANS_LOGE("Deinit last plugin: %s error", pluginInfo_->name.c_str()); } } plugin_ = PluginManager::Instance().CreateGenericPlugin(selectedInfo->name); if (plugin_ == nullptr) { - MEDIA_LOG_E("PluginManager CreatePlugin " PUBLIC_LOG_S " fail", selectedInfo->name.c_str()); + AVTRANS_LOGE("PluginManager CreatePlugin %s fail", selectedInfo->name.c_str()); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } pluginInfo_ = selectedInfo; - MEDIA_LOG_I("Create new plugin: " PUBLIC_LOG_S " success", pluginInfo_->name.c_str()); + AVTRANS_LOGI("Create new plugin: %s success", pluginInfo_->name.c_str()); return ErrorCode::SUCCESS; } bool AVOutputFilter::Configure(const std::string& inPort, const std::shared_ptr& upstreamMeta, Plugin::Meta& upstreamParams, Plugin::Meta& downstreamParams) { - MEDIA_LOG_I("DoConfigure"); + AVTRANS_LOGI("DoConfigure"); return true; } ErrorCode AVOutputFilter::InitPlugin() { - MEDIA_LOG_I("InitPlugin"); + AVTRANS_LOGI("InitPlugin"); OSAL::ScopedLock lock(outputFilterMutex_); if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } return TranslatePluginStatus(plugin_->Init()); @@ -269,20 +270,20 @@ ErrorCode AVOutputFilter::InitPlugin() ErrorCode AVOutputFilter::ConfigPlugin() { - MEDIA_LOG_I("Configure"); + AVTRANS_LOGI("Configure"); ErrorCode err = SetPluginParams(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Set Plugin fail!"); + AVTRANS_LOGE("Set Plugin fail!"); return err; } err = SetEventCallBack(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Plugin SetEventCallBack fail!"); + AVTRANS_LOGE("Plugin SetEventCallBack fail!"); return err; } err = SetDataCallBack(); if (err != ErrorCode::SUCCESS) { - MEDIA_LOG_E("Plugin SetDataCallBack fail!"); + AVTRANS_LOGE("Plugin SetDataCallBack fail!"); return err; } return ErrorCode::SUCCESS; @@ -292,7 +293,7 @@ ErrorCode AVOutputFilter::PreparePlugin() { OSAL::ScopedLock lock(outputFilterMutex_); if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_INVALID_PARAMETER_TYPE; } return TranslatePluginStatus(plugin_->Prepare()); @@ -302,11 +303,11 @@ ErrorCode AVOutputFilter::PushData(const std::string& inPort, const AVBufferPtr& { OSAL::ScopedLock lock(outputFilterMutex_); if (buffer == nullptr || plugin_ == nullptr) { - MEDIA_LOG_E("buffer or plugin is nullptr!"); + AVTRANS_LOGE("buffer or plugin is nullptr!"); return ErrorCode::ERROR_INVALID_PARAMETER_TYPE; } plugin_->PushData(inPort, buffer, offset); - MEDIA_LOG_E("push buffer to plugin."); + AVTRANS_LOGE("push buffer to plugin."); return ErrorCode::SUCCESS; } @@ -314,7 +315,7 @@ ErrorCode AVOutputFilter::SetPluginParams() { OSAL::ScopedLock lock(outputFilterMutex_); if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_NULL_POINTER; } if (paramsMap_.find(Tag::MEDIA_DESCRIPTION) != paramsMap_.end()) { @@ -336,7 +337,7 @@ ErrorCode AVOutputFilter::SetEventCallBack() { OSAL::ScopedLock lock(outputFilterMutex_); if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } plugin_->SetCallback(this); @@ -347,7 +348,7 @@ ErrorCode AVOutputFilter::SetDataCallBack() { OSAL::ScopedLock lock(outputFilterMutex_); if (plugin_ == nullptr) { - MEDIA_LOG_E("plugin is nullptr!"); + AVTRANS_LOGE("plugin is nullptr!"); return ErrorCode::ERROR_INVALID_PARAMETER_VALUE; } plugin_->SetDataCallback(std::bind(&AVOutputFilter::OnDataCallback, this, std::placeholders::_1)); @@ -358,7 +359,7 @@ void AVOutputFilter::OnDataCallback(std::shared_ptr buffer) { OSAL::ScopedLock lock(outputFilterMutex_); if (buffer == nullptr) { - MEDIA_LOG_E("buffer is nullptr!"); + AVTRANS_LOGE("buffer is nullptr!"); return; } OnEvent(Event{name_, EventType::EVENT_BUFFER_PROGRESS, buffer}); diff --git a/av_transport/av_trans_engine/plugin/plugins/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/BUILD.gn new file mode 100644 index 00000000..a98b3f0f --- /dev/null +++ b/av_transport/av_trans_engine/plugin/plugins/BUILD.gn @@ -0,0 +1,25 @@ +# Copyright (c) 2023 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +config("avtrans_cflags") { + cflags = [ + "-O2", + "-fPIC", + "-Wall", + "-frtti", + "-fexceptions", + "-Wno-unused-but-set-variable", + "-Wno-format", + ] + cflags_cc = cflags +} \ No newline at end of file diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn index c0961452..3e64ccf8 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn @@ -15,26 +15,24 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -source_set("plugin_AVTransDaudioInput") { +ohos_source_set("plugin_AVTransDaudioInput") { include_dirs = [ "${common_path}/include", - "${histreamer_path}/foundation/osal/thread", - "${histreamer_path}/include/pipeline/core", - "${histreamer_path}/include/plugin/common", - "${histreamer_path}/include/plugin/core", - "${histreamer_path}/include/plugin/interface", - "${histreamer_path}/foundation/utils", - "${histreamer_path}/plugin/core", "${plugin_path}/interface", "//third_party/json/include", ] sources = [ "daudio_input_plugin.cpp" ] - deps = [ - "${histreamer_path}/foundation:histreamer_foundation", - "${histreamer_path}/plugin:histreamer_plugin_core", - "${histreamer_path}/plugin:histreamer_plugin_intf" + external_deps = [ + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_plugin_base", + "histreamer:histreamer_ffmpeg_convert", + ] + + public_configs = [ + "${plugin_path}/plugins:avtrans_cflags", ] defines = [ @@ -42,4 +40,6 @@ source_set("plugin_AVTransDaudioInput") { "DH_LOG_TAG=\"daudio_input_plugin\"", "LOG_DOMAIN=0xD004100", ] + part_name = "distributed_hardware_fwk" + subsystem_name = "distributedhardware" } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp index 71ba62cf..9b1eacc1 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.cpp @@ -25,7 +25,7 @@ namespace DistributedHardware { GenericPluginDef CreateDaudioInputPluginDef() { - DHLOGI("DaudioInputPlugin registered."); + AVTRANS_LOGI("DaudioInputPlugin registered."); GenericPluginDef definition; definition.name = "AVTransDaudioInputPlugin"; definition.pkgName = "AVTransDaudioInputPlugin"; diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.h index bdf2061f..1bac99f3 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/daudio_input_plugin.h @@ -21,6 +21,7 @@ #include #include +#include "av_sync_utils.h" #include "av_trans_buffer.h" #include "av_trans_constants.h" #include "av_trans_log.h" diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn index 4bf984ca..9cf15ede 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn @@ -15,26 +15,24 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -source_set("plugin_AVTransDscreenInput") { +ohos_source_set("plugin_AVTransDscreenInput") { include_dirs = [ "${common_path}/include", "${plugin_path}/interface", - "${histreamer_path}/include/pipeline/core", - "${histreamer_path}/include/plugin/interface", - "${histreamer_path}/include/plugin/common", - "${histreamer_path}/include/plugin/core", - "${histreamer_path}/plugin/core", - "${histreamer_path}/include/foundation/osal/thread", - "${histreamer_path}/foundation/utils", "//third_party/json/include", ] sources = [ "dscreen_input_plugin.cpp" ] - deps = [ - "${histreamer_path}/foundation:histreamer_foundation", - "${histreamer_path}/plugin:histreamer_plugin_core", - "${histreamer_path}/plugin:histreamer_plugin_intf", + external_deps = [ + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_plugin_base", + "histreamer:histreamer_ffmpeg_convert", + ] + + public_configs = [ + "${plugin_path}/plugins:avtrans_cflags", ] defines = [ @@ -42,4 +40,6 @@ source_set("plugin_AVTransDscreenInput") { "DH_LOG_TAG=\"dscreen_input_plugin\"", "LOG_DOMAIN=0xD004100", ] + part_name = "distributed_hardware_fwk" + subsystem_name = "distributedhardware" } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp index 6badfead..e1bad397 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.cpp @@ -26,7 +26,7 @@ using json = nlohmann::json; GenericPluginDef CreateDscreenInputPluginDef() { - DHLOGI("DscreenInputPlugin registered."); + AVTRANS_LOGI("DscreenInputPlugin registered."); GenericPluginDef definition; definition.name = "AVTransDscreenInputPlugin"; definition.pkgName = "AVTransDscreenInputPlugin"; diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.h index 14184213..3f8b1e4c 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/dscreen_input_plugin.h @@ -21,6 +21,7 @@ #include #include +#include "av_sync_utils.h" #include "av_trans_buffer.h" #include "av_trans_errno.h" #include "av_trans_constants.h" diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn index ee156295..14c04a40 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn @@ -15,17 +15,10 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -source_set("plugin_AVTransDsoftbusInput") { +ohos_source_set("plugin_AVTransDsoftbusInput") { include_dirs = [ "${common_path}/include", "${plugin_path}/interface", - "${histreamer_path}/include/pipeline/core", - "${histreamer_path}/include/plugin/interface", - "${histreamer_path}/include/plugin/common", - "${histreamer_path}/include/plugin/core", - "${histreamer_path}/plugin/core", - "${histreamer_path}/include/foundation/osal/thread", - "${histreamer_path}/foundation/utils", "${dsoftbus_path}/interfaces/kits/transport", "${dsoftbus_path}/interfaces/kits/bus_center", "${dsoftbus_path}/interfaces/kits/common", @@ -34,10 +27,15 @@ source_set("plugin_AVTransDsoftbusInput") { sources = [ "dsoftbus_input_plugin.cpp" ] - deps = [ - "${histreamer_path}/foundation:histreamer_foundation", - "${histreamer_path}/plugin:histreamer_plugin_core", - "${histreamer_path}/plugin:histreamer_plugin_intf", + external_deps = [ + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_plugin_base", + "histreamer:histreamer_ffmpeg_convert", + ] + + public_configs = [ + "${plugin_path}/plugins:avtrans_cflags", ] defines = [ @@ -45,4 +43,6 @@ source_set("plugin_AVTransDsoftbusInput") { "DH_LOG_TAG=\"dsoftbus_input_plugin\"", "LOG_DOMAIN=0xD004100", ] + part_name = "distributed_hardware_fwk" + subsystem_name = "distributedhardware" } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp index 4ae05521..3f705f99 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/dsoftbus_input_plugin.cpp @@ -29,7 +29,7 @@ std::vector CreateDsoftbusInputPluginDef() int32_t capNum = 2; std::vector definitionList; for (int i = 0; i < capNum; i++) { - DHLOGI("DsoftbusInputPlugin_H264 registered."); + AVTRANS_LOGI("DsoftbusInputPlugin_H264 registered."); GenericPluginDef definition; definition.name = "AVTransDsoftbusInputPlugin_H264"; definition.pkgName = "AVTransDsoftbusInputPlugin"; @@ -45,7 +45,7 @@ std::vector CreateDsoftbusInputPluginDef() CapabilityBuilder capBuilder; capBuilder.SetMime(Media::MEDIA_MIME_VIDEO_H264); if (i == 1) { - DHLOGI("DsoftbusInputPlugin_H265 registered."); + AVTRANS_LOGI("DsoftbusInputPlugin_H265 registered."); definition.name = "AVTransDsoftbusInputPlugin_H265"; capBuilder.SetMime(Media::MEDIA_MIME_VIDEO_H265); } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn index 3b809638..3c58aa05 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn @@ -15,17 +15,10 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -source_set("plugin_AVTransDsoftbusInputAudio") { +ohos_source_set("plugin_AVTransDsoftbusInputAudio") { include_dirs = [ "${common_path}/include", "${plugin_path}/interface", - "${histreamer_path}/include/pipeline/core", - "${histreamer_path}/include/plugin/interface", - "${histreamer_path}/include/plugin/common", - "${histreamer_path}/include/plugin/core", - "${histreamer_path}/plugin/core", - "${histreamer_path}/include/foundation/osal/thread", - "${histreamer_path}/foundation/utils", "${dsoftbus_path}/interfaces/kits/transport", "${dsoftbus_path}/interfaces/kits/bus_center", "${dsoftbus_path}/interfaces/kits/common", @@ -34,10 +27,15 @@ source_set("plugin_AVTransDsoftbusInputAudio") { sources = [ "dsoftbus_input_audio_plugin.cpp" ] - deps = [ - "${histreamer_path}/foundation:histreamer_foundation", - "${histreamer_path}/plugin:histreamer_plugin_core", - "${histreamer_path}/plugin:histreamer_plugin_intf", + external_deps = [ + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_plugin_base", + "histreamer:histreamer_ffmpeg_convert", + ] + + public_configs = [ + "${plugin_path}/plugins:avtrans_cflags", ] defines = [ @@ -45,4 +43,6 @@ source_set("plugin_AVTransDsoftbusInputAudio") { "DH_LOG_TAG=\"dsoftbus_input_audio_plugin\"", "LOG_DOMAIN=0xD004100", ] + part_name = "distributed_hardware_fwk" + subsystem_name = "distributedhardware" } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp index 880ddad6..c435fe7f 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/dsoftbus_input_audio_plugin.cpp @@ -26,7 +26,7 @@ namespace DistributedHardware { GenericPluginDef CreateDsoftbusInputAudioPluginDef() { - DHLOGI("DsoftbusInputAudioPlugin registered."); + AVTRANS_LOGI("DsoftbusInputAudioPlugin registered."); GenericPluginDef definition; definition.name = "AVTransDsoftbusInputAudioPlugin"; definition.pkgName = "AVTransDsoftbusInputAudioPlugin"; diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn index 2eff6b34..0bf919f9 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn @@ -15,16 +15,9 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -source_set("plugin_AVTransDaudioOutput") { +ohos_source_set("plugin_AVTransDaudioOutput") { include_dirs = [ "${common_path}/include", - "${histreamer_path}/foundation/osal/thread", - "${histreamer_path}/include/pipeline/core", - "${histreamer_path}/include/plugin/common", - "${histreamer_path}/include/plugin/interface", - "${histreamer_path}/include/plugin/core", - "${histreamer_path}/foundation/utils", - "${histreamer_path}/plugin/core", "${plugin_path}/interface", "//third_party/json/include", "//third_party/ffmpeg", @@ -32,11 +25,15 @@ source_set("plugin_AVTransDaudioOutput") { sources = [ "daudio_output_plugin.cpp" ] - deps = [ - "${histreamer_path}/foundation:histreamer_foundation", - "${histreamer_path}/plugin:histreamer_plugin_core", - "${histreamer_path}/plugin:histreamer_plugin_intf", - "//third_party/ffmpeg:libohosffmpeg", + external_deps = [ + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_plugin_base", + "histreamer:histreamer_ffmpeg_convert", + ] + + public_configs = [ + "${plugin_path}/plugins:avtrans_cflags", ] defines = [ @@ -44,4 +41,6 @@ source_set("plugin_AVTransDaudioOutput") { "DH_LOG_TAG=\"daudio_output_plugin\"", "LOG_DOMAIN=0xD004100", ] + part_name = "distributed_hardware_fwk" + subsystem_name = "distributedhardware" } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp index 9ee02f20..0fe50b45 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.cpp @@ -25,7 +25,7 @@ namespace DistributedHardware { GenericPluginDef CreateDaudioOutputPluginDef() { - DHLOGI("DaudioOutputPlugin registered."); + AVTRANS_LOGI("DaudioOutputPlugin registered."); GenericPluginDef definition; definition.name = "AVTransDaudioOutputPlugin"; definition.pkgName = "AVTransDaudioOutputPlugin"; diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.h index 75a31e72..b634faa4 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/daudio_output_plugin.h @@ -22,6 +22,8 @@ #include #include +#include "av_sync_utils.h" +#include "av_trans_errno.h" #include "av_trans_buffer.h" #include "av_trans_constants.h" #include "av_trans_log.h" @@ -35,7 +37,7 @@ #include "nlohmann/json.hpp" #include "plugin_manager.h" #include "plugin_types.h" -#include "plugin/plugins/ffmpeg_adapter/utils/ffmpeg_utils.h" +#include "plugin/convert/ffmpeg_convert.h" namespace OHOS { namespace DistributedHardware { diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn index 4bd5d2cf..2e7db02c 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn @@ -15,26 +15,24 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -source_set("plugin_AVTransDscreenOutput") { +ohos_source_set("plugin_AVTransDscreenOutput") { include_dirs = [ "${common_path}/include", "${plugin_path}/interface", - "${histreamer_path}/include/pipeline/core", - "${histreamer_path}/include/plugin/interface", - "${histreamer_path}/include/plugin/common", - "${histreamer_path}/include/plugin/core", - "${histreamer_path}/plugin/core", - "${histreamer_path}/include/foundation/osal/thread", - "${histreamer_path}/foundation/utils", "//third_party/json/include", ] sources = [ "dscreen_output_plugin.cpp" ] - deps = [ - "${histreamer_path}/foundation:histreamer_foundation", - "${histreamer_path}/plugin:histreamer_plugin_core", - "${histreamer_path}/plugin:histreamer_plugin_intf", + external_deps = [ + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_plugin_base", + "histreamer:histreamer_ffmpeg_convert", + ] + + public_configs = [ + "${plugin_path}/plugins:avtrans_cflags", ] defines = [ @@ -42,4 +40,6 @@ source_set("plugin_AVTransDscreenOutput") { "DH_LOG_TAG=\"dscreen_output_plugin\"", "LOG_DOMAIN=0xD004100", ] + part_name = "distributed_hardware_fwk" + subsystem_name = "distributedhardware" } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp index 5ebec7e0..f7987ffa 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.cpp @@ -24,7 +24,7 @@ namespace DistributedHardware { GenericPluginDef CreateDscreenOutputPluginDef() { - DHLOGI("DscreenOutputPlugin registered."); + AVTRANS_LOGI("DscreenOutputPlugin registered."); GenericPluginDef definition; definition.name = "AVTransDscreenOutputPlugin"; definition.pkgName = "AVTransDscreenOutputPlugin"; diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.h b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.h index e14ac7c6..49580749 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.h +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/dscreen_output_plugin.h @@ -22,6 +22,7 @@ #include #include +#include "av_sync_utils.h" #include "av_trans_buffer.h" #include "av_trans_errno.h" #include "av_trans_constants.h" diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn index aed7eabe..9ab7827e 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn @@ -15,17 +15,10 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -source_set("plugin_AVTransDsoftbusOutput") { +ohos_source_set("plugin_AVTransDsoftbusOutput") { include_dirs = [ "${common_path}/include", "${plugin_path}/interface", - "${histreamer_path}/include/pipeline/core", - "${histreamer_path}/include/plugin/interface", - "${histreamer_path}/include/plugin/common", - "${histreamer_path}/include/plugin/core", - "${histreamer_path}/plugin/core", - "${histreamer_path}/include/foundation/osal/thread", - "${histreamer_path}/foundation/utils", "${dsoftbus_path}/interfaces/kits/transport", "${dsoftbus_path}/interfaces/kits/bus_center", "${dsoftbus_path}/interfaces/kits/common", @@ -34,10 +27,15 @@ source_set("plugin_AVTransDsoftbusOutput") { sources = [ "dsoftbus_output_plugin.cpp" ] - deps = [ - "${histreamer_path}/foundation:histreamer_foundation", - "${histreamer_path}/plugin:histreamer_plugin_core", - "${histreamer_path}/plugin:histreamer_plugin_intf", + external_deps = [ + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_plugin_base", + "histreamer:histreamer_ffmpeg_convert", + ] + + public_configs = [ + "${plugin_path}/plugins:avtrans_cflags", ] defines = [ @@ -45,4 +43,6 @@ source_set("plugin_AVTransDsoftbusOutput") { "DH_LOG_TAG=\"dsoftbus_output_plugin\"", "LOG_DOMAIN=0xD004100", ] + part_name = "distributed_hardware_fwk" + subsystem_name = "distributedhardware" } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp index ef25c82b..ce733828 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/dsoftbus_output_plugin.cpp @@ -27,7 +27,7 @@ std::vector CreateDsoftbusOutputPluginDef() int32_t capNum = 2; std::vector definitionList; for (int i = 0; i < capNum; i++) { - DHLOGI("DsoftbusOutputPlugin_H264 registered."); + AVTRANS_LOGI("DsoftbusOutputPlugin_H264 registered."); GenericPluginDef definition; definition.name = "AVTransDsoftbusOutputPlugin_H264"; definition.pkgName = "AVTransDsoftbusOutputPlugin"; @@ -43,7 +43,7 @@ std::vector CreateDsoftbusOutputPluginDef() CapabilityBuilder capBuilder; capBuilder.SetMime(Media::MEDIA_MIME_VIDEO_H264); if (i == 1) { - DHLOGI("DsoftbusOutputPlugin_H265 registered."); + AVTRANS_LOGI("DsoftbusOutputPlugin_H265 registered."); definition.name = "AVTransDsoftbusOutputPlugin_H265"; capBuilder.SetMime(Media::MEDIA_MIME_VIDEO_H265); } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn index 90d0b404..c096b07f 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn @@ -15,17 +15,10 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") -source_set("plugin_AVTransDsoftbusOutputAudio") { +ohos_source_set("plugin_AVTransDsoftbusOutputAudio") { include_dirs = [ "${common_path}/include", "${plugin_path}/interface", - "${histreamer_path}/include/pipeline/core", - "${histreamer_path}/include/plugin/interface", - "${histreamer_path}/include/plugin/common", - "${histreamer_path}/include/plugin/core", - "${histreamer_path}/plugin/core", - "${histreamer_path}/include/foundation/osal/thread", - "${histreamer_path}/foundation/utils", "${dsoftbus_path}/interfaces/kits/transport", "${dsoftbus_path}/interfaces/kits/bus_center", "${dsoftbus_path}/interfaces/kits/common", @@ -34,10 +27,15 @@ source_set("plugin_AVTransDsoftbusOutputAudio") { sources = [ "dsoftbus_output_audio_plugin.cpp" ] - deps = [ - "${histreamer_path}/foundation:histreamer_foundation", - "${histreamer_path}/plugin:histreamer_plugin_core", - "${histreamer_path}/plugin:histreamer_plugin_intf", + external_deps = [ + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_plugin_base", + "histreamer:histreamer_ffmpeg_convert", + ] + + public_configs = [ + "${plugin_path}/plugins:avtrans_cflags", ] defines = [ @@ -45,4 +43,6 @@ source_set("plugin_AVTransDsoftbusOutputAudio") { "DH_LOG_TAG=\"dsoftbus_output_audio_plugin\"", "LOG_DOMAIN=0xD004100", ] + part_name = "distributed_hardware_fwk" + subsystem_name = "distributedhardware" } diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp index 2e19eb48..132e55f9 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/dsoftbus_output_audio_plugin.cpp @@ -24,7 +24,7 @@ namespace DistributedHardware { GenericPluginDef CreateDsoftbusOutputAudioPluginDef() { - DHLOGI("DsoftbusOutputAudioPlugin registered."); + AVTRANS_LOGI("DsoftbusOutputAudioPlugin registered."); GenericPluginDef definition; definition.name = "AVTransDsoftbusOutputAudioPlugin"; definition.pkgName = "AVTransDsoftbusOutputAudioPlugin"; diff --git a/av_transport/common/include/av_sync_utils.h b/av_transport/common/include/av_sync_utils.h index d838f29f..424ceeb5 100644 --- a/av_transport/common/include/av_sync_utils.h +++ b/av_transport/common/include/av_sync_utils.h @@ -18,7 +18,6 @@ #include #include -#include "nocopyable.h" namespace OHOS { namespace DistributedHardware { diff --git a/av_transport/distributed_av_transport.gni b/av_transport/distributed_av_transport.gni index 5601b7c5..801ec544 100644 --- a/av_transport/distributed_av_transport.gni +++ b/av_transport/distributed_av_transport.gni @@ -18,6 +18,8 @@ distributed_av_transport_path = "${distributedhardwarefwk_path}/av_transport" histreamer_path = "//foundation/multimedia/histreamer/engine" +dsoftbus_path = "//foundation/communication/dsoftbus" + media_standard_path = "//foundation/multimedia/player_framework" drivers_disaplay_path = "//drivers/peripheral/display" @@ -32,10 +34,12 @@ handler_path = "${distributed_av_transport_path}/av_trans_handler" control_center_path = "${distributed_av_transport_path}/av_trans_control_center" +filters_path = "${distributed_av_transport_path}/av_trans_engine/filters" + dh_fwk_utils_path = "${distributedhardwarefwk_path}/common/utils" dh_fwk_services_path = "${distributedhardwarefwk_path}/services" -plugin_path = "${engine_path}/plugins" +plugin_path = "${engine_path}/plugin" build_flags = [ "-Werror" ] diff --git a/bundle.json b/bundle.json index c3f190c0..13b1b13e 100644 --- a/bundle.json +++ b/bundle.json @@ -47,7 +47,9 @@ "init", "kv_store", "resource_schedule_service", - "multimedia_histreamer" + "multimedia_histreamer", + "graphic_standard", + "histreamer" ], "third_party": [ "json", @@ -62,7 +64,9 @@ "//foundation/distributedhardware/distributed_hardware_fwk/sa_profile:dhfwk_sa_profile", "//foundation/distributedhardware/distributed_hardware_fwk/sa_profile:dhardware.cfg", "//foundation/distributedhardware/distributed_hardware_fwk/interfaces/inner_kits:libdhfwk_sdk", - "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_handler/histreamer_ability_querier:histreamer_ability_querier" + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_control_center/inner_kits:avtranscenter_sdk", + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_sender:distributed_av_sender", + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_receiver:distributed_av_receiver" ], "inner_kits": [ { @@ -77,17 +81,10 @@ }, { "type": "so", - "name": "//foundation/distributedhardware/distributed_hardware_fwk/utils:distributedhardwareutils", + "name": "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_sender:distributed_av_sender", "header": { - "header_files": [ - "anonymous_string.h", - "dh_utils_hisysevent.h", - "dh_utils_hitrace.h", - "dh_utils_tool.h", - "histreamer_ability_parser.h", - "histreamer_query_tool.h" - ], - "header_base": "//foundation/distributedhardware/distributed_hardware_fwk/utils/include" + "header_files": [], + "header_base": "//foundation/distributedhardware/distributed_hardware_fwk/av_transport" } } ], diff --git a/distributedhardwarefwk.gni b/distributedhardwarefwk.gni index 3dcc2234..22668242 100644 --- a/distributedhardwarefwk.gni +++ b/distributedhardwarefwk.gni @@ -27,8 +27,6 @@ av_trans_path = "${distributedhardwarefwk_path}/av_transport" av_trans_ctl_center_svc_path = "${av_trans_path}/av_trans_control_center/services" -histreamer_path = "//foundation/multimedia/histreamer/engine" - build_flags = [ "-Werror" ] declare_args() { -- Gitee From cea619ddc2e03a1e83c29500f1790605194968c1 Mon Sep 17 00:00:00 2001 From: liqiao49 Date: Wed, 28 Jun 2023 08:58:55 +0800 Subject: [PATCH 5/8] gn format Signed-off-by: liqiao49 --- .../av_trans_engine/av_receiver/BUILD.gn | 9 ++++----- av_transport/av_trans_engine/av_sender/BUILD.gn | 8 ++++---- av_transport/av_trans_engine/filters/BUILD.gn | 16 ++++++++-------- .../plugins/av_trans_input/daudio_input/BUILD.gn | 6 ++---- .../av_trans_input/dscreen_input/BUILD.gn | 6 ++---- .../av_trans_input/dsoftbus_input/BUILD.gn | 6 ++---- .../av_trans_input/dsoftbus_input_audio/BUILD.gn | 6 ++---- .../av_trans_output/daudio_output/BUILD.gn | 6 ++---- .../av_trans_output/dscreen_output/BUILD.gn | 6 ++---- .../av_trans_output/dsoftbus_output/BUILD.gn | 6 ++---- .../dsoftbus_output_audio/BUILD.gn | 6 ++---- 11 files changed, 32 insertions(+), 49 deletions(-) diff --git a/av_transport/av_trans_engine/av_receiver/BUILD.gn b/av_transport/av_trans_engine/av_receiver/BUILD.gn index 4a966ee1..94f10d45 100644 --- a/av_transport/av_trans_engine/av_receiver/BUILD.gn +++ b/av_transport/av_trans_engine/av_receiver/BUILD.gn @@ -24,7 +24,6 @@ config("sender_external_config") { ] } - ohos_shared_library("distributed_av_receiver") { include_dirs = [ "${drivers_disaplay_path}/interfaces/include", @@ -77,16 +76,16 @@ ohos_shared_library("distributed_av_receiver") { "dsoftbus:softbus_client", "graphic_standard:libgraphic_utils", "graphic_standard:surface", + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_ffmpeg_convert", + "histreamer:histreamer_plugin_base", "hisysevent_native:libhisysevent", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "histreamer:histreamer_base", - "histreamer:histreamer_codec_filters", - "histreamer:histreamer_plugin_base", - "histreamer:histreamer_ffmpeg_convert", ] remove_configs = [ diff --git a/av_transport/av_trans_engine/av_sender/BUILD.gn b/av_transport/av_trans_engine/av_sender/BUILD.gn index 6047cb62..d5ddc5ca 100644 --- a/av_transport/av_trans_engine/av_sender/BUILD.gn +++ b/av_transport/av_trans_engine/av_sender/BUILD.gn @@ -78,16 +78,16 @@ ohos_shared_library("distributed_av_sender") { "dsoftbus:softbus_client", "graphic_standard:libgraphic_utils", "graphic_standard:surface", + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_ffmpeg_convert", + "histreamer:histreamer_plugin_base", "hisysevent_native:libhisysevent", "hitrace_native:hitrace_meter", "hiviewdfx_hilog_native:libhilog", "ipc:ipc_core", "safwk:system_ability_fwk", "samgr:samgr_proxy", - "histreamer:histreamer_base", - "histreamer:histreamer_codec_filters", - "histreamer:histreamer_plugin_base", - "histreamer:histreamer_ffmpeg_convert", ] remove_configs = [ diff --git a/av_transport/av_trans_engine/filters/BUILD.gn b/av_transport/av_trans_engine/filters/BUILD.gn index 3b5417e1..20de8027 100644 --- a/av_transport/av_trans_engine/filters/BUILD.gn +++ b/av_transport/av_trans_engine/filters/BUILD.gn @@ -23,16 +23,16 @@ ohos_source_set("avtrans_input_filter") { ] sources = [ - "av_transport_input/av_transport_input_filter.cpp", "${plugin_path}/core/avtrans_input.cpp", + "av_transport_input/av_transport_input_filter.cpp", ] external_deps = [ - "hiviewdfx_hilog_native:libhilog", "histreamer:histreamer_base", "histreamer:histreamer_codec_filters", - "histreamer:histreamer_plugin_base", "histreamer:histreamer_ffmpeg_convert", + "histreamer:histreamer_plugin_base", + "hiviewdfx_hilog_native:libhilog", ] public_deps = [ @@ -70,16 +70,16 @@ ohos_source_set("avtrans_output_filter") { ] sources = [ - "av_transport_output/av_transport_output_filter.cpp", "${plugin_path}/core/avtrans_output.cpp", - ] + "av_transport_output/av_transport_output_filter.cpp", + ] external_deps = [ - "hiviewdfx_hilog_native:libhilog", "histreamer:histreamer_base", "histreamer:histreamer_codec_filters", - "histreamer:histreamer_plugin_base", "histreamer:histreamer_ffmpeg_convert", + "histreamer:histreamer_plugin_base", + "hiviewdfx_hilog_native:libhilog", ] public_deps = [ @@ -107,4 +107,4 @@ ohos_source_set("avtrans_output_filter") { "DH_LOG_TAG=\"av_transport_output_filter\"", "LOG_DOMAIN=0xD004100", ] -} \ No newline at end of file +} diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn index 3e64ccf8..e0ca0949 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/daudio_input/BUILD.gn @@ -27,13 +27,11 @@ ohos_source_set("plugin_AVTransDaudioInput") { external_deps = [ "histreamer:histreamer_base", "histreamer:histreamer_codec_filters", - "histreamer:histreamer_plugin_base", "histreamer:histreamer_ffmpeg_convert", + "histreamer:histreamer_plugin_base", ] - public_configs = [ - "${plugin_path}/plugins:avtrans_cflags", - ] + public_configs = [ "${plugin_path}/plugins:avtrans_cflags" ] defines = [ "HI_LOG_ENABLE", diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn index 9cf15ede..7f1a7387 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dscreen_input/BUILD.gn @@ -27,13 +27,11 @@ ohos_source_set("plugin_AVTransDscreenInput") { external_deps = [ "histreamer:histreamer_base", "histreamer:histreamer_codec_filters", - "histreamer:histreamer_plugin_base", "histreamer:histreamer_ffmpeg_convert", + "histreamer:histreamer_plugin_base", ] - public_configs = [ - "${plugin_path}/plugins:avtrans_cflags", - ] + public_configs = [ "${plugin_path}/plugins:avtrans_cflags" ] defines = [ "HI_LOG_ENABLE", diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn index 14c04a40..617713ad 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input/BUILD.gn @@ -30,13 +30,11 @@ ohos_source_set("plugin_AVTransDsoftbusInput") { external_deps = [ "histreamer:histreamer_base", "histreamer:histreamer_codec_filters", - "histreamer:histreamer_plugin_base", "histreamer:histreamer_ffmpeg_convert", + "histreamer:histreamer_plugin_base", ] - public_configs = [ - "${plugin_path}/plugins:avtrans_cflags", - ] + public_configs = [ "${plugin_path}/plugins:avtrans_cflags" ] defines = [ "HI_LOG_ENABLE", diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn index 3c58aa05..9701c366 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_input/dsoftbus_input_audio/BUILD.gn @@ -30,13 +30,11 @@ ohos_source_set("plugin_AVTransDsoftbusInputAudio") { external_deps = [ "histreamer:histreamer_base", "histreamer:histreamer_codec_filters", - "histreamer:histreamer_plugin_base", "histreamer:histreamer_ffmpeg_convert", + "histreamer:histreamer_plugin_base", ] - public_configs = [ - "${plugin_path}/plugins:avtrans_cflags", - ] + public_configs = [ "${plugin_path}/plugins:avtrans_cflags" ] defines = [ "HI_LOG_ENABLE", diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn index 0bf919f9..fd729219 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/daudio_output/BUILD.gn @@ -28,13 +28,11 @@ ohos_source_set("plugin_AVTransDaudioOutput") { external_deps = [ "histreamer:histreamer_base", "histreamer:histreamer_codec_filters", - "histreamer:histreamer_plugin_base", "histreamer:histreamer_ffmpeg_convert", + "histreamer:histreamer_plugin_base", ] - public_configs = [ - "${plugin_path}/plugins:avtrans_cflags", - ] + public_configs = [ "${plugin_path}/plugins:avtrans_cflags" ] defines = [ "HI_LOG_ENABLE", diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn index 2e7db02c..b780e423 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dscreen_output/BUILD.gn @@ -27,13 +27,11 @@ ohos_source_set("plugin_AVTransDscreenOutput") { external_deps = [ "histreamer:histreamer_base", "histreamer:histreamer_codec_filters", - "histreamer:histreamer_plugin_base", "histreamer:histreamer_ffmpeg_convert", + "histreamer:histreamer_plugin_base", ] - public_configs = [ - "${plugin_path}/plugins:avtrans_cflags", - ] + public_configs = [ "${plugin_path}/plugins:avtrans_cflags" ] defines = [ "HI_LOG_ENABLE", diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn index 9ab7827e..12d62f3d 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output/BUILD.gn @@ -30,13 +30,11 @@ ohos_source_set("plugin_AVTransDsoftbusOutput") { external_deps = [ "histreamer:histreamer_base", "histreamer:histreamer_codec_filters", - "histreamer:histreamer_plugin_base", "histreamer:histreamer_ffmpeg_convert", + "histreamer:histreamer_plugin_base", ] - public_configs = [ - "${plugin_path}/plugins:avtrans_cflags", - ] + public_configs = [ "${plugin_path}/plugins:avtrans_cflags" ] defines = [ "HI_LOG_ENABLE", diff --git a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn index c096b07f..c0538ee7 100644 --- a/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/av_trans_output/dsoftbus_output_audio/BUILD.gn @@ -30,13 +30,11 @@ ohos_source_set("plugin_AVTransDsoftbusOutputAudio") { external_deps = [ "histreamer:histreamer_base", "histreamer:histreamer_codec_filters", - "histreamer:histreamer_plugin_base", "histreamer:histreamer_ffmpeg_convert", + "histreamer:histreamer_plugin_base", ] - public_configs = [ - "${plugin_path}/plugins:avtrans_cflags", - ] + public_configs = [ "${plugin_path}/plugins:avtrans_cflags" ] defines = [ "HI_LOG_ENABLE", -- Gitee From d259d387c6dc9f62b9806086524ab43ec39084a9 Mon Sep 17 00:00:00 2001 From: liqiao49 Date: Wed, 28 Jun 2023 09:38:06 +0800 Subject: [PATCH 6/8] fix bundle.json Signed-off-by: liqiao49 --- bundle.json | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/bundle.json b/bundle.json index 13b1b13e..f7444a9b 100644 --- a/bundle.json +++ b/bundle.json @@ -66,7 +66,8 @@ "//foundation/distributedhardware/distributed_hardware_fwk/interfaces/inner_kits:libdhfwk_sdk", "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_control_center/inner_kits:avtranscenter_sdk", "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_sender:distributed_av_sender", - "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_receiver:distributed_av_receiver" + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_receiver:distributed_av_receiver", + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_handler/histreamer_ability_querier:histreamer_ability_querier" ], "inner_kits": [ { @@ -86,6 +87,21 @@ "header_files": [], "header_base": "//foundation/distributedhardware/distributed_hardware_fwk/av_transport" } + }, + { + "type": "so", + "name": "//foundation/distributedhardware/distributed_hardware_fwk/utils:distributedhardwareutils", + "header": { + "header_files": [ + "anonymous_string.h", + "dh_utils_hisysevent.h", + "dh_utils_hitrace.h", + "dh_utils_tool.h", + "histreamer_ability_parser.h", + "histreamer_query_tool.h" + ], + "header_base": "//foundation/distributedhardware/distributed_hardware_fwk/utils/include" + } } ], "test": [ -- Gitee From 3a2643b5c6c311e1fe00aea37dff09be7628d789 Mon Sep 17 00:00:00 2001 From: liqiao49 Date: Wed, 28 Jun 2023 10:03:36 +0800 Subject: [PATCH 7/8] add empty line for gn Signed-off-by: liqiao49 --- av_transport/av_trans_engine/plugin/plugins/BUILD.gn | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/av_transport/av_trans_engine/plugin/plugins/BUILD.gn b/av_transport/av_trans_engine/plugin/plugins/BUILD.gn index a98b3f0f..aae9560b 100644 --- a/av_transport/av_trans_engine/plugin/plugins/BUILD.gn +++ b/av_transport/av_trans_engine/plugin/plugins/BUILD.gn @@ -22,4 +22,4 @@ config("avtrans_cflags") { "-Wno-format", ] cflags_cc = cflags -} \ No newline at end of file +} -- Gitee From 94e50e666edd7027f7afd95a1eab0385b4f396aa Mon Sep 17 00:00:00 2001 From: liqiao49 Date: Wed, 28 Jun 2023 16:58:38 +0800 Subject: [PATCH 8/8] fix code Signed-off-by: liqiao49 --- .../histreamer_ability_querier/BUILD.gn | 37 ++++++++++--------- .../src/histreamer_ability_querier.cpp | 2 +- 2 files changed, 21 insertions(+), 18 deletions(-) diff --git a/av_transport/av_trans_handler/histreamer_ability_querier/BUILD.gn b/av_transport/av_trans_handler/histreamer_ability_querier/BUILD.gn index 7b51c804..0cd00f94 100644 --- a/av_transport/av_trans_handler/histreamer_ability_querier/BUILD.gn +++ b/av_transport/av_trans_handler/histreamer_ability_querier/BUILD.gn @@ -15,18 +15,21 @@ import("//build/ohos.gni") import( "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/distributed_av_transport.gni") +config("handler_external_config") { + include_dirs = [ + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/common/include", + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_sender/include", + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_receiver/include", + "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/interface", + ] +} + ohos_shared_library("histreamer_ability_querier") { + public_configs = [ ":handler_external_config" ] + include_dirs = [ "include", "//third_party/json/include", - "${histreamer_path}", - "${histreamer_path}/include", - "${histreamer_path}/include/plugin", - "${histreamer_path}/include/plugin/common", - "${histreamer_path}/include/pipeline/core", - "${histreamer_path}/plugin/core", - "${histreamer_path}/pipeline/filters/common", - "${histreamer_path}/scene/standard", "${media_standard_path}/interfaces/inner_api/native", "${common_path}/include", ] @@ -36,19 +39,19 @@ ohos_shared_library("histreamer_ability_querier") { "src/histreamer_ability_querier.cpp", ] - deps = [ - "${histreamer_path}/pipeline:histreamer_base", - "${histreamer_path}/plugin:histreamer_plugin_base", - "${histreamer_path}/plugin:histreamer_plugin_core", - ] - defines = [ "HI_LOG_ENABLE", "DH_LOG_TAG=\"distributed_av_transport\"", "LOG_DOMAIN=0xD004100", ] - external_deps = [ "hiviewdfx_hilog_native:libhilog" ] + external_deps = [ + "histreamer:histreamer_base", + "histreamer:histreamer_codec_filters", + "histreamer:histreamer_ffmpeg_convert", + "histreamer:histreamer_plugin_base", + "hiviewdfx_hilog_native:libhilog", + ] cflags = [ "-O2", @@ -67,8 +70,8 @@ ohos_shared_library("histreamer_ability_querier") { "//build/config/compiler:no_exceptions", ] - subsystem_name = "multimedia" - part_name = "histreamer" + part_name = "distributed_hardware_fwk" + subsystem_name = "distributedhardware" } ohos_rust_shared_ffi("histreamer_ability_querier_core") { diff --git a/av_transport/av_trans_handler/histreamer_ability_querier/src/histreamer_ability_querier.cpp b/av_transport/av_trans_handler/histreamer_ability_querier/src/histreamer_ability_querier.cpp index 0788dfcf..ff1b529f 100644 --- a/av_transport/av_trans_handler/histreamer_ability_querier/src/histreamer_ability_querier.cpp +++ b/av_transport/av_trans_handler/histreamer_ability_querier/src/histreamer_ability_querier.cpp @@ -21,7 +21,7 @@ #include #include "plugin_caps.h" #include "plugin_manager.h" -#include "plugin_utils.h" +#include "pipeline/filters/common/plugin_utils.h" #include "av_trans_log.h" -- Gitee