// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2022 // // 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/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/telegram/ConfigShared.h" #include "td/utils/logging.h" #include "td/utils/misc.h" #include "td/utils/Status.h" 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 it = videos_.find(file_id); CHECK(it != videos_.end()); return it->second->duration; } tl_object_ptr VideosManager::get_video_object(FileId file_id) const { if (!file_id.is_valid()) { return nullptr; } auto it = videos_.find(file_id); CHECK(it != videos_.end()); auto video = it->second.get(); 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 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)); } FileId VideosManager::on_get_video(unique_ptr