• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_decoder_callback_adapter_impl.h"
17 
18 #include "ohos_adapter/bridge/ark_buffer_info_adapter_wrapper.h"
19 #include "ohos_adapter/bridge/ark_ohos_buffer_adapter_wrapper.h"
20 
21 #include "base/bridge/ark_web_bridge_macros.h"
22 
23 namespace OHOS::ArkWeb {
24 
ArkDecoderCallbackAdapterImpl(std::shared_ptr<OHOS::NWeb::DecoderCallbackAdapter> ref)25 ArkDecoderCallbackAdapterImpl::ArkDecoderCallbackAdapterImpl(std::shared_ptr<OHOS::NWeb::DecoderCallbackAdapter> ref)
26     : real_(ref)
27 {}
28 
OnError(int32_t errorType,int32_t errorCode)29 void ArkDecoderCallbackAdapterImpl::OnError(int32_t errorType, int32_t errorCode)
30 {
31     real_->OnError((OHOS::NWeb::ErrorType)errorType, errorCode);
32 }
33 
OnStreamChanged(int32_t width,int32_t height,double frameRate)34 void ArkDecoderCallbackAdapterImpl::OnStreamChanged(int32_t width, int32_t height, double frameRate)
35 {
36     real_->OnStreamChanged(width, height, frameRate);
37 }
38 
OnNeedInputData(uint32_t index,ArkWebRefPtr<ArkOhosBufferAdapter> buffer)39 void ArkDecoderCallbackAdapterImpl::OnNeedInputData(uint32_t index, ArkWebRefPtr<ArkOhosBufferAdapter> buffer)
40 {
41     if (CHECK_REF_PTR_IS_NULL(buffer)) {
42         return real_->OnNeedInputData(index, nullptr);
43     }
44     real_->OnNeedInputData(index, std::make_shared<ArkOhosBufferAdapterWrapper>(buffer));
45 }
46 
OnNeedOutputData(uint32_t index,ArkWebRefPtr<ArkBufferInfoAdapter> info,uint32_t flag)47 void ArkDecoderCallbackAdapterImpl::OnNeedOutputData(
48     uint32_t index, ArkWebRefPtr<ArkBufferInfoAdapter> info, uint32_t flag)
49 {
50     if (CHECK_REF_PTR_IS_NULL(info)) {
51         return real_->OnNeedOutputData(index, nullptr, (OHOS::NWeb::BufferFlag)flag);
52     }
53     real_->OnNeedOutputData(index, std::make_shared<ArkBufferInfoAdapterWrapper>(info), (OHOS::NWeb::BufferFlag)flag);
54 }
55 
56 } // namespace OHOS::ArkWeb
57