• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
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 
11 #ifndef PC_TEST_FAKE_VIDEO_TRACK_SOURCE_H_
12 #define PC_TEST_FAKE_VIDEO_TRACK_SOURCE_H_
13 
14 #include "api/media_stream_interface.h"
15 #include "media/base/video_broadcaster.h"
16 #include "pc/video_track_source.h"
17 
18 namespace webrtc {
19 
20 // A minimal implementation of VideoTrackSource. Includes a VideoBroadcaster for
21 // injection of frames.
22 class FakeVideoTrackSource : public VideoTrackSource {
23  public:
Create(bool is_screencast)24   static rtc::scoped_refptr<FakeVideoTrackSource> Create(bool is_screencast) {
25     return new rtc::RefCountedObject<FakeVideoTrackSource>(is_screencast);
26   }
27 
Create()28   static rtc::scoped_refptr<FakeVideoTrackSource> Create() {
29     return Create(false);
30   }
31 
is_screencast()32   bool is_screencast() const override { return is_screencast_; }
33 
InjectFrame(const VideoFrame & frame)34   void InjectFrame(const VideoFrame& frame) {
35     video_broadcaster_.OnFrame(frame);
36   }
37 
38  protected:
FakeVideoTrackSource(bool is_screencast)39   explicit FakeVideoTrackSource(bool is_screencast)
40       : VideoTrackSource(false /* remote */), is_screencast_(is_screencast) {}
41   ~FakeVideoTrackSource() override = default;
42 
source()43   rtc::VideoSourceInterface<VideoFrame>* source() override {
44     return &video_broadcaster_;
45   }
46 
47  private:
48   const bool is_screencast_;
49   rtc::VideoBroadcaster video_broadcaster_;
50 };
51 
52 }  // namespace webrtc
53 
54 #endif  // PC_TEST_FAKE_VIDEO_TRACK_SOURCE_H_
55