diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 1ec06d876..4f178b33b 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -422,8 +422,9 @@ 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 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 preload_prefix_size:int32 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 diff --git a/td/telegram/DocumentsManager.cpp b/td/telegram/DocumentsManager.cpp index 756355da6..acb52fbec 100644 --- a/td/telegram/DocumentsManager.cpp +++ b/td/telegram/DocumentsManager.cpp @@ -122,9 +122,11 @@ Document DocumentsManager::on_get_document(RemoteDocument remote_document, Dialo } } int32 video_duration = 0; + int32 video_preload_prefix_size = 0; string video_waveform; if (video != nullptr) { video_duration = static_cast(std::ceil(video->duration_)); + video_preload_prefix_size = video->preload_prefix_size_; 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) { @@ -527,7 +529,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, dimensions, - supports_streaming, !is_web); + supports_streaming, 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/InlineQueriesManager.cpp b/td/telegram/InlineQueriesManager.cpp index 8caba2e15..c9281d84d 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_), copy(obj.video_)); + copy(obj.thumbnail_), obj.preload_prefix_size_, copy(obj.video_)); } template <> diff --git a/td/telegram/MessageContent.cpp b/td/telegram/MessageContent.cpp index 965aab284..86a73d5cd 100644 --- a/td/telegram/MessageContent.cpp +++ b/td/telegram/MessageContent.cpp @@ -2101,10 +2101,11 @@ static Result create_input_message_content( ttl = input_video->self_destruct_time_; bool has_stickers = !sticker_file_ids.empty(); - td->videos_manager_->create_video( - file_id, string(), thumbnail, AnimationSize(), has_stickers, std::move(sticker_file_ids), - std::move(file_name), std::move(mime_type), input_video->duration_, - get_dimensions(input_video->width_, input_video->height_, nullptr), input_video->supports_streaming_, false); + td->videos_manager_->create_video(file_id, string(), thumbnail, AnimationSize(), has_stickers, + std::move(sticker_file_ids), std::move(file_name), std::move(mime_type), + input_video->duration_, + get_dimensions(input_video->width_, input_video->height_, nullptr), + input_video->supports_streaming_, 0, false); content = make_unique(file_id, std::move(caption), input_video->has_spoiler_ && !is_secret); break; diff --git a/td/telegram/VideosManager.cpp b/td/telegram/VideosManager.cpp index b4705be55..7bbc70eef 100644 --- a/td/telegram/VideosManager.cpp +++ b/td/telegram/VideosManager.cpp @@ -46,10 +46,10 @@ 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), td_->file_manager_->get_file_object(file_id)); + 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)); } FileId VideosManager::on_get_video(unique_ptr