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_impl.h"
17 
18 #include "ohos_adapter/bridge/ark_video_control_support_adapter_impl.h"
19 #include "ohos_adapter/cpptoc/ark_format_adapter_vector_cpptoc.h"
20 
21 #include "base/bridge/ark_web_bridge_macros.h"
22 
23 namespace OHOS::ArkWeb {
24 
ArkVideoDeviceDescriptorAdapterImpl(std::shared_ptr<OHOS::NWeb::VideoDeviceDescriptorAdapter> ref)25 ArkVideoDeviceDescriptorAdapterImpl::ArkVideoDeviceDescriptorAdapterImpl(
26     std::shared_ptr<OHOS::NWeb::VideoDeviceDescriptorAdapter> ref)
27     : real_(ref)
28 {}
29 
GetDisplayName()30 ArkWebString ArkVideoDeviceDescriptorAdapterImpl::GetDisplayName()
31 {
32     std::string str = real_->GetDisplayName();
33     return ArkWebStringClassToStruct(str);
34 }
35 
GetDeviceId()36 ArkWebString ArkVideoDeviceDescriptorAdapterImpl::GetDeviceId()
37 {
38     std::string str = real_->GetDeviceId();
39     return ArkWebStringClassToStruct(str);
40 }
41 
GetModelId()42 ArkWebString ArkVideoDeviceDescriptorAdapterImpl::GetModelId()
43 {
44     std::string str = real_->GetModelId();
45     return ArkWebStringClassToStruct(str);
46 }
47 
GetControlSupport()48 ArkWebRefPtr<ArkVideoControlSupportAdapter> ArkVideoDeviceDescriptorAdapterImpl::GetControlSupport()
49 {
50     std::shared_ptr<NWeb::VideoControlSupportAdapter> adapter = real_->GetControlSupport();
51     if (CHECK_SHARED_PTR_IS_NULL(adapter)) {
52         return nullptr;
53     }
54     return new ArkVideoControlSupportAdapterImpl(adapter);
55 }
56 
GetTransportType()57 int32_t ArkVideoDeviceDescriptorAdapterImpl::GetTransportType()
58 {
59     return (int32_t)real_->GetTransportType();
60 }
61 
GetFacingMode()62 int32_t ArkVideoDeviceDescriptorAdapterImpl::GetFacingMode()
63 {
64     return (int32_t)real_->GetFacingMode();
65 }
66 
GetSupportCaptureFormats()67 ArkFormatAdapterVector ArkVideoDeviceDescriptorAdapterImpl::GetSupportCaptureFormats()
68 {
69     std::vector<std::shared_ptr<NWeb::FormatAdapter>> format = real_->GetSupportCaptureFormats();
70     ArkFormatAdapterVector result = ArkFormatAdapterVectorClassToStruct(format);
71     return result;
72 }
73 
74 } // namespace OHOS::ArkWeb
75