Add storyVideo.is_animation.

This commit is contained in:
levlam 2023-06-23 16:06:02 +03:00
parent fca432eb43
commit c34b4c3ef7
8 changed files with 25 additions and 13 deletions

View File

@ -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<int32> = 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<int32> duration:double = InputStoryContent;
//@is_animation True, if the video has no sound
inputStoryContentVideo video:InputFile added_sticker_file_ids:vector<int32> duration:double is_animation:Bool = InputStoryContent;
//@description Contains information about interactions with a story

View File

@ -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<FileId>(), 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),

View File

@ -2138,7 +2138,7 @@ static Result<InputMessageContent> 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<MessageVideo>(file_id, std::move(caption), input_video->has_spoiler_ && !is_secret);
break;

View File

@ -170,7 +170,7 @@ Result<unique_ptr<StoryContent>> 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<int32>(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<StoryContentVideo>(file_id, FileId());
}

View File

@ -64,8 +64,8 @@ td_api::object_ptr<td_api::storyVideo> VideosManager::get_story_video_object(Fil
: get_thumbnail_object(td_->file_manager_.get(), video->thumbnail, PhotoFormat::Jpeg);
return td_api::make_object<td_api::storyVideo>(
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<Video> new_video, bool replace) {
@ -83,12 +83,13 @@ FileId VideosManager::on_get_video(unique_ptr<Video> new_video, bool replace) {
}
if (v->duration != new_video->duration || v->precise_duration != new_video->precise_duration ||
v->dimensions != new_video->dimensions || v->supports_streaming != new_video->supports_streaming ||
v->preload_prefix_size != new_video->preload_prefix_size) {
v->is_animation != new_video->is_animation || v->preload_prefix_size != new_video->preload_prefix_size) {
LOG(DEBUG) << "Video " << file_id << " info has changed";
v->duration = new_video->duration;
v->precise_duration = new_video->precise_duration;
v->dimensions = new_video->dimensions;
v->supports_streaming = new_video->supports_streaming;
v->is_animation = new_video->is_animation;
v->preload_prefix_size = new_video->preload_prefix_size;
}
if (v->file_name != new_video->file_name) {
@ -188,8 +189,8 @@ 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, double precise_duration,
Dimensions dimensions, bool supports_streaming, int32 preload_prefix_size,
bool replace) {
Dimensions dimensions, bool supports_streaming, bool is_animation,
int32 preload_prefix_size, bool replace) {
auto v = make_unique<Video>();
v->file_id = file_id;
v->file_name = std::move(file_name);
@ -203,6 +204,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->is_animation = is_animation;
v->preload_prefix_size = preload_prefix_size;
v->has_stickers = has_stickers;
v->sticker_file_ids = std::move(sticker_file_ids);
@ -283,6 +285,9 @@ tl_object_ptr<telegram_api::InputMedia> VideosManager::get_input_media(
if (video->supports_streaming) {
attribute_flags |= telegram_api::documentAttributeVideo::SUPPORTS_STREAMING_MASK;
}
if (video->is_animation) {
attribute_flags |= telegram_api::documentAttributeVideo::NOSOUND_MASK;
}
vector<tl_object_ptr<telegram_api::DocumentAttribute>> attributes;
attributes.push_back(make_tl_object<telegram_api::documentAttributeVideo>(

View File

@ -39,7 +39,7 @@ 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, double precise_duration, Dimensions dimensions, bool supports_streaming,
int32 preload_prefix_size, bool replace);
bool is_animation, 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,
@ -82,6 +82,7 @@ class VideosManager {
int32 preload_prefix_size = 0;
bool supports_streaming = false;
bool is_animation = false;
bool has_stickers = false;
vector<FileId> sticker_file_ids;

View File

@ -30,6 +30,7 @@ void VideosManager::store_video(FileId file_id, StorerT &storer) const {
STORE_FLAG(has_animated_thumbnail);
STORE_FLAG(has_preload_prefix_size);
STORE_FLAG(has_precise_duration);
STORE_FLAG(video->is_animation);
END_STORE_FLAGS();
store(video->file_name, storer);
store(video->mime_type, storer);
@ -64,6 +65,7 @@ FileId VideosManager::parse_video(ParserT &parser) {
PARSE_FLAG(has_animated_thumbnail);
PARSE_FLAG(has_preload_prefix_size);
PARSE_FLAG(has_precise_duration);
PARSE_FLAG(video->is_animation);
END_PARSE_FLAGS();
parse(video->file_name, parser);
parse(video->mime_type, parser);

View File

@ -3994,7 +3994,7 @@ class CliClient final : public Actor {
get_args(args, video, caption, rules, active_period, duration, sticker_file_ids);
send_request(td_api::make_object<td_api::sendStory>(
td_api::make_object<td_api::inputStoryContentVideo>(as_input_file(video),
to_integers<int32>(sticker_file_ids), duration),
to_integers<int32>(sticker_file_ids), duration, true),
as_caption(caption), rules, active_period ? active_period : 86400, op == "ssvp"));
} else if (op == "esc") {
StoryId story_id;
@ -4022,7 +4022,7 @@ class CliClient final : public Actor {
send_request(td_api::make_object<td_api::editStory>(
story_id,
td_api::make_object<td_api::inputStoryContentVideo>(as_input_file(video),
to_integers<int32>(sticker_file_ids), duration),
to_integers<int32>(sticker_file_ids), duration, false),
as_caption(caption)));
} else if (op == "sspr") {
StoryId story_id;