This repository was archived by the owner on Mar 14, 2019. It is now read-only.
Repository navigation
Expand file tree
/
Copy pathcommon.hpp
More file actions
128 lines (107 loc) · 3.5 KB
/
Copy pathcommon.hpp
File metadata and controls
128 lines (107 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
#pragma once
#include <nlohmann/json.hpp>
using json = nlohmann::json;
namespace mtx {
//! Common structs used among many different event content types.
namespace common {
constexpr auto FORMAT_MSG_TYPE = "org.matrix.custom.html";
//! Metadata about an image thumbnail.
struct ThumbnailInfo
{
//! The height of the thumbnail in pixels.
uint64_t h = 0;
//! The width of the thumbnail in pixels.
uint64_t w = 0;
//! Size of the thumbnail in bytes.
uint64_t size = 0;
//! The mimetype of the thumbnail, e.g. image/jpeg.
std::string mimetype;
};
//! Deserialization method needed by @p nlohmann::json.
void
from_json(const json &obj, ThumbnailInfo &info);
//! Serialization method needed by @p nlohmann::json.
void
to_json(json &obj, const ThumbnailInfo &info);
//! Metadata about an image.
struct ImageInfo
{
//! The height of the image in pixels.
uint64_t h = 0;
//! The width of the image in pixels.
uint64_t w = 0;
//! Size of the image in bytes.
uint64_t size = 0;
//! Metadata about the image referred to in @p thumbnail_url.
ThumbnailInfo thumbnail_info;
//! The URL to a thumbnail of the image.
std::string thumbnail_url;
//! The mimetype of the image, `e.g. image/jpeg`.
std::string mimetype;
};
//! Deserialization method needed by @p nlohmann::json.
void
from_json(const json &obj, ImageInfo &info);
//! Serialization method needed by @p nlohmann::json.
void
to_json(json &obj, const ImageInfo &info);
//! Metadata about a file.
struct FileInfo
{
//! The size of the file in bytes.
uint64_t size = 0;
//! Metadata about the image referred to in @p thumbnail_url.
ThumbnailInfo thumbnail_info;
//! The URL to the thumbnail of the file.
std::string thumbnail_url;
//! The mimetype of the file e.g `application/pdf`.
std::string mimetype;
};
//! Deserialization method needed by @p nlohmann::json.
void
from_json(const json &obj, FileInfo &info);
//! Serialization method needed by @p nlohmann::json.
void
to_json(json &obj, const FileInfo &info);
//! Audio clip metadata.
struct AudioInfo
{
//! The size of the audio clip in bytes.
uint64_t size = 0;
//! The duration of the audio in milliseconds.
uint64_t duration = 0;
//! The mimetype of the audio e.g. `audio/aac`.
std::string mimetype;
};
//! Deserialization method needed by @p nlohmann::json.
void
from_json(const json &obj, AudioInfo &info);
//! Serialization method needed by @p nlohmann::json.
void
to_json(json &obj, const AudioInfo &info);
//! Video clip metadata.
struct VideoInfo
{
//! The size of the video in bytes.
uint64_t size = 0;
//! The duration of the video in milliseconds.
uint64_t duration = 0;
//! The height of the video in pixels.
uint64_t h = 0;
//! The width of the video in pixels.
uint64_t w = 0;
//! The mimetype of the video e.g. `video/mp4`.
std::string mimetype;
//! The URL to an image thumbnail of the video clip.
std::string thumbnail_url;
//! Metadata about the image referred to in @p thumbnail_url.
ThumbnailInfo thumbnail_info;
};
//! Deserialization method needed by @p nlohmann::json.
void
from_json(const json &obj, VideoInfo &info);
//! Serialization method needed by @p nlohmann::json.
void
to_json(json &obj, const VideoInfo &info);
} // namespace common
} // namespace mtx