Add stickerFormatWebpMask.

This commit is contained in:
levlam 2022-01-25 15:27:06 +03:00
parent d6bb83dc0e
commit e2d1824edc
5 changed files with 56 additions and 43 deletions

View File

@ -219,18 +219,6 @@ thumbnailFormatWebp = ThumbnailFormat;
thumbnail format:ThumbnailFormat width:int32 height:int32 file:file = Thumbnail;
//@class StickerFormat @description Describes format of a sticker
//@description The sticker is in TGS format
stickerFormatTgs = StickerFormat;
//@description The sticker is in WEBM format
stickerFormatWebm = StickerFormat;
//@description The sticker is in WEBP format
stickerFormatWebp = StickerFormat;
//@class MaskPoint @description Part of the face, relative to which a mask is placed
//@description The mask is placed relatively to the forehead
@ -252,6 +240,21 @@ maskPointChin = MaskPoint;
maskPosition point:MaskPoint x_shift:double y_shift:double scale:double = MaskPosition;
//@class StickerFormat @description Describes format of a sticker
//@description The sticker is in TGS format
stickerFormatTgs = StickerFormat;
//@description The sticker is in WEBM format
stickerFormatWebm = StickerFormat;
//@description The sticker is in WEBP format
stickerFormatWebp = StickerFormat;
//@description The sticker is a mask in WEBP format to be placed on photos or videos @mask_position Position where the mask is placed; may be null
stickerFormatWebpMask mask_position:maskPosition = StickerFormat;
//@description Represents a closed vector path. The path begins at the end point of the last command @commands List of vector path commands
closedVectorPath commands:vector<VectorPathCommand> = ClosedVectorPath;
@ -292,9 +295,9 @@ document file_name:string mime_type:string minithumbnail:minithumbnail thumbnail
photo has_stickers:Bool minithumbnail:minithumbnail sizes:vector<photoSize> = 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 @format Sticker format @is_mask True, if the sticker is a mask @mask_position Position where the mask is placed; may be null
//@outline Sticker's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner @thumbnail Sticker thumbnail in WEBP or JPEG format; may be null @sticker File containing the sticker
sticker set_id:int64 width:int32 height:int32 emoji:string format:StickerFormat is_mask:Bool mask_position:maskPosition outline:vector<closedVectorPath> thumbnail:thumbnail sticker:file = Sticker;
//@emoji Emoji corresponding to the sticker @format Sticker format @outline Sticker's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner
//@thumbnail Sticker thumbnail in WEBP or JPEG format; may be null @sticker File containing the sticker
sticker set_id:int64 width:int32 height:int32 emoji:string format:StickerFormat outline:vector<closedVectorPath> thumbnail:thumbnail sticker:file = Sticker;
//@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
@ -2191,17 +2194,17 @@ emojis emojis:vector<string> = Emojis;
//@id Identifier of the sticker set @title Title of the sticker set @name Name of the sticker set @thumbnail Sticker set thumbnail in WEBP or TGS format with width and height 100; may be null. The file can be downloaded only before the thumbnail is changed
//@thumbnail_outline Sticker set thumbnail's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner
//@is_installed True, if the sticker set has been installed by the current user @is_archived True, if the sticker set has been archived. A sticker set can't be installed and archived simultaneously
//@is_official True, if the sticker set is official @sticker_format Format of the stickers in the set @is_masks True, if the stickers in the set are masks @is_viewed True for already viewed trending sticker sets
//@is_official True, if the sticker set is official @sticker_format Format of the stickers in the set @is_viewed True for already viewed trending sticker sets
//@stickers List of stickers in this set @emojis A list of emoji corresponding to the stickers in the same order. The list is only for informational purposes, because a sticker is always sent with a fixed emoji from the corresponding Sticker object
stickerSet id:int64 title:string name:string thumbnail:thumbnail thumbnail_outline:vector<closedVectorPath> is_installed:Bool is_archived:Bool is_official:Bool sticker_format:StickerFormat is_masks:Bool is_viewed:Bool stickers:vector<sticker> emojis:vector<emojis> = StickerSet;
stickerSet id:int64 title:string name:string thumbnail:thumbnail thumbnail_outline:vector<closedVectorPath> is_installed:Bool is_archived:Bool is_official:Bool sticker_format:StickerFormat is_viewed:Bool stickers:vector<sticker> emojis:vector<emojis> = StickerSet;
//@description Represents short information about a sticker set
//@id Identifier of the sticker set @title Title of the sticker set @name Name of the sticker set @thumbnail Sticker set thumbnail in WEBP or TGS format with width and height 100; may be null
//@thumbnail_outline Sticker set thumbnail's outline represented as a list of closed vector paths; may be empty. The coordinate system origin is in the upper-left corner
//@is_installed True, if the sticker set has been installed by the current user @is_archived True, if the sticker set has been archived. A sticker set can't be installed and archived simultaneously
//@is_official True, if the sticker set is official @sticker_format Format of the stickers in the set @is_masks True, if the stickers in the set are masks @is_viewed True for already viewed trending sticker sets
//@is_official True, if the sticker set is official @sticker_format Format of the stickers in the set @is_viewed True for already viewed trending sticker sets
//@size Total number of stickers in the set @covers Up to the first 5 stickers from the set, depending on the context. If the application needs more stickers the full sticker set needs to be requested
stickerSetInfo id:int64 title:string name:string thumbnail:thumbnail thumbnail_outline:vector<closedVectorPath> is_installed:Bool is_archived:Bool is_official:Bool sticker_format:StickerFormat is_masks:Bool is_viewed:Bool size:int32 covers:vector<sticker> = StickerSetInfo;
stickerSetInfo id:int64 title:string name:string thumbnail:thumbnail thumbnail_outline:vector<closedVectorPath> is_installed:Bool is_archived:Bool is_official:Bool sticker_format:StickerFormat is_viewed:Bool size:int32 covers:vector<sticker> = StickerSetInfo;
//@description Represents a list of sticker sets @total_count Approximate total number of sticker sets found @sets List of sticker sets
stickerSets total_count:int32 sets:vector<stickerSetInfo> = StickerSets;

