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 NATIVE_AVMAGIC_H
17 #define NATIVE_AVMAGIC_H
18 
19 #include <refbase.h>
20 #include "avcodec_info.h"
21 #include "buffer/avsharedmemory.h"
22 #include "avcodec_common.h"
23 #include "meta/format.h"
24 
25 
26 #define AV_MAGIC(a, b, c, d) (((a) << 24) + ((b) << 16) + ((c) << 8) + ((d) << 0))
27 
28 enum class AVMagic {
29     AVCODEC_MAGIC_VIDEO_DECODER = AV_MAGIC('V', 'D', 'E', 'C'),
30     AVCODEC_MAGIC_VIDEO_ENCODER = AV_MAGIC('V', 'E', 'N', 'C'),
31     AVCODEC_MAGIC_AUDIO_DECODER = AV_MAGIC('A', 'D', 'E', 'C'),
32     AVCODEC_MAGIC_AUDIO_ENCODER = AV_MAGIC('A', 'E', 'N', 'C'),
33     AVCODEC_MAGIC_AVMUXER = AV_MAGIC('M', 'U', 'X', 'R'),
34     AVCODEC_MAGIC_AVDEMUXER = AV_MAGIC('D', 'M', 'U', 'X'),
35     AVCODEC_MAGIC_AVSOURCE = AV_MAGIC('S', 'O', 'U', 'C'),
36 };
37 
38 struct AVObjectMagic : public OHOS::RefBase {
AVObjectMagicAVObjectMagic39     explicit AVObjectMagic(enum AVMagic m) : magic_(m) {}
40     virtual ~AVObjectMagic() = default;
41     enum AVMagic magic_;
42 };
43 struct OH_AVCodec : public AVObjectMagic {
OH_AVCodecOH_AVCodec44     explicit OH_AVCodec(enum AVMagic m) : AVObjectMagic(m) {}
45     virtual ~OH_AVCodec() = default;
46 };
47 
48 struct OH_AVCapability : public OHOS::RefBase {
49     explicit OH_AVCapability(OHOS::MediaAVCodec::CapabilityData *capabilityData);
50     ~OH_AVCapability() override;
51     OHOS::MediaAVCodec::CapabilityData *capabilityData_;
52     int32_t *profiles_ = nullptr;
53     int32_t *levels_ = nullptr;
54     int32_t *pixFormats_ = nullptr;
55     int32_t *sampleRates_ = nullptr;
56 };
57 
58 struct OH_AVMuxer : public AVObjectMagic {
OH_AVMuxerOH_AVMuxer59     explicit OH_AVMuxer(enum AVMagic m) : AVObjectMagic(m) {}
60     virtual ~OH_AVMuxer() = default;
61 };
62 
63 struct OH_AVDemuxer : public AVObjectMagic {
OH_AVDemuxerOH_AVDemuxer64     explicit OH_AVDemuxer(enum AVMagic m) : AVObjectMagic(m) {}
65     virtual ~OH_AVDemuxer() = default;
66 };
67 
68 struct OH_AVSource : public AVObjectMagic {
OH_AVSourceOH_AVSource69     explicit OH_AVSource(enum AVMagic m) : AVObjectMagic(m) {}
70     virtual ~OH_AVSource() = default;
71 };
72 
73 #endif // NATIVE_AVMAGIC_H