From 00a600b630312000864f9d070799ed8f4c452fca Mon Sep 17 00:00:00 2001 From: byndyx Date: Thu, 20 Feb 2025 10:30:59 +0800 Subject: [PATCH] gn Signed-off-by: byndyx --- .../av_trans_engine/av_receiver/BUILD.gn | 11 + .../av_trans_engine/av_sender/BUILD.gn | 11 + .../common/include/av_trans_constants.h | 2 + av_transport/common/include/pipeline_event.h | 6 + .../common/src/softbus_channel_adapter.cpp | 6 +- av_transport/framework/BUILD.gn | 11 + av_transport/framework/test/demo/BUILD.gn | 84 ------ .../framework/test/demo/head_filter.cpp | 243 ----------------- .../framework/test/demo/head_filter.h | 77 ------ .../framework/test/demo/mid_filter.cpp | 247 ------------------ av_transport/framework/test/demo/mid_filter.h | 77 ------ .../framework/test/demo/pipe_demo.cpp | 209 --------------- av_transport/framework/test/demo/pipe_demo.h | 69 ----- .../framework/test/demo/tail_filter.cpp | 236 ----------------- .../framework/test/demo/tail_filter.h | 77 ------ bundle.json | 1 - 16 files changed, 44 insertions(+), 1323 deletions(-) delete mode 100644 av_transport/framework/test/demo/BUILD.gn delete mode 100644 av_transport/framework/test/demo/head_filter.cpp delete mode 100644 av_transport/framework/test/demo/head_filter.h delete mode 100644 av_transport/framework/test/demo/mid_filter.cpp delete mode 100644 av_transport/framework/test/demo/mid_filter.h delete mode 100644 av_transport/framework/test/demo/pipe_demo.cpp delete mode 100644 av_transport/framework/test/demo/pipe_demo.h delete mode 100644 av_transport/framework/test/demo/tail_filter.cpp delete mode 100644 av_transport/framework/test/demo/tail_filter.h diff --git a/av_transport/av_trans_engine/av_receiver/BUILD.gn b/av_transport/av_trans_engine/av_receiver/BUILD.gn index 2e2c26c3..09e2050b 100644 --- a/av_transport/av_trans_engine/av_receiver/BUILD.gn +++ b/av_transport/av_trans_engine/av_receiver/BUILD.gn @@ -36,6 +36,12 @@ ohos_shared_library("distributed_av_receiver") { include_dirs = [ "${common_path}/include", + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_coder", + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_input", + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_output", + "${distributed_av_transport_path}/framework", + "${distributed_av_transport_path}/framework/filter/include", + "${distributed_av_transport_path}/framework/pipeline/include", "${engine_path}", "${engine_path}/av_sender/include", "${engine_path}/av_receiver/include", @@ -58,12 +64,15 @@ ohos_shared_library("distributed_av_receiver") { "${common_path}/src/av_trans_meta.cpp", "${common_path}/src/av_trans_utils.cpp", "${common_path}/src/softbus_channel_adapter.cpp", + "${engine_path}/av_receiver/src/av_audio_receiver_engine.cpp", + "${engine_path}/av_receiver/src/av_audio_receiver_engine_provider.cpp", "${engine_path}/av_receiver/src/av_receiver_engine.cpp", "${engine_path}/av_receiver/src/av_receiver_engine_provider.cpp", ] deps = [ "${dh_fwk_sdk_path}:libdhfwk_sdk", + "${distributed_av_transport_path}/framework:distributed_av_pipeline_fwk", "${filters_path}:avtrans_input_filter", "${filters_path}:avtrans_output_filter", ] @@ -94,6 +103,8 @@ ohos_shared_library("distributed_av_receiver") { } external_deps += [ + "av_codec:av_codec_client", + "av_codec:native_media_acodec", "bounds_checking_function:libsec_shared", "cJSON:cjson", "c_utils:utils", diff --git a/av_transport/av_trans_engine/av_sender/BUILD.gn b/av_transport/av_trans_engine/av_sender/BUILD.gn index 37a4483c..6f074dc6 100644 --- a/av_transport/av_trans_engine/av_sender/BUILD.gn +++ b/av_transport/av_trans_engine/av_sender/BUILD.gn @@ -35,6 +35,12 @@ ohos_shared_library("distributed_av_sender") { public_configs = [ ":sender_external_config" ] include_dirs = [ + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_coder", + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_input", + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_output", + "${distributed_av_transport_path}/framework", + "${distributed_av_transport_path}/framework/filter/include", + "${distributed_av_transport_path}/framework/pipeline/include", "${dh_fwk_utils_path}/include", "${control_center_path}/inner_kits/include", "${control_center_path}/inner_kits/include/ipc", @@ -52,12 +58,15 @@ ohos_shared_library("distributed_av_sender") { "${common_path}/src/av_trans_meta.cpp", "${common_path}/src/av_trans_utils.cpp", "${common_path}/src/softbus_channel_adapter.cpp", + "${engine_path}/av_sender/src/av_audio_sender_engine.cpp", + "${engine_path}/av_sender/src/av_audio_sender_engine_provider.cpp", "${engine_path}/av_sender/src/av_sender_engine.cpp", "${engine_path}/av_sender/src/av_sender_engine_provider.cpp", ] deps = [ "${dh_fwk_sdk_path}:libdhfwk_sdk", + "${distributed_av_transport_path}/framework:distributed_av_pipeline_fwk", "${filters_path}:avtrans_input_filter", "${filters_path}:avtrans_output_filter", ] @@ -88,6 +97,8 @@ ohos_shared_library("distributed_av_sender") { } external_deps += [ + "av_codec:av_codec_client", + "av_codec:native_media_acodec", "bounds_checking_function:libsec_shared", "cJSON:cjson", "c_utils:utils", diff --git a/av_transport/common/include/av_trans_constants.h b/av_transport/common/include/av_trans_constants.h index 8673cdb1..6ff9da41 100644 --- a/av_transport/common/include/av_trans_constants.h +++ b/av_transport/common/include/av_trans_constants.h @@ -74,6 +74,8 @@ const std::string KEY_GROUP_INFO_ARRAY = "groupInfoArray"; const std::string KEY_SHARED_MEM_FD = "sharedMemoryFd"; const std::string KEY_SHARED_MEM_SIZE = "sharedMemorySize"; const std::string KEY_SHARED_MEM_NAME = "sharedMemoryName"; +const std::string KEY_ONWER_NAME = "ownerName"; +const std::string KEY_PEERDEVID_NAME = "peerDevId"; const std::string SCREEN_FILE_NAME_BEFOREENCODING = "/data/data/dscreen/BeforeEncoding.h265"; const std::string SCREEN_FILE_NAME_AFTERCODING = "/data/data/dscreen/AfterCoding.h265"; diff --git a/av_transport/common/include/pipeline_event.h b/av_transport/common/include/pipeline_event.h index 611373da..7411326a 100644 --- a/av_transport/common/include/pipeline_event.h +++ b/av_transport/common/include/pipeline_event.h @@ -63,6 +63,12 @@ struct Event { Media::Any param; }; +typedef enum { + AUDIO_CODEC_AAC = 0, + AUDIO_CODEC_FLAC = 1, + AUDIO_CODEC_AAC_EN = 2 +} AudioCodecType; + const char* GetEventName(EventType type); } // namespace Pipeline } // namespace DistributedHardware diff --git a/av_transport/common/src/softbus_channel_adapter.cpp b/av_transport/common/src/softbus_channel_adapter.cpp index a7f9ca56..1a333b82 100644 --- a/av_transport/common/src/softbus_channel_adapter.cpp +++ b/av_transport/common/src/softbus_channel_adapter.cpp @@ -484,7 +484,7 @@ int32_t SoftbusChannelAdapter::OnSoftbusChannelOpened(std::string peerSessionNam EventType type = (result == 0) ? EventType::EVENT_CHANNEL_OPENED : EventType::EVENT_CHANNEL_OPEN_FAIL; AVTransEvent event = {type, mySessionName, peerDevId}; { - std::lock_guard lock(listenerMtx_); + std::lock_guard subLock(listenerMtx_); for (auto it = listenerMap_.begin(); it != listenerMap_.end(); it++) { if (((it->first).find(mySessionName) != std::string::npos) && (it->second != nullptr)) { std::thread(&SoftbusChannelAdapter::SendChannelEvent, this, it->first, event).detach(); @@ -553,7 +553,7 @@ void SoftbusChannelAdapter::OnSoftbusStreamReceived(int32_t sessionId, const Str std::lock_guard lock(idMapMutex_); for (auto it = devId2SessIdMap_.begin(); it != devId2SessIdMap_.end(); it++) { if (it->second == sessionId) { - std::lock_guard lock(listenerMtx_); + std::lock_guard subLock(listenerMtx_); ISoftbusChannelListener *listener = listenerMap_[it->first]; TRUE_RETURN(listener == nullptr, "Can not find channel listener."); listener->OnStreamReceived(data, ext); @@ -580,7 +580,7 @@ void SoftbusChannelAdapter::OnSoftbusTimeSyncResult(const TimeSyncResultInfo *in std::string masterDevId(info->target.masterNetworkId); std::lock_guard lock(timeSyncMtx_); for (auto sessName : timeSyncSessNames_) { - std::lock_guard lock(listenerMtx_); + std::lock_guard subLock(listenerMtx_); ISoftbusChannelListener *listener = listenerMap_[sessName]; if (listener != nullptr) { listener->OnChannelEvent({EventType::EVENT_TIME_SYNC_RESULT, std::to_string(millisecond), targetDevId}); diff --git a/av_transport/framework/BUILD.gn b/av_transport/framework/BUILD.gn index c4672acf..2e0e6990 100644 --- a/av_transport/framework/BUILD.gn +++ b/av_transport/framework/BUILD.gn @@ -40,10 +40,21 @@ ohos_shared_library("distributed_av_pipeline_fwk") { "${dh_fwk_utils_path}/include", "${distributed_av_transport_path}/framework", "${distributed_av_transport_path}/framework/filter/include", + "${distributed_av_transport_path}/framework/pipeline/include", + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_coder", + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_input", + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_output", ] sources = [ "${common_path}/src/av_trans_log.cpp", + "${common_path}/src/softbus_channel_adapter.cpp", + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_coder/av_trans_audio_decoder_filter.cpp", + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_coder/av_trans_audio_encoder_filter.cpp", + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_input/av_trans_audio_input_filter.cpp", + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_input/av_trans_bus_input_filter.cpp", + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_output/daudio_output_filter.cpp", + "${distributed_av_transport_path}/av_trans_engine/filters/av_trans_output/dsoftbus_output_filter.cpp", "${distributed_av_transport_path}/framework/filter/src/filter.cpp", "${distributed_av_transport_path}/framework/filter/src/filter_factory.cpp", "${distributed_av_transport_path}/framework/pipeline/src/pipeline.cpp", diff --git a/av_transport/framework/test/demo/BUILD.gn b/av_transport/framework/test/demo/BUILD.gn deleted file mode 100644 index add42a8f..00000000 --- a/av_transport/framework/test/demo/BUILD.gn +++ /dev/null @@ -1,84 +0,0 @@ -# Copyright (c) 2024 Huawei Device Co., Ltd. -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -import("//build/ohos.gni") -import("../../../distributed_av_transport.gni") - -config("av_pipeline_demo_external_config") { - include_dirs = [ - "${common_path}/include", - "${dh_fwk_sdk_path}/include", - "${interface_path}", - ] -} - -ohos_executable("av_trans_pipelie_demo") { - sanitize = { - cfi = true - cfi_cross_dso = true - cfi_no_nvcall = true - cfi_vcall_icall_only = true - debug = false - boundary_sanitize = true - integer_overflow = true - ubsan = true - } - branch_protector_ret = "pac_ret" - public_configs = [ ":av_pipeline_demo_external_config" ] - - include_dirs = [ - "./include", - "${distributed_av_transport_path}/framework", - "${distributed_av_transport_path}/framework/filter/include", - ] - - sources = [ - "${distributed_av_transport_path}/framework/test/demo/head_filter.cpp", - "${distributed_av_transport_path}/framework/test/demo/mid_filter.cpp", - "${distributed_av_transport_path}/framework/test/demo/pipe_demo.cpp", - "${distributed_av_transport_path}/framework/test/demo/tail_filter.cpp", - ] - - deps = [ - "${dh_fwk_sdk_path}:libdhfwk_sdk", - "${distributed_av_transport_path}/framework:distributed_av_pipeline_fwk", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"av_trans_pipe_demo\"", - "LOG_DOMAIN=0xD004101", - ] - - external_deps = [ - "c_utils:utils", - "hilog:libhilog", - ] - - if (histreamer_compile_part) { - external_deps += [ "media_foundation:media_foundation" ] - } - - cflags = [ - "-fexceptions", - "-fno-rtti", - "-fPIC", - "-O2", - "-Wall", - ] - cflags_cc = cflags - - install_enable = false - part_name = "distributed_hardware_fwk" - subsystem_name = "distributedhardware" -} diff --git a/av_transport/framework/test/demo/head_filter.cpp b/av_transport/framework/test/demo/head_filter.cpp deleted file mode 100644 index 3cb0a226..00000000 --- a/av_transport/framework/test/demo/head_filter.cpp +++ /dev/null @@ -1,243 +0,0 @@ -/* - * Copyright (c) 2024 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 "head_filter.h" - -#include - -#include "av_trans_log.h" -#include "filter_factory.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "HeadFilter" - -namespace OHOS { -namespace DistributedHardware { -namespace Pipeline { -static AutoRegisterFilter g_registerAudioEncoderFilter("builtin.recorder.test1", - FilterType::FILTERTYPE_MUXER, - [](const std::string& name, const FilterType type) { - return std::make_shared(name, FilterType::FILTERTYPE_MUXER); - }); - -class HeadFilterLinkCallback : public FilterLinkCallback { -public: - explicit HeadFilterLinkCallback(std::shared_ptr filter) - : headFilter_(std::move(filter)) {} - ~HeadFilterLinkCallback() = default; - - void OnLinkedResult(const sptr &queue, std::shared_ptr &meta) override - { - if (auto filter = headFilter_.lock()) { - filter->OnLinkedResult(queue, meta); - } else { - AVTRANS_LOGI("invalid headFilter"); - } - } - - void OnUnlinkedResult(std::shared_ptr &meta) override - { - if (auto filter = headFilter_.lock()) { - filter->OnUnlinkedResult(meta); - } else { - AVTRANS_LOGI("invalid headFilter"); - } - } - - void OnUpdatedResult(std::shared_ptr &meta) override - { - if (auto filter = headFilter_.lock()) { - filter->OnUpdatedResult(meta); - } else { - AVTRANS_LOGI("invalid headFilter"); - } - } - -private: - std::weak_ptr headFilter_ {}; -}; - -HeadFilter::HeadFilter(std::string name, FilterType type, bool isAsyncMode) - : Filter(name, type) -{ -} - -HeadFilter::~HeadFilter() -{ - nextFiltersMap_.clear(); -} - -void HeadFilter::Init(const std::shared_ptr& receiver, const std::shared_ptr& callback) -{ - AVTRANS_LOGI("HeadFilter::Init"); - receiver_ = receiver; - callback_ = callback; - AVTRANS_LOGI("HeadFilter::Init Done"); -} - -Status HeadFilter::DoInitAfterLink() -{ - AVTRANS_LOGI("HeadFilter::DoInitAfterLink"); - return Status::OK; -} - -Status HeadFilter::DoPrepare() -{ - // 1. 本Filter的准备 - AVTRANS_LOGI("HeadFilter::DoPrepare"); - - // 2. 回调申请下一级filter - if (callback_ == nullptr) { - AVTRANS_LOGE("filter callback is null"); - return Status::ERROR_NULL_POINTER; - } - callback_->OnCallback(shared_from_this(), FilterCallBackCommand::NEXT_FILTER_NEEDED, - StreamType::STREAMTYPE_ENCODED_AUDIO); - AVTRANS_LOGI("HeadFilter::DoPrepare done"); - return Status::OK; -} - -Status HeadFilter::DoStart() -{ - AVTRANS_LOGI("HeadFilter::DoStart"); - return Status::OK; -} - -Status HeadFilter::DoPause() -{ - AVTRANS_LOGI("HeadFilter::DoPause"); - return Status::OK; -} - -Status HeadFilter::DoPauseDragging() -{ - AVTRANS_LOGI("HeadFilter::DoPauseDragging"); - return Status::OK; -} - -Status HeadFilter::DoResume() -{ - AVTRANS_LOGI("HeadFilter::DoResume"); - return Status::OK; -} - -Status HeadFilter::DoResumeDragging() -{ - AVTRANS_LOGI("HeadFilter::DoResumeDragging"); - return Status::OK; -} - -Status HeadFilter::DoStop() -{ - AVTRANS_LOGI("HeadFilter::DoStop"); - return Status::OK; -} - -Status HeadFilter::DoFlush() -{ - AVTRANS_LOGI("HeadFilter::DoFlush"); - return Status::OK; -} - -Status HeadFilter::DoRelease() -{ - AVTRANS_LOGI("HeadFilter::DoRelease"); - return Status::OK; -} - -Status HeadFilter::DoProcessInputBuffer(int recvArg, bool dropFrame) -{ - AVTRANS_LOGI("HeadFilter::DoProcessInputBuffer"); - return Status::OK; -} - -Status HeadFilter::DoProcessOutputBuffer(int recvArg, bool dropFrame, bool byIdx, uint32_t idx, int64_t renderTimee) -{ - AVTRANS_LOGI("HeadFilter::DoProcessOutputBuffer"); - return Status::OK; -} - -void HeadFilter::SetParameter(const std::shared_ptr& meta) -{ - meta_ = meta; -} - -void HeadFilter::GetParameter(std::shared_ptr& meta) -{ - meta = meta_; -} - -Status HeadFilter::LinkNext(const std::shared_ptr& nextFilter, StreamType outType) -{ - AVTRANS_LOGI("cur: HeadFilter, link next filter.."); - // 1. 插入下级filter维护map - nextFilter_ = nextFilter; - nextFiltersMap_[outType].push_back(nextFilter_); - // 2. 下级节点的Link初始化 - auto filterLinkCallback = std::make_shared(shared_from_this()); - auto ret = nextFilter->OnLinked(outType, configureParam_, filterLinkCallback); - if (ret != Status::OK) { - AVTRANS_LOGE("Onlinked failed, status: %{public}d.", ret); - return ret; - } - return Status::OK; -} - -Status HeadFilter::UpdateNext(const std::shared_ptr&, StreamType) -{ - return Status::OK; -} - -Status HeadFilter::UnLinkNext(const std::shared_ptr&, StreamType) -{ - AVTRANS_LOGI("cur: HeadFilter, unlink next filter.."); - return Status::OK; -} - -Status HeadFilter::OnLinked(StreamType inType, const std::shared_ptr &meta, - const std::shared_ptr &callback) -{ - AVTRANS_LOGI("cur: HeadFilter, OnLinked"); - return Status::OK; -}; - -Status HeadFilter::OnUpdated(StreamType, const std::shared_ptr&, - const std::shared_ptr&) -{ - return Status::OK; -} - -Status HeadFilter::OnUnLinked(StreamType, const std::shared_ptr&) -{ - AVTRANS_LOGI("cur: HeadFilter, OnUnLinked."); - return Status::OK; -} - -void HeadFilter::OnLinkedResult(const sptr& queue, std::shared_ptr& meta) -{ - // link bufferQueue - AVTRANS_LOGI("cur: HeadFilter, OnLinkedResult"); -} - -void HeadFilter::OnUnlinkedResult(std::shared_ptr& meta) -{ -} - -void HeadFilter::OnUpdatedResult(std::shared_ptr& meta) -{ -} -} // namespace Pipeline -} // namespace DistributedHardware -} // namespace OHOS diff --git a/av_transport/framework/test/demo/head_filter.h b/av_transport/framework/test/demo/head_filter.h deleted file mode 100644 index cf68cdb6..00000000 --- a/av_transport/framework/test/demo/head_filter.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2024 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 OHOS_AV_PIPELINE_HEAD_FILTER_DEMO_H -#define OHOS_AV_PIPELINE_HEAD_FILTER_DEMO_H - -#include -#include -#include - -#include "pipeline_status.h" -#include "filter.h" - -namespace OHOS { -namespace DistributedHardware { -namespace Pipeline { -// 分两步:第一先保证fiter连接正常,第二,filter保证数据流转正常 -class HeadFilter : public Filter, public std::enable_shared_from_this { -public: - HeadFilter(std::string name, FilterType type, bool asyncMode = false); - virtual ~HeadFilter(); - void Init(const std::shared_ptr& receiver, const std::shared_ptr& callback) override; - Status DoInitAfterLink() override; - Status DoPrepare() override; - Status DoStart() override; - Status DoPause() override; - Status DoPauseDragging() override; - Status DoResume() override; - Status DoResumeDragging() override; - Status DoStop() override; - Status DoFlush() override; - Status DoRelease() override; - - Status DoProcessInputBuffer(int recvArg, bool dropFrame) override; - Status DoProcessOutputBuffer(int recvArg, bool dropFrame, bool byIdx, uint32_t idx, int64_t renderTime) override; - void SetParameter(const std::shared_ptr& meta) override; - void GetParameter(std::shared_ptr& meta) override; - - Status LinkNext(const std::shared_ptr& nextFilter, StreamType outType) override; - Status UpdateNext(const std::shared_ptr& nextFilter, StreamType outType) override; - Status UnLinkNext(const std::shared_ptr& nextFilter, StreamType outType) override; - - Status OnLinked(StreamType inType, const std::shared_ptr& meta, - const std::shared_ptr& callback) override; - Status OnUpdated(StreamType inType, const std::shared_ptr& meta, - const std::shared_ptr& callback) override; - Status OnUnLinked(StreamType inType, const std::shared_ptr& callback) override; - - // PipeLinked 后处理 - void OnLinkedResult(const sptr& queue, std::shared_ptr& meta); - void OnUnlinkedResult(std::shared_ptr& meta); - void OnUpdatedResult(std::shared_ptr& meta); - -private: - std::shared_ptr configureParam_ {nullptr}; - std::shared_ptr nextFilter_ {nullptr}; - - std::shared_ptr eventReceiver_ {nullptr}; - std::shared_ptr filterCallback_ {nullptr}; - std::shared_ptr onLinkedResultCallback_ {nullptr}; -}; -} // namespace Pipeline -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_AV_PIPELINE_HEAD_FILTER_DEMO_H diff --git a/av_transport/framework/test/demo/mid_filter.cpp b/av_transport/framework/test/demo/mid_filter.cpp deleted file mode 100644 index edec23d7..00000000 --- a/av_transport/framework/test/demo/mid_filter.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/* - * Copyright (c) 2024 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 "mid_filter.h" - -#include - -#include "av_trans_log.h" -#include "filter_factory.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "MidFilter" - -namespace OHOS { -namespace DistributedHardware { -namespace Pipeline { -static AutoRegisterFilter g_registerAudioEncoderFilter("builtin.recorder.midfilter", - FilterType::FILTERTYPE_VIDEODEC, - [](const std::string& name, const FilterType type) { - return std::make_shared(name, FilterType::FILTERTYPE_VIDEODEC); - }); - -class MidFilterLinkCallback : public FilterLinkCallback { -public: - explicit MidFilterLinkCallback(std::shared_ptr filter) - : headFilter_(std::move(filter)) {} - ~MidFilterLinkCallback() = default; - - void OnLinkedResult(const sptr &queue, std::shared_ptr &meta) override - { - if (auto filter = headFilter_.lock()) { - filter->OnLinkedResult(queue, meta); - } else { - AVTRANS_LOGI("invalid headFilter"); - } - } - - void OnUnlinkedResult(std::shared_ptr &meta) override - { - if (auto filter = headFilter_.lock()) { - filter->OnUnlinkedResult(meta); - } else { - AVTRANS_LOGI("invalid headFilter"); - } - } - - void OnUpdatedResult(std::shared_ptr &meta) override - { - if (auto filter = headFilter_.lock()) { - filter->OnUpdatedResult(meta); - } else { - AVTRANS_LOGI("invalid headFilter"); - } - } - -private: - std::weak_ptr headFilter_ {}; -}; - -MidFilter::MidFilter(std::string name, FilterType type, bool isAsyncMode) - : Filter(name, type) -{ -} - -MidFilter::~MidFilter() -{ - nextFiltersMap_.clear(); -} - -void MidFilter::Init(const std::shared_ptr& receiver, const std::shared_ptr& callback) -{ - receiver_ = receiver; - callback_ = callback; -} - -Status MidFilter::DoInitAfterLink() -{ - AVTRANS_LOGI("MidFilter::DoInitAfterLink"); - return Status::OK; -} - -Status MidFilter::DoPrepare() -{ - // 1. 本Filter的准备 - AVTRANS_LOGI("MidFilter::DoPrepare"); - - // 2. 回调申请下一级filter - if (callback_ == nullptr) { - AVTRANS_LOGE("filter callback is null"); - return Status::ERROR_NULL_POINTER; - } - callback_->OnCallback(shared_from_this(), FilterCallBackCommand::NEXT_FILTER_NEEDED, - StreamType::STREAMTYPE_RAW_AUDIO); - AVTRANS_LOGI("MidFilter::DoPrepare done"); - return Status::OK; -} - -Status MidFilter::DoStart() -{ - AVTRANS_LOGI("MidFilter::DoStart"); - return Status::OK; -} - -Status MidFilter::DoPause() -{ - AVTRANS_LOGI("MidFilter::DoPause"); - return Status::OK; -} - -Status MidFilter::DoPauseDragging() -{ - AVTRANS_LOGI("MidFilter::DoPauseDragging"); - return Status::OK; -} - -Status MidFilter::DoResume() -{ - AVTRANS_LOGI("MidFilter::DoResume"); - return Status::OK; -} - -Status MidFilter::DoResumeDragging() -{ - AVTRANS_LOGI("MidFilter::DoResumeDragging"); - return Status::OK; -} - -Status MidFilter::DoStop() -{ - AVTRANS_LOGI("MidFilter::DoStop"); - return Status::OK; -} - -Status MidFilter::DoFlush() -{ - AVTRANS_LOGI("MidFilter::DoFlush"); - return Status::OK; -} - -Status MidFilter::DoRelease() -{ - AVTRANS_LOGI("MidFilter::DoRelease"); - return Status::OK; -} - -Status MidFilter::DoProcessInputBuffer(int recvArg, bool dropFrame) -{ - AVTRANS_LOGI("MidFilter::DoProcessInputBuffer"); - return Status::OK; -} - -Status MidFilter::DoProcessOutputBuffer(int recvArg, bool dropFrame, bool byIdx, uint32_t idx, int64_t renderTimee) -{ - AVTRANS_LOGI("MidFilter::DoProcessOutputBuffer"); - return Status::OK; -} - -void MidFilter::SetParameter(const std::shared_ptr& meta) -{ - meta_ = meta; -} - -void MidFilter::GetParameter(std::shared_ptr& meta) -{ - meta = meta_; -} - -Status MidFilter::LinkNext(const std::shared_ptr& nextFilter, StreamType outType) -{ - AVTRANS_LOGI("cur: MidFilter, link next filter.."); - // 1. 插入下级filter维护map - nextFilter_ = nextFilter; - nextFiltersMap_[outType].push_back(nextFilter_); - // 2. 下级节点的Link初始化 - auto filterLinkCallback = std::make_shared(shared_from_this()); - auto ret = nextFilter->OnLinked(outType, configureParam_, filterLinkCallback); - if (ret != Status::OK) { - AVTRANS_LOGE("Onlinked failed, status: %{public}d.", ret); - return ret; - } - return Status::OK; -} - -Status MidFilter::UpdateNext(const std::shared_ptr&, StreamType) -{ - return Status::OK; -} - -Status MidFilter::UnLinkNext(const std::shared_ptr&, StreamType) -{ - AVTRANS_LOGI("cur: MidFilter, unlink next filter.."); - return Status::OK; -} - -Status MidFilter::OnLinked(StreamType inType, const std::shared_ptr &meta, - const std::shared_ptr &callback) -{ - AVTRANS_LOGI("cur: MidFilter, OnLinked"); - onLinkedResultCallback_ = callback; - return Status::OK; -}; - -Status MidFilter::OnUpdated(StreamType, const std::shared_ptr&, - const std::shared_ptr&) -{ - return Status::OK; -} - -Status MidFilter::OnUnLinked(StreamType, const std::shared_ptr&) -{ - AVTRANS_LOGI("cur: MidFilter, OnUnLinked."); - return Status::OK; -} - -void MidFilter::OnLinkedResult(const sptr& queue, std::shared_ptr& meta) -{ - // link bufferQueue - AVTRANS_LOGI("cur: MidFilter, OnLinkedResult."); - sptr producer = nullptr; - std::shared_ptr midMeta = std::make_shared(); - if (onLinkedResultCallback_ != nullptr) { - onLinkedResultCallback_->OnLinkedResult(producer, midMeta); - } -} - -void MidFilter::OnUnlinkedResult(std::shared_ptr& meta) -{ -} - -void MidFilter::OnUpdatedResult(std::shared_ptr& meta) -{ -} -} // namespace Pipeline -} // namespace DistributedHardware -} // namespace OHOS diff --git a/av_transport/framework/test/demo/mid_filter.h b/av_transport/framework/test/demo/mid_filter.h deleted file mode 100644 index 51fa583b..00000000 --- a/av_transport/framework/test/demo/mid_filter.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2024 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 OHOS_AV_PIPELINE_MID_FILTER_DEMO_H -#define OHOS_AV_PIPELINE_MID_FILTER_DEMO_H - -#include -#include -#include - -#include "pipeline_status.h" -#include "filter.h" - -namespace OHOS { -namespace DistributedHardware { -namespace Pipeline { -// 分两步:第一先保证fiter连接正常,第二,filter保证数据流转正常 -class MidFilter : public Filter, public std::enable_shared_from_this { -public: - MidFilter(std::string name, FilterType type, bool asyncMode = false); - virtual ~MidFilter(); - void Init(const std::shared_ptr& receiver, const std::shared_ptr& callback) override; - Status DoInitAfterLink() override; - Status DoPrepare() override; - Status DoStart() override; - Status DoPause() override; - Status DoPauseDragging() override; - Status DoResume() override; - Status DoResumeDragging() override; - Status DoStop() override; - Status DoFlush() override; - Status DoRelease() override; - - Status DoProcessInputBuffer(int recvArg, bool dropFrame) override; - Status DoProcessOutputBuffer(int recvArg, bool dropFrame, bool byIdx, uint32_t idx, int64_t renderTime) override; - void SetParameter(const std::shared_ptr& meta) override; - void GetParameter(std::shared_ptr& meta) override; - - Status LinkNext(const std::shared_ptr& nextFilter, StreamType outType) override; - Status UpdateNext(const std::shared_ptr& nextFilter, StreamType outType) override; - Status UnLinkNext(const std::shared_ptr& nextFilter, StreamType outType) override; - - Status OnLinked(StreamType inType, const std::shared_ptr& meta, - const std::shared_ptr& callback) override; - Status OnUpdated(StreamType inType, const std::shared_ptr& meta, - const std::shared_ptr& callback) override; - Status OnUnLinked(StreamType inType, const std::shared_ptr& callback) override; - - // PipeLinked 后处理 - void OnLinkedResult(const sptr& queue, std::shared_ptr& meta); - void OnUnlinkedResult(std::shared_ptr& meta); - void OnUpdatedResult(std::shared_ptr& meta); - -private: - std::shared_ptr configureParam_ {nullptr}; - std::shared_ptr nextFilter_ {nullptr}; - - std::shared_ptr eventReceiver_ {nullptr}; - std::shared_ptr filterCallback_ {nullptr}; - std::shared_ptr onLinkedResultCallback_ {nullptr}; -}; -} // namespace Pipeline -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_AV_PIPELINE_MID_FILTER_DEMO_H diff --git a/av_transport/framework/test/demo/pipe_demo.cpp b/av_transport/framework/test/demo/pipe_demo.cpp deleted file mode 100644 index 513ad285..00000000 --- a/av_transport/framework/test/demo/pipe_demo.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (c) 2024 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 "pipe_demo.h" - -#include -#include - -#include "av_trans_log.h" -#include "filter_factory.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "PipeDemo" - -namespace OHOS { -namespace DistributedHardware { -namespace Pipeline { -class PlayerEventReceiver : public EventReceiver { -public: - explicit PlayerEventReceiver(PipeDemo* pipeDemo, std::string playerId) - { - AVTRANS_LOGI("PlayerEventReceiver ctor called."); - pipeDemo_ = pipeDemo; - } - - void OnEvent(const Event &event) - { - AVTRANS_LOGD("PlayerEventReceiver OnEvent."); - } - -private: - PipeDemo* pipeDemo_; -}; - -class PlayerFilterCallback : public FilterCallback { -public: - explicit PlayerFilterCallback(PipeDemo* pipeDemo) - { - AVTRANS_LOGI("PlayerFilterCallback ctor called."); - pipeDemo_ = pipeDemo; - } - - Status OnCallback(const std::shared_ptr& filter, FilterCallBackCommand cmd, StreamType outType) override - { - AVTRANS_LOGI("PlayerFilterCallback OnCallback."); - if (pipeDemo_ == nullptr) { - return Status::ERROR_NULL_POINTER; - } - return pipeDemo_->OnCallback(filter, cmd, outType); - } - -private: - PipeDemo* pipeDemo_; -}; - - -PipeDemo::PipeDemo() {} - -PipeDemo::~PipeDemo() {} - -int32_t PipeDemo::InitPipe() -{ - // 初始化pipeline - demoId_ = std::string("PipeDemo") + std::to_string(Pipeline::GetNextPipelineId()); - pipeline_ = std::make_shared(); - playerEventReceiver_ = std::make_shared(this, demoId_); - playerFilterCallback_ = std::make_shared(this); - - AVTRANS_LOGI("pipeline Init in"); - pipeline_->Init(playerEventReceiver_, playerFilterCallback_, demoId_); - AVTRANS_LOGI("pipeline Init out"); - // 添加头Filter - headFilter_ = FilterFactory::Instance().CreateFilter("builtin.recorder.test1", - FilterType::FILTERTYPE_MUXER); - if (headFilter_ == nullptr) { - return -1; - } - - headFilter_->Init(playerEventReceiver_, playerFilterCallback_); - pipeline_->AddHeadFilters({headFilter_}); - return 0; -} - -int32_t PipeDemo::Prepare() -{ - if (pipeline_ != nullptr) { - pipeline_->Prepare(); - } - return 0; -} - -int32_t PipeDemo::Start() -{ - if (pipeline_ != nullptr) { - pipeline_->Start(); - } - return 0; -} - -int32_t PipeDemo::Pause() -{ - if (pipeline_ != nullptr) { - pipeline_->Pause(); - } - return 0; -} - -int32_t PipeDemo::Stop() -{ - if (pipeline_ != nullptr) { - pipeline_->Stop(); - } - return 0; -} - -int32_t PipeDemo::Release() -{ - if (pipeline_ != nullptr) { - pipeline_->Release(); - } - return 0; -} - -Status PipeDemo::OnCallback(std::shared_ptr filter, const FilterCallBackCommand cmd, - StreamType outType) -{ - AVTRANS_LOGI("PipeDemo::OnCallback filter, outType: %{public}d", outType); - if (cmd == FilterCallBackCommand::NEXT_FILTER_NEEDED) { - switch (outType) { - case StreamType::STREAMTYPE_RAW_AUDIO: - return LinkAudioSinkFilter(filter, outType); - case StreamType::STREAMTYPE_ENCODED_AUDIO: - return LinkAudioDecoderFilter(filter, outType); - default: - break; - } - } - return Status::OK; -} - -Status PipeDemo::LinkAudioDecoderFilter(const std::shared_ptr& preFilter, StreamType type) -{ - AVTRANS_LOGI("PipeDemo::LinkAudioDecoderFilter"); - TRUE_RETURN_V(midFilter_ != nullptr, Status::OK); - midFilter_ = FilterFactory::Instance().CreateFilter("builtin.recorder.midfilter", - FilterType::FILTERTYPE_VIDEODEC); - TRUE_RETURN_V(midFilter_ == nullptr, Status::ERROR_NULL_POINTER); - midFilter_->Init(playerEventReceiver_, playerFilterCallback_); - - return pipeline_->LinkFilters(preFilter, {midFilter_}, type); -} - -Status PipeDemo::LinkAudioSinkFilter(const std::shared_ptr& preFilter, StreamType type) -{ - AVTRANS_LOGI("PipeDemo::LinkAudioSinkFilter"); - TRUE_RETURN_V(tailFilter_ != nullptr, Status::OK); - tailFilter_ = FilterFactory::Instance().CreateFilter("builtin.recorder.tailfilter", - FilterType::FILTERTYPE_DEMUXER); - TRUE_RETURN_V(tailFilter_ == nullptr, Status::ERROR_NULL_POINTER); - tailFilter_->Init(playerEventReceiver_, playerFilterCallback_); - - return pipeline_->LinkFilters(preFilter, {tailFilter_}, type); -} -} // namespace Pipeline -} // namespace DistributedHardware -} // namespace OHOS - - -int main(int argc, char *argv[]) -{ - auto pipeDemo = std::make_shared(); - std::cout << "Initing..." << std::endl; - pipeDemo->InitPipe(); - std::cout << "Init piep success" << std::endl; - - std::cout << "Preparing..." << std::endl; - pipeDemo->Prepare(); - std::cout << "Prepare success" << std::endl; - - std::cout << "Starting..." << std::endl; - pipeDemo->Start(); - std::cout << "Start success" << std::endl; - - std::cout << "Pausing..." << std::endl; - pipeDemo->Pause(); - std::cout << "Pause success" << std::endl; - - std::cout << "Stoping..." << std::endl; - pipeDemo->Stop(); - std::cout << "Stop success" << std::endl; - - std::cout << "Releasing..." << std::endl; - pipeDemo->Release(); - std::cout << "Release success" << std::endl; - - return 0; -} diff --git a/av_transport/framework/test/demo/pipe_demo.h b/av_transport/framework/test/demo/pipe_demo.h deleted file mode 100644 index b424d674..00000000 --- a/av_transport/framework/test/demo/pipe_demo.h +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (c) 2024 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 OHOS_AV_PIPELINE_DEMO_H -#define OHOS_AV_PIPELINE_DEMO_H - -#include -#include -#include - -#include "osal/task/mutex.h" - -#include "filter.h" -#include "head_filter.h" -#include "mid_filter.h" -#include "pipeline_status.h" -#include "pipeline/include/pipeline.h" -#include "tail_filter.h" - -namespace OHOS { -namespace DistributedHardware { -namespace Pipeline { -class PipeDemo { -public: - PipeDemo(); - ~PipeDemo(); - - int32_t InitPipe(); - - int32_t Prepare(); - - int32_t Start(); - - int32_t Pause(); - - int32_t Stop(); - - int32_t Release(); - - Status OnCallback(std::shared_ptr filter, const FilterCallBackCommand cmd, - StreamType outType); - Status LinkAudioDecoderFilter(const std::shared_ptr& preFilter, StreamType type); - Status LinkAudioSinkFilter(const std::shared_ptr& preFilter, StreamType type); - -private: - std::string demoId_ {-1}; - std::shared_ptr playerEventReceiver_ {nullptr}; - std::shared_ptr playerFilterCallback_ {nullptr}; - std::shared_ptr pipeline_ {nullptr}; - std::shared_ptr headFilter_ {nullptr}; - std::shared_ptr midFilter_ {nullptr}; - std::shared_ptr tailFilter_ {nullptr}; -}; -} // namespace Pipeline -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_AV_PIPELINE_DEMO_H diff --git a/av_transport/framework/test/demo/tail_filter.cpp b/av_transport/framework/test/demo/tail_filter.cpp deleted file mode 100644 index dc1c425d..00000000 --- a/av_transport/framework/test/demo/tail_filter.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/* - * Copyright (c) 2024 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 "tail_filter.h" - -#include - -#include "av_trans_log.h" -#include "filter_factory.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "TailFilter" - -namespace OHOS { -namespace DistributedHardware { -namespace Pipeline { -static AutoRegisterFilter g_registerAudioEncoderFilter("builtin.recorder.tailfilter", - FilterType::FILTERTYPE_DEMUXER, - [](const std::string& name, const FilterType type) { - return std::make_shared(name, FilterType::FILTERTYPE_DEMUXER); - }); - -class TailFilterLinkCallback : public FilterLinkCallback { -public: - explicit TailFilterLinkCallback(std::shared_ptr filter) - : headFilter_(std::move(filter)) {} - ~TailFilterLinkCallback() = default; - - void OnLinkedResult(const sptr &queue, std::shared_ptr &meta) override - { - if (auto filter = headFilter_.lock()) { - filter->OnLinkedResult(queue, meta); - } else { - AVTRANS_LOGI("invalid headFilter"); - } - } - - void OnUnlinkedResult(std::shared_ptr &meta) override - { - if (auto filter = headFilter_.lock()) { - filter->OnUnlinkedResult(meta); - } else { - AVTRANS_LOGI("invalid headFilter"); - } - } - - void OnUpdatedResult(std::shared_ptr &meta) override - { - if (auto filter = headFilter_.lock()) { - filter->OnUpdatedResult(meta); - } else { - AVTRANS_LOGI("invalid headFilter"); - } - } - -private: - std::weak_ptr headFilter_ {}; -}; - -TailFilter::TailFilter(std::string name, FilterType type, bool isAsyncMode) - : Filter(name, type) -{ -} - -TailFilter::~TailFilter() -{ - nextFiltersMap_.clear(); -} - -void TailFilter::Init(const std::shared_ptr& receiver, const std::shared_ptr& callback) -{ - receiver_ = receiver; - callback_ = callback; -} - -Status TailFilter::DoInitAfterLink() -{ - AVTRANS_LOGI("TailFilter::DoInitAfterLink"); - return Status::OK; -} - -Status TailFilter::DoPrepare() -{ - AVTRANS_LOGI("cur: TailFilter, notify linkedResult."); - sptr producer = nullptr; - std::shared_ptr meta = std::make_shared(); - if (onLinkedResultCallback_ != nullptr) { - onLinkedResultCallback_->OnLinkedResult(producer, meta); - } - return Status::OK; -} - -Status TailFilter::DoStart() -{ - AVTRANS_LOGI("TailFilter::DoStart"); - return Status::OK; -} - -Status TailFilter::DoPause() -{ - AVTRANS_LOGI("TailFilter::DoPause"); - return Status::OK; -} - -Status TailFilter::DoPauseDragging() -{ - AVTRANS_LOGI("TailFilter::DoPauseDragging"); - return Status::OK; -} - -Status TailFilter::DoResume() -{ - AVTRANS_LOGI("TailFilter::DoResume"); - return Status::OK; -} - -Status TailFilter::DoResumeDragging() -{ - AVTRANS_LOGI("TailFilter::DoResumeDragging"); - return Status::OK; -} - -Status TailFilter::DoStop() -{ - AVTRANS_LOGI("TailFilter::DoStop"); - return Status::OK; -} - -Status TailFilter::DoFlush() -{ - AVTRANS_LOGI("TailFilter::DoFlush"); - return Status::OK; -} - -Status TailFilter::DoRelease() -{ - AVTRANS_LOGI("TailFilter::DoRelease"); - return Status::OK; -} - -Status TailFilter::DoProcessInputBuffer(int recvArg, bool dropFrame) -{ - AVTRANS_LOGI("TailFilter::DoProcessInputBuffer"); - return Status::OK; -} - -Status TailFilter::DoProcessOutputBuffer(int recvArg, bool dropFrame, bool byIdx, uint32_t idx, int64_t renderTimee) -{ - AVTRANS_LOGI("TailFilter::DoProcessOutputBuffer"); - return Status::OK; -} - -void TailFilter::SetParameter(const std::shared_ptr& meta) -{ - meta_ = meta; -} - -void TailFilter::GetParameter(std::shared_ptr& meta) -{ - meta = meta_; -} - -Status TailFilter::LinkNext(const std::shared_ptr& nextFilter, StreamType outType) -{ - AVTRANS_LOGI("cur: TailFilter, link next filter.."); - // 1. 插入下级filter维护map - nextFilter_ = nextFilter; - nextFiltersMap_[outType].push_back(nextFilter_); - // 2. 下级节点的Link初始化 - auto filterLinkCallback = std::make_shared(shared_from_this()); - auto ret = nextFilter->OnLinked(outType, configureParam_, filterLinkCallback); - if (ret != Status::OK) { - AVTRANS_LOGE("Onlinked failed, status: %{public}d.", ret); - return ret; - } - return Status::OK; -} - -Status TailFilter::UpdateNext(const std::shared_ptr&, StreamType) -{ - return Status::OK; -} - -Status TailFilter::UnLinkNext(const std::shared_ptr&, StreamType) -{ - AVTRANS_LOGI("cur: TailFilter, unlink next filter.."); - return Status::OK; -} - -Status TailFilter::OnLinked(StreamType inType, const std::shared_ptr &meta, - const std::shared_ptr &callback) -{ - AVTRANS_LOGI("cur: TailFilter, OnLinked"); - onLinkedResultCallback_ = callback; - return Status::OK; -}; - -Status TailFilter::OnUpdated(StreamType, const std::shared_ptr&, - const std::shared_ptr&) -{ - return Status::OK; -} - -Status TailFilter::OnUnLinked(StreamType, const std::shared_ptr&) -{ - AVTRANS_LOGI("cur: TailFilter, OnUnLinked."); - return Status::OK; -} - -void TailFilter::OnLinkedResult(const sptr& queue, std::shared_ptr& meta) -{ - // link bufferQueue -} - -void TailFilter::OnUnlinkedResult(std::shared_ptr& meta) -{ -} - -void TailFilter::OnUpdatedResult(std::shared_ptr& meta) -{ -} -} // namespace Pipeline -} // namespace DistributedHardware -} // namespace OHOS diff --git a/av_transport/framework/test/demo/tail_filter.h b/av_transport/framework/test/demo/tail_filter.h deleted file mode 100644 index 4978f289..00000000 --- a/av_transport/framework/test/demo/tail_filter.h +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 2024 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 OHOS_AV_PIPELINE_TAIL_FILTER_DEMO_H -#define OHOS_AV_PIPELINE_TAIL_FILTER_DEMO_H - -#include -#include -#include - -#include "pipeline_status.h" -#include "filter.h" - -namespace OHOS { -namespace DistributedHardware { -namespace Pipeline { -// 分两步:第一先保证fiter连接正常,第二,filter保证数据流转正常 -class TailFilter : public Filter, public std::enable_shared_from_this { -public: - TailFilter(std::string name, FilterType type, bool asyncMode = false); - virtual ~TailFilter(); - void Init(const std::shared_ptr& receiver, const std::shared_ptr& callback) override; - Status DoInitAfterLink() override; - Status DoPrepare() override; - Status DoStart() override; - Status DoPause() override; - Status DoPauseDragging() override; - Status DoResume() override; - Status DoResumeDragging() override; - Status DoStop() override; - Status DoFlush() override; - Status DoRelease() override; - - Status DoProcessInputBuffer(int recvArg, bool dropFrame) override; - Status DoProcessOutputBuffer(int recvArg, bool dropFrame, bool byIdx, uint32_t idx, int64_t renderTime) override; - void SetParameter(const std::shared_ptr& meta) override; - void GetParameter(std::shared_ptr& meta) override; - - Status LinkNext(const std::shared_ptr& nextFilter, StreamType outType) override; - Status UpdateNext(const std::shared_ptr& nextFilter, StreamType outType) override; - Status UnLinkNext(const std::shared_ptr& nextFilter, StreamType outType) override; - - Status OnLinked(StreamType inType, const std::shared_ptr& meta, - const std::shared_ptr& callback) override; - Status OnUpdated(StreamType inType, const std::shared_ptr& meta, - const std::shared_ptr& callback) override; - Status OnUnLinked(StreamType inType, const std::shared_ptr& callback) override; - - // PipeLinked 后处理 - void OnLinkedResult(const sptr& queue, std::shared_ptr& meta); - void OnUnlinkedResult(std::shared_ptr& meta); - void OnUpdatedResult(std::shared_ptr& meta); - -private: - std::shared_ptr configureParam_ {nullptr}; - std::shared_ptr nextFilter_ {nullptr}; - - std::shared_ptr eventReceiver_ {nullptr}; - std::shared_ptr filterCallback_ {nullptr}; - std::shared_ptr onLinkedResultCallback_ {nullptr}; -}; -} // namespace Pipeline -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_AV_PIPELINE_TAIL_FILTER_DEMO_H diff --git a/bundle.json b/bundle.json index 6395fa7b..c851cf0a 100644 --- a/bundle.json +++ b/bundle.json @@ -69,7 +69,6 @@ "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_engine/av_sender:distributed_av_sender", "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/av_trans_handler/histreamer_ability_querier:histreamer_ability_querier", "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/framework:distributed_av_pipeline_fwk", - "//foundation/distributedhardware/distributed_hardware_fwk/av_transport/framework/test/demo:av_trans_pipelie_demo", "//foundation/distributedhardware/distributed_hardware_fwk/interfaces/inner_kits:libdhfwk_sdk", "//foundation/distributedhardware/distributed_hardware_fwk/interfaces/kits/napi:hardwaremanager", "//foundation/distributedhardware/distributed_hardware_fwk/sa_profile:dhardware.cfg", -- Gitee