• 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 "avsharedmemory.h"
22 #include "avcodec_common.h"
23 #include "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_FORMAT = AV_MAGIC('F', 'R', 'M', 'T'),
37     AVCODEC_MAGIC_SHARED_MEMORY = AV_MAGIC('S', 'M', 'E', 'M'),
38 };
39 
40 struct AVObjectMagic : public OHOS::RefBase {
AVObjectMagicAVObjectMagic41     explicit AVObjectMagic(enum AVMagic m) : magic_(m) {}
42     virtual ~AVObjectMagic() = default;
43     enum AVMagic magic_;
44 };
45 
46 struct OH_AVFormat : public AVObjectMagic {
47     OH_AVFormat();
48     explicit OH_AVFormat(const OHOS::MediaAVCodec::Format &fmt);
49     ~OH_AVFormat() override;
50     OHOS::MediaAVCodec::Format format_;
51     char *outString_ = nullptr;
52     char *dumpInfo_ = nullptr;
53 };
54 
55 struct OH_AVMemory : public AVObjectMagic {
56     explicit OH_AVMemory(const std::shared_ptr<OHOS::MediaAVCodec::AVSharedMemory> &mem);
57     ~OH_AVMemory() override;
58     bool IsEqualMemory(const std::shared_ptr<OHOS::MediaAVCodec::AVSharedMemory> &mem);
59     const std::shared_ptr<OHOS::MediaAVCodec::AVSharedMemory> memory_;
60     bool isUserCreated = false;
61 };
62 
63 struct OH_AVCodec : public AVObjectMagic {
OH_AVCodecOH_AVCodec64     explicit OH_AVCodec(enum AVMagic m) : AVObjectMagic(m) {}
65     virtual ~OH_AVCodec() = default;
66 };
67 
68 struct OH_AVCapability : public OHOS::RefBase {
69     explicit OH_AVCapability(OHOS::MediaAVCodec::CapabilityData *capabilityData);
70     ~OH_AVCapability() override;
71     OHOS::MediaAVCodec::CapabilityData *capabilityData_;
72 };
73 
74 struct OH_AVMuxer : public AVObjectMagic {
OH_AVMuxerOH_AVMuxer75     explicit OH_AVMuxer(enum AVMagic m) : AVObjectMagic(m) {}
76     virtual ~OH_AVMuxer() = default;
77 };
78 
79 struct OH_AVDemuxer : public AVObjectMagic {
OH_AVDemuxerOH_AVDemuxer80     explicit OH_AVDemuxer(enum AVMagic m) : AVObjectMagic(m) {}
81     virtual ~OH_AVDemuxer() = default;
82 };
83 
84 struct OH_AVSource : public AVObjectMagic {
OH_AVSourceOH_AVSource85     explicit OH_AVSource(enum AVMagic m) : AVObjectMagic(m) {}
86     virtual ~OH_AVSource() = default;
87 };
88 
89 #endif // NATIVE_AVMAGIC_H