OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2004 The WebRTC project authors. All Rights Reserved. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license | 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 | 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 | 6 * tree. An additional intellectual property rights grant can be found |
7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
9 */ | 9 */ |
10 | 10 |
(...skipping 10 matching lines...) Expand all Loading... |
21 #include "webrtc/media/base/videoframe.h" | 21 #include "webrtc/media/base/videoframe.h" |
22 #ifdef HAVE_WEBRTC_VIDEO | 22 #ifdef HAVE_WEBRTC_VIDEO |
23 #include "webrtc/media/engine/webrtcvideoframefactory.h" | 23 #include "webrtc/media/engine/webrtcvideoframefactory.h" |
24 #endif | 24 #endif |
25 | 25 |
26 namespace cricket { | 26 namespace cricket { |
27 | 27 |
28 // Fake video capturer that allows the test to manually pump in frames. | 28 // Fake video capturer that allows the test to manually pump in frames. |
29 class FakeVideoCapturer : public cricket::VideoCapturer { | 29 class FakeVideoCapturer : public cricket::VideoCapturer { |
30 public: | 30 public: |
31 FakeVideoCapturer() | 31 FakeVideoCapturer(bool is_screencast) |
32 : running_(false), | 32 : running_(false), |
33 initial_unix_timestamp_(time(NULL) * rtc::kNumNanosecsPerSec), | 33 initial_unix_timestamp_(time(NULL) * rtc::kNumNanosecsPerSec), |
34 next_timestamp_(rtc::kNumNanosecsPerMillisec), | 34 next_timestamp_(rtc::kNumNanosecsPerMillisec), |
35 is_screencast_(false), | 35 is_screencast_(is_screencast), |
36 rotation_(webrtc::kVideoRotation_0) { | 36 rotation_(webrtc::kVideoRotation_0) { |
37 #ifdef HAVE_WEBRTC_VIDEO | 37 #ifdef HAVE_WEBRTC_VIDEO |
38 set_frame_factory(new cricket::WebRtcVideoFrameFactory()); | 38 set_frame_factory(new cricket::WebRtcVideoFrameFactory()); |
39 #endif | 39 #endif |
40 // Default supported formats. Use ResetSupportedFormats to over write. | 40 // Default supported formats. Use ResetSupportedFormats to over write. |
41 std::vector<cricket::VideoFormat> formats; | 41 std::vector<cricket::VideoFormat> formats; |
42 formats.push_back(cricket::VideoFormat(1280, 720, | 42 formats.push_back(cricket::VideoFormat(1280, 720, |
43 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 43 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
44 formats.push_back(cricket::VideoFormat(640, 480, | 44 formats.push_back(cricket::VideoFormat(640, 480, |
45 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 45 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
46 formats.push_back(cricket::VideoFormat(320, 240, | 46 formats.push_back(cricket::VideoFormat(320, 240, |
47 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 47 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
48 formats.push_back(cricket::VideoFormat(160, 120, | 48 formats.push_back(cricket::VideoFormat(160, 120, |
49 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 49 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
50 formats.push_back(cricket::VideoFormat(1280, 720, | 50 formats.push_back(cricket::VideoFormat(1280, 720, |
51 cricket::VideoFormat::FpsToInterval(60), cricket::FOURCC_I420)); | 51 cricket::VideoFormat::FpsToInterval(60), cricket::FOURCC_I420)); |
52 ResetSupportedFormats(formats); | 52 ResetSupportedFormats(formats); |
53 } | 53 } |
| 54 FakeVideoCapturer() |
| 55 : FakeVideoCapturer(false) {} |
| 56 |
54 ~FakeVideoCapturer() { | 57 ~FakeVideoCapturer() { |
55 SignalDestroyed(this); | 58 SignalDestroyed(this); |
56 } | 59 } |
57 | 60 |
58 void ResetSupportedFormats(const std::vector<cricket::VideoFormat>& formats) { | 61 void ResetSupportedFormats(const std::vector<cricket::VideoFormat>& formats) { |
59 SetSupportedFormats(formats); | 62 SetSupportedFormats(formats); |
60 } | 63 } |
61 bool CaptureFrame() { | 64 bool CaptureFrame() { |
62 if (!GetCaptureFormat()) { | 65 if (!GetCaptureFormat()) { |
63 return false; | 66 return false; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 running_ = true; | 131 running_ = true; |
129 SetCaptureState(cricket::CS_RUNNING); | 132 SetCaptureState(cricket::CS_RUNNING); |
130 return cricket::CS_RUNNING; | 133 return cricket::CS_RUNNING; |
131 } | 134 } |
132 virtual void Stop() { | 135 virtual void Stop() { |
133 running_ = false; | 136 running_ = false; |
134 SetCaptureFormat(NULL); | 137 SetCaptureFormat(NULL); |
135 SetCaptureState(cricket::CS_STOPPED); | 138 SetCaptureState(cricket::CS_STOPPED); |
136 } | 139 } |
137 virtual bool IsRunning() { return running_; } | 140 virtual bool IsRunning() { return running_; } |
138 void SetScreencast(bool is_screencast) { | |
139 is_screencast_ = is_screencast; | |
140 } | |
141 virtual bool IsScreencast() const { return is_screencast_; } | 141 virtual bool IsScreencast() const { return is_screencast_; } |
142 bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) { | 142 bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) { |
143 fourccs->push_back(cricket::FOURCC_I420); | 143 fourccs->push_back(cricket::FOURCC_I420); |
144 fourccs->push_back(cricket::FOURCC_MJPG); | 144 fourccs->push_back(cricket::FOURCC_MJPG); |
145 return true; | 145 return true; |
146 } | 146 } |
147 | 147 |
148 void SetRotation(webrtc::VideoRotation rotation) { | 148 void SetRotation(webrtc::VideoRotation rotation) { |
149 rotation_ = rotation; | 149 rotation_ = rotation; |
150 } | 150 } |
151 | 151 |
152 webrtc::VideoRotation GetRotation() { return rotation_; } | 152 webrtc::VideoRotation GetRotation() { return rotation_; } |
153 | 153 |
154 private: | 154 private: |
155 bool running_; | 155 bool running_; |
156 int64_t initial_unix_timestamp_; | 156 int64_t initial_unix_timestamp_; |
157 int64_t next_timestamp_; | 157 int64_t next_timestamp_; |
158 bool is_screencast_; | 158 const bool is_screencast_; |
159 webrtc::VideoRotation rotation_; | 159 webrtc::VideoRotation rotation_; |
160 }; | 160 }; |
161 | 161 |
162 } // namespace cricket | 162 } // namespace cricket |
163 | 163 |
164 #endif // WEBRTC_MEDIA_BASE_FAKEVIDEOCAPTURER_H_ | 164 #endif // WEBRTC_MEDIA_BASE_FAKEVIDEOCAPTURER_H_ |
OLD | NEW |