tgbotxx 1.2.9.5
Telegram Bot C++ Library
Loading...
Searching...
No Matches
Video.hpp
Go to the documentation of this file.
1#pragma once
5
6namespace tgbotxx {
9 struct Video {
10 Video() = default;
11 explicit Video(const nl::json& json) {
13 }
14
16 std::string fileId;
17
20 std::string fileUniqueId;
21
23 std::int32_t width{};
24
26 std::int32_t height{};
27
29 std::int32_t duration{};
30
33
35 std::vector<Ptr<PhotoSize>> cover;
36
38 std::time_t startTimestamp{};
39
41 std::vector<Ptr<VideoQuality>> qualities;
42
44 std::string fileName;
45
47 std::string mimeType;
48
52 std::int64_t fileSize{};
53
56 nl::json toJson() const {
57 nl::json json = nl::json::object();
59 OBJECT_SERIALIZE_FIELD(json, "file_unique_id", fileUniqueId);
65 OBJECT_SERIALIZE_FIELD(json, "start_timestamp", startTimestamp);
70 return json;
71 }
72
74 void fromJson(const nl::json& json) {
75 OBJECT_DESERIALIZE_FIELD(json, "file_id", fileId, "", false);
76 OBJECT_DESERIALIZE_FIELD(json, "file_unique_id", fileUniqueId, "", false);
77 OBJECT_DESERIALIZE_FIELD(json, "width", width, 0, false);
78 OBJECT_DESERIALIZE_FIELD(json, "height", height, 0, false);
79 OBJECT_DESERIALIZE_FIELD(json, "duration", duration, 0, false);
80 OBJECT_DESERIALIZE_FIELD_PTR(json, "thumbnail", thumbnail, true);
82 OBJECT_DESERIALIZE_FIELD(json, "start_timestamp", startTimestamp, 0, true);
84 OBJECT_DESERIALIZE_FIELD(json, "file_name", fileName, "", true);
85 OBJECT_DESERIALIZE_FIELD(json, "mime_type", mimeType, "", true);
86 OBJECT_DESERIALIZE_FIELD(json, "file_size", fileSize, 0, true);
87 }
88 };
89}
#define OBJECT_SERIALIZE_FIELD_PTR(json, json_field, field)
Definition Object.hpp:32
#define OBJECT_SERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field)
Definition Object.hpp:39
#define OBJECT_DESERIALIZE_FIELD_PTR(json, json_field, field, optional)
Definition Object.hpp:92
#define OBJECT_SERIALIZE_FIELD(json, json_field, field)
Serialize.
Definition Object.hpp:27
#define OBJECT_DESERIALIZE_FIELD(json, json_field, field, default_value, optional)
Deserialize.
Definition Object.hpp:64
#define OBJECT_DESERIALIZE_FIELD_PTR_ARRAY(json, json_field, array_field, optional)
Definition Object.hpp:111
std::shared_ptr< T > Ptr
Definition Ptr.hpp:6
This object represents a video file. https://core.telegram.org/bots/api#video.
Definition Video.hpp:9
std::time_t startTimestamp
Optional. Timestamp in seconds from which the video will play in the message.
Definition Video.hpp:38
Video()=default
std::string fileId
Identifier for this file, which can be used to download or reuse the file.
Definition Video.hpp:16
std::vector< Ptr< VideoQuality > > qualities
Optional. List of available qualities of the video.
Definition Video.hpp:41
std::string fileName
Optional. Original filename as defined by sender.
Definition Video.hpp:44
std::string mimeType
Optional. MIME type of the file as defined by sender.
Definition Video.hpp:47
std::int32_t duration
Duration of the video in seconds as defined by sender.
Definition Video.hpp:29
std::int32_t width
Video width as defined by sender.
Definition Video.hpp:23
Video(const nl::json &json)
Definition Video.hpp:11
std::int64_t fileSize
Optional. File size in bytes. It can be bigger than 2^31 and some programming languages may have diff...
Definition Video.hpp:52
nl::json toJson() const
Serializes this object to JSON.
Definition Video.hpp:56
std::vector< Ptr< PhotoSize > > cover
Optional. Available sizes of the cover of the video in the message.
Definition Video.hpp:35
void fromJson(const nl::json &json)
Deserializes this object from JSON.
Definition Video.hpp:74
Ptr< PhotoSize > thumbnail
Optional. Video thumbnail.
Definition Video.hpp:32
std::int32_t height
Video height as defined by sender.
Definition Video.hpp:26
std::string fileUniqueId
Unique identifier for this file, which is supposed to be the same over time and for different bots....
Definition Video.hpp:20