* Copyright (C) 2026 Huawei Device Co., Ltd.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef INTERFACES_INNERKITS_INCLUDE_XMP_METADATA_H
#define INTERFACES_INNERKITS_INCLUDE_XMP_METADATA_H
#include <memory>
#include <mutex>
#include <string>
#include "image_type.h"
#include "nocopyable.h"
namespace OHOS {
namespace Media {
class XMPMetadataImpl;
class XMPMetadata {
public:
XMPMetadata();
explicit XMPMetadata(std::unique_ptr<XMPMetadataImpl> impl);
~XMPMetadata();
std::unique_ptr<XMPMetadataImpl>& GetImpl();
uint32_t RegisterNamespacePrefix(const std::string &uri, const std::string &prefix, std::string &errMsg);
uint32_t SetValue(const std::string &path, const XMPTagType &tagType, const std::string &value);
uint32_t GetTag(const std::string &path, XMPTag &tag);
uint32_t RemoveTag(const std::string &path);
using EnumerateCallback = std::function<bool(const std::string &path, const XMPTag &tag)>;
uint32_t EnumerateTags(EnumerateCallback callback, const std::string &rootPath, XMPEnumerateOptions options);
uint32_t GetBlob(std::string &buffer);
uint32_t SetBlob(const uint8_t *source, const uint32_t bufferSize);
static constexpr bool IsValidTagType(XMPTagType tagType)
{
using Underlying = std::underlying_type_t<XMPTagType>;
auto val = static_cast<Underlying>(tagType);
return val > static_cast<Underlying>(XMPTagType::UNKNOWN) &&
val <= static_cast<Underlying>(XMPTagType::STRUCTURE);
}
static constexpr bool IsContainerTagType(XMPTagType tagType)
{
return tagType == XMPTagType::STRUCTURE || tagType == XMPTagType::UNORDERED_ARRAY ||
tagType == XMPTagType::ORDERED_ARRAY || tagType == XMPTagType::ALTERNATE_ARRAY ||
tagType == XMPTagType::ALTERNATE_TEXT;
}
private:
DISALLOW_COPY_AND_MOVE(XMPMetadata);
static int32_t refCount_;
static std::mutex initMutex_;
std::unique_ptr<XMPMetadataImpl> impl_;
};
}
}
#endif