1 /*
2  * Copyright (C) 2021 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 METADATA_EXTRACTOR_H
17 #define METADATA_EXTRACTOR_H
18 
19 #include <fcntl.h>
20 #include <sstream>
21 #include <string.h>
22 #include <unistd.h>
23 
24 #include "avmetadatahelper.h"
25 #include "image_source.h"
26 #include "image_type.h"
27 #include "metadata.h"
28 
29 namespace OHOS {
30 namespace Media {
31 #define EXPORT __attribute__ ((visibility ("default")))
32 class MetadataExtractor {
33 public:
34     EXPORT static int32_t Extract(std::unique_ptr<Metadata> &data);
35     EXPORT static int32_t ExtractAVMetadata(std::unique_ptr<Metadata> &data, int32_t scene = 0);
36     EXPORT static int32_t ExtractImageMetadata(std::unique_ptr<Metadata> &data);
37     static int32_t ExtractImageExif(std::unique_ptr<ImageSource> &imageSource, std::unique_ptr<Metadata> &data);
38 
39 private:
40     MetadataExtractor() = delete;
41     ~MetadataExtractor() = delete;
42 
43     EXPORT static void FillExtractedMetadata(const std::unordered_map<int32_t, std::string> &metadataMap,
44         std::shared_ptr<Meta> &meta, std::unique_ptr<Metadata> &data);
45     static int32_t CombineMovingPhotoMetadata(std::unique_ptr<Metadata> &data);
46 };
47 } // namespace Media
48 } // namespace OHOS
49 #endif /* METADATA_EXTRACTOR_H */
50