// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024 // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // #include "td/telegram/VideosManager.h" #include "td/telegram/AuthManager.h" #include "td/telegram/files/FileManager.h" #include "td/telegram/Global.h" #include "td/telegram/PhotoFormat.h" #include "td/telegram/secret_api.h" #include "td/telegram/Td.h" #include "td/telegram/td_api.h" #include "td/telegram/telegram_api.h" #include "td/actor/actor.h" #include "td/utils/logging.h" #include "td/utils/misc.h" #include "td/utils/Status.h" #include namespace td { VideosManager::VideosManager(Td *td) : td_(td) { } VideosManager::~VideosManager() { Scheduler::instance()->destroy_on_scheduler(G()->get_gc_scheduler_id(), videos_); } int32 VideosManager::get_video_duration(FileId file_id) const { auto video = get_video(file_id); CHECK(video != nullptr); return video->duration; } td_api::object_ptr VideosManager::get_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->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, video->is_animation, get_minithumbnail_object(video->minithumbnail), std::move(thumbnail), video->preload_prefix_size, video->start_ts, td_->file_manager_->get_file_object(file_id)); } FileId VideosManager::on_get_video(unique_ptr