2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Always use crl::time for media durations.

This commit is contained in:
John Preston
2023-07-31 18:59:01 +02:00
parent 39e8ed22a9
commit bda3bae712
10 changed files with 23 additions and 17 deletions

View File

@@ -525,7 +525,7 @@ FileLoadTask::FileLoadTask(
FileLoadTask::FileLoadTask(
not_null<Main::Session*> session,
const QByteArray &voice,
int32 duration,
crl::time duration,
const VoiceWaveform &waveform,
const FileLoadTo &to,
const TextWithTags &caption)
@@ -851,8 +851,9 @@ void FileLoadTask::process(Args &&args) {
if (auto song = std::get_if<Ui::PreparedFileInformation::Song>(
&_information->media)) {
isSong = true;
const auto seconds = song->duration / 1000;
auto flags = MTPDdocumentAttributeAudio::Flag::f_title | MTPDdocumentAttributeAudio::Flag::f_performer;
attributes.push_back(MTP_documentAttributeAudio(MTP_flags(flags), MTP_int(song->duration), MTP_string(song->title), MTP_string(song->performer), MTPstring()));
attributes.push_back(MTP_documentAttributeAudio(MTP_flags(flags), MTP_int(seconds), MTP_string(song->title), MTP_string(song->performer), MTPstring()));
thumbnail = PrepareFileThumbnail(std::move(song->cover));
} else if (auto video = std::get_if<Ui::PreparedFileInformation::Video>(
&_information->media)) {
@@ -866,9 +867,10 @@ void FileLoadTask::process(Args &&args) {
if (video->supportsStreaming) {
flags |= MTPDdocumentAttributeVideo::Flag::f_supports_streaming;
}
const auto realSeconds = video->duration / 1000.;
attributes.push_back(MTP_documentAttributeVideo(
MTP_flags(flags),
MTP_double(video->duration / 1000.),
MTP_double(realSeconds),
MTP_int(coverWidth),
MTP_int(coverHeight),
MTPint())); // preload_prefix_size
@@ -970,8 +972,9 @@ void FileLoadTask::process(Args &&args) {
}
if (isVoice) {
const auto seconds = _duration / 1000;
auto flags = MTPDdocumentAttributeAudio::Flag::f_voice | MTPDdocumentAttributeAudio::Flag::f_waveform;
attributes[0] = MTP_documentAttributeAudio(MTP_flags(flags), MTP_int(_duration), MTPstring(), MTPstring(), MTP_bytes(documentWaveformEncode5bit(_waveform)));
attributes[0] = MTP_documentAttributeAudio(MTP_flags(flags), MTP_int(seconds), MTPstring(), MTPstring(), MTP_bytes(documentWaveformEncode5bit(_waveform)));
attributes.resize(1);
document = MTP_document(
MTP_flags(0),