• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2020-2021 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 DECODER_H
17 #define DECODER_H
18 #include <string>
19 #include "codec_type.h"
20 
21 namespace OHOS {
22 namespace Media {
23 const int CODEC_SUCCESS = 0;
24 const int CODEC_FAILURE = -1;
25 
26 typedef struct {
27     AvCodecMime mime;
28     uint32_t maxWidth;
29     uint32_t maxHeight;
30     uint32_t bufSize;
31     uint32_t frameBufCnt; // todo buffer ����Ӧ������������������
32     void *priv;
33 } VdecAttr;
34 
35 typedef struct {
36     AvCodecMime mime;
37     int32_t bufSize;
38     int32_t channelCnt; /* for pcm frame */
39     void *priv;
40 } AdecAttr;
41 
42 typedef struct {
43     union {
44         AdecAttr adecAttr;
45         VdecAttr vdecAttr;
46     };
47     CodecType type;
48 } AvAttribute;
49 
50 class Decoder {
51 public:
52     Decoder();
53 
54     virtual ~Decoder();
55 
56     static int32_t GetCapbilityByMime(AvCodecMime mime, CodecType type, uint32_t flags, CodecCapbility &cap);
57 
58     int32_t CreateHandle(const std::string &name, AvAttribute &attr);
59 
60     int32_t DestroyHandle();
61 
62     int32_t SetPortBufferMode(DirectionType type, BufferMode mode);
63 
64     int32_t SetMetadata(const Param *params, int paramCnt);
65 
66     int32_t GetMetadata(Param *param, int paramCnt);
67 
68     int32_t StartDec();
69 
70     int32_t StopDec();
71 
72     int32_t FlushDec();
73 
74     int32_t QueueInputBuffer(InputInfo &inputData, uint32_t timeoutMs);
75 
76     int32_t DequeInputBuffer(InputInfo &inputData, uint32_t timeoutMs);
77 
78     int32_t QueueOutputBuffer(OutputInfo &outInfo, uint32_t timeoutMs);
79 
80     int32_t DequeueOutputBuffer(OutputInfo &outInfo, uint32_t timeoutMs);
81 
82     int32_t SetCallback(CodecCallback &cb, UINTPTR instance);
83 
84 private:
85     CODEC_HANDLETYPE codecHandle_;
86 };
87 }
88 }
89 #endif
90