From 43483e743d6ea638e580dc99a4c60a5a9cfae293 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 1 Mar 2019 22:51:33 +0300 Subject: [PATCH] Update layer to 92: minithumbnails support. GitOrigin-RevId: a2e3bba42504cdaf91db1e0113bc98c450ba78c9 --- td/generate/scheme/td_api.tl | 28 ++++++----- td/generate/scheme/td_api.tlo | Bin 151896 -> 152344 bytes td/generate/scheme/telegram_api.tl | 3 +- td/generate/scheme/telegram_api.tlo | Bin 175116 -> 175316 bytes td/telegram/AnimationsManager.cpp | 10 +++- td/telegram/AnimationsManager.h | 5 +- td/telegram/AnimationsManager.hpp | 4 ++ td/telegram/AudiosManager.cpp | 16 ++++-- td/telegram/AudiosManager.h | 5 +- td/telegram/AudiosManager.hpp | 4 ++ td/telegram/DocumentsManager.cpp | 47 +++++++++++------ td/telegram/DocumentsManager.h | 4 +- td/telegram/DocumentsManager.hpp | 4 ++ td/telegram/InlineQueriesManager.cpp | 20 +++++--- td/telegram/MessageContent.cpp | 14 ++++-- td/telegram/Photo.cpp | 72 ++++++++++++++++++++++----- td/telegram/Photo.h | 22 ++++---- td/telegram/Photo.hpp | 10 ++++ td/telegram/StickersManager.cpp | 12 +++-- td/telegram/Version.h | 1 + td/telegram/VideoNotesManager.cpp | 10 +++- td/telegram/VideoNotesManager.h | 4 +- td/telegram/VideoNotesManager.hpp | 4 ++ td/telegram/VideosManager.cpp | 9 +++- td/telegram/VideosManager.h | 7 +-- td/telegram/VideosManager.hpp | 4 ++ td/telegram/WallpaperManager.cpp | 16 ++++-- td/telegram/net/MtprotoHeader.cpp | 2 +- 28 files changed, 246 insertions(+), 91 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index b98875b0..e889f20e 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -170,6 +170,9 @@ inputFileGenerated original_path:string conversion:string expected_size:int32 = //@description Photo description @type Thumbnail type (see https://core.telegram.org/constructor/photoSize) @photo Information about the photo file @width Photo width @height Photo height photoSize type:string photo:file width:int32 height:int32 = PhotoSize; +//@description A very poor quality and low resolution image thumbnail @width Thumbnail width, usually doesn't exceed 40 @height Thumbnail height, usually doesn't exceed 40 @data The thumbnail +minithumbnail width:int32 height:int32 data:bytes = Minithumbnail; + //@class MaskPoint @description Part of the face, relative to which a mask should be placed @@ -198,19 +201,20 @@ pollOption text:string voter_count:int32 vote_percentage:int32 is_chosen:Bool is //@description Describes an animation file. The animation must be encoded in GIF or MPEG4 format @duration Duration of the animation, in seconds; as defined by the sender @width Width of the animation @height Height of the animation -//@file_name Original name of the file; as defined by the sender @mime_type MIME type of the file, usually "image/gif" or "video/mp4" @thumbnail Animation thumbnail; may be null @animation File containing the animation -animation duration:int32 width:int32 height:int32 file_name:string mime_type:string thumbnail:photoSize animation:file = Animation; +//@file_name Original name of the file; as defined by the sender @mime_type MIME type of the file, usually "image/gif" or "video/mp4" +//@minithumbnail Animation minithumbnail; may be null @thumbnail Animation thumbnail; may be null @animation File containing the animation +animation duration:int32 width:int32 height:int32 file_name:string mime_type:string minithumbnail:minithumbnail thumbnail:photoSize animation:file = Animation; //@description Describes an audio file. Audio is usually in MP3 format @duration Duration of the audio, in seconds; as defined by the sender @title Title of the audio; as defined by the sender @performer Performer of the audio; as defined by the sender -//@file_name Original name of the file; as defined by the sender @mime_type The MIME type of the file; as defined by the sender @album_cover_thumbnail The thumbnail of the album cover; as defined by the sender. The full size thumbnail should be extracted from the downloaded file; may be null @audio File containing the audio -audio duration:int32 title:string performer:string file_name:string mime_type:string album_cover_thumbnail:photoSize audio:file = Audio; +//@file_name Original name of the file; as defined by the sender @mime_type The MIME type of the file; as defined by the sender @album_cover_minithumbnail The minithumbnail of the album cover; may be null @album_cover_thumbnail The thumbnail of the album cover; as defined by the sender. The full size thumbnail should be extracted from the downloaded file; may be null @audio File containing the audio +audio duration:int32 title:string performer:string file_name:string mime_type:string album_cover_minithumbnail:minithumbnail album_cover_thumbnail:photoSize audio:file = Audio; //@description Describes a document of any type @file_name Original name of the file; as defined by the sender @mime_type MIME type of the file; as defined by the sender -//@thumbnail Document thumbnail; as defined by the sender; may be null @document File containing the document -document file_name:string mime_type:string thumbnail:photoSize document:file = Document; +//@minithumbnail Document minithumbnail; may be null @thumbnail Document thumbnail; as defined by the sender; may be null @document File containing the document +document file_name:string mime_type:string minithumbnail:minithumbnail thumbnail:photoSize document:file = Document; -//@description Describes a photo @has_stickers True, if stickers were added to the photo @sizes Available variants of the photo, in different sizes -photo has_stickers:Bool sizes:vector = Photo; +//@description Describes a photo @has_stickers True, if stickers were added to the photo @minithumbnail Photo minithumbnail; may be null @sizes Available variants of the photo, in different sizes +photo has_stickers:Bool minithumbnail:minithumbnail sizes:vector = Photo; //@description Describes a sticker @set_id The identifier of the sticker set to which the sticker belongs; 0 if none @width Sticker width; as defined by the sender @height Sticker height; as defined by the sender //@emoji Emoji corresponding to the sticker @is_mask True, if the sticker is a mask @mask_position Position where the mask should be placed; may be null @thumbnail Sticker thumbnail in WEBP or JPEG format; may be null @sticker File containing the sticker @@ -218,11 +222,11 @@ sticker set_id:int64 width:int32 height:int32 emoji:string is_mask:Bool mask_pos //@description Describes a video file @duration Duration of the video, in seconds; as defined by the sender @width Video width; as defined by the sender @height Video height; as defined by the sender //@file_name Original name of the file; as defined by the sender @mime_type MIME type of the file; as defined by the sender @has_stickers True, if stickers were added to the photo -//@supports_streaming True, if the video should be tried to be streamed @thumbnail Video thumbnail; as defined by the sender; may be null @video File containing the video -video duration:int32 width:int32 height:int32 file_name:string mime_type:string has_stickers:Bool supports_streaming:Bool thumbnail:photoSize video:file = Video; +//@supports_streaming True, if the video should be tried to be streamed @minithumbnail Video minithumbnail; may be null @thumbnail Video thumbnail; as defined by the sender; may be null @video File containing the video +video duration:int32 width:int32 height:int32 file_name:string mime_type:string has_stickers:Bool supports_streaming:Bool minithumbnail:minithumbnail thumbnail:photoSize video:file = Video; -//@description Describes a video note. The video must be equal in width and height, cropped to a circle, and stored in MPEG4 format @duration Duration of the video, in seconds; as defined by the sender @length Video width and height; as defined by the sender @thumbnail Video thumbnail; as defined by the sender; may be null @video File containing the video -videoNote duration:int32 length:int32 thumbnail:photoSize video:file = VideoNote; +//@description Describes a video note. The video must be equal in width and height, cropped to a circle, and stored in MPEG4 format @duration Duration of the video, in seconds; as defined by the sender @length Video width and height; as defined by the sender @minithumbnail Video minithumbnail; may be null @thumbnail Video thumbnail; as defined by the sender; may be null @video File containing the video +videoNote duration:int32 length:int32 minithumbnail:minithumbnail thumbnail:photoSize video:file = VideoNote; //@description Describes a voice note. The voice note must be encoded with the Opus codec, and stored inside an OGG container. Voice notes can have only a single audio channel @duration Duration of the voice note, in seconds; as defined by the sender //@waveform A waveform representation of the voice note in 5-bit format @mime_type MIME type of the file; as defined by the sender @voice File containing the voice note diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index db20bdfc5d72bfb8a9b0d78c2b12f93cd4cbbcf1..709733fa8932ab1027dfa21936c2cd6ea142a214 100644 GIT binary patch delta 1136 zcmZuwUr1A76u-yao7>oE{sXmD^CjI@xo8h2t5yU`%p4>oQMsw3E!?IxC7*(v>4SuJ z98Q8u*3sNO1xSm^&+5!avlkb% z6~2HkMIP$CSP(PHcrw0^k(X0&Aqq#cN351|+n#v;lPm8L58 zaG4A_l&f3j8ss?g-T)dkb!Fta8)}>VHFd!j&!w6aC{IAqZg%mcKLrelUD3Z}l09GzXq1)>s&O%qUv!(JYTrc2O1X%)x_G+m6A zNgY0$ED;FzO)2Y?RUoVRr#L<}E|4yNr*BTT^76VsoUeppX=vK1pxmCmwI~<}7EJDx zs%ABs?er3erhhJh<4BIkrof5*GITWQvHPl$>Md1$N$8j)b4e#g4k$%~0y6N0 zTv|Jf*-0zYVlKHG6E*{mF6(eWP7h`982~8Gt;IQ;d{C zM(pb$c;U&R7HW|#By%Tk!d*=aA};npVuSyNLrxmWcPT@^-l0BAjHjX)CxRgl$B~#F zH4K)a?wi1;EU^iN+BG&6g*Y2U92kTZCPt%K&+d3MU{KL3Bi+QMy-*}RiNaRudmuSH OH?1dQ#vG496a5X{W7c&5 delta 1010 zcmZ9Le@IhN6vyA$-pjqQ(F!epQ7cWi`CuCR!$N3@Ajqf*68^DZqpdbjpU{j71H-h0 zi0la0$UuU|qy>%#&7eO9LHMV&`J<>?GJ1dA`+fI&&gY(U?qp0{ zc_Ny>K60Mq3g6ne`7)mv>v%YR%VWGBSUMn_9tcL{@q3lY&8-st;-)pLY#7#!3Sa8q z!_Rzbom9e=E)&1_^v4=b*BvqW-n|shMS>yuj2y+Abyc`tHxFqgS$_#CXk0PS7wHW| zBXS?d(f#{3`#mMtWLGdfY<(c{*yyk^0Q5P!4D>Kpfbwu0T^GF)-k4~^ z$M$y2Hgxgyk0MD^tre8k5R@+r^oIJPY81Ms9v(Xz&KC0x$~Ns-H5moU}X$S z;`+Q%qw$Zqac-oWMMul96=zC_P@fb+bddK3MZ8Oox2?ZyAo;2 zKs}~oJo=WKaU4`(Fo&GDnti?k{UzolQ=2Krsh~wy98_48LI}V)?(Cnz8)?*YS zH4%peomQ^!GuRS~uYp6zAJitXU$%;DPG}kuXapPSjl*7%O$61@yj;zKnVy3w_6KBt Bn34bh diff --git a/td/generate/scheme/telegram_api.tl b/td/generate/scheme/telegram_api.tl index 030aa5d5..5fa86fbb 100644 --- a/td/generate/scheme/telegram_api.tl +++ b/td/generate/scheme/telegram_api.tl @@ -172,6 +172,7 @@ photo#9c477dd8 flags:# has_stickers:flags.0?true id:long access_hash:long file_r photoSizeEmpty#e17e23c type:string = PhotoSize; photoSize#77bfb61b type:string location:FileLocation w:int h:int size:int = PhotoSize; photoCachedSize#e9a734fa type:string location:FileLocation w:int h:int bytes:bytes = PhotoSize; +photoStrippedSize#e0b0bc2e type:string bytes:bytes = PhotoSize; geoPointEmpty#1117dd5f = GeoPoint; geoPoint#296f104 long:double lat:double access_hash:long = GeoPoint; @@ -230,7 +231,7 @@ messages.dialogsSlice#71e094f3 count:int dialogs:Vector messages:Vector< messages.dialogsNotModified#f0e3e596 count:int = messages.Dialogs; messages.messages#8c718e87 messages:Vector chats:Vector users:Vector = messages.Messages; -messages.messagesSlice#b446ae3 count:int messages:Vector chats:Vector users:Vector = messages.Messages; +messages.messagesSlice#a6c47aaa flags:# inexact:flags.1?true count:int messages:Vector chats:Vector users:Vector = messages.Messages; messages.channelMessages#99262e37 flags:# inexact:flags.1?true pts:int count:int messages:Vector chats:Vector users:Vector = messages.Messages; messages.messagesNotModified#74535f21 count:int = messages.Messages; diff --git a/td/generate/scheme/telegram_api.tlo b/td/generate/scheme/telegram_api.tlo index 237cc4cd9b8a275132e33f3b85017b1e8250938e..fa1af615025ad6f7a7645665d3892d3f7df37bef 100644 GIT binary patch delta 584 zcmZ8dKS%;`6!yI?IHjP!wpav46xn%15RpMbL!g6DqtM^81WU}EMNUVz=$qvo{b+jzHs2U?=4e%w<2DRNFfg zJgjf56}=P>V4Xn^*97b?jq&srLJuhk2PvaC z$dp15wW6Yh@TLC$+1p!pUA5$%!&+6FMXr)7gSVm%lmI43hXl>wv{}5Lk)Szr~_tgcX-HX!3YtodBkV{ zVO_WhWo>`*i1Cj%M9{#9NoTr%K9dQUyW9iD+U}FgBm*&Gdrk_|3MPp14Z1+(2Kr1Q zVD9#qbfynbnSd;&0*K&|ET%h5oG=HnO%F_F@}7PmnW AnimationsManager::get_animation_object(FileId animation->is_changed = false; return make_tl_object(animation->duration, animation->dimensions.width, animation->dimensions.height, animation->file_name, animation->mime_type, + get_minithumbnail_object(animation->minithumbnail), get_photo_size_object(td_->file_manager_.get(), &animation->thumbnail), td_->file_manager_->get_file_object(file_id)); } @@ -195,6 +196,10 @@ FileId AnimationsManager::on_get_animation(unique_ptr new_animation, a->duration = new_animation->duration; a->is_changed = true; } + if (a->minithumbnail != new_animation->minithumbnail) { + a->minithumbnail = std::move(new_animation->minithumbnail); + a->is_changed = true; + } if (a->thumbnail != new_animation->thumbnail) { if (!a->thumbnail.file_id.is_valid()) { LOG(DEBUG) << "Animation " << file_id << " thumbnail has changed"; @@ -283,14 +288,15 @@ bool AnimationsManager::merge_animations(FileId new_id, FileId old_id, bool can_ return true; } -void AnimationsManager::create_animation(FileId file_id, PhotoSize thumbnail, string file_name, string mime_type, - int32 duration, Dimensions dimensions, bool replace) { +void AnimationsManager::create_animation(FileId file_id, string minithumbnail, PhotoSize thumbnail, string file_name, + string mime_type, int32 duration, Dimensions dimensions, bool replace) { auto a = make_unique(); a->file_id = file_id; a->file_name = std::move(file_name); a->mime_type = std::move(mime_type); a->duration = max(duration, 0); a->dimensions = dimensions; + a->minithumbnail = std::move(minithumbnail); a->thumbnail = std::move(thumbnail); on_get_animation(std::move(a), replace); } diff --git a/td/telegram/AnimationsManager.h b/td/telegram/AnimationsManager.h index d52dc264..102f4409 100644 --- a/td/telegram/AnimationsManager.h +++ b/td/telegram/AnimationsManager.h @@ -35,8 +35,8 @@ class AnimationsManager : public Actor { tl_object_ptr get_animation_object(FileId file_id, const char *source); - void create_animation(FileId file_id, PhotoSize thumbnail, string file_name, string mime_type, int32 duration, - Dimensions dimensions, bool replace); + void create_animation(FileId file_id, string minithumbnail, PhotoSize thumbnail, string file_name, string mime_type, + int32 duration, Dimensions dimensions, bool replace); tl_object_ptr get_input_media(FileId file_id, tl_object_ptr input_file, @@ -95,6 +95,7 @@ class AnimationsManager : public Actor { string mime_type; int32 duration = 0; Dimensions dimensions; + string minithumbnail; PhotoSize thumbnail; FileId file_id; diff --git a/td/telegram/AnimationsManager.hpp b/td/telegram/AnimationsManager.hpp index 8ca977bc..204f844e 100644 --- a/td/telegram/AnimationsManager.hpp +++ b/td/telegram/AnimationsManager.hpp @@ -26,6 +26,7 @@ void AnimationsManager::store_animation(FileId file_id, StorerT &storer) const { store(animation->dimensions, storer); store(animation->file_name, storer); store(animation->mime_type, storer); + store(animation->minithumbnail, storer); store(animation->thumbnail, storer); store(file_id, storer); } @@ -39,6 +40,9 @@ FileId AnimationsManager::parse_animation(ParserT &parser) { parse(animation->dimensions, parser); parse(animation->file_name, parser); parse(animation->mime_type, parser); + if (parser.version() >= static_cast(Version::SupportMinithumbnails)) { + parse(animation->minithumbnail, parser); + } parse(animation->thumbnail, parser); parse(animation->file_id, parser); return on_get_animation(std::move(animation), false); diff --git a/td/telegram/AudiosManager.cpp b/td/telegram/AudiosManager.cpp index d93a3502..7471436f 100644 --- a/td/telegram/AudiosManager.cpp +++ b/td/telegram/AudiosManager.cpp @@ -36,9 +36,10 @@ tl_object_ptr AudiosManager::get_audio_object(FileId file_id) { auto &audio = audios_[file_id]; CHECK(audio != nullptr); audio->is_changed = false; - return make_tl_object( - audio->duration, audio->title, audio->performer, audio->file_name, audio->mime_type, - get_photo_size_object(td_->file_manager_.get(), &audio->thumbnail), td_->file_manager_->get_file_object(file_id)); + return make_tl_object(audio->duration, audio->title, audio->performer, audio->file_name, + audio->mime_type, get_minithumbnail_object(audio->minithumbnail), + get_photo_size_object(td_->file_manager_.get(), &audio->thumbnail), + td_->file_manager_->get_file_object(file_id)); } FileId AudiosManager::on_get_audio(unique_ptr