1 /* 2 * Copyright (C) 2024 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 FRAMEWORKS_INNERKITSIMPL_ACCESSOR_INCLUDE_METADATA_ACCESSOR_FACTORY_H 17 #define FRAMEWORKS_INNERKITSIMPL_ACCESSOR_INCLUDE_METADATA_ACCESSOR_FACTORY_H 18 19 #include <memory> 20 #include <string> 21 22 #include "buffer_metadata_stream.h" 23 #include "image_type.h" 24 #include "metadata_accessor.h" 25 #include "metadata_stream.h" 26 27 namespace OHOS { 28 namespace Media { 29 30 struct DataInfo { 31 uint8_t *buffer = nullptr; 32 uint32_t size = 0; 33 }; 34 35 class MetadataAccessorFactory { 36 public: 37 static std::shared_ptr<MetadataAccessor> Create(uint8_t *buffer, const uint32_t size, 38 BufferMetadataStream::MemoryMode mode = BufferMetadataStream::Fix); 39 static std::shared_ptr<MetadataAccessor> Create(const int fd); 40 static std::shared_ptr<MetadataAccessor> Create(const std::string &path); 41 static std::shared_ptr<MetadataAccessor> Create(const DataInfo &dataInfo, uint32_t &error, 42 BufferMetadataStream::MemoryMode mode = BufferMetadataStream::Fix, 43 int originalFd = METADATA_STREAM_INVALID_FD, 44 const std::string &originalPath = METADATA_STREAM_INVALID_PATH); 45 static std::shared_ptr<MetadataAccessor> Create(const int fd, uint32_t &error, 46 const int originalFd = METADATA_STREAM_INVALID_FD); 47 static std::shared_ptr<MetadataAccessor> Create(const std::string &path, uint32_t &error, 48 const std::string &originalPath = METADATA_STREAM_INVALID_PATH); 49 50 private: 51 static std::shared_ptr<MetadataAccessor> Create(std::shared_ptr<MetadataStream> &stream, uint32_t &error); 52 static EncodedFormat GetImageType(std::shared_ptr<MetadataStream> &stream, uint32_t &error); 53 }; 54 } // namespace Media 55 } // namespace OHOS 56 57 #endif // FRAMEWORKS_INNERKITSIMPL_ACCESSOR_INCLUDE_METADATA_ACCESSOR_FACTORY_H 58