diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index d118d3f7a..eaaa3086a 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -422,9 +422,8 @@ sticker id:int64 set_id:int64 width:int32 height:int32 emoji:string format:Stick //@supports_streaming True, if the video is supposed to be streamed //@minithumbnail Video minithumbnail; may be null //@thumbnail Video thumbnail in JPEG or MPEG4 format; as defined by the sender; 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. Currently, it is expected to be known only for video stories //@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:thumbnail preload_prefix_size:int32 video:file = Video; +video duration:int32 width:int32 height:int32 file_name:string mime_type:string has_stickers:Bool supports_streaming:Bool minithumbnail:minithumbnail thumbnail:thumbnail 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 @@ -4834,13 +4833,25 @@ messageLink link:string is_public:Bool = MessageLink; messageLinkInfo is_public:Bool chat_id:int53 message_thread_id:int53 message:message media_timestamp:int32 for_album:Bool = MessageLinkInfo; +//@description Describes a video file sent in a story +//@duration Duration of the video, in seconds +//@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 +//@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; + + //@class StoryContent @description Contains the content of a story //@description A photo story @photo The photo storyContentPhoto photo:photo = StoryContent; -//@description A video story @video The video in MPEG4 format, encoded by x265 codec @alternative_video Alternative version of the video in MPEG4 format, encoded by x264 codec; may be null -storyContentVideo video:video alternative_video:video = StoryContent; +//@description A video story @video The video in MPEG4 format @alternative_video Alternative version of the video in MPEG4 format, encoded by x264 codec; may be null +storyContentVideo video:storyVideo alternative_video:storyVideo = StoryContent; //@description A story content that is not supported in the current TDLib version storyContentUnsupported = StoryContent; diff --git a/td/telegram/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index c9281d84d..8caba2e15 100644 --- a/td/telegram/InlineQueriesManager.cpp +++ b/td/telegram/InlineQueriesManager.cpp @@ -1322,7 +1322,7 @@ template <> tl_object_ptr copy(const td_api::video &obj) { return td_api::make_object(obj.duration_, obj.width_, obj.height_, obj.file_name_, obj.mime_type_, obj.has_stickers_, obj.supports_streaming_, copy(obj.minithumbnail_), - copy(obj.thumbnail_), obj.preload_prefix_size_, copy(obj.video_)); + copy(obj.thumbnail_), copy(obj.video_)); } template <> diff --git a/td/telegram/StoryContent.cpp b/td/telegram/StoryContent.cpp index 94b583e83..4f7b63740 100644 --- a/td/telegram/StoryContent.cpp +++ b/td/telegram/StoryContent.cpp @@ -359,8 +359,9 @@ td_api::object_ptr get_story_content_object(Td *td, const } case StoryContentType::Video: { const auto *s = static_cast(content); - return td_api::make_object(td->videos_manager_->get_video_object(s->file_id_), - td->videos_manager_->get_video_object(s->alt_file_id_)); + return td_api::make_object( + td->videos_manager_->get_story_video_object(s->file_id_), + td->videos_manager_->get_story_video_object(s->alt_file_id_)); } case StoryContentType::Unsupported: return td_api::make_object(); diff --git a/td/telegram/VideosManager.cpp b/td/telegram/VideosManager.cpp index 627abd738..8f5cafcc1 100644 --- a/td/telegram/VideosManager.cpp +++ b/td/telegram/VideosManager.cpp @@ -36,7 +36,7 @@ int32 VideosManager::get_video_duration(FileId file_id) const { return video->duration; } -tl_object_ptr VideosManager::get_video_object(FileId file_id) const { +td_api::object_ptr VideosManager::get_video_object(FileId file_id) const { if (!file_id.is_valid()) { return nullptr; } @@ -46,10 +46,26 @@ tl_object_ptr VideosManager::get_video_object(FileId file_id) con auto thumbnail = video->animated_thumbnail.file_id.is_valid() ? get_thumbnail_object(td_->file_manager_.get(), video->animated_thumbnail, PhotoFormat::Mpeg4) : get_thumbnail_object(td_->file_manager_.get(), video->thumbnail, PhotoFormat::Jpeg); - return make_tl_object( - video->duration, video->dimensions.width, video->dimensions.height, video->file_name, video->mime_type, - video->has_stickers, video->supports_streaming, get_minithumbnail_object(video->minithumbnail), - std::move(thumbnail), video->preload_prefix_size, td_->file_manager_->get_file_object(file_id)); + return td_api::make_object(video->duration, video->dimensions.width, video->dimensions.height, + video->file_name, video->mime_type, video->has_stickers, + video->supports_streaming, get_minithumbnail_object(video->minithumbnail), + std::move(thumbnail), td_->file_manager_->get_file_object(file_id)); +} + +td_api::object_ptr VideosManager::get_story_video_object(FileId file_id) const { + if (!file_id.is_valid()) { + return nullptr; + } + + auto video = get_video(file_id); + CHECK(video != nullptr); + auto thumbnail = video->animated_thumbnail.file_id.is_valid() + ? get_thumbnail_object(td_->file_manager_.get(), video->animated_thumbnail, PhotoFormat::Mpeg4) + : 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)); } FileId VideosManager::on_get_video(unique_ptr