mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 07:07:08 +02:00
Always use crl::time for media durations.
This commit is contained in:
parent
39e8ed22a9
commit
bda3bae712
10 changed files with 23 additions and 17 deletions
Telegram/SourceFiles
|
@ -3417,7 +3417,7 @@ void ApiWrap::sendSharedContact(
|
|||
void ApiWrap::sendVoiceMessage(
|
||||
QByteArray result,
|
||||
VoiceWaveform waveform,
|
||||
int duration,
|
||||
crl::time duration,
|
||||
const SendAction &action) {
|
||||
const auto caption = TextWithTags();
|
||||
const auto to = fileLoadTaskOptions(action);
|
||||
|
|
|
@ -302,7 +302,7 @@ public:
|
|||
void sendVoiceMessage(
|
||||
QByteArray result,
|
||||
VoiceWaveform waveform,
|
||||
int duration,
|
||||
crl::time duration,
|
||||
const SendAction &action);
|
||||
void sendFiles(
|
||||
Ui::PreparedList &&list,
|
||||
|
|
|
@ -25,7 +25,7 @@ struct MessageToEdit {
|
|||
struct VoiceToSend {
|
||||
QByteArray bytes;
|
||||
VoiceWaveform waveform;
|
||||
int duration = 0;
|
||||
crl::time duration = 0;
|
||||
Api::SendOptions options;
|
||||
};
|
||||
struct SendActionUpdate {
|
||||
|
|
|
@ -72,8 +72,8 @@ enum class FilterType {
|
|||
return std::clamp(float64(low) / high, 0., 1.);
|
||||
}
|
||||
|
||||
[[nodiscard]] auto Duration(int samples) {
|
||||
return samples / ::Media::Player::kDefaultFrequency;
|
||||
[[nodiscard]] crl::time Duration(int samples) {
|
||||
return samples * crl::time(1000) / ::Media::Player::kDefaultFrequency;
|
||||
}
|
||||
|
||||
[[nodiscard]] auto FormatVoiceDuration(int samples) {
|
||||
|
|
|
@ -607,7 +607,7 @@ void ScheduledWidget::send(Api::SendOptions options) {
|
|||
void ScheduledWidget::sendVoice(
|
||||
QByteArray bytes,
|
||||
VoiceWaveform waveform,
|
||||
int duration) {
|
||||
crl::time duration) {
|
||||
const auto callback = [=](Api::SendOptions options) {
|
||||
sendVoice(bytes, waveform, duration, options);
|
||||
};
|
||||
|
@ -617,7 +617,7 @@ void ScheduledWidget::sendVoice(
|
|||
void ScheduledWidget::sendVoice(
|
||||
QByteArray bytes,
|
||||
VoiceWaveform waveform,
|
||||
int duration,
|
||||
crl::time duration,
|
||||
Api::SendOptions options) {
|
||||
session().api().sendVoiceMessage(
|
||||
bytes,
|
||||
|
|
|
@ -197,11 +197,14 @@ private:
|
|||
Api::SendOptions options) const;
|
||||
void send();
|
||||
void send(Api::SendOptions options);
|
||||
void sendVoice(QByteArray bytes, VoiceWaveform waveform, int duration);
|
||||
void sendVoice(
|
||||
QByteArray bytes,
|
||||
VoiceWaveform waveform,
|
||||
int duration,
|
||||
crl::time duration);
|
||||
void sendVoice(
|
||||
QByteArray bytes,
|
||||
VoiceWaveform waveform,
|
||||
crl::time duration,
|
||||
Api::SendOptions options);
|
||||
void edit(
|
||||
not_null<HistoryItem*> item,
|
||||
|
|
|
@ -1560,7 +1560,7 @@ Ui::PreparedFileInformation PrepareForSending(
|
|||
FFMpegAttributesReader reader(Core::FileLocation(fname), data);
|
||||
const auto positionMs = crl::time(0);
|
||||
if (reader.open(positionMs) && reader.duration() > 0) {
|
||||
result.duration = reader.duration() / 1000;
|
||||
result.duration = reader.duration();
|
||||
result.title = reader.title();
|
||||
result.performer = reader.performer();
|
||||
result.cover = reader.cover();
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -256,7 +256,7 @@ public:
|
|||
FileLoadTask(
|
||||
not_null<Main::Session*> session,
|
||||
const QByteArray &voice,
|
||||
int32 duration,
|
||||
crl::time duration,
|
||||
const VoiceWaveform &waveform,
|
||||
const FileLoadTo &to,
|
||||
const TextWithTags &caption);
|
||||
|
@ -306,7 +306,7 @@ private:
|
|||
QString _filepath;
|
||||
QByteArray _content;
|
||||
std::unique_ptr<Ui::PreparedFileInformation> _information;
|
||||
int32 _duration = 0;
|
||||
crl::time _duration = 0;
|
||||
VoiceWaveform _waveform;
|
||||
SendMediaType _type;
|
||||
TextWithTags _caption;
|
||||
|
|
|
@ -27,7 +27,7 @@ struct PreparedFileInformation {
|
|||
Editor::PhotoModifications modifications;
|
||||
};
|
||||
struct Song {
|
||||
int duration = -1;
|
||||
crl::time duration = -1;
|
||||
QString title;
|
||||
QString performer;
|
||||
QImage cover;
|
||||
|
|
Loading…
Add table
Reference in a new issue