From e05ae5bbbb8acd9304f0034386c223a5080746a2 Mon Sep 17 00:00:00 2001 From: Sebastian Jansson Date: Tue, 30 Jul 2019 18:12:54 +0200 Subject: [PATCH] Adds non-forwarding frame tap to video frame matcher. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Bug: webrtc:10839 Change-Id: I9cf348435db6edf7b2e81f262ffb6cb9b87cb98f Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/147273 Commit-Queue: Sebastian Jansson Reviewed-by: Erik Språng Cr-Commit-Position: refs/heads/master@{#28723} --- test/scenario/video_frame_matcher.cc | 10 ++++++++++ test/scenario/video_frame_matcher.h | 15 +++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/test/scenario/video_frame_matcher.cc b/test/scenario/video_frame_matcher.cc index a1faa81d4c..912459183f 100644 --- a/test/scenario/video_frame_matcher.cc +++ b/test/scenario/video_frame_matcher.cc @@ -128,6 +128,16 @@ void VideoFrameMatcher::Finalize() { } } +CapturedFrameTap::CapturedFrameTap(Clock* clock, VideoFrameMatcher* matcher) + : clock_(clock), matcher_(matcher) {} + +void CapturedFrameTap::OnFrame(const VideoFrame& frame) { + matcher_->OnCapturedFrame(frame, clock_->CurrentTime()); +} +void CapturedFrameTap::OnDiscardedFrame() { + discarded_count_++; +} + ForwardingCapturedFrameTap::ForwardingCapturedFrameTap( Clock* clock, VideoFrameMatcher* matcher, diff --git a/test/scenario/video_frame_matcher.h b/test/scenario/video_frame_matcher.h index d27ed8f4b8..20a0ccca8b 100644 --- a/test/scenario/video_frame_matcher.h +++ b/test/scenario/video_frame_matcher.h @@ -76,6 +76,21 @@ class VideoFrameMatcher { TaskQueueForTest task_queue_; }; +class CapturedFrameTap : public rtc::VideoSinkInterface { + public: + CapturedFrameTap(Clock* clock, VideoFrameMatcher* matcher); + CapturedFrameTap(CapturedFrameTap&) = delete; + CapturedFrameTap& operator=(CapturedFrameTap&) = delete; + + void OnFrame(const VideoFrame& frame) override; + void OnDiscardedFrame() override; + + private: + Clock* const clock_; + VideoFrameMatcher* const matcher_; + int discarded_count_ = 0; +}; + class ForwardingCapturedFrameTap : public rtc::VideoSinkInterface, public rtc::VideoSourceInterface {