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 #include "common/native_mfmagic.h" 17 18 19 // ndk 接口: 20 // 1. 声明在 ./interface/kits/c/*.h; 21 // 2. 定义在 ./src/capi/*.cpp; 22 // 3. 编译到 ./src/capi/BUILD.gn 的 capi_packages; 23 // ndk 接口对应的struct实例: 24 // 1. 声明在 ./interface/inner_api/common/native_mfmagic.h; 25 // 2. 定义在 ./src/capi/common/native_mfmagic.cpp; 26 // 3. 编译到 ./src/BUILD.gn 的 media_foundation. 27 28 29 using namespace OHOS::Media; 30 OH_AVFormat()31OH_AVFormat::OH_AVFormat() : MFObjectMagic(MFMagic::MFMAGIC_FORMAT) {} 32 OH_AVFormat(const Format & fmt)33OH_AVFormat::OH_AVFormat(const Format &fmt) : MFObjectMagic(MFMagic::MFMAGIC_FORMAT), format_(fmt) {} 34 ~OH_AVFormat()35OH_AVFormat::~OH_AVFormat() 36 { 37 magic_ = MFMagic::MFMAGIC_UNKNOWN; 38 if (outString_ != nullptr) { 39 free(outString_); 40 outString_ = nullptr; 41 } 42 if (dumpInfo_ != nullptr) { 43 free(dumpInfo_); 44 dumpInfo_ = nullptr; 45 } 46 } 47 OH_AVMemory(const std::shared_ptr<AVSharedMemory> & mem)48OH_AVMemory::OH_AVMemory(const std::shared_ptr<AVSharedMemory> &mem) 49 : MFObjectMagic(MFMagic::MFMAGIC_SHARED_MEMORY), memory_(mem) 50 { 51 } 52 ~OH_AVMemory()53OH_AVMemory::~OH_AVMemory() 54 { 55 magic_ = MFMagic::MFMAGIC_UNKNOWN; 56 } 57 IsEqualMemory(const std::shared_ptr<AVSharedMemory> & mem)58bool OH_AVMemory::IsEqualMemory(const std::shared_ptr<AVSharedMemory> &mem) 59 { 60 return (mem == memory_) ? true : false; 61 } 62 OH_AVBuffer(const std::shared_ptr<OHOS::Media::AVBuffer> & buffer)63OH_AVBuffer::OH_AVBuffer(const std::shared_ptr<OHOS::Media::AVBuffer> &buffer) 64 : MFObjectMagic(MFMagic::MFMAGIC_AVBUFFER), buffer_(buffer) 65 { 66 } 67 ~OH_AVBuffer()68OH_AVBuffer::~OH_AVBuffer() 69 { 70 magic_ = MFMagic::MFMAGIC_UNKNOWN; 71 } 72 IsEqualBuffer(const std::shared_ptr<OHOS::Media::AVBuffer> & buffer)73bool OH_AVBuffer::IsEqualBuffer(const std::shared_ptr<OHOS::Media::AVBuffer> &buffer) 74 { 75 return (buffer == buffer_); 76 } 77