1fa7767c5Sopenharmony_ci/* 2fa7767c5Sopenharmony_ci * Copyright (C) 2023 Huawei Device Co., Ltd. 3fa7767c5Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 4fa7767c5Sopenharmony_ci * you may not use this file except in compliance with the License. 5fa7767c5Sopenharmony_ci * You may obtain a copy of the License at 6fa7767c5Sopenharmony_ci * 7fa7767c5Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 8fa7767c5Sopenharmony_ci * 9fa7767c5Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 10fa7767c5Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 11fa7767c5Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12fa7767c5Sopenharmony_ci * See the License for the specific language governing permissions and 13fa7767c5Sopenharmony_ci * limitations under the License. 14fa7767c5Sopenharmony_ci */ 15fa7767c5Sopenharmony_ci 16fa7767c5Sopenharmony_ci#include "common/native_mfmagic.h" 17fa7767c5Sopenharmony_ci 18fa7767c5Sopenharmony_ci 19fa7767c5Sopenharmony_ci// ndk 接口: 20fa7767c5Sopenharmony_ci// 1. 声明在 ./interface/kits/c/*.h; 21fa7767c5Sopenharmony_ci// 2. 定义在 ./src/capi/*.cpp; 22fa7767c5Sopenharmony_ci// 3. 编译到 ./src/capi/BUILD.gn 的 capi_packages; 23fa7767c5Sopenharmony_ci// ndk 接口对应的struct实例: 24fa7767c5Sopenharmony_ci// 1. 声明在 ./interface/inner_api/common/native_mfmagic.h; 25fa7767c5Sopenharmony_ci// 2. 定义在 ./src/capi/common/native_mfmagic.cpp; 26fa7767c5Sopenharmony_ci// 3. 编译到 ./src/BUILD.gn 的 media_foundation. 27fa7767c5Sopenharmony_ci 28fa7767c5Sopenharmony_ci 29fa7767c5Sopenharmony_ciusing namespace OHOS::Media; 30fa7767c5Sopenharmony_ci 31fa7767c5Sopenharmony_ciOH_AVFormat::OH_AVFormat() : MFObjectMagic(MFMagic::MFMAGIC_FORMAT) {} 32fa7767c5Sopenharmony_ci 33fa7767c5Sopenharmony_ciOH_AVFormat::OH_AVFormat(const Format &fmt) : MFObjectMagic(MFMagic::MFMAGIC_FORMAT), format_(fmt) {} 34fa7767c5Sopenharmony_ci 35fa7767c5Sopenharmony_ciOH_AVFormat::~OH_AVFormat() 36fa7767c5Sopenharmony_ci{ 37fa7767c5Sopenharmony_ci magic_ = MFMagic::MFMAGIC_UNKNOWN; 38fa7767c5Sopenharmony_ci if (outString_ != nullptr) { 39fa7767c5Sopenharmony_ci free(outString_); 40fa7767c5Sopenharmony_ci outString_ = nullptr; 41fa7767c5Sopenharmony_ci } 42fa7767c5Sopenharmony_ci if (dumpInfo_ != nullptr) { 43fa7767c5Sopenharmony_ci free(dumpInfo_); 44fa7767c5Sopenharmony_ci dumpInfo_ = nullptr; 45fa7767c5Sopenharmony_ci } 46fa7767c5Sopenharmony_ci} 47fa7767c5Sopenharmony_ci 48fa7767c5Sopenharmony_ciOH_AVMemory::OH_AVMemory(const std::shared_ptr<AVSharedMemory> &mem) 49fa7767c5Sopenharmony_ci : MFObjectMagic(MFMagic::MFMAGIC_SHARED_MEMORY), memory_(mem) 50fa7767c5Sopenharmony_ci{ 51fa7767c5Sopenharmony_ci} 52fa7767c5Sopenharmony_ci 53fa7767c5Sopenharmony_ciOH_AVMemory::~OH_AVMemory() 54fa7767c5Sopenharmony_ci{ 55fa7767c5Sopenharmony_ci magic_ = MFMagic::MFMAGIC_UNKNOWN; 56fa7767c5Sopenharmony_ci} 57fa7767c5Sopenharmony_ci 58fa7767c5Sopenharmony_cibool OH_AVMemory::IsEqualMemory(const std::shared_ptr<AVSharedMemory> &mem) 59fa7767c5Sopenharmony_ci{ 60fa7767c5Sopenharmony_ci return (mem == memory_) ? true : false; 61fa7767c5Sopenharmony_ci} 62fa7767c5Sopenharmony_ci 63fa7767c5Sopenharmony_ciOH_AVBuffer::OH_AVBuffer(const std::shared_ptr<OHOS::Media::AVBuffer> &buffer) 64fa7767c5Sopenharmony_ci : MFObjectMagic(MFMagic::MFMAGIC_AVBUFFER), buffer_(buffer) 65fa7767c5Sopenharmony_ci{ 66fa7767c5Sopenharmony_ci} 67fa7767c5Sopenharmony_ci 68fa7767c5Sopenharmony_ciOH_AVBuffer::~OH_AVBuffer() 69fa7767c5Sopenharmony_ci{ 70fa7767c5Sopenharmony_ci magic_ = MFMagic::MFMAGIC_UNKNOWN; 71fa7767c5Sopenharmony_ci} 72fa7767c5Sopenharmony_ci 73fa7767c5Sopenharmony_cibool OH_AVBuffer::IsEqualBuffer(const std::shared_ptr<OHOS::Media::AVBuffer> &buffer) 74fa7767c5Sopenharmony_ci{ 75fa7767c5Sopenharmony_ci return (buffer == buffer_); 76fa7767c5Sopenharmony_ci} 77