blob: d1a2ddb1c2931124ad3c67a95b79f3a3f214d494 [file] [log] [blame]
Artem Titov33f9d2b2019-12-05 15:59:00 +01001/*
2 * Copyright (c) 2019 The WebRTC project authors. All Rights Reserved.
3 *
4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree.
9 */
10#include "test/frame_forwarder.h"
11
12#include "rtc_base/checks.h"
13
14namespace webrtc {
15namespace test {
16
17FrameForwarder::FrameForwarder() : sink_(nullptr) {}
18FrameForwarder::~FrameForwarder() {}
19
20void FrameForwarder::IncomingCapturedFrame(const VideoFrame& video_frame) {
21 rtc::CritScope lock(&crit_);
22 if (sink_)
23 sink_->OnFrame(video_frame);
24}
25
26void FrameForwarder::AddOrUpdateSink(rtc::VideoSinkInterface<VideoFrame>* sink,
27 const rtc::VideoSinkWants& wants) {
28 rtc::CritScope lock(&crit_);
29 RTC_DCHECK(!sink_ || sink_ == sink);
30 sink_ = sink;
31 sink_wants_ = wants;
32}
33
34void FrameForwarder::RemoveSink(rtc::VideoSinkInterface<VideoFrame>* sink) {
35 rtc::CritScope lock(&crit_);
36 RTC_DCHECK_EQ(sink, sink_);
37 sink_ = nullptr;
38}
39
40rtc::VideoSinkWants FrameForwarder::sink_wants() const {
41 rtc::CritScope lock(&crit_);
42 return sink_wants_;
43}
44
45bool FrameForwarder::has_sinks() const {
46 rtc::CritScope lock(&crit_);
47 return sink_ != nullptr;
48}
49
50} // namespace test
51} // namespace webrtc