Add video note flags.
This commit is contained in:
parent
acf5b55792
commit
c23dceddf3
@ -56,6 +56,7 @@ enum class Version : int32 {
|
||||
AddMessageStickerFlags, // 40
|
||||
AddStickerSetListFlags,
|
||||
AddInputInvoiceFlags,
|
||||
AddVideoNoteFlags,
|
||||
Next
|
||||
};
|
||||
|
||||
|
@ -21,22 +21,54 @@ template <class StorerT>
|
||||
void VideoNotesManager::store_video_note(FileId file_id, StorerT &storer) const {
|
||||
const VideoNote *video_note = get_video_note(file_id);
|
||||
CHECK(video_note != nullptr);
|
||||
store(video_note->duration, storer);
|
||||
bool has_duration = video_note->duration != 0;
|
||||
bool has_minithumbnail = !video_note->minithumbnail.empty();
|
||||
bool has_thumbnail = video_note->thumbnail.file_id.is_valid();
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(has_duration);
|
||||
STORE_FLAG(has_minithumbnail);
|
||||
STORE_FLAG(has_thumbnail);
|
||||
END_STORE_FLAGS();
|
||||
if (has_duration) {
|
||||
store(video_note->duration, storer);
|
||||
}
|
||||
store(video_note->dimensions, storer);
|
||||
store(video_note->minithumbnail, storer);
|
||||
store(video_note->thumbnail, storer);
|
||||
if (has_minithumbnail) {
|
||||
store(video_note->minithumbnail, storer);
|
||||
}
|
||||
if (has_thumbnail) {
|
||||
store(video_note->thumbnail, storer);
|
||||
}
|
||||
store(file_id, storer);
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
FileId VideoNotesManager::parse_video_note(ParserT &parser) {
|
||||
auto video_note = make_unique<VideoNote>();
|
||||
parse(video_note->duration, parser);
|
||||
bool has_duration;
|
||||
bool has_minithumbnail;
|
||||
bool has_thumbnail;
|
||||
if (parser.version() >= static_cast<int32>(Version::AddVideoNoteFlags)) {
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(has_duration);
|
||||
PARSE_FLAG(has_minithumbnail);
|
||||
PARSE_FLAG(has_thumbnail);
|
||||
END_PARSE_FLAGS();
|
||||
} else {
|
||||
has_duration = true;
|
||||
has_minithumbnail = parser.version() >= static_cast<int32>(Version::SupportMinithumbnails);
|
||||
has_thumbnail = true;
|
||||
}
|
||||
if (has_duration) {
|
||||
parse(video_note->duration, parser);
|
||||
}
|
||||
parse(video_note->dimensions, parser);
|
||||
if (parser.version() >= static_cast<int32>(Version::SupportMinithumbnails)) {
|
||||
if (has_minithumbnail) {
|
||||
parse(video_note->minithumbnail, parser);
|
||||
}
|
||||
parse(video_note->thumbnail, parser);
|
||||
if (has_thumbnail) {
|
||||
parse(video_note->thumbnail, parser);
|
||||
}
|
||||
parse(video_note->file_id, parser);
|
||||
if (parser.get_error() != nullptr || !video_note->file_id.is_valid()) {
|
||||
return FileId();
|
||||
|
Loading…
Reference in New Issue
Block a user