diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp b/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp
index 5c39f2f65..743e6e221 100644
--- a/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp
+++ b/Telegram/SourceFiles/media/streaming/media_streaming_video_track.cpp
@@ -52,6 +52,8 @@ public:
const FrameRequest &request);
void removeFrameRequest(const Instance *instance);
+ void rasterizeFrame(not_null frame);
+
private:
enum class FrameResult {
Done,
@@ -354,36 +356,37 @@ QSize VideoTrackObject::chooseOriginalResize() const {
return chosen;
}
+void VideoTrackObject::rasterizeFrame(not_null frame) {
+ Expects(frame->position != kFinishedPosition);
+
+ fillRequests(frame);
+ frame->alpha = (frame->decoded->format == AV_PIX_FMT_BGRA);
+ frame->original = ConvertFrame(
+ _stream,
+ frame->decoded.get(),
+ chooseOriginalResize(),
+ std::move(frame->original));
+ if (frame->original.isNull()) {
+ frame->prepared.clear();
+ fail(Error::InvalidData);
+ return;
+ }
+
+ VideoTrack::PrepareFrameByRequests(frame, _stream.rotation);
+
+ Ensures(VideoTrack::IsRasterized(frame));
+}
+
void VideoTrackObject::presentFrameIfNeeded() {
if (_pausedTime != kTimeUnknown || _resumedTime == kTimeUnknown) {
return;
}
- const auto rasterize = [&](not_null frame) {
- Expects(frame->position != kFinishedPosition);
-
- fillRequests(frame);
- frame->alpha = (frame->decoded->format == AV_PIX_FMT_BGRA);
- frame->original = ConvertFrame(
- _stream,
- frame->decoded.get(),
- chooseOriginalResize(),
- std::move(frame->original));
- if (frame->original.isNull()) {
- frame->prepared.clear();
- fail(Error::InvalidData);
- return;
- }
-
- VideoTrack::PrepareFrameByRequests(frame, _stream.rotation);
-
- Ensures(VideoTrack::IsRasterized(frame));
- };
const auto dropStaleFrames = !_options.waitForMarkAsShown;
const auto presented = _shared->presentFrame(
+ this,
trackTime(),
_options.speed,
- dropStaleFrames,
- rasterize);
+ dropStaleFrames);
addTimelineDelay(presented.addedWorldTimeDelay);
if (presented.displayPosition == kFinishedPosition) {
interrupt();
@@ -693,12 +696,11 @@ bool VideoTrack::Shared::firstPresentHappened() const {
Unexpected("Counter value in VideoTrack::Shared::firstPresentHappened.");
}
-template
auto VideoTrack::Shared::presentFrame(
+ not_null object,
TimePoint time,
float64 playbackSpeed,
- bool dropStaleFrames,
- RasterizeCallback &&rasterize)
+ bool dropStaleFrames)
-> PresentFrame {
const auto present = [&](int counter, int index) -> PresentFrame {
const auto frame = getFrame(index);
@@ -707,7 +709,7 @@ auto VideoTrack::Shared::presentFrame(
if (position == kFinishedPosition) {
return { kFinishedPosition, kTimeUnknown, addedWorldTimeDelay };
}
- rasterize(frame);
+ object->rasterizeFrame(frame);
if (!IsRasterized(frame)) {
// Error happened during frame prepare.
return { kTimeUnknown, kTimeUnknown, addedWorldTimeDelay };
diff --git a/Telegram/SourceFiles/media/streaming/media_streaming_video_track.h b/Telegram/SourceFiles/media/streaming/media_streaming_video_track.h
index e92ddc566..a6525ac1c 100644
--- a/Telegram/SourceFiles/media/streaming/media_streaming_video_track.h
+++ b/Telegram/SourceFiles/media/streaming/media_streaming_video_track.h
@@ -108,13 +108,11 @@ private:
crl::time trackTime,
bool dropStaleFrames);
- // RasterizeCallback(not_null).
- template
[[nodiscard]] PresentFrame presentFrame(
+ not_null object,
TimePoint trackTime,
float64 playbackSpeed,
- bool dropStaleFrames,
- RasterizeCallback &&rasterize);
+ bool dropStaleFrames);
[[nodiscard]] bool firstPresentHappened() const;
// Called from the main thread.