Debian Codegraph @

xbmc/pictures/PictureInfoTag.h

raw
1 /*
2 * Copyright (C) 2005-2018 Team Kodi
3 * This file is part of Kodi - https://kodi.tv
4 *
5 * SPDX-License-Identifier: GPL-2.0-or-later
6 * See LICENSES/README.md for more information.
7 */
8
9 #pragma once
10
11 #include "XBDateTime.h"
12 #include "libexif.h"
13 #include "utils/IArchivable.h"
14 #include "utils/ISerializable.h"
15 #include "utils/ISortable.h"
16
17 #include <string>
18 #include <vector>
19
20 namespace KODI
21 {
22 namespace ADDONS
23 {
24 class CImageDecoder;
25 } /* namespace ADDONS */
26 } /* namespace KODI */
27
28 class CVariant;
29
30 class CPictureInfoTag : public IArchivable, public ISerializable, public ISortable
31 {
32 friend class KODI::ADDONS::CImageDecoder;
33
34 // Mimic structs from libexif.h but with C++ types instead of arrays
35 struct ExifInfo
36 {
37 ExifInfo() = default;
38 ExifInfo(const ExifInfo&) = default;
39 ExifInfo(ExifInfo&&) = default;
40 ExifInfo(const ExifInfo_t& other);
41
42 ExifInfo& operator=(const ExifInfo&) = default;
43 ExifInfo& operator=(ExifInfo&&) = default;
44
45 std::string CameraMake;
46 std::string CameraModel;
47 std::string DateTime;
48 int Height{};
49 int Width{};
50 int Orientation{};
51 int IsColor{};
52 int Process{};
53 int FlashUsed{};
54 float FocalLength{};
55 float ExposureTime{};
56 float ApertureFNumber{};
57 float Distance{};
58 float CCDWidth{};
59 float ExposureBias{};
60 float DigitalZoomRatio{};
61 int FocalLength35mmEquiv{};
62 int Whitebalance{};
63 int MeteringMode{};
64 int ExposureProgram{};
65 int ExposureMode{};
66 int ISOequivalent{};
67 int LightSource{};
68 int CommentsCharset{};
69 int XPCommentsCharset{};
70 std::string Comments;
71 std::string FileComment;
72 std::string XPComment;
73 std::string Description;
74
75 unsigned ThumbnailOffset{};
76 unsigned ThumbnailSize{};
77 unsigned LargestExifOffset{};
78
79 char ThumbnailAtEnd{};
80 int ThumbnailSizeOffset{};
81
82 std::vector<int> DateTimeOffsets;
83
84 int GpsInfoPresent{};
85 std::string GpsLat;
86 std::string GpsLong;
87 std::string GpsAlt;
88
89 private:
90 static std::string Convert(int charset, const char* data);
91 };
92
93 struct IPTCInfo
94 {
95 IPTCInfo() = default;
96 IPTCInfo(const IPTCInfo&) = default;
97 IPTCInfo(IPTCInfo&&) = default;
98 IPTCInfo(const IPTCInfo_t& other);
99
100 IPTCInfo& operator=(const IPTCInfo&) = default;
101 IPTCInfo& operator=(IPTCInfo&&) = default;
102
103 std::string RecordVersion;
104 std::string SupplementalCategories;
105 std::string Keywords;
106 std::string Caption;
107 std::string Author;
108 std::string Headline;
109 std::string SpecialInstructions;
110 std::string Category;
111 std::string Byline;
112 std::string BylineTitle;
113 std::string Credit;
114 std::string Source;
115 std::string CopyrightNotice;
116 std::string ObjectName;
117 std::string City;
118 std::string State;
119 std::string Country;
120 std::string TransmissionReference;
121 std::string Date;
122 std::string Urgency;
123 std::string ReferenceService;
124 std::string CountryCode;
125 std::string TimeCreated;
126 std::string SubLocation;
127 std::string ImageType;
128 };
129
130 public:
131 CPictureInfoTag() { Reset(); }
132 virtual ~CPictureInfoTag() = default;
133 void Reset();
134 void Archive(CArchive& ar) override;
135 void Serialize(CVariant& value) const override;
136 void ToSortable(SortItem& sortable, Field field) const override;
137 const std::string GetInfo(int info) const;
138
139 bool Loaded() const { return m_isLoaded; }
140 bool Load(const std::string &path);
141
142 void SetInfo(const std::string& key, const std::string& value);
143
144 /**
145 * GetDateTimeTaken() -- Returns the EXIF DateTimeOriginal for current picture
146 *
147 * The exif library returns DateTimeOriginal if available else the other
148 * DateTime tags. See libexif CExifParse::ProcessDir for details.
149 */
150 const CDateTime& GetDateTimeTaken() const;
151 private:
152 static int TranslateString(const std::string &info);
153
154 ExifInfo m_exifInfo;
155 IPTCInfo m_iptcInfo;
156 bool m_isLoaded; // Set to true if metadata has been loaded from the picture file successfully
157 bool m_isInfoSetExternally; // Set to true if metadata has been set by an external call to SetInfo
158 CDateTime m_dateTimeTaken;
159 void ConvertDateTime();
160 };
161