diff --git a/bundle.json b/bundle.json index c104ef9a6b630c6ac00449559e9724a1d2011e00..4d74f225d5471605c9b9cd7bbd91ae4ac2d714ea 100755 --- a/bundle.json +++ b/bundle.json @@ -71,10 +71,8 @@ "//foundation/distributedhardware/distributed_audio/services/audiomanager/servicesource:distributed_audio_source", "//foundation/distributedhardware/distributed_audio/services/audiomanager/servicesink:distributed_audio_sink", - "//foundation/distributedhardware/distributed_audio/services/audiotransport/audiochannel/audiodatachannel:distributed_audio_data_channel", - "//foundation/distributedhardware/distributed_audio/services/audiotransport/audiotransportstatus:distributed_audio_transport_status", - "//foundation/distributedhardware/distributed_audio/services/audiotransport/decodetransport:distributed_audio_decode_transport", - "//foundation/distributedhardware/distributed_audio/services/audiotransport/encodetransport:distributed_audio_encode_transport", + "//foundation/distributedhardware/distributed_audio/services/audiotransport/receiverengine:distributed_audio_decode_transport", + "//foundation/distributedhardware/distributed_audio/services/audiotransport/senderengine:distributed_audio_encode_transport", "//foundation/distributedhardware/distributed_audio/services/test_example:audio_distributed_test" ], "inner_kits": [{ @@ -99,21 +97,23 @@ }, { "type": "so", - "name": "//foundation/distributedhardware/distributed_audio/services/audiotransport/decodetransport:distributed_audio_decode_transport", + "name": "//foundation/distributedhardware/distributed_audio/services/audiotransport/receiverengine:distributed_audio_decode_transport", "header": { - "header_base": "//foundation/distributedhardware/distributed_audio/services/audiotransport/decodetransport", + "header_base": "//foundation/distributedhardware/distributed_audio/services/audiotransport/receiverengine", "header_files": [ - "include/audio_decode_transport.h" + "include/av_receiver_engine_adapter.h", + "include/av_receiver_engine_transport.h" ] } }, { "type": "so", - "name": "//foundation/distributedhardware/distributed_audio/services/audiotransport/encodetransport:distributed_audio_encode_transport", + "name": "//foundation/distributedhardware/distributed_audio/services/audiotransport/senderengine:distributed_audio_encode_transport", "header": { - "header_base": "//foundation/distributedhardware/distributed_audio/services/audiotransport/encodetransport", + "header_base": "//foundation/distributedhardware/distributed_audio/services/audiotransport/senderengine", "header_files": [ - "include/audio_encode_transport.h" + "include/av_sender_engine_adapter.h", + "include/av_sender_engine_transport.h" ] } }, diff --git a/common/dfx_utils/test/unittest/BUILD.gn b/common/dfx_utils/test/unittest/BUILD.gn index 28da89e6278fddae6e8af4e41bbad70627236803..38013170a1c44604b68b59bae7ef214a32f3ce31 100644 --- a/common/dfx_utils/test/unittest/BUILD.gn +++ b/common/dfx_utils/test/unittest/BUILD.gn @@ -26,12 +26,6 @@ config("module_private_config") { "${audio_control_path}/controlsource/include", "${audio_hdi_proxy_path}/include", "${audio_processor_path}/interface", - "${audio_processor_path}/encodeprocessor/include", - "${audio_processor_path}/decodeprocessor/include", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audiochannel/audiodatachannel/include", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", "${audio_transport_path}/decodetransport/include", "${audio_transport_path}/encodetransport/include", "${audio_transport_path}/interface", diff --git a/services/audioclient/micclient/include/dmic_client.h b/services/audioclient/micclient/include/dmic_client.h index c453410bf22025f55fd6213916bfda9ad54374c0..41896aae625de914de6454c03526d48839c43d88 100644 --- a/services/audioclient/micclient/include/dmic_client.h +++ b/services/audioclient/micclient/include/dmic_client.h @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -28,7 +29,6 @@ #include "audio_info.h" #include "audio_data.h" -#include "audio_encode_transport.h" #include "audio_event.h" #include "audio_param.h" #include "audio_status.h" diff --git a/services/audioclient/spkclient/include/dspeaker_client.h b/services/audioclient/spkclient/include/dspeaker_client.h index a346bb4735f19acbb9646fc417ced24adb716958..290202325054b18c5007e2b00d860c30a542d4a3 100644 --- a/services/audioclient/spkclient/include/dspeaker_client.h +++ b/services/audioclient/spkclient/include/dspeaker_client.h @@ -21,6 +21,7 @@ #include #include #include +#include #include #include #include @@ -33,7 +34,6 @@ #include "audio_data.h" #include "audio_status.h" -#include "audio_decode_transport.h" #include "audio_event.h" #include "av_receiver_engine_transport.h" #include "daudio_constants.h" diff --git a/services/audioclient/test/unittest/micclient/BUILD.gn b/services/audioclient/test/unittest/micclient/BUILD.gn index b7cbbe123f2dd1dc9adf0b5a39eed79eb59d3959..c4e4ff522ab8b9299699e028fa290dcd0485d1d8 100644 --- a/services/audioclient/test/unittest/micclient/BUILD.gn +++ b/services/audioclient/test/unittest/micclient/BUILD.gn @@ -28,13 +28,7 @@ config("module_private_config") { "${audio_client_path}/micclient/include", "${audio_client_path}/test/unittest/micclient/include", "${audio_client_path}/test/unittest/audioclienttestutils/include", - "${audio_processor_path}/encodeprocessor/include", "${audio_processor_path}/interface", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audiochannel/audiodatachannel/include", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", - "${audio_transport_path}/encodetransport/include", "${audio_transport_path}/interface", "${audio_transport_path}/receiverengine/include", "${audio_transport_path}/senderengine/include", diff --git a/services/audioclient/test/unittest/spkclient/BUILD.gn b/services/audioclient/test/unittest/spkclient/BUILD.gn index 13752c18cf26446d514a4bf7e51f321d8e2c3132..c4879374c76fdeab1ec96703d496f888aee9461b 100644 --- a/services/audioclient/test/unittest/spkclient/BUILD.gn +++ b/services/audioclient/test/unittest/spkclient/BUILD.gn @@ -33,13 +33,7 @@ config("module_private_config") { "${audio_client_path}/spkclient/include", "${audio_client_path}/test/unittest/spkclient/include", "${audio_client_path}/test/unittest/audioclienttestutils/include", - "${audio_processor_path}/decodeprocessor/include", "${audio_processor_path}/interface", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audiochannel/audiodatachannel/include", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", - "${audio_transport_path}/decodetransport/include", "${audio_transport_path}/interface", "${audio_transport_path}/receiverengine/include", "${audio_transport_path}/senderengine/include", diff --git a/services/audiomanager/managersource/src/dmic_dev.cpp b/services/audiomanager/managersource/src/dmic_dev.cpp index 8dae43b7ab6634ce9ec03ad09bd1a184b3be7959..113bebdd7f491c4de8fe0994212928aae87a7efd 100644 --- a/services/audiomanager/managersource/src/dmic_dev.cpp +++ b/services/audiomanager/managersource/src/dmic_dev.cpp @@ -20,7 +20,6 @@ #include #include -#include "audio_decode_transport.h" #include "daudio_constants.h" #include "daudio_errorcode.h" #include "daudio_hidumper.h" diff --git a/services/audiomanager/managersource/src/dspeaker_dev.cpp b/services/audiomanager/managersource/src/dspeaker_dev.cpp index c6c2e849115c6adce34080ad477467f7452264d4..9a98296173145761ffdaa8aa2079aced5f58afdb 100644 --- a/services/audiomanager/managersource/src/dspeaker_dev.cpp +++ b/services/audiomanager/managersource/src/dspeaker_dev.cpp @@ -22,7 +22,6 @@ #include #include -#include "audio_encode_transport.h" #include "daudio_constants.h" #include "daudio_errorcode.h" #include "daudio_hidumper.h" diff --git a/services/audiomanager/servicesink/BUILD.gn b/services/audiomanager/servicesink/BUILD.gn index 9a6381fabe520eb6e4a56c3848f51cdb649634e2..b160902a2b0118f0c59b6e44458ba5cea5d049fd 100755 --- a/services/audiomanager/servicesink/BUILD.gn +++ b/services/audiomanager/servicesink/BUILD.gn @@ -38,17 +38,7 @@ ohos_shared_library("distributed_audio_sink") { "${audio_client_path}/micclient/include", "${audio_client_path}/spkclient/include", "${audio_control_path}/controlsink/include", - "${audio_processor_path}/encodeprocessor/include", - "${audio_processor_path}/decodeprocessor/include", "${audio_processor_path}/interface", - "${audio_transport_path}/audiochannel/audiodatachannel/include", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audioctrltransport/include", - "${audio_transport_path}/audioctrltransport/interface", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", - "${audio_transport_path}/decodetransport/include", - "${audio_transport_path}/encodetransport/include", "${audio_transport_path}/interface", "${audio_transport_path}/receiverengine/include", "${audio_transport_path}/senderengine/include", @@ -79,8 +69,8 @@ ohos_shared_library("distributed_audio_sink") { ] deps = [ - "${audio_transport_path}/decodetransport:distributed_audio_decode_transport", - "${audio_transport_path}/encodetransport:distributed_audio_encode_transport", + "${audio_transport_path}/receiverengine:distributed_audio_decode_transport", + "${audio_transport_path}/senderengine:distributed_audio_encode_transport", "${innerkits_path}/native_cpp/audio_sink:distributed_audio_sink_sdk", "${services_path}/common:distributed_audio_utils", "//third_party/cJSON:cjson", diff --git a/services/audiomanager/servicesource/BUILD.gn b/services/audiomanager/servicesource/BUILD.gn index cd6b0b2e69763b7f7fd0909c3ee8d9a264810154..af16db24ebadc787f4c9d41474e80653035b8b70 100755 --- a/services/audiomanager/servicesource/BUILD.gn +++ b/services/audiomanager/servicesource/BUILD.gn @@ -42,17 +42,7 @@ ohos_shared_library("distributed_audio_source") { "${audio_client_path}/spkclient/include", "${audio_control_path}/controlsource/include", "${audio_hdi_proxy_path}/include", - "${audio_processor_path}/encodeprocessor/include", - "${audio_processor_path}/decodeprocessor/include", "${audio_processor_path}/interface", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audiochannel/audiodatachannel/include", - "${audio_transport_path}/audioctrltransport/include", - "${audio_transport_path}/audioctrltransport/interface", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", - "${audio_transport_path}/decodetransport/include", - "${audio_transport_path}/encodetransport/include", "${audio_transport_path}/interface", "${audio_transport_path}/receiverengine/include", "${audio_transport_path}/senderengine/include", @@ -91,8 +81,8 @@ ohos_shared_library("distributed_audio_source") { ] deps = [ - "${audio_transport_path}/decodetransport:distributed_audio_decode_transport", - "${audio_transport_path}/encodetransport:distributed_audio_encode_transport", + "${audio_transport_path}/receiverengine:distributed_audio_decode_transport", + "${audio_transport_path}/senderengine:distributed_audio_encode_transport", "${distributedaudio_path}/audiohandler:distributed_audio_handler", "${services_path}/common:distributed_audio_utils", "${services_path}/hdfaudioclient:daudio_client", diff --git a/services/audiomanager/test/unittest/managersink/BUILD.gn b/services/audiomanager/test/unittest/managersink/BUILD.gn index cee640d6497535f428749b2d18dfa95a42979423..aa19c34c7731ef5623566c24635fca5d80191f46 100644 --- a/services/audiomanager/test/unittest/managersink/BUILD.gn +++ b/services/audiomanager/test/unittest/managersink/BUILD.gn @@ -36,19 +36,7 @@ config("module_private_config") { "${audio_client_path}/spkclient/include", "${audio_client_path}/interface", "${audio_control_path}/controlsink/include", - "${audio_processor_path}/decodeprocessor/include", - "${audio_processor_path}/encodeprocessor/include", "${audio_processor_path}/interface", - "${audio_transport_path}/audiochannel/audiodatachannel/include", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audio_channel/include", - "${audio_transport_path}/audioctrltransport/interface", - "${audio_transport_path}/audioctrltransport/include", - "${audio_transport_path}/audiodatachannel/include", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", - "${audio_transport_path}/decodetransport/include", - "${audio_transport_path}/encodetransport/include", "${audio_transport_path}/interface", "${audio_transport_path}/receiverengine/include", "${audio_transport_path}/senderengine/include", diff --git a/services/audiomanager/test/unittest/servicesink/BUILD.gn b/services/audiomanager/test/unittest/servicesink/BUILD.gn index 467ff1dfdcdf1b2469d990711158e5c975dd3a12..b685124b6f8f62b85741e586ad0d233625f08bc0 100644 --- a/services/audiomanager/test/unittest/servicesink/BUILD.gn +++ b/services/audiomanager/test/unittest/servicesink/BUILD.gn @@ -35,19 +35,7 @@ config("module_private_config") { "${audio_client_path}/micclient/include", "${audio_client_path}/spkclient/include", "${audio_control_path}/controlsink/include", - "${audio_processor_path}/decodeprocessor/include", - "${audio_processor_path}/encodeprocessor/include", "${audio_processor_path}/interface", - "${audio_transport_path}/audiochannel/audiodatachannel/include", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audioctrltransport/interface", - "${audio_transport_path}/audioctrltransport/include", - "${audio_transport_path}/audio_channel/include", - "${audio_transport_path}/audiodatachannel/include", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", - "${audio_transport_path}/decodetransport/include", - "${audio_transport_path}/encodetransport/include", "${audio_transport_path}/interface", "${audio_transport_path}/receiverengine/include", "${audio_transport_path}/senderengine/include", diff --git a/services/audiomanager/test/unittest/servicesource/BUILD.gn b/services/audiomanager/test/unittest/servicesource/BUILD.gn index ad5c8333ad4d24e5fc90c06e347df12c005b77f1..116278e4c498db86d045d158cc49f78b6803ff31 100644 --- a/services/audiomanager/test/unittest/servicesource/BUILD.gn +++ b/services/audiomanager/test/unittest/servicesource/BUILD.gn @@ -35,19 +35,7 @@ config("module_private_config") { include_dirs += [ "${audio_control_path}/controlsource/include", "${audio_hdi_proxy_path}/include", - "${audio_processor_path}/decodeprocessor/include", - "${audio_processor_path}/encodeprocessor/include", "${audio_processor_path}/interface", - "${audio_transport_path}/audiochannel/audiodatachannel/include", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audioctrltransport/interface", - "${audio_transport_path}/audioctrltransport/include", - "${audio_transport_path}/audio_channel/include", - "${audio_transport_path}/audiodatachannel/include", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", - "${audio_transport_path}/decodetransport/include", - "${audio_transport_path}/encodetransport/include", "${audio_transport_path}/interface", "${audio_transport_path}/receiverengine/include", "${audio_transport_path}/senderengine/include", diff --git a/services/audiomanager/test/unittest/sourcedevice/BUILD.gn b/services/audiomanager/test/unittest/sourcedevice/BUILD.gn index 63a4566deacdc9d8b6ea7e4a6addcdf70374ee77..6fafdd8458bf7ced9e32d3cde248fe1fe338643d 100644 --- a/services/audiomanager/test/unittest/sourcedevice/BUILD.gn +++ b/services/audiomanager/test/unittest/sourcedevice/BUILD.gn @@ -33,12 +33,6 @@ config("module_private_config") { "${audio_control_path}/controlsource/include", "${audio_hdi_proxy_path}/include", "${audio_processor_path}/interface", - "${audio_transport_path}/audioctrltransport/interface", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", - "${audio_transport_path}/encodetransport/include", - "${audio_transport_path}/decodetransport/include", "${audio_transport_path}/interface", "${audio_transport_path}/receiverengine/include", "${audio_transport_path}/senderengine/include", @@ -68,8 +62,8 @@ ohos_unittest("DaudioSourceDevTest") { configs = [ ":module_private_config" ] deps = [ - "${audio_transport_path}/decodetransport:distributed_audio_decode_transport", - "${audio_transport_path}/encodetransport:distributed_audio_encode_transport", + "${audio_transport_path}/receiverengine:distributed_audio_decode_transport", + "${audio_transport_path}/senderengine:distributed_audio_encode_transport", "${services_path}/audiomanager/servicesource:distributed_audio_source", "${services_path}/common:distributed_audio_utils", "//third_party/googletest:gmock", @@ -96,7 +90,7 @@ ohos_unittest("DMicDevTest") { configs = [ ":module_private_config" ] deps = [ - "${audio_transport_path}/decodetransport:distributed_audio_decode_transport", + "${audio_transport_path}/receiverengine:distributed_audio_decode_transport", "${services_path}/audiomanager/servicesource:distributed_audio_source", "//third_party/googletest:gmock", "//third_party/googletest:gtest_main", @@ -120,7 +114,7 @@ ohos_unittest("DSpeakerDevTest") { configs = [ ":module_private_config" ] deps = [ - "${audio_transport_path}/encodetransport:distributed_audio_encode_transport", + "${audio_transport_path}/senderengine:distributed_audio_encode_transport", "${services_path}/audiomanager/servicesource:distributed_audio_source", "//third_party/googletest:gmock", "//third_party/googletest:gtest_main", diff --git a/services/audiomanager/test/unittest/sourcedevice/src/daudio_source_dev_test.cpp b/services/audiomanager/test/unittest/sourcedevice/src/daudio_source_dev_test.cpp index a369e004a2b10e29fd6f9b6e6a1ed6760686d9fa..e14e6a3c6dc01092104f2c47d277391ad7f56daf 100644 --- a/services/audiomanager/test/unittest/sourcedevice/src/daudio_source_dev_test.cpp +++ b/services/audiomanager/test/unittest/sourcedevice/src/daudio_source_dev_test.cpp @@ -15,9 +15,6 @@ #include "daudio_source_dev_test.h" -#include "audio_encode_transport.h" -#include "audio_decode_transport.h" - using namespace testing::ext; namespace OHOS { @@ -632,7 +629,7 @@ HWTEST_F(DAudioSourceDevTest, TaskCloseDSpeaker_002, TestSize.Level1) auto speaker = std::make_shared(DEV_ID, sourceDev_); int32_t dhId = DEFAULT_RENDER_ID; sourceDev_->deviceMap_[dhId] = speaker; - speaker->speakerTrans_ = std::make_shared(DEV_ID); + speaker->speakerTrans_ = std::make_shared(DEV_ID, speaker); json jParam_spk = { { KEY_DH_ID, DH_ID_SPK } }; EXPECT_EQ(ERR_DH_AUDIO_FAILED, sourceDev_->TaskCloseDSpeaker(jParam_spk.dump())); @@ -701,7 +698,7 @@ HWTEST_F(DAudioSourceDevTest, TaskCloseDMic_002, TestSize.Level1) auto mic = std::make_shared(DEV_ID, sourceDev_); int32_t dhId = DEFAULT_CAPTURE_ID; sourceDev_->deviceMap_[dhId] = mic; - mic->micTrans_ = std::make_shared(DEV_ID); + mic->micTrans_ = std::make_shared(DEV_ID, mic); json jParam_mic = { { KEY_DH_ID, DH_ID_MIC } }; EXPECT_EQ(DH_SUCCESS, sourceDev_->TaskCloseDMic(jParam_mic.dump())); @@ -747,7 +744,7 @@ HWTEST_F(DAudioSourceDevTest, TaskSetVolume_001, TestSize.Level1) json jParam = { { STREAM_MUTE_STATUS, 3 }, { "dhId", "3" } }; auto speaker = std::make_shared(DEV_ID, sourceDev_); sourceDev_->deviceMap_[dhId] = speaker; - speaker->speakerTrans_ = std::make_shared(DEV_ID); + speaker->speakerTrans_ = std::make_shared(DEV_ID, speaker); EXPECT_EQ(DH_SUCCESS, sourceDev_->TaskSetVolume(jParam.dump())); } diff --git a/services/audiomanager/test/unittest/sourcedevice/src/dmic_dev_test.cpp b/services/audiomanager/test/unittest/sourcedevice/src/dmic_dev_test.cpp index 5afce04b5182a4fd595b2a1004410638bd03ebfd..bfe29a877ba7387eab3cf941f1a9cfbc304f28c1 100644 --- a/services/audiomanager/test/unittest/sourcedevice/src/dmic_dev_test.cpp +++ b/services/audiomanager/test/unittest/sourcedevice/src/dmic_dev_test.cpp @@ -15,8 +15,6 @@ #include "dmic_dev_test.h" -#include "audio_decode_transport.h" - using namespace testing::ext; namespace OHOS { @@ -185,7 +183,7 @@ HWTEST_F(DMicDevTest, Start_001, TestSize.Level1) mic_->micTrans_ = nullptr; EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, mic_->Start()); - mic_->micTrans_ = std::make_shared(DEV_ID); + mic_->micTrans_ = std::make_shared(DEV_ID, mic_); EXPECT_NE(DH_SUCCESS, mic_->Start()); EXPECT_FALSE(mic_->IsOpened()); @@ -228,7 +226,7 @@ HWTEST_F(DMicDevTest, Stop_001, TestSize.Level1) mic_->micTrans_ = nullptr; EXPECT_EQ(DH_SUCCESS, mic_->Stop()); - mic_->micTrans_ = std::make_shared(DEV_ID); + mic_->micTrans_ = std::make_shared(DEV_ID, mic_); EXPECT_EQ(DH_SUCCESS, mic_->Stop()); mic_->micTrans_ = std::make_shared(); @@ -262,8 +260,8 @@ HWTEST_F(DMicDevTest, Release_001, TestSize.Level1) mic_->micTrans_ = nullptr; EXPECT_EQ(DH_SUCCESS, mic_->Release()); - mic_->micTrans_ = std::make_shared(DEV_ID); - EXPECT_EQ(DH_SUCCESS, mic_->Release()); + mic_->micTrans_ = std::make_shared(DEV_ID, mic_); + EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, mic_->Release()); mic_->micTrans_ = std::make_shared(); EXPECT_EQ(DH_SUCCESS, mic_->Release()); diff --git a/services/audiomanager/test/unittest/sourcedevice/src/dspeaker_dev_test.cpp b/services/audiomanager/test/unittest/sourcedevice/src/dspeaker_dev_test.cpp index e3aae6f8e047a1546d330548aee359611d08fd07..079f20000e75fb3dbc7c9bb18638dc083e8557dd 100644 --- a/services/audiomanager/test/unittest/sourcedevice/src/dspeaker_dev_test.cpp +++ b/services/audiomanager/test/unittest/sourcedevice/src/dspeaker_dev_test.cpp @@ -15,8 +15,6 @@ #include "dspeaker_dev_test.h" -#include "audio_encode_transport.h" - using namespace testing::ext; namespace OHOS { @@ -182,7 +180,7 @@ HWTEST_F(DSpeakerDevTest, Start_001, TestSize.Level1) spk_->speakerTrans_ = nullptr; EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, spk_->Start()); - spk_->speakerTrans_ = std::make_shared(DEV_ID); + spk_->speakerTrans_ = std::make_shared(DEV_ID, spk_); EXPECT_NE(DH_SUCCESS, spk_->Start()); EXPECT_FALSE(spk_->IsOpened()); } @@ -262,7 +260,7 @@ HWTEST_F(DSpeakerDevTest, Pause_001, TestSize.Level1) spk_->speakerTrans_ = nullptr; EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, spk_->Pause()); - spk_->speakerTrans_ = std::make_shared(DEV_ID); + spk_->speakerTrans_ = std::make_shared(DEV_ID, spk_); EXPECT_NE(DH_SUCCESS, spk_->Pause()); spk_->speakerTrans_ = std::make_shared(); @@ -290,7 +288,7 @@ HWTEST_F(DSpeakerDevTest, Restart_001, TestSize.Level1) .ext = "Test", }; EXPECT_EQ(DH_SUCCESS, spk_->SetParameters(DEV_ID, DH_ID, param)); - spk_->speakerTrans_ = std::make_shared(DEV_ID); + spk_->speakerTrans_ = std::make_shared(DEV_ID, spk_); EXPECT_NE(DH_SUCCESS, spk_->Restart()); spk_->speakerTrans_ = std::make_shared(); @@ -308,7 +306,7 @@ HWTEST_F(DSpeakerDevTest, Release_001, TestSize.Level1) spk_->speakerTrans_ = nullptr; EXPECT_EQ(DH_SUCCESS, spk_->Release()); - spk_->speakerTrans_ = std::make_shared(DEV_ID); + spk_->speakerTrans_ = std::make_shared(DEV_ID, spk_); EXPECT_EQ(DH_SUCCESS, spk_->Release()); spk_->speakerTrans_ = std::make_shared(); @@ -344,7 +342,7 @@ HWTEST_F(DSpeakerDevTest, WriteStreamData_002, TestSize.Level1) { const size_t capacity = 1; auto writeData = std::make_shared(capacity); - spk_->speakerTrans_ = std::make_shared(DEV_ID); + spk_->speakerTrans_ = std::make_shared(DEV_ID, spk_); EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, spk_->WriteStreamData(DEV_ID, DH_ID, writeData)); spk_->speakerTrans_ = std::make_shared(); diff --git a/services/audioprocessor/interface/iaudio_codec.h b/services/audioprocessor/interface/iaudio_codec.h deleted file mode 100644 index 515d96acafb6054ee145f2c4168098df127ce743..0000000000000000000000000000000000000000 --- a/services/audioprocessor/interface/iaudio_codec.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2022 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_IAUDIO_CODEC_H -#define OHOS_IAUDIO_CODEC_H - -#include - -#include "audio_param.h" -#include "audio_data.h" -#include "iaudio_codec.h" -#include "iaudio_codec_callback.h" - -namespace OHOS { -namespace DistributedHardware { -class IAudioCodec { -public: - IAudioCodec() = default; - virtual ~IAudioCodec() = default; - - virtual int32_t ConfigureAudioCodec(const AudioCommonParam &codecParam, - const std::shared_ptr &codecCallback) = 0; - virtual int32_t ReleaseAudioCodec() = 0; - virtual int32_t StartAudioCodec() = 0; - virtual int32_t StopAudioCodec() = 0; - virtual int32_t FeedAudioData(const std::shared_ptr &inputData) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_IAUDIO_CODEC_H diff --git a/services/audioprocessor/interface/iaudio_codec_callback.h b/services/audioprocessor/interface/iaudio_codec_callback.h deleted file mode 100644 index ed95e5638eeceb74d7e21bfaf5da83823421d049..0000000000000000000000000000000000000000 --- a/services/audioprocessor/interface/iaudio_codec_callback.h +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2022 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_IAUDIO_CODEC_CALLBACK_H -#define OHOS_IAUDIO_CODEC_CALLBACK_H - -#include - -#include "audio_data.h" -#include "audio_event.h" - -namespace OHOS { -namespace DistributedHardware { -class IAudioCodecCallback { -public: - IAudioCodecCallback() = default; - virtual ~IAudioCodecCallback() = default; - - virtual void OnCodecDataDone(const std::shared_ptr &outputData) = 0; - virtual void OnCodecStateNotify(const AudioEvent &event) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_IAUDIO_CODEC_CALLBACK_H diff --git a/services/audioprocessor/test/unittest/BUILD.gn b/services/audioprocessor/test/unittest/BUILD.gn index 342e1d6e84a7b6dd7c6f4f3b6ea0f5708e39ae23..7f887d6b5b5a7115aa9afb2c3695cbbfb5420296 100644 --- a/services/audioprocessor/test/unittest/BUILD.gn +++ b/services/audioprocessor/test/unittest/BUILD.gn @@ -17,5 +17,5 @@ import("../../../../distributedaudio.gni") group("daudio_processor_test") { testonly = true - deps = [ "${audio_processor_path}/test/unittest/common/decodeprocessor:decode_processor_test" ] + deps = [ "${audio_processor_path}/test/unittest/common/directprocessor:decode_processor_test" ] } diff --git a/services/audioprocessor/test/unittest/common/audio_processor_callback_test.h b/services/audioprocessor/test/unittest/common/audio_processor_callback_test.h deleted file mode 100644 index 8cbe899bdc8bca07ced500b9bbff097c42e2125a..0000000000000000000000000000000000000000 --- a/services/audioprocessor/test/unittest/common/audio_processor_callback_test.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 2022 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_DAUDIO_PROCESSOR_CALLBACK_TEST_H -#define OHOS_DAUDIO_PROCESSOR_CALLBACK_TEST_H - -#include "audio_data.h" -#include "audio_event.h" -#include "daudio_log.h" -#include "iaudio_processor_callback.h" - -namespace OHOS { -namespace DistributedHardware { -class AudioProcessorCallbackTest : public IAudioProcessorCallback { -public: - AudioProcessorCallbackTest() {}; - ~AudioProcessorCallbackTest() = default; - - void OnAudioDataDone(const std::shared_ptr &outputData) override; - void OnStateNotify(const AudioEvent &event) override; - -private: - int32_t outputCnt_ = 0; -}; - -void AudioProcessorCallbackTest::OnAudioDataDone(const std::shared_ptr &outputData) -{ - DHLOGD("Test : On audio data done."); - outputCnt_++; - DHLOGD("Test : output the [%d]th processed audiodata, size %d sucessfuly.", outputCnt_, outputData->Size()); -} - -void AudioProcessorCallbackTest::OnStateNotify(const AudioEvent &event) -{ - DHLOGE("Test : On state notify, event: %d.", event.type); -} -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_DAUDIO_PROCESSOR_CALLBACK_TEST_H \ No newline at end of file diff --git a/services/audioprocessor/test/unittest/common/decoder_callback_test.h b/services/audioprocessor/test/unittest/common/decoder_callback_test.h deleted file mode 100644 index 36158cc7bb644d0e6a8b43c9f6dcbdb8dd2e26b7..0000000000000000000000000000000000000000 --- a/services/audioprocessor/test/unittest/common/decoder_callback_test.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2022 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_DECODER_CALLBACK_TEST_H -#define OHOS_DECODER_CALLBACK_TEST_H - -#include "audio_data.h" -#include "audio_event.h" -#include "daudio_log.h" -#include "iaudio_codec_callback.h" -#include "iaudio_codec.h" -#include "audio_param.h" -#include "securec.h" - -#include "avcodec_common.h" -#include "media_errors.h" -#include "format.h" - -namespace OHOS { -namespace DistributedHardware { -class AudioDecoderCallbackTest : public IAudioCodecCallback { -public: - AudioDecoderCallbackTest() {}; - ~AudioDecoderCallbackTest() = default; - - void OnCodecDataDone(const std::shared_ptr &outputData) override; - void OnCodecStateNotify(const AudioEvent &event) override; -}; - -void AudioDecoderCallbackTest::OnCodecDataDone(const std::shared_ptr &outputData) -{ - (void)outputData; -} - -void AudioDecoderCallbackTest::OnCodecStateNotify(const AudioEvent &event) -{ - (void)event; -} -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_DECODER_CALLBACK_TEST_H \ No newline at end of file diff --git a/services/audioprocessor/test/unittest/common/decodeprocessor/BUILD.gn b/services/audioprocessor/test/unittest/common/directprocessor/BUILD.gn similarity index 87% rename from services/audioprocessor/test/unittest/common/decodeprocessor/BUILD.gn rename to services/audioprocessor/test/unittest/common/directprocessor/BUILD.gn index 226c325b75ae8d56aa53ef998a6b3b5627c2d20f..d03348aadcd0500bb1d52427d45c5d4827356938 100644 --- a/services/audioprocessor/test/unittest/common/decodeprocessor/BUILD.gn +++ b/services/audioprocessor/test/unittest/common/directprocessor/BUILD.gn @@ -17,7 +17,7 @@ import("//build/test.gni") import("../../../../../../distributedaudio.gni") module_output_path = - "distributed_audio/services/audioprocessor/decode_processor_test" + "distributed_audio/services/audioprocessor/direct_processor_test" config("module_private_config") { visibility = [ ":*" ] @@ -35,19 +35,18 @@ config("module_private_config") { "${services_path}/common/audiodata/include", "${audio_processor_path}/directprocessor/include", "${audio_processor_path}/interface", - "${audio_processor_path}/test/unittest/common", ] } ohos_unittest("DirectProcessorTest") { module_out_path = module_output_path - sources = [ "../directprocessor/audio_direct_processor_test.cpp" ] + sources = [ "audio_direct_processor_test.cpp" ] configs = [ ":module_private_config" ] deps = [ - "${audio_transport_path}/decodetransport:distributed_audio_decode_transport", + "${audio_transport_path}/receiverengine:distributed_audio_decode_transport", "${services_path}/common:distributed_audio_utils", "//third_party/googletest:gtest_main", ] diff --git a/services/audioprocessor/test/unittest/common/encoder_callback_test.h b/services/audioprocessor/test/unittest/common/encoder_callback_test.h deleted file mode 100644 index b4c4130cfdab293966e1cf34dcfe16c70aa7386b..0000000000000000000000000000000000000000 --- a/services/audioprocessor/test/unittest/common/encoder_callback_test.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (c) 2022 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_ENCODER_CALLBACK_TEST_H -#define OHOS_ENCODER_CALLBACK_TEST_H - -#include "audio_data.h" -#include "audio_event.h" -#include "daudio_log.h" -#include "iaudio_codec_callback.h" -#include "iaudio_codec.h" -#include "audio_param.h" -#include "securec.h" - -#include "avcodec_common.h" -#include "media_errors.h" -#include "format.h" - -namespace OHOS { -namespace DistributedHardware { -class AudioEncoderCallbackTest : public IAudioCodecCallback { -public: - AudioEncoderCallbackTest() {}; - ~AudioEncoderCallbackTest() = default; - - void OnCodecDataDone(const std::shared_ptr &outputData) override; - void OnCodecStateNotify(const AudioEvent &event) override; -}; - -void AudioEncoderCallbackTest::OnCodecDataDone(const std::shared_ptr &outputData) -{ - (void)outputData; -} - -void AudioEncoderCallbackTest::OnCodecStateNotify(const AudioEvent &event) -{ - (void)event; -} -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_ENCODER_CALLBACK_TEST_H \ No newline at end of file diff --git a/services/audiotransport/audiochannel/audiodatachannel/BUILD.gn b/services/audiotransport/audiochannel/audiodatachannel/BUILD.gn deleted file mode 100644 index 2ce556161ebab720944a38e804a076c545ff7f93..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiochannel/audiodatachannel/BUILD.gn +++ /dev/null @@ -1,61 +0,0 @@ -# Copyright (c) 2022 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("//build/ohos_var.gni") -import("../../../../distributedaudio.gni") - -ohos_shared_library("distributed_audio_data_channel") { - branch_protector_ret = "pac_ret" - sanitize = { - boundary_sanitize = true - cfi = true - cfi_cross_dso = true - debug = false - integer_overflow = true - ubsan = true - } - stack_protector_ret = true - include_dirs = [ - "${fwk_common_path}/utils/include", - "//third_party/json/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - "${common_path}/dfx_utils/include", - "${services_path}/common/audioparam", - "${services_path}/common/audiodata/include", - "${audio_transport_path}/audiochannel/interface", - ] - - sources = [ "src/audio_data_channel.cpp" ] - - deps = [ "${services_path}/common:distributed_audio_utils" ] - - external_deps = [ - "c_utils:utils", - "dsoftbus:softbus_client", - "hitrace:hitrace_meter", - ] - - defines = [ - "HI_LOG_ENABLE", - "LOG_DOMAIN=0xD004100", - ] - - subsystem_name = "distributedhardware" - - part_name = "distributed_audio" -} diff --git a/services/audiotransport/audiochannel/audiodatachannel/include/audio_data_channel.h b/services/audiotransport/audiochannel/audiodatachannel/include/audio_data_channel.h deleted file mode 100644 index 4bf679b6767a564e71f7cda5d0778defcd0b1709..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiochannel/audiodatachannel/include/audio_data_channel.h +++ /dev/null @@ -1,52 +0,0 @@ - /* - * Copyright (c) 2022 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_AUDIO_DATA_CHANNEL_H -#define OHOS_AUDIO_DATA_CHANNEL_H - -#include -#include - -#include "iaudio_channel_listener.h" -#include "iaudio_channel.h" -#include "daudio_errorcode.h" -#include "daudio_log.h" -#include "daudio_util.h" - -namespace OHOS { -namespace DistributedHardware { -class AudioDataChannel : public IAudioChannel, - public std::enable_shared_from_this { -public: - explicit AudioDataChannel(const std::string &peerDevId) : peerDevId_(peerDevId) {}; - ~AudioDataChannel() override = default; - - int32_t CreateSession(const std::shared_ptr &listener, - const std::string &sessionName) override; - int32_t ReleaseSession() override; - int32_t OpenSession() override; - int32_t CloseSession() override; - int32_t SendData(const std::shared_ptr &audioData) override; - int32_t SendEvent(const AudioEvent &audioEvent) override; - -private: - const std::string peerDevId_; - int32_t sessionId_ = 0; - std::string sessionName_; - std::weak_ptr channelListener_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_AUDIO_DATA_CHANNEL_H diff --git a/services/audiotransport/audiochannel/audiodatachannel/src/audio_data_channel.cpp b/services/audiotransport/audiochannel/audiodatachannel/src/audio_data_channel.cpp deleted file mode 100644 index 3da91b9f2609416c5ebcfba4a5d4bc6316aa750e..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiochannel/audiodatachannel/src/audio_data_channel.cpp +++ /dev/null @@ -1,79 +0,0 @@ - /* - * Copyright (c) 2022 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 "audio_data_channel.h" - -#include - -#include "daudio_hitrace.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioDataChannel" - -namespace OHOS { -namespace DistributedHardware { -int32_t AudioDataChannel::CreateSession(const std::shared_ptr &listener, - const std::string &sessionName) -{ - DHLOGI("Create session, peerDevId: %s.", GetAnonyString(peerDevId_).c_str()); - CHECK_NULL_RETURN(listener, ERR_DH_AUDIO_NULLPTR); - channelListener_ = listener; - sessionName_ = sessionName; - DHLOGI("Create softbus session success."); - return DH_SUCCESS; -} - -int32_t AudioDataChannel::ReleaseSession() -{ - DHLOGI("Release session, peerDevId: %s.", GetAnonyString(peerDevId_).c_str()); - channelListener_.reset(); - - DHLOGI("Release softbus session success."); - return DH_SUCCESS; -} - -int32_t AudioDataChannel::OpenSession() -{ - DHLOGI("Open session, peerDevId: %s.", GetAnonyString(peerDevId_).c_str()); - - DHLOGI("Open audio session success, sessionId: %d.", sessionId_); - return DH_SUCCESS; -} - -int32_t AudioDataChannel::CloseSession() -{ - DHLOGI("Close session, sessionId: %d.", sessionId_); - if (sessionId_ == 0) { - DHLOGD("Session is already close."); - return DH_SUCCESS; - } - - DHLOGI("Close audio session success."); - return DH_SUCCESS; -} - -int32_t AudioDataChannel::SendEvent(const AudioEvent &audioEvent) -{ - (void) audioEvent; - return DH_SUCCESS; -} - -int32_t AudioDataChannel::SendData(const std::shared_ptr &audioData) -{ - DHLOGD("Send data, sessionId: %d.", sessionId_); - return DH_SUCCESS; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/audiotransport/audiochannel/interface/iaudio_channel.h b/services/audiotransport/audiochannel/interface/iaudio_channel.h deleted file mode 100644 index 502d481080b4da0514970823caff2d56481bed9e..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiochannel/interface/iaudio_channel.h +++ /dev/null @@ -1,39 +0,0 @@ - /* - * Copyright (c) 2022 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_ISAUDIO_CHANNEL_H -#define OHOS_ISAUDIO_CHANNEL_H - -#include "audio_data.h" -#include "audio_event.h" -#include "iaudio_channel_listener.h" - -namespace OHOS { -namespace DistributedHardware { -class IAudioChannel { -public: - virtual ~IAudioChannel() = default; - - virtual int32_t CreateSession(const std::shared_ptr &listener, - const std::string &sessionName) = 0; - virtual int32_t ReleaseSession() = 0; - virtual int32_t OpenSession() = 0; - virtual int32_t CloseSession() = 0; - virtual int32_t SendData(const std::shared_ptr &data) = 0; - virtual int32_t SendEvent(const AudioEvent &event) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_ISAUDIO_CHANNEL_H diff --git a/services/audiotransport/audiochannel/interface/iaudio_channel_listener.h b/services/audiotransport/audiochannel/interface/iaudio_channel_listener.h deleted file mode 100644 index 21f9850c393854f3d8bc3a2d43f30b7693ff79bc..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiochannel/interface/iaudio_channel_listener.h +++ /dev/null @@ -1,35 +0,0 @@ - /* - * Copyright (c) 2022 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_IAUDIO_CHANNEL_LISTENER_H -#define OHOS_IAUDIO_CHANNEL_LISTENER_H - -#include "audio_data.h" -#include "audio_event.h" - -namespace OHOS { -namespace DistributedHardware { -class IAudioChannelListener { -public: - virtual ~IAudioChannelListener() = default; - - virtual void OnSessionOpened() = 0; - virtual void OnSessionClosed() = 0; - virtual void OnDataReceived(const std::shared_ptr &data) = 0; - virtual void OnEventReceived(const AudioEvent &event) = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_IAUDIO_CHANNEL_LISTENER_H diff --git a/services/audiotransport/audiotransportstatus/BUILD.gn b/services/audiotransport/audiotransportstatus/BUILD.gn deleted file mode 100644 index 916fe9582d16e8ddab3750aa0024f8fc32d7a9ee..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiotransportstatus/BUILD.gn +++ /dev/null @@ -1,80 +0,0 @@ -# Copyright (c) 2022 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("//build/ohos_var.gni") -import("../../../distributedaudio.gni") - -ohos_shared_library("distributed_audio_transport_status") { - sanitize = { - boundary_sanitize = true - cfi = true - cfi_cross_dso = true - debug = false - integer_overflow = true - ubsan = true - } - stack_protector_ret = true - include_dirs = [ - "${fwk_common_path}/utils/include", - "${mediastandard_path}/interfaces/innerkits/native/media/include", - "${mediastandardfwk_path}/audiocommon/include", - "//third_party/json/include", - ] - - include_dirs += [ - "include", - "interface", - "${common_path}/include", - "${audio_processor_path}/decoder/include", - "${audio_processor_path}/decodeprocessor/include", - "${audio_processor_path}/interface", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audiochannel/audiodatachannel/include", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", - "${audio_transport_path}/audiotransportstatus/interface", - "${services_path}/common/audioparam", - "${services_path}/common/audiodata/include", - ] - - sources = [ - "${audio_transport_path}/audiotransportstatus/src/audio_transport_context.cpp", - "${audio_transport_path}/audiotransportstatus/src/audio_transport_pause_status.cpp", - "${audio_transport_path}/audiotransportstatus/src/audio_transport_start_status.cpp", - "${audio_transport_path}/audiotransportstatus/src/audio_transport_status_factory.cpp", - "${audio_transport_path}/audiotransportstatus/src/audio_transport_stop_status.cpp", - ] - - deps = [ - "${audio_transport_path}/audiochannel/audiodatachannel:distributed_audio_data_channel", - "${services_path}/common:distributed_audio_utils", - ] - - external_deps = [ - "c_utils:utils", - "dsoftbus:softbus_client", - "hisysevent:libhisysevent", - "hitrace:hitrace_meter", - "player_framework:media_client", - ] - - defines = [ - "HI_LOG_ENABLE", - "LOG_DOMAIN=0xD004100", - ] - - subsystem_name = "distributedhardware" - - part_name = "distributed_audio" -} diff --git a/services/audiotransport/audiotransportstatus/include/audio_transport_context.h b/services/audiotransport/audiotransportstatus/include/audio_transport_context.h deleted file mode 100644 index 8b2dd9f018b8fdeacab2894929b301c89d092fe7..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiotransportstatus/include/audio_transport_context.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2021 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 AUDIO_TRANSPORT_CONTEXT_H -#define AUDIO_TRANSPORT_CONTEXT_H - -#include "audio_transport_status.h" -#include "iaudio_channel.h" -#include "iaudio_processor.h" - -namespace OHOS { -namespace DistributedHardware { -class AudioTransportContext : public std::enable_shared_from_this { -public: - AudioTransportContext() = default; - ~AudioTransportContext() = default; - void SetTransportStatus(TransportStateType stateType); - int32_t GetTransportStatusType(); - void SetAudioChannel(std::shared_ptr &audioChannel); - void SetAudioProcessor(std::shared_ptr &processor); - int32_t Start(); - int32_t Stop(); - int32_t Pause(); - int32_t Restart(const AudioParam &localParam, const AudioParam &remoteParam); - -private: - std::shared_ptr currentState_; - std::shared_ptr audioChannel_ = nullptr; - std::shared_ptr processor_ = nullptr; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // AUDIO_TRANSPORT_CONTEXT_H diff --git a/services/audiotransport/audiotransportstatus/include/audio_transport_pause_status.h b/services/audiotransport/audiotransportstatus/include/audio_transport_pause_status.h deleted file mode 100644 index 8aebbe6440d4766d6c14398560342e0abfe7691e..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiotransportstatus/include/audio_transport_pause_status.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2021 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 AUDIO_TRANSPORT_PAUSE_STATUS_H -#define AUDIO_TRANSPORT_PAUSE_STATUS_H - -#include "audio_transport_context.h" - -namespace OHOS { -namespace DistributedHardware { -class AudioTransportPauseStatus : public AudioTransportStatus { -public: - explicit AudioTransportPauseStatus(std::shared_ptr& stateContext); - ~AudioTransportPauseStatus() override {} - int32_t Start(std::shared_ptr audioChannel, std::shared_ptr processor) override; - int32_t Stop(std::shared_ptr audioChannel, std::shared_ptr processor) override; - int32_t Pause(std::shared_ptr processor) override; - int32_t Restart(const AudioParam &localParam, const AudioParam &remoteParam, - std::shared_ptr processor) override; - TransportStateType GetStateType() override; - -private: - std::weak_ptr stateContext_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // AUDIO_TRANSPORT_PAUSE_STATUS_H diff --git a/services/audiotransport/audiotransportstatus/include/audio_transport_start_status.h b/services/audiotransport/audiotransportstatus/include/audio_transport_start_status.h deleted file mode 100644 index f7ce80245c4a477276a13de3afe55f8254e6db76..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiotransportstatus/include/audio_transport_start_status.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2021 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 AUDIO_TRANSPORT_START_STATUS_H -#define AUDIO_TRANSPORT_START_STATUS_H - -#include "audio_transport_context.h" - -namespace OHOS { -namespace DistributedHardware { -class AudioTransportStartStatus : public AudioTransportStatus { -public: - explicit AudioTransportStartStatus(std::shared_ptr& stateContext); - ~AudioTransportStartStatus() override {} - int32_t Start(std::shared_ptr audioChannel, std::shared_ptr processor) override; - int32_t Stop(std::shared_ptr audioChannel, std::shared_ptr processor) override; - int32_t Pause(std::shared_ptr processor) override; - int32_t Restart(const AudioParam &localParam, const AudioParam &remoteParam, - std::shared_ptr processor) override; - TransportStateType GetStateType() override; - -private: - std::weak_ptr stateContext_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // AUDIO_TRANSPORT_START_STATUS_H diff --git a/services/audiotransport/audiotransportstatus/include/audio_transport_status_factory.h b/services/audiotransport/audiotransportstatus/include/audio_transport_status_factory.h deleted file mode 100644 index 99dfef36b756c29caf7230561a4071c058365c79..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiotransportstatus/include/audio_transport_status_factory.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Copyright (c) 2021 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 AUDIO_TRANSPORT_STATUS_FACTORY_H -#define AUDIO_TRANSPORT_STATUS_FACTORY_H - -#include "audio_transport_context.h" -#include "audio_transport_status.h" -#include "single_instance.h" - -namespace OHOS { -namespace DistributedHardware { -class AudioTransportStatusFactory { -DECLARE_SINGLE_INSTANCE(AudioTransportStatusFactory); -public: - std::shared_ptr CreateState(TransportStateType stateType, - std::shared_ptr& stateContext); -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // AUDIO_TRANSPORT_STATUS_FACTORY_H diff --git a/services/audiotransport/audiotransportstatus/include/audio_transport_stop_status.h b/services/audiotransport/audiotransportstatus/include/audio_transport_stop_status.h deleted file mode 100644 index 32260d8d9de380544d1d9f52706e1cc2d65c55e7..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiotransportstatus/include/audio_transport_stop_status.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2021 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 AUDIO_TRANSPORT_STOP_STATUS_H -#define AUDIO_TRANSPORT_STOP_STATUS_H - -#include "audio_transport_context.h" - -namespace OHOS { -namespace DistributedHardware { -class AudioTransportStopStatus : public AudioTransportStatus { -public: - explicit AudioTransportStopStatus(std::shared_ptr& stateContext); - ~AudioTransportStopStatus() override {} - int32_t Start(std::shared_ptr audioChannel, std::shared_ptr processor) override; - int32_t Stop(std::shared_ptr audioChannel, std::shared_ptr processor) override; - int32_t Pause(std::shared_ptr processor) override; - int32_t Restart(const AudioParam &localParam, const AudioParam &remoteParam, - std::shared_ptr processor) override; - TransportStateType GetStateType() override; - -private: - std::weak_ptr stateContext_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // AUDIO_TRANSPORT_STOP_STATUS_H diff --git a/services/audiotransport/audiotransportstatus/interface/audio_transport_status.h b/services/audiotransport/audiotransportstatus/interface/audio_transport_status.h deleted file mode 100644 index 24d46ff972190d38ec4ce62ed008d1437b3b957a..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiotransportstatus/interface/audio_transport_status.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2022 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 AUDIO_TRANSPORT_STATUS_H -#define AUDIO_TRANSPORT_STATUS_H - -#include "audio_param.h" -#include "iaudio_channel.h" -#include "iaudio_processor.h" - -namespace OHOS { -namespace DistributedHardware { -typedef enum { - TRANSPORT_STATE_START = 0, - TRANSPORT_STATE_PAUSE = 1, - TRANSPORT_STATE_STOP = 2, -} TransportStateType; - -class AudioTransportStatus { -public: - AudioTransportStatus() = default; - virtual ~AudioTransportStatus() = default; - virtual int32_t Start(std::shared_ptr audioChannel, std::shared_ptr processor) = 0; - virtual int32_t Stop(std::shared_ptr audioChannel, std::shared_ptr processor) = 0; - virtual int32_t Pause(std::shared_ptr processor) = 0; - virtual int32_t Restart(const AudioParam &localParam, const AudioParam &remoteParam, - std::shared_ptr processor) = 0; - virtual TransportStateType GetStateType() = 0; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // AUDIO_TRANSPORT_STATUS_H diff --git a/services/audiotransport/audiotransportstatus/src/audio_transport_context.cpp b/services/audiotransport/audiotransportstatus/src/audio_transport_context.cpp deleted file mode 100644 index 7c7e154d63b59ee11d6a9e5f64b8e4a58583cdf8..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiotransportstatus/src/audio_transport_context.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2021 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 "audio_transport_context.h" -#include "audio_transport_status_factory.h" - -#include "daudio_errorcode.h" -#include "daudio_log.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioTransportContext" - -namespace OHOS { -namespace DistributedHardware { -void AudioTransportContext::SetTransportStatus(TransportStateType stateType) -{ - DHLOGD("Set transport status in state %d", stateType); - auto stateContext = std::shared_ptr(shared_from_this()); - currentState_ = AudioTransportStatusFactory::GetInstance().CreateState(stateType, stateContext); -} - -int32_t AudioTransportContext::GetTransportStatusType() -{ - CHECK_NULL_RETURN(currentState_, ERR_DH_AUDIO_NULLPTR); - DHLOGI("Get transport status in state %d", currentState_->GetStateType()); - return currentState_->GetStateType(); -} - -int32_t AudioTransportContext::Start() -{ - CHECK_NULL_RETURN(currentState_, ERR_DH_AUDIO_NULLPTR); - DHLOGI("Audio transport context start."); - return currentState_->Start(audioChannel_, processor_); -} - -int32_t AudioTransportContext::Stop() -{ - CHECK_NULL_RETURN(currentState_, ERR_DH_AUDIO_NULLPTR); - DHLOGI("Audio transport context stop."); - return currentState_->Stop(audioChannel_, processor_); -} - -int32_t AudioTransportContext::Pause() -{ - CHECK_NULL_RETURN(currentState_, ERR_DH_AUDIO_NULLPTR); - DHLOGI("Audio transport context pause."); - return currentState_->Pause(processor_); -} - -int32_t AudioTransportContext::Restart(const AudioParam &localParam, const AudioParam &remoteParam) -{ - CHECK_NULL_RETURN(currentState_, ERR_DH_AUDIO_NULLPTR); - DHLOGI("Audio transport context restart."); - return currentState_->Restart(localParam, remoteParam, processor_); -} - -void AudioTransportContext::SetAudioChannel(std::shared_ptr &audioChannel) -{ - audioChannel_ = audioChannel; -} - -void AudioTransportContext::SetAudioProcessor(std::shared_ptr &processor) -{ - processor_ = processor; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/audiotransport/audiotransportstatus/src/audio_transport_pause_status.cpp b/services/audiotransport/audiotransportstatus/src/audio_transport_pause_status.cpp deleted file mode 100644 index afe7fb329bf92d4d48e83ba1cad5d0e4b8b8d0d8..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiotransportstatus/src/audio_transport_pause_status.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * Copyright (c) 2021 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 "audio_transport_pause_status.h" - -#include "daudio_errorcode.h" -#include "daudio_log.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioTransportPauseStatus" - -namespace OHOS { -namespace DistributedHardware { -AudioTransportPauseStatus::AudioTransportPauseStatus(std::shared_ptr& stateContext) - : stateContext_(stateContext) -{ - DHLOGD("AudioTransportPauseStatus contruct."); -} - -int32_t AudioTransportPauseStatus::Start(std::shared_ptr audioChannel, - std::shared_ptr processor) -{ - (void)audioChannel; - (void)processor; - DHLOGE("Audiotransportstatus is pause, can not start."); - return ERR_DH_AUDIO_TRANS_ILLEGAL_OPERATION; -} - -int32_t AudioTransportPauseStatus::Stop(std::shared_ptr audioChannel, - std::shared_ptr processor) -{ - (void)processor; - DHLOGI("Audio transport status is pause."); - CHECK_NULL_RETURN(audioChannel, ERR_DH_AUDIO_NULLPTR); - int32_t ret = audioChannel->CloseSession(); - if (ret != DH_SUCCESS) { - DHLOGE("Close session failed, ret: %d.", ret); - return ret; - } - - std::shared_ptr stateContext = stateContext_.lock(); - CHECK_NULL_RETURN(stateContext, ERR_DH_AUDIO_NULLPTR); - stateContext->SetTransportStatus(TRANSPORT_STATE_STOP); - return DH_SUCCESS; -} - -int32_t AudioTransportPauseStatus::Pause(std::shared_ptr processor) -{ - (void)processor; - DHLOGI("Audio transport status is pasue."); - return DH_SUCCESS; -} - -int32_t AudioTransportPauseStatus::Restart(const AudioParam &localParam, const AudioParam &remoteParam, - std::shared_ptr processor) -{ - DHLOGI("Restart."); - CHECK_NULL_RETURN(processor, ERR_DH_AUDIO_NULLPTR); - auto ret = processor->StartAudioProcessor(); - if (ret != DH_SUCCESS) { - DHLOGE("Restart processor failed, ret: %d.", ret); - return ret; - } - - std::shared_ptr stateContext = stateContext_.lock(); - CHECK_NULL_RETURN(stateContext, ERR_DH_AUDIO_NULLPTR); - stateContext->SetTransportStatus(TRANSPORT_STATE_START); - DHLOGI("Restart success."); - return DH_SUCCESS; -} - -TransportStateType AudioTransportPauseStatus::GetStateType() -{ - DHLOGI("Audio transport get state stype."); - return TRANSPORT_STATE_PAUSE; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/audiotransport/audiotransportstatus/src/audio_transport_start_status.cpp b/services/audiotransport/audiotransportstatus/src/audio_transport_start_status.cpp deleted file mode 100644 index 8db19bf8a79e70d6b2fb1ea50aeb07f6bfbf7e80..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiotransportstatus/src/audio_transport_start_status.cpp +++ /dev/null @@ -1,101 +0,0 @@ -/* - * Copyright (c) 2021 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 "audio_transport_start_status.h" - -#include "daudio_errorcode.h" -#include "daudio_log.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioTransportStartStatus" - -namespace OHOS { -namespace DistributedHardware { -AudioTransportStartStatus::AudioTransportStartStatus(std::shared_ptr& stateContext) - : stateContext_(stateContext) -{ - DHLOGD("AudioTransportStartStatus contruct."); -} -int32_t AudioTransportStartStatus::Start(std::shared_ptr audioChannel, - std::shared_ptr processor) -{ - (void)audioChannel; - (void)processor; - DHLOGI("Audio transport status is start."); - return DH_SUCCESS; -} - -int32_t AudioTransportStartStatus::Stop(std::shared_ptr audioChannel, - std::shared_ptr processor) -{ - DHLOGI("Audio transport status is start."); - CHECK_NULL_RETURN(processor, ERR_DH_AUDIO_NULLPTR); - CHECK_NULL_RETURN(audioChannel, ERR_DH_AUDIO_NULLPTR); - - int32_t ret = processor->StopAudioProcessor(); - if (ret != DH_SUCCESS) { - DHLOGE("Stop audio processor failed, ret: %d.", ret); - return ret; - } - ret = audioChannel->CloseSession(); - if (ret != DH_SUCCESS) { - DHLOGE("Close session failed, ret: %d.", ret); - return ret; - } - std::shared_ptr stateContext = stateContext_.lock(); - CHECK_NULL_RETURN(stateContext, ERR_DH_AUDIO_BAD_VALUE); - stateContext->SetTransportStatus(TRANSPORT_STATE_STOP); - return DH_SUCCESS; -} - -int32_t AudioTransportStartStatus::Pause(std::shared_ptr processor) -{ - DHLOGI("Audio transport status is start."); - CHECK_NULL_RETURN(processor, ERR_DH_AUDIO_NULLPTR); - int32_t ret = processor->StopAudioProcessor(); - if (ret != DH_SUCCESS) { - DHLOGE("Pause processor failed, ret: %d.", ret); - return ret; - } - ret = processor->ReleaseAudioProcessor(); - if (ret != DH_SUCCESS) { - DHLOGE("Release audio processor failed, ret: %d.", ret); - return ret; - } - - std::shared_ptr stateContext = stateContext_.lock(); - CHECK_NULL_RETURN(stateContext, ERR_DH_AUDIO_BAD_VALUE); - stateContext->SetTransportStatus(TRANSPORT_STATE_PAUSE); - DHLOGI("Pause success."); - return DH_SUCCESS; -} - -int32_t AudioTransportStartStatus::Restart(const AudioParam &localParam, const AudioParam &remoteParam, - std::shared_ptr processor) -{ - (void)localParam; - (void)remoteParam; - (void)processor; - DHLOGE("Audio transport status is start."); - return DH_SUCCESS; -} - -TransportStateType AudioTransportStartStatus::GetStateType() -{ - DHLOGD("Get audio transport status."); - return TRANSPORT_STATE_START; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/audiotransport/audiotransportstatus/src/audio_transport_status_factory.cpp b/services/audiotransport/audiotransportstatus/src/audio_transport_status_factory.cpp deleted file mode 100644 index 4149c54b13367ec105bff4c3905c9956b25f37cc..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiotransportstatus/src/audio_transport_status_factory.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2021 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 "audio_transport_status_factory.h" - -#include "audio_transport_pause_status.h" -#include "audio_transport_start_status.h" -#include "audio_transport_status.h" -#include "audio_transport_stop_status.h" -#include "daudio_errorcode.h" -#include "daudio_log.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioTransportStatusFactory" - -namespace OHOS { -namespace DistributedHardware { -IMPLEMENT_SINGLE_INSTANCE(AudioTransportStatusFactory); - -std::shared_ptr AudioTransportStatusFactory::CreateState(TransportStateType stateType, - std::shared_ptr& stateContext) -{ - std::shared_ptr state = nullptr; - switch (stateType) { - case TRANSPORT_STATE_START: { - state = std::make_shared(stateContext); - break; - } - case TRANSPORT_STATE_PAUSE: { - state = std::make_shared(stateContext); - break; - } - case TRANSPORT_STATE_STOP: { - state = std::make_shared(stateContext); - break; - } - default: { - DHLOGE("AudioTransportStatusFactory create state failed, wrong type %d", stateType); - return nullptr; - } - } - return state; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/audiotransport/audiotransportstatus/src/audio_transport_stop_status.cpp b/services/audiotransport/audiotransportstatus/src/audio_transport_stop_status.cpp deleted file mode 100644 index 4614ae82d172aa7d8a64644330a880fc625a6caf..0000000000000000000000000000000000000000 --- a/services/audiotransport/audiotransportstatus/src/audio_transport_stop_status.cpp +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2021 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 "audio_transport_stop_status.h" - -#include "daudio_errorcode.h" -#include "daudio_log.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioTransportStopStatus" - -namespace OHOS { -namespace DistributedHardware { -AudioTransportStopStatus::AudioTransportStopStatus(std::shared_ptr& stateContext) - : stateContext_(stateContext) -{ - DHLOGD("AudioTransportStopStatus contruct."); -} -int32_t AudioTransportStopStatus::Start(std::shared_ptr audioChannel, - std::shared_ptr processor) -{ - (void)audioChannel; - CHECK_NULL_RETURN(processor, ERR_DH_AUDIO_NULLPTR); - int32_t ret = processor->StartAudioProcessor(); - if (ret != DH_SUCCESS) { - DHLOGE("Open audio processor failed ret: %d.", ret); - processor = nullptr; - return ERR_DH_AUDIO_NULLPTR; - } - - std::shared_ptr stateContext = stateContext_.lock(); - CHECK_NULL_RETURN(stateContext, ERR_DH_AUDIO_BAD_VALUE); - stateContext->SetTransportStatus(TRANSPORT_STATE_START); - DHLOGI("Start success."); - return DH_SUCCESS; -} - -int32_t AudioTransportStopStatus::Stop(std::shared_ptr audioChannel, - std::shared_ptr processor) -{ - (void)audioChannel; - (void)processor; - DHLOGE("Audio transport status status is stop."); - return DH_SUCCESS; -} - -int32_t AudioTransportStopStatus::Pause(std::shared_ptr processor) -{ - (void)processor; - DHLOGE("Audio transport status is stop, can not pause."); - return ERR_DH_AUDIO_TRANS_ILLEGAL_OPERATION; -} - -int32_t AudioTransportStopStatus::Restart(const AudioParam &localParam, const AudioParam &remoteParam, - std::shared_ptr processor) -{ - (void)localParam; - (void)remoteParam; - (void)processor; - DHLOGE("Audio transport status status is stop, can not restart."); - return ERR_DH_AUDIO_TRANS_ILLEGAL_OPERATION; -} - -TransportStateType AudioTransportStopStatus::GetStateType() -{ - return TRANSPORT_STATE_STOP; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/audiotransport/decodetransport/include/audio_decode_transport.h b/services/audiotransport/decodetransport/include/audio_decode_transport.h deleted file mode 100644 index 90027e620008018a52cde112fb11533153f572a8..0000000000000000000000000000000000000000 --- a/services/audiotransport/decodetransport/include/audio_decode_transport.h +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright (c) 2022-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 AUDIO_DECODE_TRANSPORT_H -#define AUDIO_DECODE_TRANSPORT_H - -#include -#include -#include -#include - -#include "audio_event.h" -#include "audio_transport_context.h" -#include "daudio_constants.h" -#include "iaudio_channel.h" -#include "iaudio_datatrans_callback.h" -#include "iaudio_data_transport.h" -#include "iaudio_processor.h" -#include "iaudio_processor_callback.h" - -namespace OHOS { -namespace DistributedHardware { -class AudioDecodeTransport : public IAudioDataTransport, - public IAudioChannelListener, - public IAudioProcessorCallback, - public std::enable_shared_from_this { -public: - explicit AudioDecodeTransport(const std::string &peerDevId) : peerDevId_(peerDevId) - { - audioParam_.comParam.sampleRate = AudioSampleRate::SAMPLE_RATE_8000; - audioParam_.comParam.channelMask = AudioChannel::MONO; - audioParam_.comParam.bitFormat = AudioSampleFormat::SAMPLE_U8; - audioParam_.comParam.codecType = AudioCodecType::AUDIO_CODEC_AAC; - } - ~AudioDecodeTransport() override = default; - int32_t SetUp(const AudioParam &localParam, const AudioParam &remoteParam, - const std::shared_ptr &callback, const PortCapType capType) override; - int32_t Start() override; - int32_t Stop() override; - int32_t Release() override; - int32_t Pause() override; - int32_t Restart(const AudioParam &localParam, const AudioParam &remoteParam) override; - int32_t FeedAudioData(std::shared_ptr &audioData) override; - int32_t CreateCtrl() override; - int32_t InitEngine(IAVEngineProvider *providerPtr) override; - int32_t SendMessage(uint32_t type, std::string content, std::string dstDevId) override; - - void OnSessionOpened() override; - void OnSessionClosed() override; - void OnDataReceived(const std::shared_ptr &data) override; - void OnEventReceived(const AudioEvent &event) override; - - void OnAudioDataDone(const std::shared_ptr &outputData) override; - void OnStateNotify(const AudioEvent &event) override; - -private: - int32_t InitAudioDecodeTransport(const AudioParam &localParam, const AudioParam &remoteParam, - const PortCapType capType); - int32_t RegisterChannelListener(const PortCapType capType); - int32_t RegisterProcessorListener(const AudioParam &localParam, const AudioParam &remoteParam); - -private: - static constexpr size_t DATA_QUEUE_MAX_SIZE = 10; - static constexpr size_t SLEEP_TIME = 20000; - - std::weak_ptr dataTransCallback_; - std::shared_ptr audioChannel_ = nullptr; - std::shared_ptr processor_ = nullptr; - std::shared_ptr context_ = nullptr; - - std::mutex dataQueueMtx_; - std::queue> dataQueue_; - std::string peerDevId_; - AudioParam audioParam_; - PortCapType capType_ = CAP_UNKNOWN; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // AUDIO_DECODE_TRANSPORT_H diff --git a/services/audiotransport/decodetransport/src/audio_decode_transport.cpp b/services/audiotransport/decodetransport/src/audio_decode_transport.cpp deleted file mode 100644 index 9c129c291c1e9dc490a228359afece5ee08b1c36..0000000000000000000000000000000000000000 --- a/services/audiotransport/decodetransport/src/audio_decode_transport.cpp +++ /dev/null @@ -1,246 +0,0 @@ -/* - * Copyright (c) 2022-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 "audio_decode_transport.h" - -#include "audio_data_channel.h" -#include "audio_direct_processor.h" -#include "audio_param.h" -#include "daudio_errorcode.h" -#include "daudio_log.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioDecodeTransport" - -namespace OHOS { -namespace DistributedHardware { -int32_t AudioDecodeTransport::SetUp(const AudioParam &localParam, const AudioParam &remoteParam, - const std::shared_ptr &callback, const PortCapType capType) -{ - CHECK_NULL_RETURN(callback, ERR_DH_AUDIO_TRANS_ERROR); - dataTransCallback_ = callback; - context_ = std::make_shared(); - context_->SetTransportStatus(TRANSPORT_STATE_STOP); - int32_t ret = InitAudioDecodeTransport(localParam, remoteParam, capType); - if (ret != DH_SUCCESS) { - DHLOGE("Init audio encode transport, ret: %d.", ret); - return ret; - } - capType_ = capType; - DHLOGI("SetUp success."); - return DH_SUCCESS; -} - -int32_t AudioDecodeTransport::Start() -{ - DHLOGI("Start audio decode transport."); - CHECK_NULL_RETURN(audioChannel_, ERR_DH_AUDIO_NULLPTR); - CHECK_NULL_RETURN(context_, ERR_DH_AUDIO_NULLPTR); - - if (capType_ == CAP_MIC && audioChannel_->OpenSession() != DH_SUCCESS) { - DHLOGE("Audio channel open session failed."); - return ERR_DH_AUDIO_TRANS_SESSION_NOT_OPEN; - } - int32_t ret = context_->Start(); - if (ret != DH_SUCCESS) { - DHLOGE("Context start failed ret: %d.", ret); - audioChannel_->CloseSession(); - return ret; - } - return DH_SUCCESS; -} - -int32_t AudioDecodeTransport::Stop() -{ - DHLOGI("Stop audio decode transport."); - if (audioChannel_ != nullptr) { - audioChannel_->CloseSession(); - } - CHECK_NULL_RETURN(context_, ERR_DH_AUDIO_NULLPTR); - return context_->Stop(); -} - -int32_t AudioDecodeTransport::Pause() -{ - DHLOGI("Pause."); - CHECK_NULL_RETURN(context_, ERR_DH_AUDIO_NULLPTR); - return context_->Pause(); -} - -int32_t AudioDecodeTransport::Restart(const AudioParam &localParam, const AudioParam &remoteParam) -{ - DHLOGI("Restart."); - int32_t ret = RegisterProcessorListener(localParam, remoteParam); - if (ret != DH_SUCCESS) { - DHLOGE("Register processor listener failed, ret: %d.", ret); - processor_ = nullptr; - return ERR_DH_AUDIO_TRANS_ERROR; - } - CHECK_NULL_RETURN(context_, ERR_DH_AUDIO_NULLPTR); - return context_->Restart(localParam, remoteParam); -} - -int32_t AudioDecodeTransport::Release() -{ - DHLOGI("Release audio decode transport."); - bool releaseStatus = true; - if (processor_ != nullptr) { - int32_t ret = processor_->ReleaseAudioProcessor(); - if (ret != DH_SUCCESS) { - DHLOGE("Release audio processor failed, ret: %d.", ret); - releaseStatus = false; - } - } - if (audioChannel_ != nullptr) { - int32_t ret = audioChannel_->ReleaseSession(); - if (ret != DH_SUCCESS) { - DHLOGE("Release session failed, ret: %d.", ret); - releaseStatus = false; - } - } - if (!releaseStatus) { - DHLOGE("The releaseStatus is false."); - return ERR_DH_AUDIO_TRANS_ERROR; - } - DHLOGI("Release success."); - return DH_SUCCESS; -} - -int32_t AudioDecodeTransport::FeedAudioData(std::shared_ptr &audioData) -{ - (void)audioData; - return DH_SUCCESS; -} - -int32_t AudioDecodeTransport::CreateCtrl() -{ - DHLOGI("create ctrl not support."); - return DH_SUCCESS; -} - -int32_t AudioDecodeTransport::InitEngine(IAVEngineProvider *providerPtr) -{ - (void)providerPtr; - return DH_SUCCESS; -} - -int32_t AudioDecodeTransport::SendMessage(uint32_t type, std::string content, std::string dstDevId) -{ - (void)type; - (void)content; - (void)dstDevId; - DHLOGI("Send message not support."); - return DH_SUCCESS; -} - -void AudioDecodeTransport::OnSessionOpened() -{ - DHLOGI("On channel session opened."); - auto cbObj = dataTransCallback_.lock(); - CHECK_NULL_VOID(cbObj); - cbObj->OnStateChange(AudioEventType::DATA_OPENED); -} - -void AudioDecodeTransport::OnSessionClosed() -{ - DHLOGI("On channel session closed."); - auto cbObj = dataTransCallback_.lock(); - CHECK_NULL_VOID(cbObj); - cbObj->OnStateChange(AudioEventType::DATA_CLOSED); -} - -void AudioDecodeTransport::OnDataReceived(const std::shared_ptr &data) -{ - DHLOGI("On audio data received."); - CHECK_NULL_VOID(processor_); - if (processor_->FeedAudioProcessor(data) != DH_SUCCESS) { - DHLOGE("Feed audio processor failed."); - } -} - -void AudioDecodeTransport::OnEventReceived(const AudioEvent &event) -{ - (void)event; -} - -void AudioDecodeTransport::OnAudioDataDone(const std::shared_ptr &outputData) -{ - DHLOGI("On audio data done."); - std::lock_guard lock(dataQueueMtx_); - auto cbObj = dataTransCallback_.lock(); - CHECK_NULL_VOID(cbObj); - cbObj->OnDecodeTransDataDone(outputData); -} - -void AudioDecodeTransport::OnStateNotify(const AudioEvent &event) -{ - (void)event; -} - -int32_t AudioDecodeTransport::InitAudioDecodeTransport(const AudioParam &localParam, - const AudioParam &remoteParam, const PortCapType capType) -{ - int32_t ret = RegisterChannelListener(capType); - if (ret != DH_SUCCESS) { - DHLOGE("Register channel listener failed, ret: %d.", ret); - audioChannel_ = nullptr; - return ERR_DH_AUDIO_TRANS_ERROR; - } - - ret = RegisterProcessorListener(localParam, remoteParam); - if (ret != DH_SUCCESS) { - DHLOGE("Register processor listener failed, ret: %d.", ret); - processor_ = nullptr; - return ERR_DH_AUDIO_TRANS_ERROR; - } - audioParam_ = remoteParam; - return DH_SUCCESS; -} - -int32_t AudioDecodeTransport::RegisterChannelListener(const PortCapType capType) -{ - DHLOGI("Register Channel Listener."); - audioChannel_ = std::make_shared(peerDevId_); - int32_t result = (capType == CAP_SPK) ? - audioChannel_->CreateSession(shared_from_this(), DATA_SPEAKER_SESSION_NAME) : - audioChannel_->CreateSession(shared_from_this(), DATA_MIC_SESSION_NAME); - if (result != DH_SUCCESS) { - DHLOGE("Create session failed."); - return ERR_DH_AUDIO_TRANS_ERROR; - } - CHECK_NULL_RETURN(context_, ERR_DH_AUDIO_NULLPTR); - context_->SetAudioChannel(audioChannel_); - return DH_SUCCESS; -} - -int32_t AudioDecodeTransport::RegisterProcessorListener(const AudioParam &localParam, const AudioParam &remoteParam) -{ - DHLOGI("Register processor listener."); - if (localParam.renderOpts.renderFlags == MMAP_MODE || localParam.captureOpts.capturerFlags == MMAP_MODE) { - DHLOGI("Use direct processor, renderFlags: %d, capturerFlags: %d.", - localParam.renderOpts.renderFlags, localParam.captureOpts.capturerFlags); - processor_ = std::make_shared(); - } - int32_t ret = processor_->ConfigureAudioProcessor(localParam.comParam, remoteParam.comParam, shared_from_this()); - if (ret != DH_SUCCESS) { - DHLOGE("Configure audio processor failed."); - return ret; - } - CHECK_NULL_RETURN(context_, ERR_DH_AUDIO_NULLPTR); - context_->SetAudioProcessor(processor_); - return DH_SUCCESS; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/audiotransport/encodetransport/include/audio_encode_transport.h b/services/audiotransport/encodetransport/include/audio_encode_transport.h deleted file mode 100644 index 5106b0cfe34fafd4cabc254da7e6f9905cf767e8..0000000000000000000000000000000000000000 --- a/services/audiotransport/encodetransport/include/audio_encode_transport.h +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2022-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 AUDIO_ENCODE_TRANSPORT_H -#define AUDIO_ENCODE_TRANSPORT_H - -#include -#include -#include -#include -#include - -#include "audio_event.h" -#include "audio_transport_context.h" -#include "daudio_constants.h" -#include "iaudio_channel.h" -#include "iaudio_datatrans_callback.h" -#include "iaudio_data_transport.h" -#include "iaudio_processor.h" -#include "iaudio_processor_callback.h" - -namespace OHOS { -namespace DistributedHardware { -class AudioEncodeTransport : public IAudioDataTransport, - public IAudioChannelListener, - public IAudioProcessorCallback, - public std::enable_shared_from_this { -public: - explicit AudioEncodeTransport(const std::string peerDevId) : peerDevId_(peerDevId) {} - ~AudioEncodeTransport() override = default; - int32_t SetUp(const AudioParam &localParam, const AudioParam &remoteParam, - const std::shared_ptr &callback, const PortCapType capType) override; - int32_t Start() override; - int32_t Stop() override; - int32_t Release() override; - int32_t Pause() override; - int32_t Restart(const AudioParam &localParam, const AudioParam &remoteParam) override; - int32_t FeedAudioData(std::shared_ptr &audioData) override; - int32_t CreateCtrl() override; - int32_t InitEngine(IAVEngineProvider *providerPtr) override; - int32_t SendMessage(uint32_t type, std::string content, std::string dstDevId) override; - - void OnSessionOpened() override; - void OnSessionClosed() override; - void OnDataReceived(const std::shared_ptr &data) override; - void OnEventReceived(const AudioEvent &event) override; - - void OnAudioDataDone(const std::shared_ptr &outputData) override; - void OnStateNotify(const AudioEvent &event) override; - -private: - int32_t InitAudioEncodeTrans(const AudioParam &localParam, const AudioParam &remoteParam, - const PortCapType capType); - int32_t RegisterChannelListener(const PortCapType capType); - int32_t RegisterProcessorListener(const AudioParam &localParam, const AudioParam &remoteParam); - -private: - static const constexpr uint8_t SESSION_WAIT_SECONDS = 5; - - std::weak_ptr dataTransCallback_; - std::shared_ptr audioChannel_ = nullptr; - std::shared_ptr processor_ = nullptr; - std::shared_ptr context_ = nullptr; - std::string peerDevId_; - PortCapType capType_ = CAP_UNKNOWN; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // AUDIO_ENCODE_TRANSPORT_H diff --git a/services/audiotransport/encodetransport/src/audio_encode_transport.cpp b/services/audiotransport/encodetransport/src/audio_encode_transport.cpp deleted file mode 100644 index 4510bae688bdc7242d54a3cec42c758cc0af28e7..0000000000000000000000000000000000000000 --- a/services/audiotransport/encodetransport/src/audio_encode_transport.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* - * Copyright (c) 2022-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 "audio_encode_transport.h" - -#include "audio_data_channel.h" -#include "audio_direct_processor.h" -#include "audio_param.h" -#include "daudio_errorcode.h" -#include "daudio_log.h" - -#undef DH_LOG_TAG -#define DH_LOG_TAG "AudioEncodeTransport" - -namespace OHOS { -namespace DistributedHardware { -int32_t AudioEncodeTransport::SetUp(const AudioParam &localParam, const AudioParam &remoteParam, - const std::shared_ptr &callback, const PortCapType capType) -{ - CHECK_NULL_RETURN(callback, ERR_DH_AUDIO_TRANS_ERROR); - dataTransCallback_ = callback; - context_ = std::make_shared(); - context_->SetTransportStatus(TRANSPORT_STATE_STOP); - auto ret = InitAudioEncodeTrans(localParam, remoteParam, capType); - if (ret != DH_SUCCESS) { - DHLOGE("Init audio encode transport, ret: %d.", ret); - return ERR_DH_AUDIO_TRANS_ERROR; - } - capType_ = capType; - DHLOGI("SetUp success."); - return DH_SUCCESS; -} - -int32_t AudioEncodeTransport::Start() -{ - DHLOGI("Start audio encode transport."); - CHECK_NULL_RETURN(audioChannel_, ERR_DH_AUDIO_NULLPTR); - CHECK_NULL_RETURN(context_, ERR_DH_AUDIO_NULLPTR); - if (capType_ == CAP_SPK && audioChannel_->OpenSession() != DH_SUCCESS) { - DHLOGE("Audio channel open session failed."); - return ERR_DH_AUDIO_TRANS_SESSION_NOT_OPEN; - } - int32_t ret = context_->Start(); - if (ret != DH_SUCCESS) { - DHLOGE("Start failed ret: %d.", ret); - audioChannel_->CloseSession(); - return ret; - } - DHLOGI("Start success."); - return DH_SUCCESS; -} - -int32_t AudioEncodeTransport::Stop() -{ - DHLOGI("Stop audio encode transport."); - CHECK_NULL_RETURN(context_, ERR_DH_AUDIO_NULLPTR); - return context_->Stop(); -} - -int32_t AudioEncodeTransport::Pause() -{ - DHLOGI("Pause."); - CHECK_NULL_RETURN(context_, ERR_DH_AUDIO_NULLPTR); - return context_->Pause(); -} - -int32_t AudioEncodeTransport::Restart(const AudioParam &localParam, const AudioParam &remoteParam) -{ - DHLOGI("Restart."); - int32_t ret = RegisterProcessorListener(localParam, remoteParam); - if (ret != DH_SUCCESS) { - DHLOGE("Restart failed, register processor listener failed ret: %d.", ret); - processor_ = nullptr; - return ERR_DH_AUDIO_TRANS_ERROR; - } - CHECK_NULL_RETURN(context_, ERR_DH_AUDIO_NULLPTR); - return context_->Restart(localParam, remoteParam); -} - -int32_t AudioEncodeTransport::Release() -{ - DHLOGI("Release audio encode transport."); - bool releaseStatus = true; - int32_t ret; - if (processor_ != nullptr) { - ret = processor_->ReleaseAudioProcessor(); - if (ret != DH_SUCCESS) { - DHLOGE("Release audio processor failed, ret: %d.", ret); - releaseStatus = false; - } - } - if (audioChannel_ != nullptr) { - ret = audioChannel_->ReleaseSession(); - if (ret != DH_SUCCESS) { - DHLOGE("Release session failed, ret: %d.", ret); - releaseStatus = false; - } - } - if (!releaseStatus) { - DHLOGE("The releaseStatus is false: %d."); - return ERR_DH_AUDIO_TRANS_ERROR; - } - DHLOGI("Release success."); - return DH_SUCCESS; -} - -int32_t AudioEncodeTransport::FeedAudioData(std::shared_ptr &audioData) -{ - DHLOGI("Feed audio data."); - if (!processor_) { - DHLOGE("Processor is null, setup first."); - return ERR_DH_AUDIO_NULLPTR; - } - - int32_t ret = processor_->FeedAudioProcessor(audioData); - if (ret != DH_SUCCESS) { - DHLOGE("Feed audio processor failed, ret: %d.", ret); - return ERR_DH_AUDIO_TRANS_ERROR; - } - return DH_SUCCESS; -} -int32_t AudioEncodeTransport::CreateCtrl() -{ - DHLOGI("create ctrl not support."); - return DH_SUCCESS; -} - -int32_t AudioEncodeTransport::InitEngine(IAVEngineProvider *providerPtr) -{ - (void)providerPtr; - DHLOGI("Init engine not support."); - return DH_SUCCESS; -} - -int32_t AudioEncodeTransport::SendMessage(uint32_t type, std::string content, std::string dstDevId) -{ - (void)type; - (void)content; - (void)dstDevId; - DHLOGI("Send message not support."); - return DH_SUCCESS; -} - -int32_t AudioEncodeTransport::InitAudioEncodeTrans(const AudioParam &localParam, - const AudioParam &remoteParam, const PortCapType capType) -{ - int32_t ret = RegisterChannelListener(capType); - if (ret != DH_SUCCESS) { - DHLOGE("Register channel listener failed, ret: %d.", ret); - audioChannel_ = nullptr; - return ERR_DH_AUDIO_TRANS_ERROR; - } - - ret = RegisterProcessorListener(localParam, remoteParam); - if (ret != DH_SUCCESS) { - DHLOGE("Register processor listener failed, ret: %d.", ret); - processor_ = nullptr; - return ERR_DH_AUDIO_TRANS_ERROR; - } - return DH_SUCCESS; -} - -int32_t AudioEncodeTransport::RegisterChannelListener(const PortCapType capType) -{ - DHLOGI("Register channel listener."); - audioChannel_ = std::make_shared(peerDevId_); - int32_t result = (capType == CAP_SPK) ? - audioChannel_->CreateSession(shared_from_this(), DATA_SPEAKER_SESSION_NAME) : - audioChannel_->CreateSession(shared_from_this(), DATA_MIC_SESSION_NAME); - if (result != DH_SUCCESS) { - DHLOGE("CreateSession failed."); - return ERR_DH_AUDIO_TRANS_ERROR; - } - CHECK_NULL_RETURN(context_, ERR_DH_AUDIO_NULLPTR); - context_->SetAudioChannel(audioChannel_); - return DH_SUCCESS; -} - -int32_t AudioEncodeTransport::RegisterProcessorListener(const AudioParam &localParam, const AudioParam &remoteParam) -{ - DHLOGI("Register processor listener."); - if (localParam.renderOpts.renderFlags == MMAP_MODE || localParam.captureOpts.capturerFlags == MMAP_MODE) { - DHLOGI("Use direct processor, renderFlags: %d, capturerFlags: %d.", - localParam.renderOpts.renderFlags, localParam.captureOpts.capturerFlags); - processor_ = std::make_shared(); - } - CHECK_NULL_RETURN(audioChannel_, ERR_DH_AUDIO_TRANS_ERROR); - CHECK_NULL_RETURN(processor_, ERR_DH_AUDIO_NULLPTR); - auto ret = processor_->ConfigureAudioProcessor(localParam.comParam, remoteParam.comParam, shared_from_this()); - if (ret != DH_SUCCESS) { - DHLOGE("Configure audio processor failed."); - return ERR_DH_AUDIO_TRANS_ERROR; - } - - CHECK_NULL_RETURN(context_, ERR_DH_AUDIO_NULLPTR); - context_->SetAudioProcessor(processor_); - return DH_SUCCESS; -} - -void AudioEncodeTransport::OnSessionOpened() -{ - DHLOGD("On channel session opened."); - auto cbObj = dataTransCallback_.lock(); - CHECK_NULL_VOID(cbObj); - cbObj->OnStateChange(AudioEventType::DATA_OPENED); -} - -void AudioEncodeTransport::OnSessionClosed() -{ - DHLOGD("On channel session close."); - auto cbObj = dataTransCallback_.lock(); - CHECK_NULL_VOID(cbObj); - cbObj->OnStateChange(AudioEventType::DATA_CLOSED); -} - -void AudioEncodeTransport::OnDataReceived(const std::shared_ptr &data) -{ - (void)data; -} - -void AudioEncodeTransport::OnEventReceived(const AudioEvent &event) -{ - (void)event; -} - -void AudioEncodeTransport::OnAudioDataDone(const std::shared_ptr &outputData) -{ - DHLOGD("On audio data done."); - if (!audioChannel_) { - DHLOGE("Channel is null, setup first."); - return; - } - int32_t ret = audioChannel_->SendData(outputData); - if (ret != DH_SUCCESS) { - DHLOGE("Send data failed ret: %d.", ret); - return; - } -} - -void AudioEncodeTransport::OnStateNotify(const AudioEvent &event) -{ - (void)event; -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/audiotransport/decodetransport/BUILD.gn b/services/audiotransport/receiverengine/BUILD.gn similarity index 79% rename from services/audiotransport/decodetransport/BUILD.gn rename to services/audiotransport/receiverengine/BUILD.gn index 3bbf508ad2646d547d2776ce0b7fe5f2a818b8b6..6db639fbe095bcdc48b9f0fb2960210067f10fa8 100644 --- a/services/audiotransport/decodetransport/BUILD.gn +++ b/services/audiotransport/receiverengine/BUILD.gn @@ -18,10 +18,6 @@ import("../../../distributedaudio.gni") config("decode_transport_pub_config") { include_dirs = [ "include", - "../audiochannel/audiodatachannel/include", - "../audiochannel/interface", - "../audiotransportstatus/include", - "../audiotransportstatus/interface", "../interface", "../../audioprocessor/interface", ] @@ -47,10 +43,6 @@ ohos_shared_library("distributed_audio_decode_transport") { "include", "${audio_processor_path}/directprocessor/include", "${audio_processor_path}/interface", - "${audio_transport_path}/audiochannel/audiodatachannel/include", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", "${audio_transport_path}/interface", "${audio_transport_path}/receiverengine/include", "${common_path}/include", @@ -66,12 +58,9 @@ ohos_shared_library("distributed_audio_decode_transport") { "${audio_transport_path}/receiverengine/src/av_receiver_engine_adapter.cpp", "${audio_transport_path}/receiverengine/src/av_receiver_engine_transport.cpp", "${services_path}/common/audiodata/src/audio_data.cpp", - "src/audio_decode_transport.cpp", ] deps = [ - "${audio_transport_path}/audiochannel/audiodatachannel:distributed_audio_data_channel", - "${audio_transport_path}/audiotransportstatus:distributed_audio_transport_status", "${services_path}/common:distributed_audio_utils", ] diff --git a/services/audiotransport/encodetransport/BUILD.gn b/services/audiotransport/senderengine/BUILD.gn similarity index 79% rename from services/audiotransport/encodetransport/BUILD.gn rename to services/audiotransport/senderengine/BUILD.gn index 86417298d257d6c5fbece77d8b8bf376ea68781d..c2ebd46ef54ec40b46f1c2c8f85bff561e88a0f1 100644 --- a/services/audiotransport/encodetransport/BUILD.gn +++ b/services/audiotransport/senderengine/BUILD.gn @@ -18,10 +18,6 @@ import("../../../distributedaudio.gni") config("encode_transport_pub_config") { include_dirs = [ "include", - "../audiochannel/audiodatachannel/include", - "../audiochannel/interface", - "../audiotransportstatus/include", - "../audiotransportstatus/interface", "../interface", "../../audioprocessor/interface", ] @@ -47,10 +43,6 @@ ohos_shared_library("distributed_audio_encode_transport") { "include", "${audio_processor_path}/directprocessor/include", "${audio_processor_path}/interface", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audiochannel/audiodatachannel/include", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", "${audio_transport_path}/interface", "${audio_transport_path}/senderengine/include", "${common_path}/dfx_utils/include", @@ -66,12 +58,9 @@ ohos_shared_library("distributed_audio_encode_transport") { "${audio_transport_path}/senderengine/src/av_sender_engine_adapter.cpp", "${audio_transport_path}/senderengine/src/av_sender_engine_transport.cpp", "${services_path}/common/audiodata/src/audio_data.cpp", - "src/audio_encode_transport.cpp", ] deps = [ - "${audio_transport_path}/audiochannel/audiodatachannel:distributed_audio_data_channel", - "${audio_transport_path}/audiotransportstatus:distributed_audio_transport_status", "${services_path}/common:distributed_audio_utils", ] diff --git a/services/audiotransport/test/unittest/BUILD.gn b/services/audiotransport/test/unittest/BUILD.gn index e2dd9df655a4a864989a165a439e54977b1ada89..98a959999321f8552f7d9708cd001d184e29c52f 100644 --- a/services/audiotransport/test/unittest/BUILD.gn +++ b/services/audiotransport/test/unittest/BUILD.gn @@ -18,7 +18,6 @@ import("../../../../distributedaudio.gni") group("daudio_transport_test") { testonly = true deps = [ - "${audio_transport_path}/test/unittest/audiotransportstatus:transport_status_test", "${audio_transport_path}/test/unittest/receiverengine:av_receiver_engine_adapter_test", "${audio_transport_path}/test/unittest/senderengine:av_sender_engine_adapter_test", ] diff --git a/services/audiotransport/test/unittest/audiotransportstatus/BUILD.gn b/services/audiotransport/test/unittest/audiotransportstatus/BUILD.gn deleted file mode 100644 index 8eed1d60df84c60863cc00f9f8ab421434f0ceba..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/audiotransportstatus/BUILD.gn +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright (c) 2022 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("//build/ohos_var.gni") -import("//build/test.gni") -import("../../../../../distributedaudio.gni") - -module_output_path = - "distributed_audio/services/audiotransport/transport_status_test" - -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "${fwk_common_path}/utils/include", - "${mediastandard_path}/interfaces/innerkits/native/media/include", - "${mediastandardfwk_path}/audiocommon/include", - "//third_party/json/include", - ] - - include_dirs += [ - "include", - "${common_path}/include", - "${audio_processor_path}/decoder/include", - "${audio_processor_path}/decodeprocessor/include", - "${audio_processor_path}/interface", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audiochannel/audiodatachannel/include", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", - "${audio_transport_path}/test/unittest/audiotranstestutils/include", - "${services_path}/common/audioparam", - "${services_path}/common/audiodata/include", - ] -} - -ohos_unittest("TransportStatusTest") { - module_out_path = module_output_path - - sources = [ - "src/audio_transport_context_test.cpp", - "src/audio_transport_pause_status_test.cpp", - "src/audio_transport_start_status_test.cpp", - "src/audio_transport_stop_status_test.cpp", - ] - - configs = [ ":module_private_config" ] - - deps = [ - "${audio_transport_path}/audiochannel/audiodatachannel:distributed_audio_data_channel", - "${audio_transport_path}/audiotransportstatus:distributed_audio_transport_status", - "${services_path}/common:distributed_audio_utils", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ "dsoftbus:softbus_client" ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"daudio_trans_test\"", - "LOG_DOMAIN=0xD004100", - ] -} - -group("transport_status_test") { - testonly = true - deps = [ ":TransportStatusTest" ] -} diff --git a/services/audiotransport/test/unittest/audiotransportstatus/include/audio_transport_context_test.h b/services/audiotransport/test/unittest/audiotransportstatus/include/audio_transport_context_test.h deleted file mode 100644 index 20a7de6c95dc14e3a8775bd153c162c1a5821e29..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/audiotransportstatus/include/audio_transport_context_test.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * Copyright (c) 2022 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 AUDIO_TRANSPORT_CONTEXT_TEST_H -#define AUDIO_TRANSPORT_CONTEXT_TEST_H - -#include - -#define private public -#include "audio_transport_context.h" -#undef private - -namespace OHOS { -namespace DistributedHardware { -class AudioTransportContextTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - std::shared_ptr stateContext_ = nullptr; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // AUDIO_TRANSPORT_CONTEXT_TEST_H diff --git a/services/audiotransport/test/unittest/audiotransportstatus/include/audio_transport_pause_status_test.h b/services/audiotransport/test/unittest/audiotransportstatus/include/audio_transport_pause_status_test.h deleted file mode 100644 index 029227353528791812d21d760a7fe325b8eeef9e..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/audiotransportstatus/include/audio_transport_pause_status_test.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2022 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 AUDIO_TRANSPORT_PAUSE_STATUS_TEST_H -#define AUDIO_TRANSPORT_PAUSE_STATUS_TEST_H - -#include - -#define private public -#include "audio_transport_pause_status.h" -#undef private - -#include "audio_transport_status.h" -#include "iaudio_channel.h" -#include "iaudio_processor.h" - -namespace OHOS { -namespace DistributedHardware { -class AudioTransportPauseStatusTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - std::shared_ptr stateContext_ = nullptr; - std::shared_ptr audioStatus_ = nullptr; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // AUDIO_TRANSPORT_PAUSE_STATUS_TEST_H diff --git a/services/audiotransport/test/unittest/audiotransportstatus/include/audio_transport_start_status_test.h b/services/audiotransport/test/unittest/audiotransportstatus/include/audio_transport_start_status_test.h deleted file mode 100644 index 172ed948d22fee5ed20f6e94b355f6648acf6d09..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/audiotransportstatus/include/audio_transport_start_status_test.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022 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 AUDIO_TRANSPORT_START_STATUS_TEST_H -#define AUDIO_TRANSPORT_START_STATUS_TEST_H - -#include - -#define private public -#include "audio_transport_start_status.h" -#undef private - -#include "audio_transport_status.h" -#include "iaudio_channel.h" -#include "iaudio_processor.h" - -namespace OHOS { -namespace DistributedHardware { -class AudioTransportStartStatusTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - std::shared_ptr audioChannel_ = nullptr; - std::shared_ptr processor_ = nullptr; - std::shared_ptr stateContext_ = nullptr; - std::shared_ptr audioStatus_ = nullptr; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // AUDIO_TRANSPORT_START_STATUS_TEST_H diff --git a/services/audiotransport/test/unittest/audiotransportstatus/include/audio_transport_stop_status_test.h b/services/audiotransport/test/unittest/audiotransportstatus/include/audio_transport_stop_status_test.h deleted file mode 100644 index 1f47c35d5c4512b083edab78f5970aa4ac90fdf4..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/audiotransportstatus/include/audio_transport_stop_status_test.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2022 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 AUDIO_TRANSPORT_STOP_STATUS_TEST_H -#define AUDIO_TRANSPORT_STOP_STATUS_TEST_H - -#include - -#define private public -#include "audio_transport_stop_status.h" -#undef private - -#include "audio_transport_status.h" -#include "iaudio_channel.h" -#include "iaudio_processor.h" - -namespace OHOS { -namespace DistributedHardware { -class AudioTransportStopStatusTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - std::shared_ptr audioChannel_ = nullptr; - std::shared_ptr processor_ = nullptr; - std::shared_ptr stateContext_ = nullptr; - std::shared_ptr audioStatus_ = nullptr; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // AUDIO_TRANSPORT_STOP_STATUS_TEST_H diff --git a/services/audiotransport/test/unittest/audiotransportstatus/src/audio_transport_context_test.cpp b/services/audiotransport/test/unittest/audiotransportstatus/src/audio_transport_context_test.cpp deleted file mode 100644 index 959ebf332ea10849786e9a8acbc37fd088e321b7..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/audiotransportstatus/src/audio_transport_context_test.cpp +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (c) 2022 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 "audio_transport_context_test.h" - -#include "daudio_errorcode.h" -#include "daudio_log.h" -#include "daudio_util.h" - -using namespace testing::ext; - -namespace OHOS { -namespace DistributedHardware { -void AudioTransportContextTest::SetUpTestCase(void) {} - -void AudioTransportContextTest::TearDownTestCase(void) {} - -void AudioTransportContextTest::SetUp(void) -{ - stateContext_ = std::make_shared(); -} - -void AudioTransportContextTest::TearDown(void) -{ - stateContext_ = nullptr; -} - -/** - * @tc.name: GetTransportStatus_001 - * @tc.desc: Verify GetTransportStatus func. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportContextTest, GetTransportStatus_001, TestSize.Level1) -{ - TransportStateType type = TransportStateType::TRANSPORT_STATE_START; - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, stateContext_->GetTransportStatusType()); - stateContext_->SetTransportStatus(type); - EXPECT_EQ(TransportStateType::TRANSPORT_STATE_START, stateContext_->GetTransportStatusType()); -} - -/** - * @tc.name: Stop_001 - * @tc.desc: Verify Stop func. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportContextTest, Stop_001, TestSize.Level1) -{ - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, stateContext_->Start()); - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, stateContext_->Pause()); - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, stateContext_->Stop()); - TransportStateType type = TransportStateType::TRANSPORT_STATE_START; - stateContext_->SetTransportStatus(type); - EXPECT_EQ(DH_SUCCESS, stateContext_->Start()); - EXPECT_NE(DH_SUCCESS, stateContext_->Stop()); -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/audiotransport/test/unittest/audiotransportstatus/src/audio_transport_pause_status_test.cpp b/services/audiotransport/test/unittest/audiotransportstatus/src/audio_transport_pause_status_test.cpp deleted file mode 100644 index bd607d87a4656b18e04e24ad6824e04c3c069be9..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/audiotransportstatus/src/audio_transport_pause_status_test.cpp +++ /dev/null @@ -1,155 +0,0 @@ -/* - * Copyright (c) 2022 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 "audio_transport_pause_status_test.h" - -#include "audio_transport_context.h" -#include "daudio_errorcode.h" -#include "daudio_log.h" -#include "daudio_util.h" -#include "mock_audio_data_channel.h" -#include "mock_audio_processor.h" -#include "securec.h" - -using namespace testing::ext; - -namespace OHOS { -namespace DistributedHardware { - -void AudioTransportPauseStatusTest::SetUpTestCase(void) -{ -} - -void AudioTransportPauseStatusTest::TearDownTestCase(void) -{ -} - -void AudioTransportPauseStatusTest::SetUp(void) -{ - stateContext_ = std::shared_ptr(); - audioStatus_ = std::make_shared(stateContext_); -} - -void AudioTransportPauseStatusTest::TearDown(void) -{ - stateContext_ = nullptr; - audioStatus_ = nullptr; -} - -/** - * @tc.name: transport_pause_test_001 - * @tc.desc: Verify start action when status is pause. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportPauseStatusTest, transport_pause_test_001, TestSize.Level1) -{ - std::string peerDevId = "peerDevId"; - std::shared_ptr audioChannel_ = std::make_shared(peerDevId); - std::shared_ptr processor_ = std::make_shared(); - EXPECT_EQ(ERR_DH_AUDIO_TRANS_ILLEGAL_OPERATION, audioStatus_->Start(audioChannel_, processor_)); - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, audioStatus_->Stop(nullptr, processor_)); -} - -/** - * @tc.name: transport_pause_test_002 - * @tc.desc: Verify stop action when status is pause. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportPauseStatusTest, transport_pause_test_002, TestSize.Level1) -{ - std::string peerDevId = "peerDevId"; - std::shared_ptr audioChannel_ = std::make_shared(peerDevId); - std::shared_ptr processor_ = std::make_shared(); - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, audioStatus_->Stop(audioChannel_, processor_)); -} - -/** - * @tc.name: transport_pause_test_003 - * @tc.desc: Verify pause action when status is pause. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportPauseStatusTest, transport_pause_test_003, TestSize.Level1) -{ - std::string peerDevId = "peerDevId"; - std::shared_ptr audioChannel_ = std::make_shared(peerDevId); - std::shared_ptr processor_ = std::make_shared(); - EXPECT_EQ(DH_SUCCESS, audioStatus_->Pause(processor_)); -} - -/** - * @tc.name: transport_pause_test_004 - * @tc.desc: Verify reStart action when status is pause. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportPauseStatusTest, transport_pause_test_004, TestSize.Level1) -{ - AudioParam testLocalParaEnc = { - { - SAMPLE_RATE_48000, - STEREO, - SAMPLE_S16LE, - AUDIO_CODEC_FLAC - }, - { - SOURCE_TYPE_INVALID, - NORMAL_MODE - }, - { - CONTENT_TYPE_UNKNOWN, - STREAM_USAGE_UNKNOWN, - NORMAL_MODE - } - }; - AudioParam testRemoteParaEnc = { - { - SAMPLE_RATE_48000, - STEREO, - SAMPLE_S16LE, - AUDIO_CODEC_FLAC - }, - { - SOURCE_TYPE_INVALID, - NORMAL_MODE - }, - { - CONTENT_TYPE_UNKNOWN, - STREAM_USAGE_UNKNOWN, - NORMAL_MODE - } - }; - std::string peerDevId = "peerDevId"; - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, audioStatus_->Restart(testLocalParaEnc, testRemoteParaEnc, nullptr)); - - std::shared_ptr audioChannel_ = std::make_shared(peerDevId); - std::shared_ptr processor_ = std::make_shared(); - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, audioStatus_->Restart(testLocalParaEnc, testRemoteParaEnc, processor_)); -} - -/** - * @tc.name: transport_getstatetype_test_001 - * @tc.desc: Verify pause action when status is start. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportPauseStatusTest, transport_getstatetype_test_001, TestSize.Level1) -{ - EXPECT_EQ(TRANSPORT_STATE_PAUSE, audioStatus_->GetStateType()); -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/audiotransport/test/unittest/audiotransportstatus/src/audio_transport_start_status_test.cpp b/services/audiotransport/test/unittest/audiotransportstatus/src/audio_transport_start_status_test.cpp deleted file mode 100644 index 2b096dbde0a269e6472c7dc25d407c63cb1da991..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/audiotransportstatus/src/audio_transport_start_status_test.cpp +++ /dev/null @@ -1,168 +0,0 @@ -/* - * Copyright (c) 2022 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 "audio_transport_start_status_test.h" - -#include "audio_transport_context.h" -#include "daudio_errorcode.h" -#include "daudio_log.h" -#include "daudio_util.h" -#include "mock_audio_data_channel.h" -#include "mock_audio_processor.h" -#include "securec.h" - -using namespace testing::ext; - -namespace OHOS { -namespace DistributedHardware { - -void AudioTransportStartStatusTest::SetUpTestCase(void) -{ -} - -void AudioTransportStartStatusTest::TearDownTestCase(void) -{ -} - -void AudioTransportStartStatusTest::SetUp(void) -{ - audioChannel_ = std::shared_ptr(); - processor_ = std::shared_ptr(); - stateContext_ = std::shared_ptr(); - audioStatus_ = std::make_shared(stateContext_); -} - -void AudioTransportStartStatusTest::TearDown(void) -{ - audioChannel_ = nullptr; - processor_ = nullptr; - stateContext_ = nullptr; - audioStatus_ = nullptr; -} - -/** - * @tc.name: transport_start_test_001 - * @tc.desc: Verify start action when status is start. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportStartStatusTest, transport_start_test_001, TestSize.Level1) -{ - EXPECT_EQ(DH_SUCCESS, audioStatus_->Start(audioChannel_, processor_)); -} - -/** - * @tc.name: transport_Stop_test_001 - * @tc.desc: Verify stop action when status is stop. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportStartStatusTest, transport_Stop_test_001, TestSize.Level1) -{ - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, audioStatus_->Stop(audioChannel_, processor_)); -} - -/** - * @tc.name: transport_stop_test_002 - * @tc.desc: Verify stop action when status is start. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportStartStatusTest, transport_stop_test_002, TestSize.Level1) -{ - std::shared_ptr processor_ = std::make_shared(); - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, audioStatus_->Stop(audioChannel_, processor_)); -} - -/** - * @tc.name: transport_Pause_test_001 - * @tc.desc: Verify pause action when status is start. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportStartStatusTest, transport_pause_test_001, TestSize.Level1) -{ - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, audioStatus_->Pause(processor_)); -} - -/** - * @tc.name: transport_Pause_test_002 - * @tc.desc: Verify pause action when status is start. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportStartStatusTest, transport_Pause_test_002, TestSize.Level1) -{ - processor_ = std::make_shared(); - EXPECT_EQ(ERR_DH_AUDIO_BAD_VALUE, audioStatus_->Pause(processor_)); -} - -/** - * @tc.name: transport_Restart_test_001 - * @tc.desc: Verify action when status is start. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportStartStatusTest, transport_restart_test_001, TestSize.Level1) -{ - AudioParam testLocalParaEnc = { - { - SAMPLE_RATE_48000, - STEREO, - SAMPLE_S16LE, - AUDIO_CODEC_FLAC - }, - { - SOURCE_TYPE_INVALID, - NORMAL_MODE - }, - { - CONTENT_TYPE_UNKNOWN, - STREAM_USAGE_UNKNOWN, - NORMAL_MODE - } - }; - AudioParam testRemoteParaEnc = { - { - SAMPLE_RATE_48000, - STEREO, - SAMPLE_S16LE, - AUDIO_CODEC_FLAC - }, - { - SOURCE_TYPE_INVALID, - NORMAL_MODE - }, - { - CONTENT_TYPE_UNKNOWN, - STREAM_USAGE_UNKNOWN, - NORMAL_MODE - } - }; - EXPECT_EQ(DH_SUCCESS, audioStatus_->Restart(testLocalParaEnc, testRemoteParaEnc, processor_)); -} - -/** - * @tc.name: transport_getstatetype_test_001 - * @tc.desc: Verify pause action when status is start. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportStartStatusTest, transport_getstatetype_test_001, TestSize.Level1) -{ - EXPECT_EQ(TRANSPORT_STATE_START, audioStatus_->GetStateType()); -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/audiotransport/test/unittest/audiotransportstatus/src/audio_transport_stop_status_test.cpp b/services/audiotransport/test/unittest/audiotransportstatus/src/audio_transport_stop_status_test.cpp deleted file mode 100644 index 36e2878848cb4c70ec5d40197c558269aed80ece..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/audiotransportstatus/src/audio_transport_stop_status_test.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* - * Copyright (c) 2022 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 "audio_transport_stop_status_test.h" - -#include "audio_transport_context.h" -#include "daudio_errorcode.h" -#include "daudio_log.h" -#include "daudio_util.h" -#include "mock_audio_data_channel.h" -#include "mock_audio_processor.h" -#include "securec.h" - -using namespace testing::ext; - -namespace OHOS { -namespace DistributedHardware { - -void AudioTransportStopStatusTest::SetUpTestCase(void) -{ -} - -void AudioTransportStopStatusTest::TearDownTestCase(void) -{ -} - -void AudioTransportStopStatusTest::SetUp(void) -{ - audioChannel_ = std::shared_ptr(); - processor_ = std::shared_ptr(); - stateContext_ = std::shared_ptr(); - audioStatus_ = std::make_shared(stateContext_); -} - -void AudioTransportStopStatusTest::TearDown(void) -{ - audioChannel_ = nullptr; - processor_ = nullptr; - stateContext_ = nullptr; - audioStatus_ = nullptr; -} - -/** - * @tc.name: transport_stop_test_001 - * @tc.desc: Verify start action when status is stop. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportStopStatusTest, transport_stop_test_001, TestSize.Level1) -{ - std::string peerDevId = "peerDevId"; - std::shared_ptr audioChannel_ = std::make_shared(peerDevId); - std::shared_ptr processor_ = std::make_shared(); - EXPECT_EQ(ERR_DH_AUDIO_BAD_VALUE, audioStatus_->Start(audioChannel_, processor_)); - EXPECT_EQ(DH_SUCCESS, audioStatus_->Stop(audioChannel_, processor_)); -} - -/** - * @tc.name: transport_stop_test_002 - * @tc.desc: Verify stop action when status is stop. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportStopStatusTest, transport_stop_test_002, TestSize.Level1) -{ - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, audioStatus_->Start(audioChannel_, nullptr)); - EXPECT_EQ(DH_SUCCESS, audioStatus_->Stop(audioChannel_, processor_)); -} - -/** - * @tc.name: transport_stop_test_003 - * @tc.desc: Verify pause action when status is stop. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportStopStatusTest, transport_stop_test_003, TestSize.Level1) -{ - EXPECT_EQ(ERR_DH_AUDIO_TRANS_ILLEGAL_OPERATION, audioStatus_->Pause(processor_)); -} - -/** - * @tc.name: transport_stop_test_004 - * @tc.desc: Verify reStart action when status is stop. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportStopStatusTest, transport_stop_test_004, TestSize.Level1) -{ - AudioParam testLocalParaEnc = { - { - SAMPLE_RATE_48000, - STEREO, - SAMPLE_S16LE, - AUDIO_CODEC_FLAC - }, - { - SOURCE_TYPE_INVALID, - NORMAL_MODE - }, - { - CONTENT_TYPE_UNKNOWN, - STREAM_USAGE_UNKNOWN, - NORMAL_MODE - } - }; - AudioParam testRemoteParaEnc = { - { - SAMPLE_RATE_48000, - STEREO, - SAMPLE_S16LE, - AUDIO_CODEC_FLAC - }, - { - SOURCE_TYPE_INVALID, - NORMAL_MODE - }, - { - CONTENT_TYPE_UNKNOWN, - STREAM_USAGE_UNKNOWN, - NORMAL_MODE - } - }; - EXPECT_EQ(ERR_DH_AUDIO_TRANS_ILLEGAL_OPERATION, - audioStatus_->Restart(testLocalParaEnc, testRemoteParaEnc, processor_)); -} - -/** - * @tc.name: transport_getstatetype_test_001 - * @tc.desc: Verify pause action when status is start. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(AudioTransportStopStatusTest, transport_getstatetype_test_001, TestSize.Level1) -{ - EXPECT_EQ(TRANSPORT_STATE_STOP, audioStatus_->GetStateType()); -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/audiotransport/test/unittest/audiotranstestutils/include/audiotrans_test_utils.h b/services/audiotransport/test/unittest/audiotranstestutils/include/audiotrans_test_utils.h deleted file mode 100644 index 6735e6318283f7b920020e30f0866f40505bff9f..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/audiotranstestutils/include/audiotrans_test_utils.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2022 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_AUDIO_TRANS_TEST_UTILS_H -#define OHOS_AUDIO_TRANS_TEST_UTILS_H - -#include "iaudio_channel_listener.h" -#include "iaudio_channel.h" - -namespace OHOS { -namespace DistributedHardware { -constexpr size_t DATA_LEN = 128; - -class MockIAudioChannelListener : public IAudioChannelListener { -public: - MockIAudioChannelListener() {} - ~MockIAudioChannelListener() {} - void OnSessionOpened() override {}; - void OnSessionClosed() override {}; - void OnDataReceived(const std::shared_ptr &data) override {}; - void OnEventReceived(const AudioEvent &event) override {}; -}; - -class MockAudioCtrlChannel : public IAudioChannel { -public: - explicit MockAudioCtrlChannel(std::string peerDevId) : peerDevId_(peerDevId) {} - ~MockAudioCtrlChannel() {} - - int32_t CreateSession(const std::shared_ptr &listener, - const std::string &sessionName) override - { - return 0; - } - int32_t ReleaseSession() override - { - return 0; - } - int32_t OpenSession() override - { - return 0; - } - int32_t CloseSession() override - { - return 0; - } - int32_t SendData(const std::shared_ptr &audioData) override - { - return 0; - } - int32_t SendEvent(const AudioEvent &audioEvent) override - { - return 0; - } - -private: - const std::string peerDevId_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_AUDIO_TRANS_TEST_UTILS_H \ No newline at end of file diff --git a/services/audiotransport/test/unittest/audiotranstestutils/include/mock_audio_data_channel.h b/services/audiotransport/test/unittest/audiotranstestutils/include/mock_audio_data_channel.h deleted file mode 100644 index d3a8f507bc9d198006e45b5b2f17db3efb4aa051..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/audiotranstestutils/include/mock_audio_data_channel.h +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2022 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_MOCK_AUDIO_DATA_CHANNEL_H -#define OHOS_MOCK_AUDIO_DATA_CHANNEL_H - -#include -#include - -#include "iaudio_channel_listener.h" -#include "iaudio_channel.h" - -namespace OHOS { -namespace DistributedHardware { -class MockAudioDataChannel : public IAudioChannel { -public: - explicit MockAudioDataChannel(std::string peerDevId) : peerDevId_(peerDevId) {} - ~MockAudioDataChannel() {} - - int32_t CreateSession(const std::shared_ptr &listener, - const std::string &sessionName) override - { - return DH_SUCCESS; - } - - int32_t ReleaseSession() override - { - return DH_SUCCESS; - } - - int32_t OpenSession() override - { - return DH_SUCCESS; - } - - int32_t CloseSession() override - { - return DH_SUCCESS; - } - - int32_t SendData(const std::shared_ptr &audioData) override - { - return DH_SUCCESS; - } - - int32_t SendEvent(const AudioEvent &audioEvent) override - { - return DH_SUCCESS; - } - -private: - const std::string peerDevId_; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_MOCK_AUDIO_DATA_CHANNEL_H diff --git a/services/audiotransport/test/unittest/audiotranstestutils/include/mock_audio_processor.h b/services/audiotransport/test/unittest/audiotranstestutils/include/mock_audio_processor.h deleted file mode 100644 index d3d959f7ecec93142425eabdaab24a5396e6e47d..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/audiotranstestutils/include/mock_audio_processor.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * Copyright (c) 2022 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_AUDIO_PROCESSOR_H -#define OHOS_AUDIO_PROCESSOR_H - -#include "iaudio_processor.h" - -namespace OHOS { -namespace DistributedHardware { -class MockIAudioProcessor : public IAudioProcessor { -public: - explicit MockIAudioProcessor() {} - ~MockIAudioProcessor() {} - - int32_t ConfigureAudioProcessor(const AudioCommonParam &localDevParam, const AudioCommonParam &remoteDevParam, - const std::shared_ptr &procCallback) override - { - (void)localDevParam; - (void)remoteDevParam; - (void)procCallback; - return 0; - } - - int32_t ReleaseAudioProcessor() override - { - return 0; - } - - int32_t StartAudioProcessor() override - { - return 0; - } - - int32_t StopAudioProcessor() override - { - return 0; - } - - int32_t FeedAudioProcessor(const std::shared_ptr &inputData) override - { - (void) inputData; - return 0; - } -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_AUDIO_PROCESSOR_H \ No newline at end of file diff --git a/services/audiotransport/test/unittest/audiotranstestutils/include/mock_audio_transport_callback.h b/services/audiotransport/test/unittest/audiotranstestutils/include/mock_audio_transport_callback.h deleted file mode 100644 index c222ba6adb453ce61176937765b2f4e1cb4e6819..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/audiotranstestutils/include/mock_audio_transport_callback.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 2022 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_MOCK_AUDIO_TRANSPORT_CALLBACK_H -#define OHOS_MOCK_AUDIO_TRANSPORT_CALLBACK_H - -#include "audio_event.h" -#include "daudio_errorcode.h" -#include "daudio_log.h" -#include "iaudio_processor_callback.h" - -namespace OHOS { -namespace DistributedHardware { -class MockAudioTransportCallback : public IAudioDataTransCallback { -public: - MockAudioTransportCallback() = default; - ~MockAudioTransportCallback() = default; - - int32_t OnStateChange(const AudioEventType type) override; - int32_t OnDecodeTransDataDone(const std::shared_ptr &audioData) override; -}; - -int32_t MockAudioTransportCallback::OnStateChange(const AudioEventType type) -{ - DHLOGD("Test : On state change, state: %d.", type); - return DH_SUCCESS; -} - -int32_t MockAudioTransportCallback::OnDecodeTransDataDone(const std::shared_ptr &audioData) -{ - (void) audioData; - DHLOGE("Test : On decode trans data done."); - return DH_SUCCESS; -} -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_MOCK_AUDIO_TRANSPORT_CALLBACK_H diff --git a/services/audiotransport/test/unittest/decodetransport/BUILD.gn b/services/audiotransport/test/unittest/decodetransport/BUILD.gn deleted file mode 100644 index 81b388318acb7c064e25adbc8c5ce1aefc172f7b..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/decodetransport/BUILD.gn +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright (c) 2022-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. - -import("//build/ohos.gni") -import("//build/ohos_var.gni") -import("//build/test.gni") -import("../../../../../distributedaudio.gni") - -module_output_path = - "distributed_audio/services/audiotransport/decode_transport_test" - -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "${fwk_common_path}/utils/include", - "//third_party/json/include", - ] - - include_dirs += [ - "include", - "${audio_processor_path}/decodeprocessor/include", - "${audio_processor_path}/interface", - "${audio_transport_path}/audiochannel/audiodatachannel/include", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", - "${audio_transport_path}/decodetransport/include", - "${audio_transport_path}/interface", - "${audio_transport_path}/receiverengine/include", - "${audio_transport_path}/senderengine/include", - "${audio_transport_path}/test/unittest/audiotranstestutils/include", - "${common_path}/include", - "${services_path}/common/audiodata/include", - "${services_path}/common/audioparam", - ] -} - -ohos_unittest("DecodeTransportTest") { - module_out_path = module_output_path - - sources = [ "src/decode_transport_test.cpp" ] - - configs = [ ":module_private_config" ] - - deps = [ - "${audio_transport_path}/decodetransport:distributed_audio_decode_transport", - "${services_path}/common:distributed_audio_utils", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "distributed_hardware_fwk:distributed_av_receiver", - "distributed_hardware_fwk:distributed_av_sender", - "dsoftbus:softbus_client", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"daudio_trans_test\"", - "LOG_DOMAIN=0xD004100", - ] -} - -group("decode_transport_test") { - testonly = true - deps = [ ":DecodeTransportTest" ] -} diff --git a/services/audiotransport/test/unittest/decodetransport/include/decode_transport_test.h b/services/audiotransport/test/unittest/decodetransport/include/decode_transport_test.h deleted file mode 100644 index 36d3fb185ee392e33adbfbd142e250003cb49ee6..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/decodetransport/include/decode_transport_test.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Copyright (c) 2022 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_DAUDIO_DECODE_TRANS_TEST_H -#define OHOS_DAUDIO_DECODE_TRANS_TEST_H - -#include - -#define private public -#include "audio_decode_transport.h" -#undef private - -#include "iaudio_channel.h" -#include "iaudio_datatrans_callback.h" -#include "daudio_errorcode.h" - -namespace OHOS { -namespace DistributedHardware { -class DecodeTransportTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - std::shared_ptr transCallback_ = nullptr; - std::shared_ptr decodeTrans_ = nullptr; -}; - -class MockIAudioChannel : public IAudioChannel { -public: - int32_t CreateSession(const std::shared_ptr &listener, - const std::string &sessionName) override - { - return DH_SUCCESS; - } - int32_t ReleaseSession() override - { - return ERR_DH_AUDIO_FAILED; - } - virtual int32_t OpenSession() override - { - return ERR_DH_AUDIO_FAILED; - } - virtual int32_t CloseSession() override - { - return DH_SUCCESS; - } - int32_t SendData(const std::shared_ptr &data) override - { - return DH_SUCCESS; - } - int32_t SendEvent(const AudioEvent &event) override - { - return DH_SUCCESS; - } -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_DAUDIO_DECODE_TRANS_TEST_H diff --git a/services/audiotransport/test/unittest/decodetransport/src/decode_transport_test.cpp b/services/audiotransport/test/unittest/decodetransport/src/decode_transport_test.cpp deleted file mode 100644 index ed3058ffbc2be97707b9cbcfa68065ca049c72a0..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/decodetransport/src/decode_transport_test.cpp +++ /dev/null @@ -1,215 +0,0 @@ -/* - * Copyright (c) 2022-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 "decode_transport_test.h" - -#include - -#include "audio_data.h" -#include "audio_event.h" -#include "audio_param.h" -#include "daudio_log.h" -#include "daudio_util.h" -#include "mock_audio_data_channel.h" -#include "mock_audio_processor.h" -#include "mock_audio_transport_callback.h" -#include "securec.h" - -using namespace testing::ext; - -namespace OHOS { -namespace DistributedHardware { -const std::string RMT_DEV_ID_TEST = "RemoteTest"; -const PortCapType ROLE_TEST = CAP_SPK; - -void DecodeTransportTest::SetUpTestCase(void) -{ -} - -void DecodeTransportTest::TearDownTestCase(void) -{ -} - -void DecodeTransportTest::SetUp(void) -{ - transCallback_ = std::make_shared(); - decodeTrans_ = std::make_shared(RMT_DEV_ID_TEST); -} - -void DecodeTransportTest::TearDown(void) -{ - transCallback_ = nullptr; - decodeTrans_ = nullptr; -} - -/** - * @tc.name: decode_transport_test_001 - * @tc.desc: Verify the configure processor function. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(DecodeTransportTest, decode_transport_test_001, TestSize.Level1) -{ - AudioParam testLocalParaEnc = { - { - SAMPLE_RATE_48000, - STEREO, - SAMPLE_S16LE, - AUDIO_CODEC_FLAC - }, - { - SOURCE_TYPE_INVALID, - NORMAL_MODE - }, - { - CONTENT_TYPE_UNKNOWN, - STREAM_USAGE_UNKNOWN, - NORMAL_MODE - } - }; - AudioParam testRemoteParaEnc = { - { - SAMPLE_RATE_48000, - STEREO, - SAMPLE_S16LE, - AUDIO_CODEC_FLAC - }, - { - SOURCE_TYPE_INVALID, - NORMAL_MODE - }, - { - CONTENT_TYPE_UNKNOWN, - STREAM_USAGE_UNKNOWN, - NORMAL_MODE - } - }; - EXPECT_NE(DH_SUCCESS, decodeTrans_->SetUp(testLocalParaEnc, testRemoteParaEnc, transCallback_, ROLE_TEST)); - std::shared_ptr callback = nullptr; - EXPECT_NE(DH_SUCCESS, decodeTrans_->SetUp(testLocalParaEnc, testRemoteParaEnc, callback, ROLE_TEST)); - EXPECT_EQ(DH_SUCCESS, decodeTrans_->Release()); -} - -/** - * @tc.name: decode_transport_test_002 - * @tc.desc: Verify the start processor without configure processor function. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(DecodeTransportTest, decode_transport_test_002, TestSize.Level1) -{ - EXPECT_NE(DH_SUCCESS, decodeTrans_->Start()); - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, decodeTrans_->Stop()); - EXPECT_EQ(DH_SUCCESS, decodeTrans_->Release()); - - decodeTrans_->audioChannel_ = std::make_shared(); - decodeTrans_->context_ = std::make_shared(); - decodeTrans_->capType_ = CAP_MIC; - EXPECT_EQ(ERR_DH_AUDIO_TRANS_SESSION_NOT_OPEN, decodeTrans_->Start()); - EXPECT_NE(DH_SUCCESS, decodeTrans_->Release()); -} - -/** - * @tc.name: decode_transport_test_003 - * @tc.desc: Verify the pause and processor without configure processor function. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(DecodeTransportTest, decode_transport_test_003, TestSize.Level1) -{ - AudioParam testLocalParaEnc = { - { - SAMPLE_RATE_48000, - STEREO, - SAMPLE_S16LE, - AUDIO_CODEC_FLAC - }, - { - SOURCE_TYPE_INVALID, - NORMAL_MODE - }, - { - CONTENT_TYPE_UNKNOWN, - STREAM_USAGE_UNKNOWN, - NORMAL_MODE - } - }; - AudioParam testRemoteParaEnc = { - { - SAMPLE_RATE_48000, - STEREO, - SAMPLE_S16LE, - AUDIO_CODEC_FLAC - }, - { - SOURCE_TYPE_INVALID, - NORMAL_MODE - }, - { - CONTENT_TYPE_UNKNOWN, - STREAM_USAGE_UNKNOWN, - NORMAL_MODE - } - }; - EXPECT_EQ(ERR_DH_AUDIO_BAD_VALUE, decodeTrans_->RegisterProcessorListener(testLocalParaEnc, testRemoteParaEnc)); - EXPECT_EQ(ERR_DH_AUDIO_TRANS_ERROR, - decodeTrans_->InitAudioDecodeTransport(testLocalParaEnc, testRemoteParaEnc, ROLE_TEST)); - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, decodeTrans_->Pause()); - EXPECT_EQ(ERR_DH_AUDIO_TRANS_ERROR, decodeTrans_->Restart(testLocalParaEnc, testRemoteParaEnc)); -} - -/** - * @tc.name: decode_transport_test_004 - * @tc.desc: Verify the FeedAudioData function. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(DecodeTransportTest, decode_transport_test_004, TestSize.Level1) -{ - std::shared_ptr audioData = nullptr; - AudioEvent event; - decodeTrans_->OnSessionOpened(); - decodeTrans_->OnSessionClosed(); - decodeTrans_->OnDataReceived(audioData); - decodeTrans_->OnEventReceived(event); - decodeTrans_->OnStateNotify(event); - decodeTrans_->OnAudioDataDone(audioData); - decodeTrans_->dataTransCallback_ = std::make_shared(); - decodeTrans_->OnSessionOpened(); - decodeTrans_->OnSessionClosed(); - decodeTrans_->OnAudioDataDone(audioData); - - EXPECT_EQ(DH_SUCCESS, decodeTrans_->FeedAudioData(audioData)); -} - -/** - * @tc.name: decode_transport_test_005 - * @tc.desc: Verify the RegisterChannelListener function. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(DecodeTransportTest, decode_transport_test_005, TestSize.Level1) -{ - IAVEngineProvider *providerPtr = nullptr; - uint32_t type = 0; - std::string content = "content"; - std::string dstDevId = "dstDevId"; - EXPECT_EQ(ERR_DH_AUDIO_TRANS_ERROR, decodeTrans_->RegisterChannelListener(ROLE_TEST)); - EXPECT_EQ(DH_SUCCESS, decodeTrans_->CreateCtrl()); - EXPECT_EQ(DH_SUCCESS, decodeTrans_->InitEngine(providerPtr)); - EXPECT_EQ(DH_SUCCESS, decodeTrans_->SendMessage(type, content, dstDevId)); -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/audiotransport/test/unittest/encodetransport/BUILD.gn b/services/audiotransport/test/unittest/encodetransport/BUILD.gn deleted file mode 100644 index 66b2d087a9243288ba601ebf35d2590edf9cf8be..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/encodetransport/BUILD.gn +++ /dev/null @@ -1,79 +0,0 @@ -# Copyright (c) 2022-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. - -import("//build/ohos.gni") -import("//build/ohos_var.gni") -import("//build/test.gni") -import("../../../../../distributedaudio.gni") - -module_output_path = - "distributed_audio/services/audiotransport/encode_transport_test" - -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "${fwk_common_path}/utils/include", - "//third_party/json/include", - ] - - include_dirs += [ - "include", - "${audio_processor_path}/interface", - "${audio_processor_path}/encodeprocessor/include", - "${audio_transport_path}/audiochannel/interface", - "${audio_transport_path}/audiochannel/audiodatachannel/include", - "${audio_transport_path}/audiotransportstatus/include", - "${audio_transport_path}/audiotransportstatus/interface", - "${audio_transport_path}/encodetransport/include", - "${audio_transport_path}/interface", - "${audio_transport_path}/receiverengine/include", - "${audio_transport_path}/senderengine/include", - "${audio_transport_path}/test/unittest/audiotranstestutils/include", - "${common_path}/include", - "${services_path}/common/audiodata/include", - "${services_path}/common/audioparam", - ] -} - -ohos_unittest("EncodeTransportTest") { - module_out_path = module_output_path - - sources = [ "src/encode_transport_test.cpp" ] - - configs = [ ":module_private_config" ] - - deps = [ - "${audio_transport_path}/audiotransportstatus:distributed_audio_transport_status", - "${audio_transport_path}/encodetransport:distributed_audio_encode_transport", - "${services_path}/common:distributed_audio_utils", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "distributed_hardware_fwk:distributed_av_receiver", - "distributed_hardware_fwk:distributed_av_sender", - "dsoftbus:softbus_client", - ] - - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"daudio_trans_test\"", - "LOG_DOMAIN=0xD004100", - ] -} - -group("encode_transport_test") { - testonly = true - deps = [ ":EncodeTransportTest" ] -} diff --git a/services/audiotransport/test/unittest/encodetransport/include/encode_transport_test.h b/services/audiotransport/test/unittest/encodetransport/include/encode_transport_test.h deleted file mode 100644 index 7dd3bffbef5ed704f0f71c1f9387762ff20d29d3..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/encodetransport/include/encode_transport_test.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2022 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_DAUDIO_ENCODE_TRANS_TEST_H -#define OHOS_DAUDIO_ENCODE_TRANS_TEST_H - -#include - -#define private public -#include "audio_encode_transport.h" -#undef private - -#include "iaudio_channel.h" -#include "iaudio_datatrans_callback.h" - -namespace OHOS { -namespace DistributedHardware { -class EncodeTransportTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); - - std::shared_ptr transCallback_ = nullptr; - std::shared_ptr encodeTrans_ = nullptr; -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif // OHOS_DAUDIO_ENCODE_TRANS_TEST_H diff --git a/services/audiotransport/test/unittest/encodetransport/src/encode_transport_test.cpp b/services/audiotransport/test/unittest/encodetransport/src/encode_transport_test.cpp deleted file mode 100644 index aef7fc8476a3600947a35797284eabde4fae2b50..0000000000000000000000000000000000000000 --- a/services/audiotransport/test/unittest/encodetransport/src/encode_transport_test.cpp +++ /dev/null @@ -1,218 +0,0 @@ -/* - * Copyright (c) 2022-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 "encode_transport_test.h" - -#include - -#include "audio_data.h" -#include "audio_event.h" -#include "audio_transport_status.h" -#include "audio_transport_status_factory.h" -#include "audio_param.h" -#include "daudio_errorcode.h" -#include "daudio_log.h" -#include "daudio_util.h" -#include "audio_transport_context.h" -#include "mock_audio_data_channel.h" -#include "mock_audio_transport_callback.h" -#include "securec.h" - -using namespace testing::ext; - -namespace OHOS { -namespace DistributedHardware { -const std::string RMT_DEV_ID_TEST = "RemoteDevIdTest"; -const PortCapType ROLE_TEST = CAP_SPK; - -void EncodeTransportTest::SetUpTestCase(void) -{ -} - -void EncodeTransportTest::TearDownTestCase(void) -{ -} - -void EncodeTransportTest::SetUp(void) -{ - transCallback_ = std::make_shared(); - encodeTrans_ = std::make_shared(RMT_DEV_ID_TEST); -} - -void EncodeTransportTest::TearDown(void) -{ - transCallback_ = nullptr; - encodeTrans_ = nullptr; -} - -/** - * @tc.name: encode_transport_test_001 - * @tc.desc: Verify the configure transport function. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(EncodeTransportTest, encode_transport_test_001, TestSize.Level1) -{ - AudioParam testLocalParaEnc = { - { - SAMPLE_RATE_48000, - STEREO, - SAMPLE_S16LE, - AUDIO_CODEC_FLAC - }, - { - SOURCE_TYPE_INVALID, - NORMAL_MODE - }, - { - CONTENT_TYPE_UNKNOWN, - STREAM_USAGE_UNKNOWN, - NORMAL_MODE - } - }; - AudioParam testRemoteParaEnc = { - { - SAMPLE_RATE_48000, - STEREO, - SAMPLE_S16LE, - AUDIO_CODEC_FLAC - }, - { - SOURCE_TYPE_INVALID, - NORMAL_MODE - }, - { - CONTENT_TYPE_UNKNOWN, - STREAM_USAGE_UNKNOWN, - NORMAL_MODE - } - }; - EXPECT_NE(DH_SUCCESS, encodeTrans_->SetUp(testLocalParaEnc, testRemoteParaEnc, transCallback_, ROLE_TEST)); - EXPECT_EQ(DH_SUCCESS, encodeTrans_->Release()); -} - -/** - * @tc.name: encode_transport_test_002 - * @tc.desc: Verify the start transport without configure transport function. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(EncodeTransportTest, encode_transport_test_002, TestSize.Level1) -{ - encodeTrans_->audioChannel_ = std::make_shared(RMT_DEV_ID_TEST); - encodeTrans_->context_ = std::make_shared(); - auto stateContext = std::shared_ptr(encodeTrans_->context_); - encodeTrans_->context_->currentState_ = - AudioTransportStatusFactory::GetInstance().CreateState(TRANSPORT_STATE_START, stateContext); - EXPECT_EQ(DH_SUCCESS, encodeTrans_->Start()); - encodeTrans_->context_->currentState_ = - AudioTransportStatusFactory::GetInstance().CreateState(TRANSPORT_STATE_STOP, stateContext); - EXPECT_EQ(DH_SUCCESS, encodeTrans_->Stop()); - EXPECT_EQ(DH_SUCCESS, encodeTrans_->Release()); -} - -/** - * @tc.name: encode_transport_test_003 - * @tc.desc: Verify the pasue and restart transport without configure transport function. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(EncodeTransportTest, encode_transport_test_003, TestSize.Level1) -{ - AudioParam testLocalParaEnc = { - { - SAMPLE_RATE_48000, - STEREO, - SAMPLE_S16LE, - AUDIO_CODEC_FLAC - }, - { - SOURCE_TYPE_INVALID, - NORMAL_MODE - }, - { - CONTENT_TYPE_UNKNOWN, - STREAM_USAGE_UNKNOWN, - NORMAL_MODE - } - }; - AudioParam testRemoteParaEnc = { - { - SAMPLE_RATE_48000, - STEREO, - SAMPLE_S16LE, - AUDIO_CODEC_FLAC - }, - { - SOURCE_TYPE_INVALID, - NORMAL_MODE - }, - { - CONTENT_TYPE_UNKNOWN, - STREAM_USAGE_UNKNOWN, - NORMAL_MODE - } - }; - - EXPECT_EQ(ERR_DH_AUDIO_TRANS_ERROR, encodeTrans_->RegisterProcessorListener(testLocalParaEnc, testRemoteParaEnc)); - EXPECT_EQ(ERR_DH_AUDIO_TRANS_ERROR, - encodeTrans_->InitAudioEncodeTrans(testLocalParaEnc, testRemoteParaEnc, ROLE_TEST)); - encodeTrans_->context_ = std::make_shared(); - auto stateContext = std::shared_ptr(encodeTrans_->context_); - encodeTrans_->context_->currentState_ = - AudioTransportStatusFactory::GetInstance().CreateState(TRANSPORT_STATE_PAUSE, stateContext); - EXPECT_EQ(DH_SUCCESS, encodeTrans_->Pause()); - EXPECT_EQ(ERR_DH_AUDIO_TRANS_ERROR, encodeTrans_->Restart(testLocalParaEnc, testRemoteParaEnc)); -} - -/** - * @tc.name: encode_transport_test_004 - * @tc.desc: Verify encode_transport_test function. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(EncodeTransportTest, encode_transport_test_004, TestSize.Level1) -{ - std::shared_ptr audioData = nullptr; - AudioEvent event; - encodeTrans_->OnSessionOpened(); - encodeTrans_->OnSessionClosed(); - encodeTrans_->OnDataReceived(audioData); - encodeTrans_->OnEventReceived(event); - encodeTrans_->OnStateNotify(event); - encodeTrans_->OnAudioDataDone(audioData); - - EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, encodeTrans_->FeedAudioData(audioData)); -} - -/** - * @tc.name: encode_transport_test_005 - * @tc.desc: Verify RegisterChannelListener function. - * @tc.type: FUNC - * @tc.require: AR000H0E5U - */ -HWTEST_F(EncodeTransportTest, encode_transport_test_005, TestSize.Level1) -{ - IAVEngineProvider *providerPtr = nullptr; - uint32_t type = 0; - std::string content = "content"; - std::string dstDevId = "dstDevId"; - EXPECT_EQ(ERR_DH_AUDIO_TRANS_ERROR, encodeTrans_->RegisterChannelListener(ROLE_TEST)); - EXPECT_EQ(DH_SUCCESS, encodeTrans_->CreateCtrl()); - EXPECT_EQ(DH_SUCCESS, encodeTrans_->InitEngine(providerPtr)); - EXPECT_EQ(DH_SUCCESS, encodeTrans_->SendMessage(type, content, dstDevId)); -} -} // namespace DistributedHardware -} // namespace OHOS diff --git a/services/audiotransport/test/unittest/receiverengine/BUILD.gn b/services/audiotransport/test/unittest/receiverengine/BUILD.gn index f7572da067e196d5b32f7df728e80d51c6b4e66f..ed6b92cfbfb6a42b4e82740d37066e51c73a43aa 100644 --- a/services/audiotransport/test/unittest/receiverengine/BUILD.gn +++ b/services/audiotransport/test/unittest/receiverengine/BUILD.gn @@ -50,7 +50,7 @@ ohos_unittest("AVTransReceiverAdapterTest") { configs = [ ":module_private_config" ] deps = [ - "${audio_transport_path}/decodetransport:distributed_audio_decode_transport", + "${audio_transport_path}/receiverengine:distributed_audio_decode_transport", "${services_path}/common:distributed_audio_utils", "//third_party/googletest:gmock", "//third_party/googletest:gtest_main", diff --git a/services/audiotransport/test/unittest/senderengine/BUILD.gn b/services/audiotransport/test/unittest/senderengine/BUILD.gn index a8e841868cdcb20ef59be995dd92acdee5d0c6f5..aa16a660d59495b48702aa7b5da81f0249388ead 100644 --- a/services/audiotransport/test/unittest/senderengine/BUILD.gn +++ b/services/audiotransport/test/unittest/senderengine/BUILD.gn @@ -49,7 +49,7 @@ ohos_unittest("AVTransSenderAdapterTest") { configs = [ ":module_private_config" ] deps = [ - "${audio_transport_path}/encodetransport:distributed_audio_encode_transport", + "${audio_transport_path}/senderengine:distributed_audio_encode_transport", "${services_path}/common:distributed_audio_utils", "//third_party/googletest:gmock", "//third_party/googletest:gtest_main", diff --git a/services/audiotransport/test/unittest/senderengine/src/av_sender_engine_adapter_test.cpp b/services/audiotransport/test/unittest/senderengine/src/av_sender_engine_adapter_test.cpp index 416a96423d7f0558692d8f7c4a99ceae25f2c22b..5c5d140ef515fa722fa98afb627ec2cf69e9b9c9 100644 --- a/services/audiotransport/test/unittest/senderengine/src/av_sender_engine_adapter_test.cpp +++ b/services/audiotransport/test/unittest/senderengine/src/av_sender_engine_adapter_test.cpp @@ -51,7 +51,7 @@ HWTEST_F(AVSenderEngineAdapterTest, Initialize_001, TestSize.Level1) std::string peerDevId = "peerDevId"; EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, senderAdapter_->Initialize(providerPtr, peerDevId)); senderAdapter_->initialized_ = true; - EXPECT_EQ(DH_SUCCESS, senderAdapter_->Initialize(providerPtr, peerDevId)); + EXPECT_EQ(ERR_DH_AUDIO_NULLPTR, senderAdapter_->Initialize(providerPtr, peerDevId)); } /**