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