blob: d6562313c5bef686e62fd2bd619bcbee0de0bff9 [file] [log] [blame]
nisseaf510af2016-03-21 15:20:421/*
2 * Copyright 2016 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
Steve Anton10542f22019-01-11 17:11:0011#ifndef PC_TEST_FAKE_VIDEO_TRACK_SOURCE_H_
12#define PC_TEST_FAKE_VIDEO_TRACK_SOURCE_H_
nisseaf510af2016-03-21 15:20:4213
Steve Anton10542f22019-01-11 17:11:0014#include "api/media_stream_interface.h"
Niels Möller3eaf9f12019-01-17 15:31:3615#include "media/base/video_broadcaster.h"
Steve Anton10542f22019-01-11 17:11:0016#include "pc/video_track_source.h"
nisseaf510af2016-03-21 15:20:4217
18namespace webrtc {
19
Niels Möller3eaf9f12019-01-17 15:31:3620// A minimal implementation of VideoTrackSource. Includes a VideoBroadcaster for
21// injection of frames.
nisseaf510af2016-03-21 15:20:4222class FakeVideoTrackSource : public VideoTrackSource {
23 public:
pbos5214a0a2016-12-16 23:39:1124 static rtc::scoped_refptr<FakeVideoTrackSource> Create(bool is_screencast) {
25 return new rtc::RefCountedObject<FakeVideoTrackSource>(is_screencast);
26 }
27
nisseaf510af2016-03-21 15:20:4228 static rtc::scoped_refptr<FakeVideoTrackSource> Create() {
pbos5214a0a2016-12-16 23:39:1129 return Create(false);
nisseaf510af2016-03-21 15:20:4230 }
31
pbos5214a0a2016-12-16 23:39:1132 bool is_screencast() const override { return is_screencast_; }
Niels Möller3eaf9f12019-01-17 15:31:3633
34 void InjectFrame(const VideoFrame& frame) {
35 video_broadcaster_.OnFrame(frame);
36 }
pbos5214a0a2016-12-16 23:39:1137
nisseaf510af2016-03-21 15:20:4238 protected:
pbos5214a0a2016-12-16 23:39:1139 explicit FakeVideoTrackSource(bool is_screencast)
Niels Möller5d67f822018-05-23 14:28:1740 : VideoTrackSource(false /* remote */), is_screencast_(is_screencast) {}
41 ~FakeVideoTrackSource() override = default;
42
Niels Möller3eaf9f12019-01-17 15:31:3643 rtc::VideoSourceInterface<VideoFrame>* source() override {
44 return &video_broadcaster_;
45 }
nisseaf510af2016-03-21 15:20:4246
47 private:
pbos5214a0a2016-12-16 23:39:1148 const bool is_screencast_;
Niels Möller3eaf9f12019-01-17 15:31:3649 rtc::VideoBroadcaster video_broadcaster_;
nisseaf510af2016-03-21 15:20:4250};
51
52} // namespace webrtc
53
Steve Anton10542f22019-01-11 17:11:0054#endif // PC_TEST_FAKE_VIDEO_TRACK_SOURCE_H_