Add chatPhoto.small_animation.

This commit is contained in:
levlam 2022-05-30 04:01:55 +03:00
parent 42ab42c83a
commit 3b4b276737
3 changed files with 27 additions and 11 deletions

View File

@ -407,8 +407,9 @@ animatedChatPhoto length:int32 file:file main_frame_timestamp:double = AnimatedC
//@added_date Point in time (Unix timestamp) when the photo has been added
//@minithumbnail Photo minithumbnail; may be null
//@sizes Available variants of the photo in JPEG format, in different size
//@animation Animated variant of the photo in MPEG4 format; may be null
chatPhoto id:int64 added_date:int32 minithumbnail:minithumbnail sizes:vector<photoSize> animation:animatedChatPhoto = ChatPhoto;
//@animation A big (640x640) animated variant of the photo in MPEG4 format; may be null
//@small_animation A small (160x160) animated variant of the photo in MPEG4 format; may be null even the big animation is available
chatPhoto id:int64 added_date:int32 minithumbnail:minithumbnail sizes:vector<photoSize> animation:animatedChatPhoto small_animation:animatedChatPhoto = ChatPhoto;
//@description Contains a list of chat or user profile photos @total_count Total number of photos @photos List of photos
chatPhotos total_count:int32 photos:vector<chatPhoto> = ChatPhotos;

View File

@ -304,7 +304,8 @@ Photo get_photo(FileManager *file_manager, tl_object_ptr<telegram_api::photo> &&
owner_dialog_id, std::move(size_ptr), PhotoFormat::Jpeg);
if (photo_size.get_offset() == 0) {
PhotoSize &size = photo_size.get<0>();
if (size.type == 0 || size.type == 't' || size.type == 'i' || size.type == 'u' || size.type == 'v') {
if (size.type == 0 || size.type == 't' || size.type == 'i' || size.type == 'p' || size.type == 'u' ||
size.type == 'v') {
LOG(ERROR) << "Skip unallowed photo size " << size;
continue;
}
@ -351,10 +352,23 @@ tl_object_ptr<td_api::chatPhoto> get_chat_photo_object(FileManager *file_manager
return nullptr;
}
const AnimationSize *animation = photo.animations.empty() ? nullptr : &photo.animations.back();
const AnimationSize *small_animation = nullptr;
const AnimationSize *big_animation = nullptr;
for (auto &animation : photo.animations) {
if (animation.type == 'p') {
small_animation = &animation;
} else if (animation.type == 'u') {
big_animation = &animation;
}
}
if (big_animation == nullptr && small_animation != nullptr) {
LOG(ERROR) << "Have small animation without big animation in " << photo;
small_animation = nullptr;
}
return td_api::make_object<td_api::chatPhoto>(
photo.id.get(), photo.date, get_minithumbnail_object(photo.minithumbnail),
get_photo_sizes_object(file_manager, photo.photos), get_animated_chat_photo_object(file_manager, animation));
get_photo_sizes_object(file_manager, photo.photos), get_animated_chat_photo_object(file_manager, big_animation),
get_animated_chat_photo_object(file_manager, small_animation));
}
void photo_delete_thumbnail(Photo &photo) {
@ -488,10 +502,11 @@ SecretInputMedia photo_get_secret_input_media(FileManager *file_manager, const P
size = 0;
}
return SecretInputMedia{std::move(input_file), make_tl_object<secret_api::decryptedMessageMediaPhoto>(
std::move(thumbnail), thumbnail_width, thumbnail_height, width,
height, static_cast<int32>(size), BufferSlice(encryption_key.key_slice()),
BufferSlice(encryption_key.iv_slice()), caption)};
return SecretInputMedia{
std::move(input_file),
make_tl_object<secret_api::decryptedMessageMediaPhoto>(
std::move(thumbnail), thumbnail_width, thumbnail_height, width, height, static_cast<int32>(size),
BufferSlice(encryption_key.key_slice()), BufferSlice(encryption_key.iv_slice()), caption)};
}
vector<FileId> photo_get_file_ids(const Photo &photo) {

View File

@ -263,8 +263,8 @@ AnimationSize get_animation_size(FileManager *file_manager, PhotoSizeSource sour
tl_object_ptr<telegram_api::videoSize> &&size) {
CHECK(size != nullptr);
AnimationSize res;
if (size->type_ != "v" && size->type_ != "u") {
LOG(ERROR) << "Wrong videoSize \"" << size->type_ << "\" in " << to_string(size);
if (size->type_ != "p" && size->type_ != "u" && size->type_ != "v") {
LOG(ERROR) << "Unsupported videoSize \"" << size->type_ << "\" in " << to_string(size);
}
res.type = static_cast<uint8>(size->type_[0]);
if (res.type >= 128) {