Add video.preload_prefix_size.
This commit is contained in:
parent
0ec13a13e2
commit
f5208dd8bd
@ -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
|
||||
|
@ -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<int32>(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<FileId>(),
|
||||
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),
|
||||
|
@ -1322,7 +1322,7 @@ template <>
|
||||
tl_object_ptr<td_api::video> copy(const td_api::video &obj) {
|
||||
return td_api::make_object<td_api::video>(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 <>
|
||||
|
@ -2101,10 +2101,11 @@ static Result<InputMessageContent> 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<MessageVideo>(file_id, std::move(caption), input_video->has_spoiler_ && !is_secret);
|
||||
break;
|
||||
|
@ -46,10 +46,10 @@ tl_object_ptr<td_api::video> 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<td_api::video>(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<td_api::video>(
|
||||
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<Video> new_video, bool replace) {
|
||||
@ -66,11 +66,13 @@ FileId VideosManager::on_get_video(unique_ptr<Video> new_video, bool replace) {
|
||||
v->mime_type = std::move(new_video->mime_type);
|
||||
}
|
||||
if (v->duration != new_video->duration || v->dimensions != new_video->dimensions ||
|
||||
v->supports_streaming != new_video->supports_streaming) {
|
||||
v->supports_streaming != new_video->supports_streaming ||
|
||||
v->preload_prefix_size != new_video->preload_prefix_size) {
|
||||
LOG(DEBUG) << "Video " << file_id << " info has changed";
|
||||
v->duration = new_video->duration;
|
||||
v->dimensions = new_video->dimensions;
|
||||
v->supports_streaming = new_video->supports_streaming;
|
||||
v->preload_prefix_size = new_video->preload_prefix_size;
|
||||
}
|
||||
if (v->file_name != new_video->file_name) {
|
||||
LOG(DEBUG) << "Video " << file_id << " file name has changed";
|
||||
@ -169,7 +171,7 @@ void VideosManager::merge_videos(FileId new_id, FileId old_id) {
|
||||
void VideosManager::create_video(FileId file_id, string minithumbnail, PhotoSize thumbnail,
|
||||
AnimationSize animated_thumbnail, bool has_stickers, vector<FileId> &&sticker_file_ids,
|
||||
string file_name, string mime_type, int32 duration, Dimensions dimensions,
|
||||
bool supports_streaming, bool replace) {
|
||||
bool supports_streaming, int32 preload_prefix_size, bool replace) {
|
||||
auto v = make_unique<Video>();
|
||||
v->file_id = file_id;
|
||||
v->file_name = std::move(file_name);
|
||||
@ -182,6 +184,7 @@ void VideosManager::create_video(FileId file_id, string minithumbnail, PhotoSize
|
||||
v->thumbnail = std::move(thumbnail);
|
||||
v->animated_thumbnail = std::move(animated_thumbnail);
|
||||
v->supports_streaming = supports_streaming;
|
||||
v->preload_prefix_size = preload_prefix_size;
|
||||
v->has_stickers = has_stickers;
|
||||
v->sticker_file_ids = std::move(sticker_file_ids);
|
||||
on_get_video(std::move(v), replace);
|
||||
|
@ -36,7 +36,8 @@ class VideosManager {
|
||||
|
||||
void create_video(FileId file_id, string minithumbnail, PhotoSize thumbnail, AnimationSize animated_thumbnail,
|
||||
bool has_stickers, vector<FileId> &&sticker_file_ids, string file_name, string mime_type,
|
||||
int32 duration, Dimensions dimensions, bool supports_streaming, bool replace);
|
||||
int32 duration, Dimensions dimensions, bool supports_streaming, int32 preload_prefix_size,
|
||||
bool replace);
|
||||
|
||||
tl_object_ptr<telegram_api::InputMedia> get_input_media(FileId file_id,
|
||||
tl_object_ptr<telegram_api::InputFile> input_file,
|
||||
@ -75,6 +76,7 @@ class VideosManager {
|
||||
string minithumbnail;
|
||||
PhotoSize thumbnail;
|
||||
AnimationSize animated_thumbnail;
|
||||
int32 preload_prefix_size = 0;
|
||||
|
||||
bool supports_streaming = false;
|
||||
|
||||
|
@ -22,10 +22,12 @@ void VideosManager::store_video(FileId file_id, StorerT &storer) const {
|
||||
const Video *video = get_video(file_id);
|
||||
CHECK(video != nullptr);
|
||||
bool has_animated_thumbnail = video->animated_thumbnail.file_id.is_valid();
|
||||
bool has_preload_prefix_size = video->preload_prefix_size != 0;
|
||||
BEGIN_STORE_FLAGS();
|
||||
STORE_FLAG(video->has_stickers);
|
||||
STORE_FLAG(video->supports_streaming);
|
||||
STORE_FLAG(has_animated_thumbnail);
|
||||
STORE_FLAG(has_preload_prefix_size);
|
||||
END_STORE_FLAGS();
|
||||
store(video->file_name, storer);
|
||||
store(video->mime_type, storer);
|
||||
@ -40,16 +42,21 @@ void VideosManager::store_video(FileId file_id, StorerT &storer) const {
|
||||
if (has_animated_thumbnail) {
|
||||
store(video->animated_thumbnail, storer);
|
||||
}
|
||||
if (has_preload_prefix_size) {
|
||||
store(video->preload_prefix_size, storer);
|
||||
}
|
||||
}
|
||||
|
||||
template <class ParserT>
|
||||
FileId VideosManager::parse_video(ParserT &parser) {
|
||||
auto video = make_unique<Video>();
|
||||
bool has_animated_thumbnail;
|
||||
bool has_preload_prefix_size;
|
||||
BEGIN_PARSE_FLAGS();
|
||||
PARSE_FLAG(video->has_stickers);
|
||||
PARSE_FLAG(video->supports_streaming);
|
||||
PARSE_FLAG(has_animated_thumbnail);
|
||||
PARSE_FLAG(has_preload_prefix_size);
|
||||
END_PARSE_FLAGS();
|
||||
parse(video->file_name, parser);
|
||||
parse(video->mime_type, parser);
|
||||
@ -66,6 +73,9 @@ FileId VideosManager::parse_video(ParserT &parser) {
|
||||
if (has_animated_thumbnail) {
|
||||
parse(video->animated_thumbnail, parser);
|
||||
}
|
||||
if (has_preload_prefix_size) {
|
||||
parse(video->preload_prefix_size, parser);
|
||||
}
|
||||
if (parser.get_error() != nullptr || !video->file_id.is_valid()) {
|
||||
return FileId();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user