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 11 matching lines...) Loading... |
22 #include "webrtc/media/base/videoframe.h" | 22 #include "webrtc/media/base/videoframe.h" |
23 #ifdef HAVE_WEBRTC_VIDEO | 23 #ifdef HAVE_WEBRTC_VIDEO |
24 #include "webrtc/media/engine/webrtcvideoframefactory.h" | 24 #include "webrtc/media/engine/webrtcvideoframefactory.h" |
25 #endif | 25 #endif |
26 | 26 |
27 namespace cricket { | 27 namespace cricket { |
28 | 28 |
29 // Fake video capturer that allows the test to manually pump in frames. | 29 // Fake video capturer that allows the test to manually pump in frames. |
30 class FakeVideoCapturer : public cricket::VideoCapturer { | 30 class FakeVideoCapturer : public cricket::VideoCapturer { |
31 public: | 31 public: |
32 FakeVideoCapturer() | 32 FakeVideoCapturer(bool is_screencast) |
33 : running_(false), | 33 : running_(false), |
34 initial_unix_timestamp_(time(NULL) * rtc::kNumNanosecsPerSec), | 34 initial_unix_timestamp_(time(NULL) * rtc::kNumNanosecsPerSec), |
35 next_timestamp_(rtc::kNumNanosecsPerMillisec), | 35 next_timestamp_(rtc::kNumNanosecsPerMillisec), |
36 is_screencast_(false), | 36 is_screencast_(is_screencast), |
37 rotation_(webrtc::kVideoRotation_0) { | 37 rotation_(webrtc::kVideoRotation_0) { |
38 #ifdef HAVE_WEBRTC_VIDEO | 38 #ifdef HAVE_WEBRTC_VIDEO |
39 set_frame_factory(new cricket::WebRtcVideoFrameFactory()); | 39 set_frame_factory(new cricket::WebRtcVideoFrameFactory()); |
40 #endif | 40 #endif |
41 // Default supported formats. Use ResetSupportedFormats to over write. | 41 // Default supported formats. Use ResetSupportedFormats to over write. |
42 std::vector<cricket::VideoFormat> formats; | 42 std::vector<cricket::VideoFormat> formats; |
43 formats.push_back(cricket::VideoFormat(1280, 720, | 43 formats.push_back(cricket::VideoFormat(1280, 720, |
44 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 44 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
45 formats.push_back(cricket::VideoFormat(640, 480, | 45 formats.push_back(cricket::VideoFormat(640, 480, |
46 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 46 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
47 formats.push_back(cricket::VideoFormat(320, 240, | 47 formats.push_back(cricket::VideoFormat(320, 240, |
48 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 48 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
49 formats.push_back(cricket::VideoFormat(160, 120, | 49 formats.push_back(cricket::VideoFormat(160, 120, |
50 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 50 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
51 formats.push_back(cricket::VideoFormat(1280, 720, | 51 formats.push_back(cricket::VideoFormat(1280, 720, |
52 cricket::VideoFormat::FpsToInterval(60), cricket::FOURCC_I420)); | 52 cricket::VideoFormat::FpsToInterval(60), cricket::FOURCC_I420)); |
53 ResetSupportedFormats(formats); | 53 ResetSupportedFormats(formats); |
54 } | 54 } |
| 55 FakeVideoCapturer() : FakeVideoCapturer(false) {} |
| 56 |
55 ~FakeVideoCapturer() { | 57 ~FakeVideoCapturer() { |
56 SignalDestroyed(this); | 58 SignalDestroyed(this); |
57 } | 59 } |
58 | 60 |
59 void ResetSupportedFormats(const std::vector<cricket::VideoFormat>& formats) { | 61 void ResetSupportedFormats(const std::vector<cricket::VideoFormat>& formats) { |
60 SetSupportedFormats(formats); | 62 SetSupportedFormats(formats); |
61 } | 63 } |
62 bool CaptureFrame() { | 64 bool CaptureFrame() { |
63 if (!GetCaptureFormat()) { | 65 if (!GetCaptureFormat()) { |
64 return false; | 66 return false; |
(...skipping 64 matching lines...) Loading... |
129 running_ = true; | 131 running_ = true; |
130 SetCaptureState(cricket::CS_RUNNING); | 132 SetCaptureState(cricket::CS_RUNNING); |
131 return cricket::CS_RUNNING; | 133 return cricket::CS_RUNNING; |
132 } | 134 } |
133 virtual void Stop() { | 135 virtual void Stop() { |
134 running_ = false; | 136 running_ = false; |
135 SetCaptureFormat(NULL); | 137 SetCaptureFormat(NULL); |
136 SetCaptureState(cricket::CS_STOPPED); | 138 SetCaptureState(cricket::CS_STOPPED); |
137 } | 139 } |
138 virtual bool IsRunning() { return running_; } | 140 virtual bool IsRunning() { return running_; } |
139 void SetScreencast(bool is_screencast) { | |
140 is_screencast_ = is_screencast; | |
141 } | |
142 virtual bool IsScreencast() const { return is_screencast_; } | 141 virtual bool IsScreencast() const { return is_screencast_; } |
143 bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) { | 142 bool GetPreferredFourccs(std::vector<uint32_t>* fourccs) { |
144 fourccs->push_back(cricket::FOURCC_I420); | 143 fourccs->push_back(cricket::FOURCC_I420); |
145 fourccs->push_back(cricket::FOURCC_MJPG); | 144 fourccs->push_back(cricket::FOURCC_MJPG); |
146 return true; | 145 return true; |
147 } | 146 } |
148 | 147 |
149 void SetRotation(webrtc::VideoRotation rotation) { | 148 void SetRotation(webrtc::VideoRotation rotation) { |
150 rotation_ = rotation; | 149 rotation_ = rotation; |
151 } | 150 } |
152 | 151 |
153 webrtc::VideoRotation GetRotation() { return rotation_; } | 152 webrtc::VideoRotation GetRotation() { return rotation_; } |
154 | 153 |
155 private: | 154 private: |
156 bool running_; | 155 bool running_; |
157 int64_t initial_unix_timestamp_; | 156 int64_t initial_unix_timestamp_; |
158 int64_t next_timestamp_; | 157 int64_t next_timestamp_; |
159 bool is_screencast_; | 158 const bool is_screencast_; |
160 webrtc::VideoRotation rotation_; | 159 webrtc::VideoRotation rotation_; |
161 }; | 160 }; |
162 | 161 |
163 } // namespace cricket | 162 } // namespace cricket |
164 | 163 |
165 #endif // WEBRTC_MEDIA_BASE_FAKEVIDEOCAPTURER_H_ | 164 #endif // WEBRTC_MEDIA_BASE_FAKEVIDEOCAPTURER_H_ |
OLD | NEW |