// // 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/AudiosManager.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/utils/logging.h" #include "td/utils/misc.h" #include "td/utils/SliceBuilder.h" #include "td/utils/Status.h" namespace td { AudiosManager::AudiosManager(Td *td) : td_(td) { } int32 AudiosManager::get_audio_duration(FileId file_id) const { auto it = audios_.find(file_id); if (it == audios_.end() || it->second == nullptr) { return 0; } return it->second->duration; } tl_object_ptr AudiosManager::get_audio_object(FileId file_id) { if (!file_id.is_valid()) { return nullptr; } auto &audio = audios_[file_id]; if (audio == nullptr) { return nullptr; } audio->is_changed = false; return make_tl_object( audio->duration, audio->title, audio->performer, audio->file_name, audio->mime_type, get_minithumbnail_object(audio->minithumbnail), get_thumbnail_object(td_->file_manager_.get(), audio->thumbnail, PhotoFormat::Jpeg), td_->file_manager_->get_file_object(file_id)); } FileId AudiosManager::on_get_audio(unique_ptr