From c34b4c3ef7fba91621ab1820271700ca4d215071 Mon Sep 17 00:00:00 2001 From: levlam Date: Fri, 23 Jun 2023 16:06:02 +0300 Subject: [PATCH] Add storyVideo.is_animation. --- td/generate/scheme/td_api.tl | 6 ++++-- td/telegram/DocumentsManager.cpp | 4 +++- td/telegram/MessageContent.cpp | 2 +- td/telegram/StoryContent.cpp | 2 +- td/telegram/VideosManager.cpp | 15 ++++++++++----- td/telegram/VideosManager.h | 3 ++- td/telegram/VideosManager.hpp | 2 ++ td/telegram/cli.cpp | 4 ++-- 8 files changed, 25 insertions(+), 13 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 37fb1af27..f2feacfc5 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -4878,11 +4878,12 @@ messageLinkInfo is_public:Bool chat_id:int53 message_thread_id:int53 message:mes //@width Video width //@height Video height //@has_stickers True, if stickers were added to the video. The list of corresponding sticker sets can be received using getAttachedStickerSets +//@is_animation True, if the video has no sound //@minithumbnail Video minithumbnail; may be null //@thumbnail Video thumbnail in JPEG or MPEG4 format; may be null //@preload_prefix_size Number of bytes from the video file beginning, which is enough to load to play the video for one second; 0 if unknown //@video File containing the video -storyVideo duration:double width:int32 height:int32 has_stickers:Bool minithumbnail:minithumbnail thumbnail:thumbnail preload_prefix_size:int32 video:file = StoryVideo; +storyVideo duration:double width:int32 height:int32 has_stickers:Bool is_animation:Bool minithumbnail:minithumbnail thumbnail:thumbnail preload_prefix_size:int32 video:file = StoryVideo; //@class StoryContent @description Contains the content of a story @@ -4908,7 +4909,8 @@ inputStoryContentPhoto photo:InputFile added_sticker_file_ids:vector = In //@video Video to be sent. The video size must be 720x1280. The video must be streamable and stored in MPEG4 format, after encoding with x265 codec and key frames added each second //@added_sticker_file_ids File identifiers of the stickers added to the video, if applicable //@duration Precise duration of the video, in seconds; 0-60 -inputStoryContentVideo video:InputFile added_sticker_file_ids:vector duration:double = InputStoryContent; +//@is_animation True, if the video has no sound +inputStoryContentVideo video:InputFile added_sticker_file_ids:vector duration:double is_animation:Bool = InputStoryContent; //@description Contains information about interactions with a story diff --git a/td/telegram/DocumentsManager.cpp b/td/telegram/DocumentsManager.cpp index f54d95cc2..c5d304ddc 100644 --- a/td/telegram/DocumentsManager.cpp +++ b/td/telegram/DocumentsManager.cpp @@ -121,6 +121,7 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo UNREACHABLE(); } } + bool video_is_animation = false; double video_precise_duration = 0.0; int32 video_duration = 0; int32 video_preload_prefix_size = 0; @@ -131,6 +132,7 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo if (document_subtype == Subtype::Story) { video_preload_prefix_size = video->preload_prefix_size_; } + video_is_animation = video->nosound_; auto video_dimensions = get_dimensions(video->w_, video->h_, "documentAttributeVideo"); if (dimensions.width == 0 || (video_dimensions.width != 0 && video_dimensions != dimensions)) { if (dimensions.width != 0) { @@ -541,7 +543,7 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo td_->videos_manager_->create_video( file_id, std::move(minithumbnail), std::move(thumbnail), std::move(animated_thumbnail), has_stickers, vector(), std::move(file_name), std::move(mime_type), video_duration, video_precise_duration, - dimensions, supports_streaming, video_preload_prefix_size, !is_web); + dimensions, supports_streaming, video_is_animation, video_preload_prefix_size, !is_web); break; case Document::Type::VideoNote: td_->video_notes_manager_->create_video_note(file_id, std::move(minithumbnail), std::move(thumbnail), diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 43f704d9b..328260974 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -2138,7 +2138,7 @@ static Result create_input_message_content( std::move(sticker_file_ids), std::move(file_name), std::move(mime_type), input_video->duration_, input_video->duration_, get_dimensions(input_video->width_, input_video->height_, nullptr), - input_video->supports_streaming_, 0, false); + input_video->supports_streaming_, false, 0, false); content = make_unique(file_id, std::move(caption), input_video->has_spoiler_ && !is_secret); break; diff --git a/td/telegram/StoryContent.cpp b/td/telegram/StoryContent.cpp index aaff428b2..4769ba51a 100644 --- a/td/telegram/StoryContent.cpp +++ b/td/telegram/StoryContent.cpp @@ -170,7 +170,7 @@ Result> get_input_story_content( td->videos_manager_->create_video(file_id, string(), PhotoSize(), AnimationSize(), has_stickers, std::move(sticker_file_ids), "story.mp4", "video/mp4", static_cast(std::ceil(input_story->duration_)), input_story->duration_, - get_dimensions(720, 1280, nullptr), true, 0, false); + get_dimensions(720, 1280, nullptr), true, input_story->is_animation_, 0, false); return make_unique(file_id, FileId()); } diff --git a/td/telegram/VideosManager.cpp b/td/telegram/VideosManager.cpp index 8f5cafcc1..13e4cfac9 100644 --- a/td/telegram/VideosManager.cpp +++ b/td/telegram/VideosManager.cpp @@ -64,8 +64,8 @@ td_api::object_ptr VideosManager::get_story_video_object(Fil : get_thumbnail_object(td_->file_manager_.get(), video->thumbnail, PhotoFormat::Jpeg); return td_api::make_object( video->precise_duration, video->dimensions.width, video->dimensions.height, video->has_stickers, - get_minithumbnail_object(video->minithumbnail), std::move(thumbnail), video->preload_prefix_size, - td_->file_manager_->get_file_object(file_id)); + video->is_animation, get_minithumbnail_object(video->minithumbnail), std::move(thumbnail), + video->preload_prefix_size, td_->file_manager_->get_file_object(file_id)); } FileId VideosManager::on_get_video(unique_ptr