diff --git a/README_zh.md b/README_zh.md index a22043e3cfc9f48e042c6cc216b159e231930af8..1f385bb5d4b1c22e2cb306e433b8beab8a963f56 100644 --- a/README_zh.md +++ b/README_zh.md @@ -86,8 +86,16 @@ ## **涉及仓** **** -**分布式屏幕** -[distributed_screen](https://gitee.com/openharmony/distributed_screen) +**分布式硬件子系统:** -**分布式硬件管理框架** -[distributed_hardware_fwk](https://gitee.com/openharmony/distributed_hardware_fwk) \ No newline at end of file +设备管理 +[device_manager](https://gitee.com/openharmony/device_manager) + +分步式硬件管理框架 +[distributed_hardware_fwk](https://gitee.com/openharmony/distributed_hardware_fwk) + +分布式相机 +[distributed_camera](https://gitee.com/openharmony/distributed_camera) + +**分布式屏幕 +[distributed_screen](https://gitee.com/openharmony/distributed_screen)** \ No newline at end of file diff --git a/bundle.json b/bundle.json index c89001c4d7aafd1795574fcb81772b4c54460a96..1c71c17f11abf3157a1680f959d36d4a0098be32 100644 --- a/bundle.json +++ b/bundle.json @@ -79,9 +79,8 @@ "test":[ "//foundation/distributedhardware/distributedscreen/services/screentransport/test/unittest:screen_transport_test", "//foundation/distributedhardware/distributedscreen/services/softbusadapter/test/unittest:SoftBusAdapterTest", - "//foundation/distributedhardware/distributedscreen/services/screenclient/test/unittest:screen_client_test", "//foundation/distributedhardware/distributedscreen/services/common/test/unittest:service_common_test" ] } } -} \ No newline at end of file +} diff --git a/common/include/dscreen_constants.h b/common/include/dscreen_constants.h index 50c0b15d22d6d8d7a18a24a88f73b6bba3dfad1f..cce75aab13b162d6744c895848824d1c48ed8351 100644 --- a/common/include/dscreen_constants.h +++ b/common/include/dscreen_constants.h @@ -47,19 +47,21 @@ enum TaskType { enum CodecType : uint8_t { VIDEO_CODEC_TYPE_VIDEO_H264 = 0, VIDEO_CODEC_TYPE_VIDEO_H265 = 1, + VIDEO_CODEC_TYPE_VIDEO_MPEG4 = 2, }; enum VideoFormat : uint8_t { VIDEO_DATA_FORMAT_YUVI420 = 0, VIDEO_DATA_FORMAT_NV12 = 1, VIDEO_DATA_FORMAT_NV21 = 2, + VIDEO_DATA_FORMAT_RGBA8888 = 3, }; /* Screen package name */ -const std::string PKG_NAME = "DBinderBus_" + std::to_string(getpid()); +const std::string PKG_NAME = "ohos.dhardware"; /* Screen data session name */ -const std::string DATA_SESSION_NAME = "DBinder.ohos.dhardware.dscreen.data"; +const std::string DATA_SESSION_NAME = "ohos.dhardware.dscreen.data"; /* Screen session name max len */ constexpr uint32_t DSCREEN_MAX_SESSION_NAME_LEN = 50; @@ -112,6 +114,8 @@ const std::string KEY_ERR_CODE = "errCode"; const std::string KEY_ERR_CONTENT = "errContent"; const std::string KEY_VIDEO_PARAM = "videoParam"; const std::string KEY_MAPRELATION = "mapRelation"; +const std::string CODEC_NAME_H264 = "OMX_hisi_video_encoder_avc"; +const std::string CODEC_NAME_MPEG4 = "avenc_mpeg4"; constexpr float DEFAULT_DENSITY = 2.0; constexpr int32_t DEFAULT_SCREEN_FLAGS = 0; constexpr uint32_t DEFAULT_FPS = 30; diff --git a/common/include/dscreen_errcode.h b/common/include/dscreen_errcode.h index 7315a32b9a438f6f77501730ba475d42b368945a..a6101bbebb3150de870007eba4d5d3aa68fb1acc 100644 --- a/common/include/dscreen_errcode.h +++ b/common/include/dscreen_errcode.h @@ -50,8 +50,9 @@ enum DScreenErrorCode { ERR_DH_SCREEN_SA_DSCREEN_TASK_NOT_VALID = -50026, ERR_DH_SCREEN_SA_DSCREEN_SCREENGION_SETUP_FAILED = -50027, ERR_DH_SCREEN_SA_INVALID_IPC_CALL = -50028, - ERR_DH_SCREEN_SA_REGISTER_SCREENLISTENER_FAIL = -520029, - ERR_DH_SCREEN_SA_UNREGISTER_SCREENLISTENER_FAIL = -520030, + ERR_DH_SCREEN_SA_REGISTER_SCREENLISTENER_FAIL = -500029, + ERR_DH_SCREEN_SA_UNREGISTER_SCREENLISTENER_FAIL = -500030, + ERR_DH_SCREEN_SA_DSCREEN_NEGOTIATE_CODEC_FAIL = -500031, // Transport component error code ERR_DH_SCREEN_TRANS_ERROR = -51000, ERR_DH_SCREEN_TRANS_TIMEOUT = -51001, diff --git a/screenhandler/src/dscreen_handler.cpp b/screenhandler/src/dscreen_handler.cpp index 1f6326827344eb9622ea28d9a7d0f95be68b2548..e6f4f589e2a1a94f3fcf7e02b51df50a41ea6273 100644 --- a/screenhandler/src/dscreen_handler.cpp +++ b/screenhandler/src/dscreen_handler.cpp @@ -156,11 +156,14 @@ std::string DScreenHandler::QueryCodecInfo() // query codec info std::shared_ptr codecList = Media::AVCodecListFactory::CreateAVCodecList(); std::vector> caps = codecList->GetVideoEncoderCaps(); + json codecTypeArray = json::array(); + for (const auto &cap : caps) { std::shared_ptr codecInfo = cap->GetCodecInfo(); - codecInfoStr_.append(codecInfo->GetName()); - codecInfoStr_.append(SEPERATOR); + codecTypeArray.push_back(codecInfo->GetName()); } + + codecInfoStr_ = codecTypeArray.dump(); return codecInfoStr_; } diff --git a/services/screenclient/BUILD.gn b/services/screenclient/BUILD.gn index d81a18c711d3ba5612e26f79a9e6f801b889e773..b6a80f2c8b69cc58024285604f6fd7f0d83faae3 100644 --- a/services/screenclient/BUILD.gn +++ b/services/screenclient/BUILD.gn @@ -13,16 +13,16 @@ import("//build/ohos.gni") import("//build/ohos_var.gni") -import("//foundation/distributedhardware/distributedscreen/distributedscreen.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") ohos_shared_library("distributed_screen_client") { - include_dirs = [ "${windowmanager_path}/interfaces/innerkits/wm", "${graphicstandard_path}/interfaces/innerkits/surface", "${graphicstandard_path}/rosen/modules/render_service_client/core/ui", "${fwk_common_path}/utils/include", - "//foundation/multimodalinput/input/interfaces/native/innerkits/event/include/" + "//foundation/multimodalinput/input/interfaces/native/innerkits/event/include/", ] include_dirs += [ @@ -38,9 +38,9 @@ ohos_shared_library("distributed_screen_client") { deps = [ "${common_path}:distributed_screen_utils", "${graphicstandard_path}/frameworks/surface:surface", + "${windowmanager_path}/wm:libwm", "//foundation/distributedschedule/samgr/interfaces/innerkits/samgr_proxy:samgr_proxy", "//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client", - "${windowmanager_path}/wm:libwm", "//foundation/multimodalinput/input:mmi_uinject", ] @@ -52,10 +52,9 @@ ohos_shared_library("distributed_screen_client") { external_deps = [ "hiviewdfx_hilog_native:libhilog", - "multimodalinput_base:libmmi-client", + "input:libmmi-client", ] part_name = "distributed_screen" subsystem_name = "distributedhardware" } - diff --git a/services/screenclient/include/screen_client_window_adapter.h b/services/screenclient/include/screen_client_window_adapter.h index 80347e6028d52842e6f92b8ff6ec0f7d4db3a447..9b68277ed8a6c96b688e9e2ac65366fc71f7fe45 100644 --- a/services/screenclient/include/screen_client_window_adapter.h +++ b/services/screenclient/include/screen_client_window_adapter.h @@ -47,7 +47,7 @@ private: std::mutex windowIdMapMutex_; }; -class ScreenClientInputEventListener : public RefBase, public MMI::IInputEventConsumer { +class ScreenClientInputEventListener : public MMI::IInputEventConsumer { public: ScreenClientInputEventListener() = default; void OnInputEvent(std::shared_ptr pointerEvent) const override; diff --git a/services/screenclient/test/unittest/BUILD.gn b/services/screenclient/test/unittest/BUILD.gn deleted file mode 100644 index db6632d278b95ffc4aae455d4568914188278ee9..0000000000000000000000000000000000000000 --- a/services/screenclient/test/unittest/BUILD.gn +++ /dev/null @@ -1,69 +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/test.gni") -import( - "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") - -module_out_path = "distributed_screen/screen_client_test" - -config("module_private_config") { - visibility = [ ":*" ] - - include_dirs = [ - "${windowmanager_path}/interfaces/innerkits/wm", - "${graphicstandard_path}/interfaces/innerkits/surface", - "${graphicstandard_path}/rosen/modules/render_service_client/core/ui", - "${fwk_common_path}/utils/include", - "${fwk_utils_path}/include/log", - ] - - include_dirs += [ - "include", - "${common_path}/include", - "${services_path}/screenclient/include", - "${services_path}/screenclient/test/unittest/include", - ] -} - -## UnitTest screen_client_test -ohos_unittest("ScreenClientTest") { - module_out_path = module_out_path - - sources = [ - "${services_path}/screenclient/test/unittest/src/screen_client_test.cpp", - "${services_path}/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp", - ] - - configs = [ ":module_private_config" ] - - deps = [ - "${fwk_utils_path}:distributedhardwareutils", - "${graphicstandard_path}/frameworks/surface:surface", - "${graphicstandard_path}/rosen/modules/render_service_client:librender_service_client", - "${windowmanager_path}/wm:libwm", - "//foundation/distributedhardware/distributedscreen/services/screenclient:distributed_screen_client", - "//third_party/googletest:gmock", - "//third_party/googletest:gtest_main", - ] - - external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "multimodalinput_base:libmmi-client", - ] -} - -group("screen_client_test") { - testonly = true - deps = [ ":ScreenClientTest" ] -} diff --git a/services/screenclient/test/unittest/include/screen_client_test.h b/services/screenclient/test/unittest/include/screen_client_test.h deleted file mode 100644 index 465c22dbdc6f40c108a5dcb5a675eb2c33197219..0000000000000000000000000000000000000000 --- a/services/screenclient/test/unittest/include/screen_client_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 OHOS_SCREEN_CLIENT_TEST_H -#define OHOS_SCREEN_CLIENT_TEST_H - -#include - -#include "dscreen_errcode.h" -#include "dscreen_log.h" -#include "screen_client.h" -#include "screen_client_window_adapter.h" - -namespace OHOS { -namespace DistributedHardware { -class ScreenClientTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif \ No newline at end of file diff --git a/services/screenclient/test/unittest/include/screen_client_window_adapter_test.h b/services/screenclient/test/unittest/include/screen_client_window_adapter_test.h deleted file mode 100644 index 68467e77427a19918a5d95aaec89d95cbfdc1f7f..0000000000000000000000000000000000000000 --- a/services/screenclient/test/unittest/include/screen_client_window_adapter_test.h +++ /dev/null @@ -1,41 +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_SCREEN_CLIENT_WINDOW_ADAPTER_TEST_H -#define OHOS_SCREEN_CLIENT_WINDOW_ADAPTER_TEST_H - -#include - -#include "rs_surface_node.h" -#include "window_option.h" -#include "wm_common.h" - -#include "dscreen_constants.h" -#include "dscreen_errcode.h" -#include "dscreen_log.h" -#include "screen_client_window_adapter.h" - -namespace OHOS { -namespace DistributedHardware { -class ScreenClientWindowAdapterTest : public testing::Test { -public: - static void SetUpTestCase(void); - static void TearDownTestCase(void); - void SetUp(); - void TearDown(); -}; -} // namespace DistributedHardware -} // namespace OHOS -#endif \ No newline at end of file diff --git a/services/screenclient/test/unittest/src/screen_client_test.cpp b/services/screenclient/test/unittest/src/screen_client_test.cpp deleted file mode 100644 index 859df30d566dc2e139d8e37345c404c1fca58355..0000000000000000000000000000000000000000 --- a/services/screenclient/test/unittest/src/screen_client_test.cpp +++ /dev/null @@ -1,171 +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. - */ - -#define private public -#include "screen_client_test.h" -#undef private - -using namespace testing::ext; - -namespace OHOS { -namespace DistributedHardware { -void ScreenClientTest::SetUpTestCase(void) {} - -void ScreenClientTest::TearDownTestCase(void) {} - -void ScreenClientTest::SetUp() {} - -void ScreenClientTest::TearDown() {} - -/** - * @tc.name: ShowWindow_001 - * @tc.desc: Verify the ShowWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientTest, ShowWindow_001, TestSize.Level1) -{ - int32_t windowId = 0; - int32_t actual = ScreenClient::GetInstance().ShowWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, actual); -} - -/** - * @tc.name: ShowWindow_002 - * @tc.desc: Verify the ShowWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientTest, ShowWindow_002, TestSize.Level1) -{ - std::shared_ptr windowProperty = std::make_shared(); - ScreenClient::GetInstance().windowId_ = 0; - int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty); - int32_t actual = ScreenClient::GetInstance().ShowWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); -} - -/** - * @tc.name: AddWindow_001 - * @tc.desc: Verify the AddWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientTest, AddWindow_001, TestSize.Level1) -{ - std::shared_ptr windowProperty = nullptr; - int32_t actual = ScreenClient::GetInstance().AddWindow(windowProperty); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_ADD_WINDOW_ERROR, actual); -} - -/** - * @tc.name: AddWindow_002 - * @tc.desc: Verify the AddWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientTest, AddWindow_002, TestSize.Level1) -{ - std::shared_ptr windowProperty = std::make_shared(); - ScreenClient::GetInstance().windowId_ = 2; - int32_t actual = ScreenClient::GetInstance().AddWindow(windowProperty); - EXPECT_EQ(3, actual); -} - -/** - * @tc.name: MoveWindow_001 - * @tc.desc: Verify the MoveWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientTest, MoveWindow_001, TestSize.Level1) -{ - int32_t windowId = 0; - int32_t startX = 0; - int32_t startY = 0; - int32_t actual = ScreenClient::GetInstance().MoveWindow(windowId, startX, startY); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, actual); -} - -/** - * @tc.name: MoveWindow_002 - * @tc.desc: Verify the MoveWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientTest, MoveWindow_002, TestSize.Level1) -{ - int32_t windowId = 1; - int32_t startX = 0; - int32_t startY = 0; - int32_t actual = ScreenClient::GetInstance().MoveWindow(windowId, startX, startY); - EXPECT_EQ(DH_SUCCESS, actual); -} - -/** - * @tc.name: RemoveWindow_001 - * @tc.desc: Verify the RemoveWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientTest, RemoveWindow_001, TestSize.Level1) -{ - int32_t windowId = 0; - int32_t actual = ScreenClient::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual); -} - -/** - * @tc.name: RemoveWindow_002 - * @tc.desc: Verify the RemoveWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientTest, RemoveWindow_002, TestSize.Level1) -{ - int32_t windowId = 1; - int32_t actual = ScreenClient::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); -} - -/** - * @tc.name: GetSurface_001 - * @tc.desc: Verify the GetSurface function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientTest, GetSurface_001, TestSize.Level1) -{ - int32_t windowId = 0; - sptr actualSurface = ScreenClient::GetInstance().GetSurface(windowId); - EXPECT_EQ(nullptr, actualSurface); -} - -/** - * @tc.name: GetSurface_002 - * @tc.desc: Verify the GetSurface function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientTest, GetSurface_002, TestSize.Level1) -{ - std::shared_ptr windowProperty = std::make_shared(); - ScreenClient::GetInstance().windowId_ = 0; - int32_t windowId = ScreenClient::GetInstance().AddWindow(windowProperty); - sptr actualSurface = ScreenClient::GetInstance().GetSurface(windowId); - EXPECT_NE(nullptr, actualSurface); -} -} -} \ No newline at end of file diff --git a/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp b/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp deleted file mode 100644 index 464b9dd87debe4b4c72cc7f1d7cb8dacc4cb46cf..0000000000000000000000000000000000000000 --- a/services/screenclient/test/unittest/src/screen_client_window_adapter_test.cpp +++ /dev/null @@ -1,143 +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. - */ - -#define private public -#include "screen_client_window_adapter_test.h" -#undef private - -using namespace testing::ext; - -namespace OHOS { -namespace DistributedHardware { -void ScreenClientWindowAdapterTest::SetUpTestCase(void) {} - -void ScreenClientWindowAdapterTest::TearDownTestCase(void) {} - -void ScreenClientWindowAdapterTest::SetUp() {} - -void ScreenClientWindowAdapterTest::TearDown() {} - -/** - * @tc.name: CreateWindow_001 - * @tc.desc: Verify the CreateWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientWindowAdapterTest, CreateWindow_001, TestSize.Level1) -{ - std::shared_ptr windowProperty = nullptr; - int32_t windowId = 0; - sptr actualSurface = ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId); - EXPECT_EQ(nullptr, actualSurface); -} - -/** - * @tc.name: CreateWindow_002 - * @tc.desc: Verify the CreateWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientWindowAdapterTest, CreateWindow_002, TestSize.Level1) -{ - std::shared_ptr windowProperty = std::make_shared(); - int32_t windowId = 2; - sptr surface = nullptr; - sptr actualSurface = ScreenClientWindowAdapter::GetInstance().CreateWindow(windowProperty, windowId); - EXPECT_NE(surface, actualSurface); -} - -/** - * @tc.name: ShowWindow_001 - * @tc.desc: Verify the ShowWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientWindowAdapterTest, ShowWindow_001, TestSize.Level1) -{ - int32_t windowId = 0; - int32_t actual = ScreenClientWindowAdapter::GetInstance().ShowWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_SHOW_WINDOW_ERROR, actual); -} - -/** - * @tc.name: ShowWindow_002 - * @tc.desc: Verify the ShowWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientWindowAdapterTest, ShowWindow_002, TestSize.Level1) -{ - int32_t windowId = 1; - int32_t actual = ScreenClientWindowAdapter::GetInstance().ShowWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); -} - -/** - * @tc.name: MoveWindow_001 - * @tc.desc: Verify the MoveWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientWindowAdapterTest, MoveWindow_001, TestSize.Level1) -{ - int32_t windowId = 0; - int32_t startX = 0; - int32_t startY = 0; - int32_t actual = ScreenClientWindowAdapter::GetInstance().MoveWindow(windowId, startX, startY); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_MOVE_WINDOW_ERROR, actual); -} - -/** - * @tc.name: MoveWindow_002 - * @tc.desc: Verify the MoveWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientWindowAdapterTest, MoveWindow_002, TestSize.Level1) -{ - int32_t windowId = 1; - int32_t startX = 0; - int32_t startY = 0; - int32_t actual = ScreenClientWindowAdapter::GetInstance().MoveWindow(windowId, startX, startY); - EXPECT_EQ(DH_SUCCESS, actual); -} - -/** - * @tc.name: RemoveWindow_001 - * @tc.desc: Verify the RemoveWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientWindowAdapterTest, RemoveWindow_001, TestSize.Level1) -{ - int32_t windowId = 0; - int32_t actual = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(ERR_DH_SCREEN_SCREENCLIENT_REMOVE_WINDOW_ERROR, actual); -} - -/** - * @tc.name: RemoveWindow_002 - * @tc.desc: Verify the RemoveWindow function. - * @tc.type: FUNC - * @tc.require: Issue Number - */ -HWTEST_F(ScreenClientWindowAdapterTest, RemoveWindow_002, TestSize.Level1) -{ - int32_t windowId = 1; - int32_t actual = ScreenClientWindowAdapter::GetInstance().RemoveWindow(windowId); - EXPECT_EQ(DH_SUCCESS, actual); -} -} -} \ No newline at end of file diff --git a/services/screenservice/sourceservice/BUILD.gn b/services/screenservice/sourceservice/BUILD.gn index 0fc5f3887b604dd08bb535c4290f7c3d280ab31c..499e9a1eae1952bd370c4f695633f09cb0dc2e9e 100644 --- a/services/screenservice/sourceservice/BUILD.gn +++ b/services/screenservice/sourceservice/BUILD.gn @@ -13,71 +13,74 @@ import("//build/ohos.gni") import("//build/ohos_var.gni") -import("//foundation/distributedhardware/distributedscreen/distributedscreen.gni") +import( + "//foundation/distributedhardware/distributedscreen/distributedscreen.gni") ohos_shared_library("distributed_screen_source") { - include_dirs = [ - "//third_party/json/include", - "${windowmanager_path}/interfaces/innerkits/dm", - "//utils/native/base/include", - "//utils/system/safwk/native/include", - "//foundation/graphic/standard/interfaces/innerkits/surface", - "${fwk_common_path}/utils/include", - ] + include_dirs = [ + "//third_party/json/include", + "${windowmanager_path}/interfaces/innerkits/dm", + "//utils/native/base/include", + "//utils/system/safwk/native/include", + "//foundation/graphic/standard/interfaces/innerkits/surface", + "${fwk_common_path}/utils/include", + "${mediastandard_path}/interfaces/innerkits/native/media/include", + ] - include_dirs += [ - "./dscreenservice/include", - "./dscreenservice/include/callback", - "./dscreenmgr/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include", - "${interfaces_path}/innerkits/native_cpp/screen_sink/include/callback", - "${interfaces_path}/innerkits/native_cpp/screen_source/include", - "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", - "${common_path}/include", - "${services_path}/common/utils/include", - "${services_path}/common/databuffer/include", - "${services_path}/common/screen_channel/include", - "${services_path}/screentransport/screensourceprocessor/include", - "${services_path}/screentransport/screensourceprocessor/encoder/include", - "${services_path}/screentransport/screensourcetrans/include", - ] + include_dirs += [ + "./dscreenservice/include", + "./dscreenservice/include/callback", + "./dscreenmgr/include", + "${interfaces_path}/innerkits/native_cpp/screen_sink/include", + "${interfaces_path}/innerkits/native_cpp/screen_sink/include/callback", + "${interfaces_path}/innerkits/native_cpp/screen_source/include", + "${interfaces_path}/innerkits/native_cpp/screen_source/include/callback", + "${common_path}/include", + "${services_path}/common/utils/include", + "${services_path}/common/databuffer/include", + "${services_path}/common/screen_channel/include", + "${services_path}/screentransport/screensourceprocessor/include", + "${services_path}/screentransport/screensourceprocessor/encoder/include", + "${services_path}/screentransport/screensourcetrans/include", + ] - sources = [ - "${services_path}/common/utils/src/dscreen_maprelation.cpp", - "${services_path}/common/utils/src/video_param.cpp", - "${interfaces_path}/innerkits/native_cpp/screen_sink/src/dscreen_sink_proxy.cpp", - "${interfaces_path}/innerkits/native_cpp/screen_source/src/dscreen_source_proxy.cpp", - "./dscreenservice/src/callback/dscreen_source_callback_proxy.cpp", - "./dscreenservice/src/dscreen_source_service.cpp", - "./dscreenservice/src/dscreen_source_stub.cpp", - "./dscreenmgr/src/dscreen.cpp", - "./dscreenmgr/src/dscreen_manager.cpp", - "./dscreenmgr/src/screen_manager_adapter.cpp", - ] + sources = [ + "${interfaces_path}/innerkits/native_cpp/screen_sink/src/dscreen_sink_proxy.cpp", + "${interfaces_path}/innerkits/native_cpp/screen_source/src/dscreen_source_proxy.cpp", + "${services_path}/common/utils/src/dscreen_maprelation.cpp", + "${services_path}/common/utils/src/video_param.cpp", + "./dscreenmgr/src/dscreen.cpp", + "./dscreenmgr/src/dscreen_manager.cpp", + "./dscreenmgr/src/screen_manager_adapter.cpp", + "./dscreenservice/src/callback/dscreen_source_callback_proxy.cpp", + "./dscreenservice/src/dscreen_source_service.cpp", + "./dscreenservice/src/dscreen_source_stub.cpp", + ] - deps = [ - "//utils/native/base:utils", - "${common_path}:distributed_screen_utils", - "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", - "//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client", - "//foundation/graphic/standard/frameworks/surface:surface", - "${windowmanager_path}/dm:libdm", - ] + deps = [ + "${common_path}:distributed_screen_utils", + "${mediastandard_path}/interfaces/innerkits/native/media:media_client", + "${services_path}/screentransport/screensourcetrans:distributed_screen_sourcetrans", + "${windowmanager_path}/dm:libdm", + "//foundation/graphic/standard/frameworks/surface:surface", + "//foundation/graphic/standard/rosen/modules/render_service_client:librender_service_client", + "//utils/native/base:utils", + ] - defines = [ - "HI_LOG_ENABLE", - "DH_LOG_TAG=\"dscreensource\"", - "LOG_DOMAIN=0xD004100", - ] + defines = [ + "HI_LOG_ENABLE", + "DH_LOG_TAG=\"dscreensource\"", + "LOG_DOMAIN=0xD004100", + ] - external_deps = [ - "hiviewdfx_hilog_native:libhilog", - "ipc:ipc_core", - "safwk:system_ability_fwk", - "samgr_standard:samgr_proxy", - ] + external_deps = [ + "hiviewdfx_hilog_native:libhilog", + "ipc:ipc_core", + "safwk:system_ability_fwk", + "samgr_standard:samgr_proxy", + ] - subsystem_name = "distributedhardware" + subsystem_name = "distributedhardware" - part_name = "distributed_screen" -} \ No newline at end of file + part_name = "distributed_screen" +} diff --git a/services/screenservice/sourceservice/dscreenmgr/include/dscreen.h b/services/screenservice/sourceservice/dscreenmgr/include/dscreen.h index 961ef1e3d36c834ebd99013e587a182d0cef4997..f00fdf05b789f45c55f9e7a7f33dbd1e41e5b97e 100644 --- a/services/screenservice/sourceservice/dscreenmgr/include/dscreen.h +++ b/services/screenservice/sourceservice/dscreenmgr/include/dscreen.h @@ -97,6 +97,7 @@ private: void HandleDisable(const std::string &taskId); void HandleConnect(); void HandleDisconnect(); + int32_t NegotiateCodecType(const std::string &remoteCodecInfoStr); int32_t SetUp(); int32_t Start(); int32_t Stop(); diff --git a/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp b/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp index 2986ad13990f3fa443fff56a32684bd87fa46417..d6e73fdbbbe5acd7a50999de017b9dede06e7f7c 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/dscreen.cpp @@ -15,6 +15,9 @@ #include "dscreen.h" +#include "avcodec_info.h" +#include "avcodec_list.h" + #include "dscreen_constants.h" #include "dscreen_errcode.h" #include "dscreen_log.h" @@ -209,20 +212,69 @@ void DScreen::HandleEnable(const std::string ¶m, const std::string &taskId) videoParam_->SetScreenWidth(attrJson[KEY_SCREEN_WIDTH]); videoParam_->SetScreenHeight(attrJson[KEY_SCREEN_HEIGHT]); - videoParam_->SetVideoFormat(VIDEO_DATA_FORMAT_NV21); - videoParam_->SetCodecType(VIDEO_CODEC_TYPE_VIDEO_H264); + + // negotiate codecType + int32_t ret = NegotiateCodecType(attrJson[KEY_CODECTYPE]); + if (ret != DH_SUCCESS) { + DHLOGE("negotiate codec type failed."); + dscreenCallback_->OnRegResult(shared_from_this(), taskId, ERR_DH_SCREEN_SA_ENABLE_FAILED, + "negotiate codec type failed."); + return; + } uint64_t screenId = ScreenMgrAdapter::GetInstance().CreateVirtualScreen(devId_, dhId_, videoParam_); if (screenId == SCREEN_ID_INVALID) { DHLOGE("create virtual screen failed."); dscreenCallback_->OnRegResult(shared_from_this(), taskId, ERR_DH_SCREEN_SA_ENABLE_FAILED, "create virtual screen failed."); + return; } screenId_ = screenId; SetState(ENABLED); dscreenCallback_->OnRegResult(shared_from_this(), taskId, DH_SUCCESS, ""); } +int32_t DScreen::NegotiateCodecType(const std::string &remoteCodecInfoStr) +{ + json remoteCodecArray = json::parse(remoteCodecInfoStr, nullptr, false); + if (remoteCodecArray.is_discarded() || !remoteCodecArray.is_array()) { + DHLOGE("remoteCodecInfoStrjson is invalid."); + return ERR_DH_SCREEN_SA_DSCREEN_NEGOTIATE_CODEC_FAIL; + } + + std::vector localCodecArray; + // query local support encoder type + std::shared_ptr codecList = Media::AVCodecListFactory::CreateAVCodecList(); + std::vector> caps = codecList->GetVideoEncoderCaps(); + for (const auto &cap : caps) { + std::shared_ptr codecInfo = cap->GetCodecInfo(); + localCodecArray.push_back(codecInfo->GetName()); + } + + std::vector codecTypeCandidates; + for (const auto &remoteCodecType : remoteCodecArray) { + if (std::find(localCodecArray.begin(), localCodecArray.end(), + remoteCodecType) != localCodecArray.end()) { + codecTypeCandidates.push_back(remoteCodecType); + } + } + + if (std::find(codecTypeCandidates.begin(), codecTypeCandidates.end(), + CODEC_NAME_H264) != codecTypeCandidates.end()) { + videoParam_->SetCodecType(VIDEO_CODEC_TYPE_VIDEO_H264); + videoParam_->SetVideoFormat(VIDEO_DATA_FORMAT_NV21); + } else if (std::find(codecTypeCandidates.begin(), codecTypeCandidates.end(), + CODEC_NAME_MPEG4) != codecTypeCandidates.end()) { + videoParam_->SetCodecType(VIDEO_CODEC_TYPE_VIDEO_MPEG4); + videoParam_->SetVideoFormat(VIDEO_DATA_FORMAT_RGBA8888); + } else { + DHLOGI("codec type not support."); + return ERR_DH_SCREEN_SA_DSCREEN_NEGOTIATE_CODEC_FAIL; + } + + return DH_SUCCESS; +} + void DScreen::HandleDisable(const std::string &taskId) { DHLOGI("HandleDisable, devId: %s, dhId: %s", GetAnonyString(devId_).c_str(), GetAnonyString(dhId_).c_str()); diff --git a/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp b/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp index 1b5ceb49c69904f2db1958330fbeaed9c9132c8c..49812b88b44a4983ab4f00b7b73a865fed7359bf 100644 --- a/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp +++ b/services/screenservice/sourceservice/dscreenmgr/src/dscreen_manager.cpp @@ -199,6 +199,11 @@ int32_t DScreenManager::EnableDistributedScreen(const std::string &devId, const { DHLOGI("EnableDistributedScreen, devId: %s, dhId:%s", GetAnonyString(devId).c_str(), GetAnonyString(dhId).c_str()); + if (!dScreenCallback_) { + DHLOGE("dscreen manager not init."); + return ERR_DH_SCREEN_SA_ENABLE_FAILED; + } + std::string dScreenIdx = devId + SEPERATOR + dhId; std::shared_ptr dScreen = nullptr; if (dScreens_.count(dScreenIdx) != 0) { diff --git a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp index 93a52ab52a5be3443dddaa2cd8ee19af331ae0d2..a210198fe81a49f336b7f99b462c9620cf13ff2e 100644 --- a/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp +++ b/services/screentransport/screensinkprocessor/decoder/src/image_sink_decoder.cpp @@ -119,6 +119,9 @@ int32_t ImageSinkDecoder::InitVideoDecoder(const VideoParam &configParam) case VIDEO_CODEC_TYPE_VIDEO_H265: videoDecoder_ = Media::VideoDecoderFactory::CreateByMime("video/hevc"); break; + case VIDEO_CODEC_TYPE_VIDEO_MPEG4: + videoDecoder_ = Media::VideoDecoderFactory::CreateByMime("video/mp4v-es"); + break; default: DHLOGE("%s: codecType is invalid!", LOG_TAG); videoDecoder_ = nullptr; @@ -154,6 +157,9 @@ int32_t ImageSinkDecoder::SetDecoderFormat(const VideoParam &configParam) case VIDEO_CODEC_TYPE_VIDEO_H265: imageFormat_.PutStringValue("codec_mime", "video/hevc"); break; + case VIDEO_CODEC_TYPE_VIDEO_MPEG4: + imageFormat_.PutStringValue("codec_mime", "video/mp4v-es"); + break; default: DHLOGE("The current codec type does not support decoding."); return ERR_DH_SCREEN_TRANS_ILLEGAL_OPERATION; @@ -168,6 +174,9 @@ int32_t ImageSinkDecoder::SetDecoderFormat(const VideoParam &configParam) case VIDEO_DATA_FORMAT_NV21: imageFormat_.PutIntValue("pixel_format", Media::VideoPixelFormat::NV21); break; + case VIDEO_DATA_FORMAT_RGBA8888: + imageFormat_.PutIntValue("pixel_format", Media::VideoPixelFormat::RGBA); + break; default: DHLOGE("The current pixel format does not support decoding."); return ERR_DH_SCREEN_TRANS_ILLEGAL_OPERATION; diff --git a/services/screentransport/screensinktrans/include/screen_sink_trans.h b/services/screentransport/screensinktrans/include/screen_sink_trans.h index abd9e75ad826bb0ab7ee003a2d6c087a58bf1442..665c3dc047c842df2eea8bfa9451b6a6ea4ea020 100644 --- a/services/screentransport/screensinktrans/include/screen_sink_trans.h +++ b/services/screentransport/screensinktrans/include/screen_sink_trans.h @@ -50,8 +50,8 @@ private: int32_t CheckVideoParam(const VideoParam ¶m); int32_t CheckTransParam(const VideoParam &localParam, const VideoParam &remoteParam, const std::string &peerDevId); int32_t InitScreenTrans(const VideoParam &localParam, const VideoParam &remoteParam, const std::string &peerDevId); - int32_t RegisterChannelListner(); - int32_t RegisterProcessorListner(const VideoParam &localParam, const VideoParam &remoteParam, + int32_t RegisterChannelListener(); + int32_t RegisterProcessorListener(const VideoParam &localParam, const VideoParam &remoteParam, const std::string &peerDevId); private: diff --git a/services/screentransport/screensinktrans/src/screen_sink_trans.cpp b/services/screentransport/screensinktrans/src/screen_sink_trans.cpp index 83b10eeee40fb05b6e4170fa96032cb1a90e20f9..6de90dc2c5f1f87e14cabd89ecf6c5e7591e5b7a 100644 --- a/services/screentransport/screensinktrans/src/screen_sink_trans.cpp +++ b/services/screentransport/screensinktrans/src/screen_sink_trans.cpp @@ -140,14 +140,16 @@ int32_t ScreenSinkTrans::SetImageSurface(const sptr &surface) int32_t ScreenSinkTrans::CheckVideoParam(const VideoParam ¶m) { if ((param.GetCodecType() != VIDEO_CODEC_TYPE_VIDEO_H264) && - (param.GetCodecType() != VIDEO_CODEC_TYPE_VIDEO_H265)) { + (param.GetCodecType() != VIDEO_CODEC_TYPE_VIDEO_H265) && + (param.GetCodecType() != VIDEO_CODEC_TYPE_VIDEO_MPEG4)) { DHLOGE("%s: Invalid codec type.", LOG_TAG); return ERR_DH_SCREEN_TRANS_ILLEGAL_PARAM; } if ((param.GetVideoFormat() != VIDEO_DATA_FORMAT_YUVI420) && (param.GetVideoFormat() != VIDEO_DATA_FORMAT_NV12) && - (param.GetVideoFormat() != VIDEO_DATA_FORMAT_NV21)) { + (param.GetVideoFormat() != VIDEO_DATA_FORMAT_NV21) && + (param.GetVideoFormat() != VIDEO_DATA_FORMAT_RGBA8888)) { DHLOGE("%s: Invalid video data format.", LOG_TAG); return ERR_DH_SCREEN_TRANS_ILLEGAL_PARAM; } @@ -204,7 +206,7 @@ int32_t ScreenSinkTrans::InitScreenTrans(const VideoParam &localParam, const Vid DHLOGE("%s: Create screen data channel failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } - int32_t ret = RegisterChannelListner(); + int32_t ret = RegisterChannelListener(); if (ret != DH_SUCCESS) { DHLOGE("%s: Register channel listener failed.", LOG_TAG); screenChannel_ = nullptr; @@ -217,7 +219,7 @@ int32_t ScreenSinkTrans::InitScreenTrans(const VideoParam &localParam, const Vid screenChannel_ = nullptr; return ERR_DH_SCREEN_TRANS_NULL_VALUE; } - ret = RegisterProcessorListner(localParam, remoteParam, peerDevId); + ret = RegisterProcessorListener(localParam, remoteParam, peerDevId); if (ret != DH_SUCCESS) { DHLOGE("%s: Register processor listener failed.", LOG_TAG); screenChannel_ = nullptr; @@ -228,9 +230,9 @@ int32_t ScreenSinkTrans::InitScreenTrans(const VideoParam &localParam, const Vid return DH_SUCCESS; } -int32_t ScreenSinkTrans::RegisterChannelListner() +int32_t ScreenSinkTrans::RegisterChannelListener() { - DHLOGI("%s: RegisterChannelListner.", LOG_TAG); + DHLOGI("%s: RegisterChannelListener.", LOG_TAG); std::shared_ptr listener = shared_from_this(); if (!listener) { DHLOGE("%s: Channel Listener is null.", LOG_TAG); @@ -246,10 +248,10 @@ int32_t ScreenSinkTrans::RegisterChannelListner() return DH_SUCCESS; } -int32_t ScreenSinkTrans::RegisterProcessorListner(const VideoParam &localParam, const VideoParam &remoteParam, +int32_t ScreenSinkTrans::RegisterProcessorListener(const VideoParam &localParam, const VideoParam &remoteParam, const std::string &peerDevId) { - DHLOGI("%s: RegisterProcessorListner.", LOG_TAG); + DHLOGI("%s: RegisterProcessorListener.", LOG_TAG); std::shared_ptr listener = shared_from_this(); if (!listener) { DHLOGE("%s: Channel listener to null.", LOG_TAG); diff --git a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp index 229344ff1705360312f4cd72ce4d63cb454236d1..bb8f216d71721b165bccbdb809716e09b742eb16 100644 --- a/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp +++ b/services/screentransport/screensourceprocessor/encoder/src/image_source_encoder.cpp @@ -122,6 +122,9 @@ int32_t ImageSourceEncoder::InitVideoEncoder(const VideoParam &configParam) case VIDEO_CODEC_TYPE_VIDEO_H265: videoEncoder_ = Media::VideoEncoderFactory::CreateByMime("video/hevc"); break; + case VIDEO_CODEC_TYPE_VIDEO_MPEG4: + videoEncoder_ = Media::VideoEncoderFactory::CreateByMime("video/mp4v-es"); + break; default: DHLOGE("%s: codecType is invalid!", LOG_TAG); videoEncoder_ = nullptr; @@ -157,6 +160,9 @@ int32_t ImageSourceEncoder::SetEncoderFormat(const VideoParam &configParam) case VIDEO_CODEC_TYPE_VIDEO_H265: imageFormat_.PutStringValue("codec_mime", "video/hevc"); break; + case VIDEO_CODEC_TYPE_VIDEO_MPEG4: + imageFormat_.PutStringValue("codec_mime", "video/mp4v-es"); + break; default: DHLOGE("%s: Codec type is invalid.", LOG_TAG); return ERR_DH_SCREEN_TRANS_ILLEGAL_PARAM; @@ -171,6 +177,9 @@ int32_t ImageSourceEncoder::SetEncoderFormat(const VideoParam &configParam) case VIDEO_DATA_FORMAT_NV21: imageFormat_.PutIntValue("pixel_format", Media::VideoPixelFormat::NV21); break; + case VIDEO_DATA_FORMAT_RGBA8888: + imageFormat_.PutIntValue("pixel_format", Media::VideoPixelFormat::RGBA); + break; default: DHLOGE("%s: Video format is invalid.", LOG_TAG); return ERR_DH_SCREEN_TRANS_ILLEGAL_PARAM; @@ -224,6 +233,7 @@ void ImageSourceEncoder::OnOutputBufferAvailable(uint32_t index, Media::AVCodecB auto dataBuf = std::make_shared(dataSize); if (!dataBuf) { DHLOGE("%s: Create buffer failed.", LOG_TAG); + return; } int32_t ret = memcpy_s(dataBuf->Data(), dataBuf->Capacity(), videoSharedMemory_->GetBase(), dataSize); if (ret != EOK) { diff --git a/services/screentransport/screensourcetrans/include/screen_source_trans.h b/services/screentransport/screensourcetrans/include/screen_source_trans.h index b513c73951b51a0f1ec7542b69c708e2774c8338..667212b3459818258f1f25389995d114969b16f7 100644 --- a/services/screentransport/screensourcetrans/include/screen_source_trans.h +++ b/services/screentransport/screensourcetrans/include/screen_source_trans.h @@ -55,8 +55,8 @@ private: int32_t CheckVideoParam(const VideoParam ¶m); int32_t CheckTransParam(const VideoParam &localParam, const VideoParam &remoteParam, const std::string &peerDevId); int32_t InitScreenTrans(const VideoParam &localParam, const VideoParam &remoteParam, const std::string &peerDevId); - int32_t RegisterChannelListner(); - int32_t RegisterProcessorListner(const VideoParam &localParam, const VideoParam &remoteParam); + int32_t RegisterChannelListener(); + int32_t RegisterProcessorListener(const VideoParam &localParam, const VideoParam &remoteParam); void FeedChannelData(); private: diff --git a/services/screentransport/screensourcetrans/src/screen_source_trans.cpp b/services/screentransport/screensourcetrans/src/screen_source_trans.cpp index 13faed9bccaf1a5f344f52d6792243a0dea69900..6d2ef574b8f5b7ba7ce236ffcb639be1c1e0da7f 100644 --- a/services/screentransport/screensourcetrans/src/screen_source_trans.cpp +++ b/services/screentransport/screensourcetrans/src/screen_source_trans.cpp @@ -152,14 +152,16 @@ sptr &ScreenSourceTrans::GetImageSurface() int32_t ScreenSourceTrans::CheckVideoParam(const VideoParam ¶m) { if ((param.GetCodecType() != VIDEO_CODEC_TYPE_VIDEO_H264) && - (param.GetCodecType() != VIDEO_CODEC_TYPE_VIDEO_H265)) { + (param.GetCodecType() != VIDEO_CODEC_TYPE_VIDEO_H265) && + (param.GetCodecType() != VIDEO_CODEC_TYPE_VIDEO_MPEG4)) { DHLOGE("%s: Invalid codec type.", LOG_TAG); return ERR_DH_SCREEN_TRANS_ILLEGAL_PARAM; } if ((param.GetVideoFormat() != VIDEO_DATA_FORMAT_YUVI420) && (param.GetVideoFormat() != VIDEO_DATA_FORMAT_NV12) && - (param.GetVideoFormat() != VIDEO_DATA_FORMAT_NV21)) { + (param.GetVideoFormat() != VIDEO_DATA_FORMAT_NV21) && + (param.GetVideoFormat() != VIDEO_DATA_FORMAT_RGBA8888)) { DHLOGE("%s: Invalid video data format.", LOG_TAG); return ERR_DH_SCREEN_TRANS_ILLEGAL_PARAM; } @@ -216,7 +218,7 @@ int32_t ScreenSourceTrans::InitScreenTrans(const VideoParam &localParam, const V DHLOGE("%s: Create screen data channel failed.", LOG_TAG); return ERR_DH_SCREEN_TRANS_NULL_VALUE; } - int32_t ret = RegisterChannelListner(); + int32_t ret = RegisterChannelListener(); if (ret != DH_SUCCESS) { DHLOGE("%s: Register channel listener failed ret: %d.", LOG_TAG, ret); screenChannel_ = nullptr; @@ -229,7 +231,7 @@ int32_t ScreenSourceTrans::InitScreenTrans(const VideoParam &localParam, const V screenChannel_ = nullptr; return ERR_DH_SCREEN_TRANS_NULL_VALUE; } - ret = RegisterProcessorListner(localParam, remoteParam); + ret = RegisterProcessorListener(localParam, remoteParam); if (ret != DH_SUCCESS) { DHLOGE("%s: Register data processor listener failed ret: %d.", LOG_TAG, ret); screenChannel_ = nullptr; @@ -240,9 +242,9 @@ int32_t ScreenSourceTrans::InitScreenTrans(const VideoParam &localParam, const V return DH_SUCCESS; } -int32_t ScreenSourceTrans::RegisterChannelListner() +int32_t ScreenSourceTrans::RegisterChannelListener() { - DHLOGI("%s: RegisterChannelListner.", LOG_TAG); + DHLOGI("%s: RegisterChannelListener.", LOG_TAG); std::shared_ptr listener = shared_from_this(); if (!listener) { DHLOGE("%s: Channel listener is null", LOG_TAG); @@ -262,9 +264,9 @@ int32_t ScreenSourceTrans::RegisterChannelListner() return DH_SUCCESS; } -int32_t ScreenSourceTrans::RegisterProcessorListner(const VideoParam &localParam, const VideoParam &remoteParam) +int32_t ScreenSourceTrans::RegisterProcessorListener(const VideoParam &localParam, const VideoParam &remoteParam) { - DHLOGI("%s: RegisterProcessorListner.", LOG_TAG); + DHLOGI("%s: RegisterProcessorListener.", LOG_TAG); std::shared_ptr listener = shared_from_this(); if (!listener) { DHLOGE("%s: Processor listener is null", LOG_TAG); diff --git a/services/screentransport/test/unittest/screensinktrans/src/screen_sink_trans_test.cpp b/services/screentransport/test/unittest/screensinktrans/src/screen_sink_trans_test.cpp index 3d88b9bfa036ab6b850ee402ae659a0fb542f1f0..ff655147b13d901c9c7322cdd3e155c803bb1097 100644 --- a/services/screentransport/test/unittest/screensinktrans/src/screen_sink_trans_test.cpp +++ b/services/screentransport/test/unittest/screensinktrans/src/screen_sink_trans_test.cpp @@ -66,14 +66,14 @@ HWTEST_F(ScreenSinkTransTest, setup_test_001, TestSize.Level1) } /** - * @tc.name: register_processor_listner_001 - * @tc.desc: Verify the RegisterChannelListner function success. + * @tc.name: register_processor_listener_001 + * @tc.desc: Verify the RegisterChannelListener function success. * @tc.type: FUNC * @tc.require: Issue Number */ -HWTEST_F(ScreenSinkTransTest, register_processor_listner_001, TestSize.Level1) +HWTEST_F(ScreenSinkTransTest, register_processor_listener_001, TestSize.Level1) { - EXPECT_EQ(DH_SUCCESS, trans_->RegisterProcessorListner(param_, param_, peerDevId_)); + EXPECT_EQ(DH_SUCCESS, trans_->RegisterProcessorListener(param_, param_, peerDevId_)); } /** @@ -230,7 +230,7 @@ HWTEST_F(ScreenSinkTransTest, on_data_received_test_001, TestSize.Level1) /** * @tc.name: on_processor_state_notify_test_001 - * @tc.desc: Verify the RegisterChannelListner function. + * @tc.desc: Verify the RegisterChannelListener function. * @tc.type: FUNC * @tc.require: Issue Number */ @@ -243,7 +243,7 @@ HWTEST_F(ScreenSinkTransTest, on_processor_state_notify_test_001, TestSize.Level /** * @tc.name: on_processor_state_notify_test_002 - * @tc.desc: Verify the RegisterChannelListner function. + * @tc.desc: Verify the RegisterChannelListener function. * @tc.type: FUNC * @tc.require: Issue Number */ diff --git a/services/softbusadapter/src/softbus_adapter.cpp b/services/softbusadapter/src/softbus_adapter.cpp index 30ce06b752bff17e85b3a93b78bd252a0cf95745..540590b01a1d578df6bcfdaed850ec22c264ba1f 100644 --- a/services/softbusadapter/src/softbus_adapter.cpp +++ b/services/softbusadapter/src/softbus_adapter.cpp @@ -326,6 +326,7 @@ void SoftbusAdapter::OnStreamReceived(int32_t sessionId, const StreamData *data, std::shared_ptr &listener = GetSoftbusListenerByName(sessionId); if (!listener) { DHLOGE("Get softbus listener failed."); + return; } listener->OnStreamReceived(sessionId, data, ext, frameInfo); }