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 #ifndef ARK_MEDIA_CODEC_DECODER_ADAPTER_H 17 #define ARK_MEDIA_CODEC_DECODER_ADAPTER_H 18 #pragma once 19 20 #include "ohos_adapter/include/ark_media_codec_adapter.h" 21 22 namespace OHOS::ArkWeb { 23 24 /*--ark web(source=webcore)--*/ 25 class ArkDecoderFormatAdapter : public virtual ArkWebBaseRefCounted { 26 public: 27 /*--ark web()--*/ 28 virtual int32_t GetWidth() = 0; 29 30 /*--ark web()--*/ 31 virtual int32_t GetHeight() = 0; 32 33 /*--ark web()--*/ 34 virtual double GetFrameRate() = 0; 35 36 /*--ark web()--*/ 37 virtual void SetWidth(int32_t width) = 0; 38 39 /*--ark web()--*/ 40 virtual void SetHeight(int32_t height) = 0; 41 42 /*--ark web()--*/ 43 virtual void SetFrameRate(double frameRate) = 0; 44 }; 45 46 /*--ark web(source=webcore)--*/ 47 class ArkDecoderCallbackAdapter : public virtual ArkWebBaseRefCounted { 48 public: 49 /*--ark web()--*/ 50 virtual void OnError(int32_t errorType, int32_t errorCode) = 0; 51 52 /*--ark web()--*/ 53 virtual void OnStreamChanged(int32_t width, int32_t height, double frameRate) = 0; 54 55 /*--ark web()--*/ 56 virtual void OnNeedInputData(uint32_t index, ArkWebRefPtr<ArkOhosBufferAdapter> buffer) = 0; 57 58 /*--ark web()--*/ 59 virtual void OnNeedOutputData(uint32_t index, ArkWebRefPtr<ArkBufferInfoAdapter> info, uint32_t flag) = 0; 60 }; 61 62 /*--ark web(source=webview)--*/ 63 class ArkMediaCodecDecoderAdapter : public virtual ArkWebBaseRefCounted { 64 public: 65 /*--ark web()--*/ 66 virtual int32_t CreateVideoDecoderByMime(const ArkWebString& mimetype) = 0; 67 68 /*--ark web()--*/ 69 virtual int32_t CreateVideoDecoderByName(const ArkWebString& name) = 0; 70 71 /*--ark web()--*/ 72 virtual int32_t ConfigureDecoder(const ArkWebRefPtr<ArkDecoderFormatAdapter> format) = 0; 73 74 /*--ark web()--*/ 75 virtual int32_t SetParameterDecoder(const ArkWebRefPtr<ArkDecoderFormatAdapter> format) = 0; 76 77 /*--ark web()--*/ 78 virtual int32_t SetOutputSurface(void* window) = 0; 79 80 /*--ark web()--*/ 81 virtual int32_t PrepareDecoder() = 0; 82 83 /*--ark web()--*/ 84 virtual int32_t StartDecoder() = 0; 85 86 /*--ark web()--*/ 87 virtual int32_t StopDecoder() = 0; 88 89 /*--ark web()--*/ 90 virtual int32_t FlushDecoder() = 0; 91 92 /*--ark web()--*/ 93 virtual int32_t ResetDecoder() = 0; 94 95 /*--ark web()--*/ 96 virtual int32_t ReleaseDecoder() = 0; 97 98 /*--ark web()--*/ 99 virtual int32_t QueueInputBufferDec( 100 uint32_t index, int64_t presentationTimeUs, int32_t size, int32_t offset, uint32_t flag) = 0; 101 102 /*--ark web()--*/ 103 virtual int32_t GetOutputFormatDec(ArkWebRefPtr<ArkDecoderFormatAdapter> format) = 0; 104 105 /*--ark web()--*/ 106 virtual int32_t ReleaseOutputBufferDec(uint32_t index, bool isRender) = 0; 107 108 /*--ark web()--*/ 109 virtual int32_t SetCallbackDec(const ArkWebRefPtr<ArkDecoderCallbackAdapter> callback) = 0; 110 }; 111 112 } // namespace OHOS::ArkWeb 113 114 #endif // ARK_MEDIA_CODEC_DECODER_ADAPTER_H 115