diff --git a/webrtc/webrtc_video_track.cpp b/webrtc/webrtc_video_track.cpp
index 84bdee8..344bcde 100644
--- a/webrtc/webrtc_video_track.cpp
+++ b/webrtc/webrtc_video_track.cpp
@@ -171,11 +171,17 @@ class VideoTrack::Sink final
using PrepareFrame = not_null;
using PrepareState = bool;
+ struct FrameWithIndex {
+ not_null frame;
+ int index = -1;
+ };
+
[[nodiscard]] bool firstPresentHappened() const;
// Called from the main thread.
void markFrameShown();
[[nodiscard]] not_null frameForPaint();
+ [[nodiscard]] FrameWithIndex frameForPaintWithIndex();
[[nodiscard]] rpl::producer<> renderNextFrameOnMain() const;
void destroyFrameForPaint();
@@ -352,7 +358,12 @@ bool VideoTrack::Sink::firstPresentHappened() const {
}
not_null VideoTrack::Sink::frameForPaint() {
- return getFrame(counter() / 2);
+ return frameForPaintWithIndex().frame;
+}
+
+VideoTrack::Sink::FrameWithIndex VideoTrack::Sink::frameForPaintWithIndex() {
+ const auto index = counter() / 2;
+ return { .frame = getFrame(index), .index = index };
}
void VideoTrack::Sink::destroyFrameForPaint() {
@@ -445,14 +456,18 @@ QImage VideoTrack::frame(const FrameRequest &request) {
return frame->prepared;
}
-std::pair VideoTrack::frameOriginalWithRotation() const {
+FrameWithInfo VideoTrack::frameWithInfo() const {
if (_disabledFrom > 0
&& (_disabledFrom + kDropFramesWhileInactive > crl::now())) {
_sink->destroyFrameForPaint();
return {};
}
- const auto frame = _sink->frameForPaint();
- return { frame->original, frame->rotation };
+ const auto data = _sink->frameForPaintWithIndex();
+ return {
+ .original = data.frame->original,
+ .rotation = data.frame->rotation,
+ .index = data.index,
+ };
}
QSize VideoTrack::frameSize() const {
diff --git a/webrtc/webrtc_video_track.h b/webrtc/webrtc_video_track.h
index c403b04..2b07987 100644
--- a/webrtc/webrtc_video_track.h
+++ b/webrtc/webrtc_video_track.h
@@ -63,6 +63,12 @@ enum class VideoState {
Active,
};
+struct FrameWithInfo {
+ QImage original;
+ int rotation = 0;
+ int index = -1;
+};
+
class VideoTrack final {
public:
// Called from the main thread.
@@ -71,7 +77,7 @@ class VideoTrack final {
void markFrameShown();
[[nodiscard]] QImage frame(const FrameRequest &request);
- [[nodiscard]] std::pair frameOriginalWithRotation() const;
+ [[nodiscard]] FrameWithInfo frameWithInfo() const;
[[nodiscard]] QSize frameSize() const;
[[nodiscard]] rpl::producer<> renderNextFrame() const;
[[nodiscard]] std::shared_ptr sink();