2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-30 22:25:12 +00:00

Update API scheme on layer 160: Duration.

This commit is contained in:
John Preston
2023-06-05 16:50:43 +04:00
parent b71d72ca7c
commit aba84a6010
23 changed files with 88 additions and 87 deletions

View File

@@ -326,6 +326,7 @@ Main::Session &DocumentData::session() const {
void DocumentData::setattributes(
const QVector<MTPDocumentAttribute> &attributes) {
_duration = -1;
_flags &= ~(Flag::ImageType
| Flag::HasAttachedStickers
| Flag::UseTextColor
@@ -389,12 +390,12 @@ void DocumentData::setattributes(
: VideoDocument;
if (data.is_round_message()) {
_additional = std::make_unique<RoundData>();
round()->duration = data.vduration().v;
}
} else if (const auto info = sticker()) {
info->type = StickerType::Webm;
}
_duration = data.vduration().v;
_duration = crl::time(
base::SafeRound(data.vduration().v * 1000));
setMaybeSupportsStreaming(data.is_supports_streaming());
dimensions = QSize(data.vw().v, data.vh().v);
}, [&](const MTPDdocumentAttributeAudio &data) {
@@ -408,14 +409,14 @@ void DocumentData::setattributes(
}
}
if (const auto voiceData = voice() ? voice() : round()) {
voiceData->duration = data.vduration().v;
_duration = data.vduration().v * crl::time(1000);
voiceData->waveform = documentWaveformDecode(
data.vwaveform().value_or_empty());
voiceData->wavemax = voiceData->waveform.empty()
? uchar(0)
: *ranges::max_element(voiceData->waveform);
} else if (const auto songData = song()) {
songData->duration = data.vduration().v;
_duration = data.vduration().v * crl::time(1000);
songData->title = qs(data.vtitle().value_or_empty());
songData->performer = qs(data.vperformer().value_or_empty());
refreshPossibleCoverThumbnail();
@@ -1516,19 +1517,12 @@ bool DocumentData::isVideoFile() const {
return (type == VideoDocument);
}
TimeId DocumentData::getDuration() const {
if (const auto song = this->song()) {
return std::max(song->duration, 0);
} else if (const auto voice = this->voice()) {
return std::max(voice->duration, 0);
} else if (isAnimation() || isVideoFile()) {
return std::max(_duration, 0);
} else if (const auto sticker = this->sticker()) {
if (sticker->isWebm()) {
return std::max(_duration, 0);
}
}
return -1;
crl::time DocumentData::duration() const {
return std::max(_duration, crl::time());
}
bool DocumentData::hasDuration() const {
return _duration >= 0;
}
bool DocumentData::isImage() const {