1 /* 2 * Copyright (C) 2022-2022 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 "format.h" 21 #include "avsharedmemory.h" 22 23 #define AV_MAGIC(a, b, c, d) (((a) << 24) + ((b) << 16) + ((c) << 8) + ((d) << 0)) 24 25 enum AVMagic { 26 MEDIA_MAGIC_VIDEO_DECODER = AV_MAGIC('V', 'D', 'E', 'C'), 27 MEDIA_MAGIC_VIDEO_ENCODER = AV_MAGIC('V', 'E', 'N', 'C'), 28 MEDIA_MAGIC_AUDIO_DECODER = AV_MAGIC('A', 'D', 'E', 'C'), 29 MEDIA_MAGIC_AUDIO_ENCODER = AV_MAGIC('A', 'E', 'N', 'C'), 30 MEDIA_MAGIC_VIDEO_PLAYER = AV_MAGIC('V', 'P', 'L', 'Y'), 31 MEDIA_MAGIC_AUDIO_PLAYER = AV_MAGIC('A', 'P', 'L', 'Y'), 32 MEDIA_MAGIC_VIDEO_RECORDER = AV_MAGIC('V', 'R', 'E', 'C'), 33 MEDIA_MAGIC_AUDIO_RECORDER = AV_MAGIC('A', 'R', 'E', 'C'), 34 MEDIA_MAGIC_FORMAT = AV_MAGIC('F', 'R', 'M', 'T'), 35 MEDIA_MAGIC_SHARED_MEMORY = AV_MAGIC('S', 'M', 'E', 'M'), 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 44 struct OH_AVFormat : public AVObjectMagic { 45 OH_AVFormat(); 46 explicit OH_AVFormat(const OHOS::Media::Format &fmt); 47 ~OH_AVFormat() override; 48 OHOS::Media::Format format_; 49 char *outString_ = nullptr; 50 char *dumpInfo_ = nullptr; 51 }; 52 53 struct OH_AVMemory : public AVObjectMagic { 54 explicit OH_AVMemory(const std::shared_ptr<OHOS::Media::AVSharedMemory> &mem); 55 ~OH_AVMemory() override; 56 bool IsEqualMemory(const std::shared_ptr<OHOS::Media::AVSharedMemory> &mem); 57 const std::shared_ptr<OHOS::Media::AVSharedMemory> memory_; 58 }; 59 60 struct OH_AVCodec : public AVObjectMagic { OH_AVCodecOH_AVCodec61 explicit OH_AVCodec(enum AVMagic m) : AVObjectMagic(m) {} 62 virtual ~OH_AVCodec() = default; 63 }; 64 #endif // NATIVE_AVMAGIC_H