2019-02-13 21:10:18 +03:00
|
|
|
/*
|
|
|
|
This file is part of Telegram Desktop,
|
|
|
|
the official desktop application for the Telegram messaging service.
|
|
|
|
|
|
|
|
For license and copyright information please follow this link:
|
|
|
|
https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
namespace Media {
|
|
|
|
|
2019-02-17 15:08:29 +04:00
|
|
|
constexpr auto kTimeUnknown = std::numeric_limits<crl::time>::min();
|
2019-02-17 10:54:57 +04:00
|
|
|
|
2019-02-21 20:01:55 +04:00
|
|
|
namespace Audio {
|
|
|
|
bool SupportsSpeedControl();
|
|
|
|
} // namespace Audio
|
|
|
|
|
2019-02-21 15:15:44 +04:00
|
|
|
namespace Streaming {
|
|
|
|
|
2019-02-21 20:01:55 +04:00
|
|
|
inline bool SupportsSpeedControl() {
|
|
|
|
return Media::Audio::SupportsSpeedControl();
|
|
|
|
}
|
|
|
|
|
2019-02-20 17:28:48 +04:00
|
|
|
class VideoTrack;
|
|
|
|
class AudioTrack;
|
|
|
|
|
2019-02-13 21:10:18 +03:00
|
|
|
enum class Mode {
|
|
|
|
Both,
|
|
|
|
Audio,
|
|
|
|
Video,
|
2019-02-17 10:54:57 +04:00
|
|
|
Inspection,
|
2019-02-13 21:10:18 +03:00
|
|
|
};
|
|
|
|
|
2019-02-21 13:17:25 +04:00
|
|
|
struct PlaybackOptions {
|
|
|
|
Mode mode = Mode::Both;
|
|
|
|
crl::time position = 0;
|
|
|
|
float64 speed = 1.; // Valid values between 0.5 and 2.
|
2019-02-21 17:40:09 +04:00
|
|
|
bool syncVideoByAudio = true;
|
2019-02-21 13:17:25 +04:00
|
|
|
};
|
|
|
|
|
2019-02-17 15:08:29 +04:00
|
|
|
struct TrackState {
|
|
|
|
crl::time position = kTimeUnknown;
|
|
|
|
crl::time receivedTill = kTimeUnknown;
|
2019-02-20 17:28:48 +04:00
|
|
|
crl::time duration = kTimeUnknown;
|
2019-02-17 15:08:29 +04:00
|
|
|
};
|
|
|
|
|
2019-02-20 17:28:48 +04:00
|
|
|
struct VideoInformation {
|
|
|
|
TrackState state;
|
|
|
|
QSize size;
|
|
|
|
QImage cover;
|
|
|
|
int rotation = 0;
|
2019-02-17 15:08:29 +04:00
|
|
|
};
|
|
|
|
|
2019-02-20 17:28:48 +04:00
|
|
|
struct AudioInformation {
|
|
|
|
TrackState state;
|
|
|
|
};
|
2019-02-13 21:10:18 +03:00
|
|
|
|
2019-02-20 17:28:48 +04:00
|
|
|
struct Information {
|
|
|
|
VideoInformation video;
|
|
|
|
AudioInformation audio;
|
2019-02-13 21:10:18 +03:00
|
|
|
};
|
|
|
|
|
2019-02-20 17:28:48 +04:00
|
|
|
template <typename Track>
|
|
|
|
struct PreloadedUpdate {
|
|
|
|
crl::time till = kTimeUnknown;
|
2019-02-17 15:08:29 +04:00
|
|
|
};
|
|
|
|
|
2019-02-20 17:28:48 +04:00
|
|
|
template <typename Track>
|
|
|
|
struct PlaybackUpdate {
|
|
|
|
crl::time position = kTimeUnknown;
|
2019-02-13 21:10:18 +03:00
|
|
|
};
|
|
|
|
|
2019-02-20 17:28:48 +04:00
|
|
|
using PreloadedVideo = PreloadedUpdate<VideoTrack>;
|
|
|
|
using UpdateVideo = PlaybackUpdate<VideoTrack>;
|
|
|
|
using PreloadedAudio = PreloadedUpdate<AudioTrack>;
|
|
|
|
using UpdateAudio = PlaybackUpdate<AudioTrack>;
|
|
|
|
|
2019-02-17 10:54:57 +04:00
|
|
|
struct WaitingForData {
|
2019-02-13 21:10:18 +03:00
|
|
|
};
|
|
|
|
|
2019-02-17 10:54:57 +04:00
|
|
|
struct MutedByOther {
|
2019-02-13 21:10:18 +03:00
|
|
|
};
|
2019-02-16 14:29:55 +04:00
|
|
|
|
2019-02-22 15:58:26 +04:00
|
|
|
struct Finished {
|
|
|
|
};
|
|
|
|
|
2019-02-17 10:54:57 +04:00
|
|
|
struct Update {
|
|
|
|
base::variant<
|
|
|
|
Information,
|
2019-02-20 17:28:48 +04:00
|
|
|
PreloadedVideo,
|
2019-02-17 15:08:29 +04:00
|
|
|
UpdateVideo,
|
2019-02-20 17:28:48 +04:00
|
|
|
PreloadedAudio,
|
2019-02-17 15:08:29 +04:00
|
|
|
UpdateAudio,
|
2019-02-17 10:54:57 +04:00
|
|
|
WaitingForData,
|
2019-02-22 15:58:26 +04:00
|
|
|
MutedByOther,
|
|
|
|
Finished> data;
|
2019-02-16 14:29:55 +04:00
|
|
|
};
|
|
|
|
|
2019-02-17 10:54:57 +04:00
|
|
|
struct Error {
|
2019-02-13 21:10:18 +03:00
|
|
|
};
|
|
|
|
|
2019-02-17 15:08:29 +04:00
|
|
|
struct FrameRequest {
|
|
|
|
QSize resize;
|
|
|
|
QSize outer;
|
|
|
|
ImageRoundRadius radius = ImageRoundRadius();
|
|
|
|
RectParts corners = RectPart::AllCorners;
|
|
|
|
|
|
|
|
bool empty() const {
|
|
|
|
return resize.isEmpty();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool operator==(const FrameRequest &other) const {
|
|
|
|
return (resize == other.resize)
|
|
|
|
&& (outer == other.outer)
|
|
|
|
&& (radius == other.radius)
|
|
|
|
&& (corners == other.corners);
|
|
|
|
}
|
|
|
|
bool operator!=(const FrameRequest &other) const {
|
|
|
|
return !(*this == other);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2019-02-13 21:10:18 +03:00
|
|
|
} // namespace Streaming
|
|
|
|
} // namespace Media
|