diff --git a/av_transport/av_trans_control_center/inner_kits/include/av_trans_control_center_callback.h b/av_transport/av_trans_control_center/inner_kits/include/av_trans_control_center_callback.h index 521da97b89c93aea51b8cc7beb6997be0e26e27c..e43c29092c9144a45ff6aa3ff2946a49d5992d92 100644 --- a/av_transport/av_trans_control_center/inner_kits/include/av_trans_control_center_callback.h +++ b/av_transport/av_trans_control_center/inner_kits/include/av_trans_control_center_callback.h @@ -29,7 +29,6 @@ public: ~AVTransControlCenterCallback() override = default; int32_t SetParameter(uint32_t tag, const std::string &value) override; - int32_t SetSharedMemory(const AVTransSharedMemoryExt& memory) override; int32_t Notify(const AVTransEventExt& event) override; void SetSenderEngine(const std::shared_ptr &sender); diff --git a/av_transport/av_trans_control_center/inner_kits/src/av_trans_control_center_callback.cpp b/av_transport/av_trans_control_center/inner_kits/src/av_trans_control_center_callback.cpp index 7fb896fed8738afb4be4abfd27515d388c8f51ec..e6145efa49b8c0cfb78e4e9b6a53f3d3202ea597 100644 --- a/av_transport/av_trans_control_center/inner_kits/src/av_trans_control_center_callback.cpp +++ b/av_transport/av_trans_control_center/inner_kits/src/av_trans_control_center_callback.cpp @@ -33,28 +33,6 @@ int32_t AVTransControlCenterCallback::SetParameter(uint32_t tag, const std::stri return DH_AVT_SUCCESS; } -int32_t AVTransControlCenterCallback::SetSharedMemory(const AVTransSharedMemoryExt &memory) -{ - DHLOGW("AVTransControlCenterCallback::SetSharedMemory enter."); - - AVTransSharedMemory memoryTrans; - memoryTrans.size = memory.size; - memoryTrans.fd = memory.fd; - memoryTrans.name = memory.name; - - std::shared_ptr sendEngine = senderEngine_.lock(); - if (sendEngine != nullptr) { - sendEngine->SetParameter(AVTransTag::SHARED_MEMORY_FD, MarshalSharedMemory(memoryTrans)); - } - - std::shared_ptr rcvEngine = receiverEngine_.lock(); - if (rcvEngine != nullptr) { - rcvEngine->SetParameter(AVTransTag::SHARED_MEMORY_FD, MarshalSharedMemory(memoryTrans)); - } - - return DH_AVT_SUCCESS; -} - int32_t AVTransControlCenterCallback::Notify(const AVTransEventExt& event) { DHLOGW("AVTransControlCenterCallback::Notify enter."); diff --git a/av_transport/av_trans_control_center/services/src/av_trans_control_center.cpp b/av_transport/av_trans_control_center/services/src/av_trans_control_center.cpp index 5a888269d153db151f03d6e8a77edf08ef9364f1..61595a89f683e6aac1eebe74da59853200d48a9f 100644 --- a/av_transport/av_trans_control_center/services/src/av_trans_control_center.cpp +++ b/av_transport/av_trans_control_center/services/src/av_trans_control_center.cpp @@ -240,12 +240,7 @@ void AVTransControlCenter::SetParam2Engines(AVTransTag tag, const std::string &v void AVTransControlCenter::SetParam2Engines(const AVTransSharedMemory &memory) { - std::lock_guard lock(callbackMutex_); - for (auto iter = callbackMap_.begin(); iter != callbackMap_.end(); iter++) { - if (iter->second != nullptr) { - iter->second->SetSharedMemory(AVTransSharedMemoryExt(memory)); - } - } + (void)memory; } void AVTransControlCenter::OnChannelEvent(const AVTransEvent &event) diff --git a/av_transport/av_trans_control_center/test/fuzztest/BUILD.gn b/av_transport/av_trans_control_center/test/fuzztest/BUILD.gn index ee237584e1f5054f475205040c5058b28c945dd5..50b2a149b552ed1b3db0bfdbf38ea87edc89cbbc 100644 --- a/av_transport/av_trans_control_center/test/fuzztest/BUILD.gn +++ b/av_transport/av_trans_control_center/test/fuzztest/BUILD.gn @@ -17,7 +17,6 @@ group("fuzztest") { deps = [ "avtranscallbacknotify_fuzzer:fuzztest", "avtranscallbacksetparameter_fuzzer:fuzztest", - "avtranscallbacksetsharedmemory_fuzzer:fuzztest", "avtransonsessionclosed_fuzzer:fuzztest", "onbytesreceived_fuzzer:fuzztest", "onsoftbustimesyncresult_fuzzer:fuzztest", diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/BUILD.gn b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/BUILD.gn deleted file mode 100644 index 92aa39a0c986b88d4159dee9409f8dacd0547aa4..0000000000000000000000000000000000000000 --- a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/BUILD.gn +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (c) 2024-2025 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. - -#####################hydra-fuzz################### -import("//build/config/features.gni") -import("//build/test.gni") -import("../../../../distributed_av_transport.gni") - -##############################fuzztest########################################## -ohos_fuzztest("AVTransCallbackSetSharedMemoryFuzzTest") { - module_out_path = fuzz_test_output_path - fuzz_config_file = "${control_center_path}/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer" - - include_dirs = [ - "include", - "${common_path}/include", - "${dh_fwk_utils_path}/include", - "${interface_path}", - "${control_center_path}/inner_kits/include", - "${control_center_path}/inner_kits/include/ipc", - ] - - cflags = [ - "-g", - "-O0", - "-Wno-unused-variable", - "-fno-omit-frame-pointer", - ] - - sources = [ "avtranscallbacksetsharedmemory_fuzzer.cpp" ] - - deps = [ - "${dh_fwk_sdk_path}:dhfwk_idl_hardware_head", - "${dh_fwk_sdk_path}:libdhfwk_sdk", - ] - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"AVTransCallbackSetSharedMemoryFuzzTest\"", - "LOG_DOMAIN=0xD004101", - ] - - external_deps = [ - "cJSON:cjson", - "c_utils:utils", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr:samgr_proxy", - "hilog:libhilog", - ] -} - -############################################################################### -group("fuzztest") { - testonly = true - deps = [ ":AVTransCallbackSetSharedMemoryFuzzTest" ] -} -############################################################################### diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/avtranscallbacksetsharedmemory_fuzzer.cpp b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/avtranscallbacksetsharedmemory_fuzzer.cpp deleted file mode 100644 index d4cd7c426cc5906084cfa4531ce48636ade7a1b0..0000000000000000000000000000000000000000 --- a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/avtranscallbacksetsharedmemory_fuzzer.cpp +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 2024-2025 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 "avtranscallbacksetsharedmemory_fuzzer.h" - -#include -#include "av_trans_control_center_callback.h" -#include "av_sync_utils.h" - -namespace OHOS { -namespace DistributedHardware { -void AVTransCallbackSetSharedMemoryFuzzTest(const uint8_t *data, size_t size) -{ - if ((data == nullptr) || (size < sizeof(int32_t))) { - return; - } - FuzzedDataProvider fdp(data, size); - int32_t fd = fdp.ConsumeIntegral(); - int32_t len = fdp.ConsumeIntegral(); - std::string name(reinterpret_cast(data), size); - AVTransSharedMemory memory = AVTransSharedMemory{ fd, len, name }; - AVTransSharedMemoryExt memoryExt = AVTransSharedMemoryExt(memory); - sptr controlCenterCallback(new (std::nothrow) AVTransControlCenterCallback()); - if (controlCenterCallback == nullptr) { - return; - } - controlCenterCallback->SetSharedMemory(memoryExt); -} -} // namespace DistributedHardware -} // namespace OHOS - -/* Fuzzer entry point */ -extern "C" int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) -{ - /* Run your code on data */ - OHOS::DistributedHardware::AVTransCallbackSetSharedMemoryFuzzTest(data, size); - return 0; -} \ No newline at end of file diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/avtranscallbacksetsharedmemory_fuzzer.h b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/avtranscallbacksetsharedmemory_fuzzer.h deleted file mode 100644 index 08255fd94b1e70cc4d0320073626067a8cb3075d..0000000000000000000000000000000000000000 --- a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/avtranscallbacksetsharedmemory_fuzzer.h +++ /dev/null @@ -1,21 +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 TEST_AVTRANSCALLBACKSETSHAREDMEMORY_FUZZER_H -#define TEST_AVTRANSCALLBACKSETSHAREDMEMORY_FUZZER_H - -#define FUZZ_PROJECT_NAME "avtranscallbacksetsharedmemory_fuzzer.cpp" - -#endif \ No newline at end of file diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/corpus/init b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/corpus/init deleted file mode 100644 index 6198079a28e860189d4294f6598f8ac6804c0dff..0000000000000000000000000000000000000000 --- a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/corpus/init +++ /dev/null @@ -1,16 +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. - */ - -FUZZ \ No newline at end of file diff --git a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/project.xml b/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/project.xml deleted file mode 100644 index 7133b2b92440904a5ed04b838733acea0f97486a..0000000000000000000000000000000000000000 --- a/av_transport/av_trans_control_center/test/fuzztest/avtranscallbacksetsharedmemory_fuzzer/project.xml +++ /dev/null @@ -1,25 +0,0 @@ - - - - - - 1000 - - 300 - - 4096 - - diff --git a/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.cpp b/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.cpp index d02eff92d31768866cfc8920d8715744609dbae0..fefc661d693b28b5b49021c215ac14a13c1a7017 100644 --- a/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.cpp +++ b/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.cpp @@ -86,24 +86,6 @@ HWTEST_F(AVTransControlCenterCallbackTest, set_parameter_003, TestSize.Level0) EXPECT_EQ(DH_AVT_SUCCESS, ret); } -/** - * @tc.name: set_shared_memory_001 - * @tc.desc: set shared memory function. - * @tc.type: FUNC - * @tc.require: AR000GHSK9 - */ -HWTEST_F(AVTransControlCenterCallbackTest, set_shared_memory_001, TestSize.Level1) -{ - callBack_ = std::make_shared(); - callBack_->receiverEngine_ = std::shared_ptr(); - callBack_->senderEngine_ = std::shared_ptr(); - AVTransSharedMemoryExt memory; - int32_t ret = callBack_->SetSharedMemory(memory); - EXPECT_EQ(DH_AVT_SUCCESS, ret); - callBack_->senderEngine_ = std::shared_ptr(); - EXPECT_EQ(DH_AVT_SUCCESS, ret); -} - /** * @tc.name: notify_001 * @tc.desc: notify function. diff --git a/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.h b/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.h index 32511d0833f86e670c102445bdf3633de9f7d1f7..bbfa86e3ae3b1bfea767b654d2a8d9d2ff557925 100644 --- a/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.h +++ b/av_transport/av_trans_control_center/test/unittest/inner_kits/av_trans_control_center_callback_test.h @@ -178,6 +178,146 @@ public: return false; } }; + +class ReceiverEngineFailTest : public IAVReceiverEngine { +public: + ReceiverEngineFailTest() = default; + ~ReceiverEngineFailTest() override = default; + int32_t Initialize() override + { + return DH_AVT_SUCCESS; + } + + int32_t Release() override + { + return DH_AVT_SUCCESS; + } + + int32_t Start() override + { + return DH_AVT_SUCCESS; + } + + int32_t Stop() override + { + return DH_AVT_SUCCESS; + } + + int32_t SetParameter(AVTransTag tag, const std::string &value) override + { + (void) tag; + (void) value; + return ERR_DH_AVT_INVALID_OPERATION; + } + + int32_t SendMessage(const std::shared_ptr &message) override + { + (void) message; + return DH_AVT_SUCCESS; + } + + int32_t CreateControlChannel(const std::vector &dstDevIds, + const ChannelAttribute &attribution) override + { + (void) dstDevIds; + (void) attribution; + return DH_AVT_SUCCESS; + } + + int32_t RegisterReceiverCallback(const std::shared_ptr &callback) override + { + (void) callback; + return DH_AVT_SUCCESS; + } + + bool StartDumpMediaData() override + { + return false; + } + + bool StopDumpMediaData() override + { + return false; + } + + bool ReStartDumpMediaData() override + { + return false; + } +}; + +class SenderEngineFailTest : public IAVSenderEngine { +public: + SenderEngineFailTest() = default; + ~SenderEngineFailTest() override = default; + int32_t Initialize() override + { + return DH_AVT_SUCCESS; + } + + int32_t Release() override + { + return DH_AVT_SUCCESS; + } + + int32_t Start() override + { + return DH_AVT_SUCCESS; + } + + int32_t Stop() override + { + return DH_AVT_SUCCESS; + } + + int32_t PushData(const std::shared_ptr &buffer) override + { + (void) buffer; + return DH_AVT_SUCCESS; + } + + int32_t SetParameter(AVTransTag tag, const std::string &value) override + { + (void) tag; + (void) value; + return ERR_DH_AVT_INVALID_OPERATION; + } + + int32_t SendMessage(const std::shared_ptr &message) override + { + (void) message; + return DH_AVT_SUCCESS; + } + + int32_t CreateControlChannel(const std::vector &dstDevIds, + const ChannelAttribute &attribution) override + { + (void) dstDevIds; + (void) attribution; + return DH_AVT_SUCCESS; + } + + int32_t RegisterSenderCallback(const std::shared_ptr &callback) override + { + (void) callback; + return DH_AVT_SUCCESS; + } + + bool StartDumpMediaData() override + { + return false; + } + + bool StopDumpMediaData() override + { + return false; + } + + bool ReStartDumpMediaData() override + { + return false; + } +}; } // namespace DistributedHardware } // namespace OHOS #endif diff --git a/av_transport/av_trans_control_center/test/unittest/services/av_trans_control_center_test.h b/av_transport/av_trans_control_center/test/unittest/services/av_trans_control_center_test.h index 926d6bca12e8a9f6022e1bd9a0dd910a11acd5bb..c6640de4240fc92a80ad8cd2a44cb1089831bb16 100644 --- a/av_transport/av_trans_control_center/test/unittest/services/av_trans_control_center_test.h +++ b/av_transport/av_trans_control_center/test/unittest/services/av_trans_control_center_test.h @@ -45,11 +45,6 @@ public: value_ = value; return DH_AVT_SUCCESS; } - int32_t SetSharedMemory(const AVTransSharedMemoryExt &memory) override - { - memory_ = memory; - return DH_AVT_SUCCESS; - } int32_t Notify(const AVTransEventExt &event) override { return DH_AVT_SUCCESS; diff --git a/av_transport/av_trans_engine/av_sender/src/av_audio_sender_engine.cpp b/av_transport/av_trans_engine/av_sender/src/av_audio_sender_engine.cpp index 7e59e038b07bcdcc401d4f34cae1d0cea00334ba..33a5a12ba5b33a4e65a632eacf6fadeef58cad6e 100644 --- a/av_transport/av_trans_engine/av_sender/src/av_audio_sender_engine.cpp +++ b/av_transport/av_trans_engine/av_sender/src/av_audio_sender_engine.cpp @@ -316,18 +316,19 @@ void AVAudioSenderEngine::SetParameterInner(AVTransTag tag, const std::string &v int32_t AVAudioSenderEngine::SetParameter(AVTransTag tag, const std::string &value) { AVTRANS_LOGI("AVTransTag=%{public}u.", tag); + int32_t ret = DH_AVT_SUCCESS; switch (tag) { case AVTransTag::VIDEO_WIDTH: - SetVideoWidth(value); + ret = SetVideoWidth(value); break; case AVTransTag::VIDEO_HEIGHT: - SetVideoHeight(value); + ret = SetVideoHeight(value); break; case AVTransTag::VIDEO_PIXEL_FORMAT: - SetVideoPixelFormat(value); + ret = SetVideoPixelFormat(value); break; case AVTransTag::VIDEO_FRAME_RATE: - SetVideoFrameRate(value); + ret = SetVideoFrameRate(value); break; case AVTransTag::AUDIO_BIT_RATE: SetAudioBitRate(value); diff --git a/interfaces/inner_kits/IAvTransControlCenterCallback.idl b/interfaces/inner_kits/IAvTransControlCenterCallback.idl index 572afca178777099d47ee5f0f354e61a8006d94b..731342850ae8d564f92f3bc685200e942c26665d 100644 --- a/interfaces/inner_kits/IAvTransControlCenterCallback.idl +++ b/interfaces/inner_kits/IAvTransControlCenterCallback.idl @@ -18,6 +18,5 @@ sequenceable AvTransTypes..OHOS.DistributedHardware.AVTransEventExt; sequenceable AvSyncUtils..OHOS.DistributedHardware.AVTransSharedMemoryExt; interface OHOS.DistributedHardware.IAvTransControlCenterCallback { [ipccode 1] void SetParameter([in] unsigned int tag, [in] String value); - [ipccode 2] void SetSharedMemory([in] AVTransSharedMemoryExt memory); - [ipccode 3] void Notify([in] AVTransEventExt event); + [ipccode 2] void Notify([in] AVTransEventExt event); } \ No newline at end of file diff --git a/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.cpp b/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.cpp index ba099657d5f1434b07894a48e1a79cd59e676ab5..811b8d33ead618f56c13d835f105455c1b23b93a 100644 --- a/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.cpp +++ b/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.cpp @@ -85,12 +85,6 @@ int32_t TestAVTransControlCenterCallback::SetParameter(uint32_t tag, const std:: return DH_FWK_SUCCESS; } -int32_t TestAVTransControlCenterCallback::SetSharedMemory(const AVTransSharedMemoryExt &memory) -{ - (void)memory; - return DH_FWK_SUCCESS; -} - int32_t TestAVTransControlCenterCallback::Notify(const AVTransEventExt &event) { (void)event; diff --git a/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.h b/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.h index 1f4dfa41236218d8a23b855b6902973b8d544210..b9502e2e2992273cec3b484aaff2a7279abff4d0 100644 --- a/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.h +++ b/interfaces/inner_kits/test/fuzztest/distributedhardwarefwkkit_fuzzer/distributedhardwarefwkkit_fuzzer.h @@ -66,7 +66,6 @@ public: virtual ~TestAVTransControlCenterCallback() = default; protected: int32_t SetParameter(uint32_t tag, const std::string &value) override; - int32_t SetSharedMemory(const AVTransSharedMemoryExt& memory) override; int32_t Notify(const AVTransEventExt& event) override; sptr AsObject() override {