2016-03-21 08:20:42 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright 2016 The WebRTC project authors. All Rights Reserved.
|
|
|
|
|
*
|
|
|
|
|
* Use of this source code is governed by a BSD-style license
|
|
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
|
|
|
|
* in the file PATENTS. All contributing project authors may
|
|
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
|
|
|
|
*/
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#ifndef PC_TEST_FAKE_VIDEO_TRACK_SOURCE_H_
|
|
|
|
|
#define PC_TEST_FAKE_VIDEO_TRACK_SOURCE_H_
|
2016-03-21 08:20:42 -07:00
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "api/media_stream_interface.h"
|
2019-01-17 16:31:36 +01:00
|
|
|
#include "media/base/video_broadcaster.h"
|
2019-01-11 09:11:00 -08:00
|
|
|
#include "pc/video_track_source.h"
|
2016-03-21 08:20:42 -07:00
|
|
|
|
|
|
|
|
namespace webrtc {
|
|
|
|
|
|
2019-01-17 16:31:36 +01:00
|
|
|
// A minimal implementation of VideoTrackSource. Includes a VideoBroadcaster for
|
|
|
|
|
// injection of frames.
|
2016-03-21 08:20:42 -07:00
|
|
|
class FakeVideoTrackSource : public VideoTrackSource {
|
|
|
|
|
public:
|
2016-12-16 15:39:11 -08:00
|
|
|
static rtc::scoped_refptr<FakeVideoTrackSource> Create(bool is_screencast) {
|
2021-04-27 14:43:08 +02:00
|
|
|
return rtc::make_ref_counted<FakeVideoTrackSource>(is_screencast);
|
2016-12-16 15:39:11 -08:00
|
|
|
}
|
|
|
|
|
|
2016-03-21 08:20:42 -07:00
|
|
|
static rtc::scoped_refptr<FakeVideoTrackSource> Create() {
|
2016-12-16 15:39:11 -08:00
|
|
|
return Create(false);
|
2016-03-21 08:20:42 -07:00
|
|
|
}
|
|
|
|
|
|
2016-12-16 15:39:11 -08:00
|
|
|
bool is_screencast() const override { return is_screencast_; }
|
2019-01-17 16:31:36 +01:00
|
|
|
|
|
|
|
|
void InjectFrame(const VideoFrame& frame) {
|
|
|
|
|
video_broadcaster_.OnFrame(frame);
|
|
|
|
|
}
|
2016-12-16 15:39:11 -08:00
|
|
|
|
2016-03-21 08:20:42 -07:00
|
|
|
protected:
|
2016-12-16 15:39:11 -08:00
|
|
|
explicit FakeVideoTrackSource(bool is_screencast)
|
2018-05-23 16:28:17 +02:00
|
|
|
: VideoTrackSource(false /* remote */), is_screencast_(is_screencast) {}
|
|
|
|
|
~FakeVideoTrackSource() override = default;
|
2016-03-21 08:20:42 -07:00
|
|
|
|
2019-01-17 16:31:36 +01:00
|
|
|
rtc::VideoSourceInterface<VideoFrame>* source() override {
|
|
|
|
|
return &video_broadcaster_;
|
|
|
|
|
}
|
2018-02-08 09:44:42 +01:00
|
|
|
|
2018-05-23 16:28:17 +02:00
|
|
|
private:
|
2016-12-16 15:39:11 -08:00
|
|
|
const bool is_screencast_;
|
2019-01-17 16:31:36 +01:00
|
|
|
rtc::VideoBroadcaster video_broadcaster_;
|
2016-03-21 08:20:42 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
} // namespace webrtc
|
|
|
|
|
|
2019-01-11 09:11:00 -08:00
|
|
|
#endif // PC_TEST_FAKE_VIDEO_TRACK_SOURCE_H_
|