tdesktop/Telegram/SourceFiles/media/streaming/media_streaming_common.h

133 lines
2.4 KiB
C
Raw Normal View History

/*
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 {
constexpr auto kTimeUnknown = std::numeric_limits<crl::time>::min();
2019-02-21 16:01:55 +00:00
namespace Audio {
bool SupportsSpeedControl();
} // namespace Audio
2019-02-21 11:15:44 +00:00
namespace Streaming {
2019-02-21 16:01:55 +00:00
inline bool SupportsSpeedControl() {
return Media::Audio::SupportsSpeedControl();
}
class VideoTrack;
class AudioTrack;
enum class Mode {
Both,
Audio,
Video,
Inspection,
};
struct PlaybackOptions {
Mode mode = Mode::Both;
crl::time position = 0;
float64 speed = 1.; // Valid values between 0.5 and 2.
2019-02-28 21:03:25 +00:00
AudioMsgId audioId;
bool syncVideoByAudio = true;
2019-02-27 11:36:19 +00:00
bool dropStaleFrames = true;
bool loop = false;
};
struct TrackState {
crl::time position = kTimeUnknown;
crl::time receivedTill = kTimeUnknown;
crl::time duration = kTimeUnknown;
};
struct VideoInformation {
TrackState state;
QSize size;
QImage cover;
int rotation = 0;
};
struct AudioInformation {
TrackState state;
};
struct Information {
VideoInformation video;
AudioInformation audio;
};
template <typename Track>
struct PreloadedUpdate {
crl::time till = kTimeUnknown;
};
template <typename Track>
struct PlaybackUpdate {
crl::time position = kTimeUnknown;
};
using PreloadedVideo = PreloadedUpdate<VideoTrack>;
using UpdateVideo = PlaybackUpdate<VideoTrack>;
using PreloadedAudio = PreloadedUpdate<AudioTrack>;
using UpdateAudio = PlaybackUpdate<AudioTrack>;
struct WaitingForData {
2019-03-01 11:16:55 +00:00
bool waiting = false;
};
struct MutedByOther {
};
2019-02-22 11:58:26 +00:00
struct Finished {
};
struct Update {
base::variant<
Information,
PreloadedVideo,
UpdateVideo,
PreloadedAudio,
UpdateAudio,
WaitingForData,
2019-02-22 11:58:26 +00:00
MutedByOther,
Finished> data;
};
2019-03-05 13:56:27 +00:00
enum class Error {
OpenFailed,
LoadFailed,
InvalidData,
NotStreamable,
};
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);
}
};
} // namespace Streaming
} // namespace Media