• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2025 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_AUDIO_CODEC_DECODER_ADAPTER_IMPL_H
17 #define ARK_AUDIO_CODEC_DECODER_ADAPTER_IMPL_H
18 #pragma once
19 
20 #include "audio_codec_decoder_adapter.h"
21 #include "ohos_adapter/include/ark_audio_codec_decoder_adapter.h"
22 #include "audio_cenc_info_adapter.h"
23 #include "ohos_adapter/include/ark_audio_cenc_info_adapter.h"
24 
25 namespace OHOS::ArkWeb {
26 
27 class ArkAudioCodecDecoderAdapterImpl : public ArkAudioCodecDecoderAdapter {
28 public:
29     explicit ArkAudioCodecDecoderAdapterImpl(std::shared_ptr<OHOS::NWeb::AudioCodecDecoderAdapter>);
30 
31     int32_t CreateAudioDecoderByMime(const ArkWebString& mimetype) override;
32 
33     int32_t CreateAudioDecoderByName(const ArkWebString& name) override;
34 
35     int32_t ConfigureDecoder(const ArkWebRefPtr<ArkAudioDecoderFormatAdapter> format) override;
36 
37     int32_t SetParameterDecoder(const ArkWebRefPtr<ArkAudioDecoderFormatAdapter> format) override;
38 
39     int32_t PrepareDecoder() override;
40 
41     int32_t StartDecoder() override;
42 
43     int32_t StopDecoder() override;
44 
45     int32_t FlushDecoder() override;
46 
47     int32_t ResetDecoder() override;
48 
49     int32_t ReleaseDecoder() override;
50 
51     int32_t QueueInputBufferDec(uint32_t index, int64_t presentationTimeUs, uint8_t *bufferData, int32_t bufferSize,
52         const ArkWebRefPtr<ArkAudioCencInfoAdapter> cencInfo, bool isEncrypted, uint32_t flag) override;
53 
54     int32_t GetOutputFormatDec(ArkWebRefPtr<ArkAudioDecoderFormatAdapter> format) override;
55 
56     int32_t ReleaseOutputBufferDec(uint32_t index) override;
57 
58     int32_t SetCallbackDec(const ArkWebRefPtr<ArkAudioDecoderCallbackAdapter> callback) override;
59 
60     int32_t SetDecryptionConfig(void *session, bool secureAudio) override;
61 
62 private:
63     std::shared_ptr<OHOS::NWeb::AudioCodecDecoderAdapter> real_;
64 
65     IMPLEMENT_REFCOUNTING(ArkAudioCodecDecoderAdapterImpl);
66 };
67 
68 } // namespace OHOS::ArkWeb
69 
70 #endif // ARK_AUDIO_CODEC_DECODER_ADAPTER_IMPL_H
71