View File

@ -975,21 +975,6 @@ tl_object_ptr<td_api::thumbnail> copy(const td_api::thumbnail &obj) {
return td_api::make_object<td_api::thumbnail>(std::move(format), obj.width_, obj.height_, copy(obj.file_));
}
template <>
tl_object_ptr<td_api::StickerFormat> copy(const td_api::StickerFormat &obj) {
switch (obj.get_id()) {
case td_api::stickerFormatWebp::ID:
return td_api::make_object<td_api::stickerFormatWebp>();
case td_api::stickerFormatTgs::ID:
return td_api::make_object<td_api::stickerFormatTgs>();
case td_api::stickerFormatWebm::ID:
return td_api::make_object<td_api::stickerFormatWebm>();
default:
UNREACHABLE();
}
return nullptr;
}
template <>
tl_object_ptr<td_api::MaskPoint> copy(const td_api::MaskPoint &obj) {
switch (obj.get_id()) {
@ -1012,6 +997,25 @@ tl_object_ptr<td_api::maskPosition> copy(const td_api::maskPosition &obj) {
return td_api::make_object<td_api::maskPosition>(copy(obj.point_), obj.x_shift_, obj.y_shift_, obj.scale_);
}
template <>
tl_object_ptr<td_api::StickerFormat> copy(const td_api::StickerFormat &obj) {
switch (obj.get_id()) {
case td_api::stickerFormatWebp::ID:
return td_api::make_object<td_api::stickerFormatWebp>();
case td_api::stickerFormatTgs::ID:
return td_api::make_object<td_api::stickerFormatTgs>();
case td_api::stickerFormatWebm::ID:
return td_api::make_object<td_api::stickerFormatWebm>();
case td_api::stickerFormatWebpMask::ID: {
auto &mask_position = static_cast<const td_api::stickerFormatWebpMask &>(obj).mask_position_;
return td_api::make_object<td_api::stickerFormatWebpMask>(copy(mask_position));
}
default:
UNREACHABLE();
}
return nullptr;
}
template <>
tl_object_ptr<td_api::point> copy(const td_api::point &obj) {
return td_api::make_object<td_api::point>(obj.x_, obj.y_);
@ -1078,9 +1082,9 @@ tl_object_ptr<td_api::photo> copy(const td_api::photo &obj) {
template <>
tl_object_ptr<td_api::sticker> copy(const td_api::sticker &obj) {
return td_api::make_object<td_api::sticker>(
obj.set_id_, obj.width_, obj.height_, obj.emoji_, copy(obj.format_), obj.is_mask_, copy(obj.mask_position_),
transform(obj.outline_, copy_closed_vector_path), copy(obj.thumbnail_), copy(obj.sticker_));
return td_api::make_object<td_api::sticker>(obj.set_id_, obj.width_, obj.height_, obj.emoji_, copy(obj.format_),
transform(obj.outline_, copy_closed_vector_path), copy(obj.thumbnail_),
copy(obj.sticker_));
}
template <>

View File

@ -23,12 +23,16 @@ StickerFormat get_sticker_format(Slice mime_type) {
return StickerFormat::Unknown;
}
td_api::object_ptr<td_api::StickerFormat> get_sticker_format_object(StickerFormat sticker_format) {
td_api::object_ptr<td_api::StickerFormat> get_sticker_format_object(
StickerFormat sticker_format, bool is_masks, td_api::object_ptr<td_api::maskPosition> mask_position) {
switch (sticker_format) {
case StickerFormat::Unknown:
LOG(ERROR) << "Have a sticker of unknown format";
return td_api::make_object<td_api::stickerFormatWebp>();
case StickerFormat::Webp:
if (is_masks) {
return td_api::make_object<td_api::stickerFormatWebpMask>(std::move(mask_position));
}
return td_api::make_object<td_api::stickerFormatWebp>();
case StickerFormat::Tgs:
return td_api::make_object<td_api::stickerFormatTgs>();

View File

@ -19,7 +19,8 @@ enum class StickerFormat : int32 { Unknown, Webp, Tgs, Webm };
StickerFormat get_sticker_format(Slice mime_type);
td_api::object_ptr<td_api::StickerFormat> get_sticker_format_object(StickerFormat sticker_format);
td_api::object_ptr<td_api::StickerFormat> get_sticker_format_object(
StickerFormat sticker_format, bool is_masks, td_api::object_ptr<td_api::maskPosition> mask_position);
string get_sticker_format_mime_type(StickerFormat sticker_format);

View File

@ -1851,8 +1851,9 @@ tl_object_ptr<td_api::sticker> StickersManager::get_sticker_object(FileId file_i
height = static_cast<int32>(height * zoom + 0.5);
}
return make_tl_object<td_api::sticker>(
sticker->set_id.get(), width, height, sticker->alt, get_sticker_format_object(sticker->format), sticker->is_mask,
std::move(mask_position), get_sticker_minithumbnail(sticker->minithumbnail, sticker->set_id, document_id, zoom),
sticker->set_id.get(), width, height, sticker->alt,
get_sticker_format_object(sticker->format, sticker->is_mask, std::move(mask_position)),
get_sticker_minithumbnail(sticker->minithumbnail, sticker->set_id, document_id, zoom),
std::move(thumbnail_object), td_->file_manager_->get_file_object(file_id));
}
@ -1975,7 +1976,7 @@ tl_object_ptr<td_api::stickerSet> StickersManager::get_sticker_set_object(Sticke
sticker_set->id.get(), sticker_set->title, sticker_set->short_name, std::move(thumbnail),
get_sticker_minithumbnail(sticker_set->minithumbnail, sticker_set->id, -2, 1.0),
sticker_set->is_installed && !sticker_set->is_archived, sticker_set->is_archived, sticker_set->is_official,
get_sticker_format_object(sticker_set->sticker_format), sticker_set->is_masks, sticker_set->is_viewed,
get_sticker_format_object(sticker_set->sticker_format, sticker_set->is_masks, nullptr), sticker_set->is_viewed,
std::move(stickers), std::move(emojis));
}
@ -2022,7 +2023,7 @@ tl_object_ptr<td_api::stickerSetInfo> StickersManager::get_sticker_set_info_obje
sticker_set->id.get(), sticker_set->title, sticker_set->short_name, std::move(thumbnail),
get_sticker_minithumbnail(sticker_set->minithumbnail, sticker_set->id, -3, 1.0),
sticker_set->is_installed && !sticker_set->is_archived, sticker_set->is_archived, sticker_set->is_official,
get_sticker_format_object(sticker_set->sticker_format), sticker_set->is_masks, sticker_set->is_viewed,
get_sticker_format_object(sticker_set->sticker_format, sticker_set->is_masks, nullptr), sticker_set->is_viewed,
sticker_set->was_loaded ? narrow_cast<int32>(sticker_set->sticker_ids.size()) : sticker_set->sticker_count,
std::move(stickers));
}