• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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     AVCODEC_MAGIC_AVCAPABILITY = AV_MAGIC('C', 'A', 'P', 'A'),
37 };
38 
39 struct AVObjectMagic : public OHOS::RefBase {
AVObjectMagicAVObjectMagic40     explicit AVObjectMagic(enum AVMagic m) : magic_(m) {}
41     virtual ~AVObjectMagic() = default;
42     enum AVMagic magic_;
43 };
44 struct OH_AVCodec : public AVObjectMagic {
OH_AVCodecOH_AVCodec45     explicit OH_AVCodec(enum AVMagic m) : AVObjectMagic(m) {}
46     virtual ~OH_AVCodec() = default;
47 };
48 
49 struct OH_AVCapability : public OHOS::RefBase {
50     OH_AVCapability();
51     ~OH_AVCapability() override;
52     OHOS::MediaAVCodec::CapabilityData *capabilityData_;
53     int32_t *profiles_ = nullptr;
54     int32_t *levels_ = nullptr;
55     int32_t *pixFormats_ = nullptr;
56     int32_t *sampleRates_ = nullptr;
57     enum AVMagic magic_;
58 };
59 
60 struct OH_AVMuxer : public AVObjectMagic {
OH_AVMuxerOH_AVMuxer61     explicit OH_AVMuxer(enum AVMagic m) : AVObjectMagic(m) {}
62     virtual ~OH_AVMuxer() = default;
63 };
64 
65 struct OH_AVDemuxer : public AVObjectMagic {
OH_AVDemuxerOH_AVDemuxer66     explicit OH_AVDemuxer(enum AVMagic m) : AVObjectMagic(m) {}
67     virtual ~OH_AVDemuxer() = default;
68 };
69 
70 struct OH_AVSource : public AVObjectMagic {
OH_AVSourceOH_AVSource71     explicit OH_AVSource(enum AVMagic m) : AVObjectMagic(m) {}
72     virtual ~OH_AVSource() = default;
73 };
74 
75 #endif // NATIVE_AVMAGIC_H