• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2024 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 OH_VEF_CODEC_DECODER_H
17 #define OH_VEF_CODEC_DECODER_H
18 
19 #include <string>
20 #include "codec/common/codec_common.h"
21 
22 namespace OHOS {
23 namespace Media {
24 
25 class CodecDecoder {
26 public:
27     CodecDecoder() = delete;
28     CodecDecoder(uint64_t id, std::string logTag);
29     virtual ~CodecDecoder();
30 
31     virtual VEFError Init(OH_AVFormat* format) = 0;
32     virtual VEFError Start() = 0;
33     virtual VEFError Stop() = 0;
34 
35 protected:
36     OH_AVCodecAsyncCallback GetAVCodecAsyncCallback();
37     virtual void CodecOnErrorInner(OH_AVCodec* codec, int32_t errorCode) = 0;
38 
39     uint64_t id_ { 0 };
40     std::string logTag_;
41     OH_AVCodec* decoder_ { nullptr };
42     std::string codecMime_;
43     CodecState state_ { CodecState::INIT };
44 
45 private:
46     virtual void CodecOnStreamChangedInner(OH_AVFormat* format) = 0;
47     virtual void CodecOnNeedInputDataInner(OH_AVCodec* codec, uint32_t index, OH_AVMemory* data) = 0;
48     virtual void CodecOnNewOutputDataInner(OH_AVCodec* codec, uint32_t index, OH_AVMemory* data,
49         OH_AVCodecBufferAttr* attr) = 0;
50 };
51 } // namespace Media
52 } // namespace OHOS
53 
54 #endif // OH_VEF_CODEC_DECODER_H