// // Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2021 // // 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/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) { } int32 VideosManager::get_video_duration(FileId file_id) const { auto it = videos_.find(file_id); if (it == videos_.end() || it->second == nullptr) { return 0; } return it->second->duration; } tl_object_ptr VideosManager::get_video_object(FileId file_id) { if (!file_id.is_valid()) { return nullptr; } auto &video = videos_[file_id]; if (video == nullptr) { return nullptr; } video->is_changed = false; 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