1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #include "ohos_adapter/bridge/ark_video_device_descriptor_adapter_wrapper.h" 17 18 #include "ohos_adapter/bridge/ark_video_control_support_adapter_wrapper.h" 19 #include "ohos_adapter/ctocpp/ark_format_adapter_vector_ctocpp.h" 20 21 #include "base/bridge/ark_web_bridge_macros.h" 22 23 namespace OHOS::ArkWeb { 24 ArkVideoDeviceDescriptorAdapterWrapper(ArkWebRefPtr<ArkVideoDeviceDescriptorAdapter> ref)25ArkVideoDeviceDescriptorAdapterWrapper::ArkVideoDeviceDescriptorAdapterWrapper( 26 ArkWebRefPtr<ArkVideoDeviceDescriptorAdapter> ref) 27 : ctocpp_(ref) 28 {} 29 GetDisplayName()30std::string ArkVideoDeviceDescriptorAdapterWrapper::GetDisplayName() 31 { 32 ArkWebString str = ctocpp_->GetDisplayName(); 33 std::string result = ArkWebStringStructToClass(str); 34 35 ArkWebStringStructRelease(str); 36 return result; 37 } 38 GetDeviceId()39std::string ArkVideoDeviceDescriptorAdapterWrapper::GetDeviceId() 40 { 41 ArkWebString str = ctocpp_->GetDeviceId(); 42 std::string result = ArkWebStringStructToClass(str); 43 44 ArkWebStringStructRelease(str); 45 return result; 46 } 47 GetModelId()48std::string ArkVideoDeviceDescriptorAdapterWrapper::GetModelId() 49 { 50 ArkWebString str = ctocpp_->GetModelId(); 51 std::string result = ArkWebStringStructToClass(str); 52 53 ArkWebStringStructRelease(str); 54 return result; 55 } 56 GetControlSupport()57std::shared_ptr<NWeb::VideoControlSupportAdapter> ArkVideoDeviceDescriptorAdapterWrapper::GetControlSupport() 58 { 59 ArkWebRefPtr<ArkVideoControlSupportAdapter> adapter = ctocpp_->GetControlSupport(); 60 if (CHECK_REF_PTR_IS_NULL(adapter)) { 61 return nullptr; 62 } 63 return std::make_shared<ArkVideoControlSupportAdapterWrapper>(adapter); 64 } 65 GetTransportType()66NWeb::VideoTransportType ArkVideoDeviceDescriptorAdapterWrapper::GetTransportType() 67 { 68 return (NWeb::VideoTransportType)ctocpp_->GetTransportType(); 69 } 70 GetFacingMode()71NWeb::VideoFacingModeAdapter ArkVideoDeviceDescriptorAdapterWrapper::GetFacingMode() 72 { 73 return (NWeb::VideoFacingModeAdapter)ctocpp_->GetFacingMode(); 74 } 75 GetSupportCaptureFormats()76std::vector<std::shared_ptr<NWeb::FormatAdapter>> ArkVideoDeviceDescriptorAdapterWrapper::GetSupportCaptureFormats() 77 { 78 ArkFormatAdapterVector ark_vector = ctocpp_->GetSupportCaptureFormats(); 79 std::vector<std::shared_ptr<NWeb::FormatAdapter>> result = ArkFormatAdapterVectorStructToClass(ark_vector); 80 ArkFormatAdapterVectorStructRelease(ark_vector); 81 return result; 82 } 83 84 } // namespace OHOS::ArkWeb 85