| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2012 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 |
| 11 // FakePeriodicVideoCapturer implements a fake cricket::VideoCapturer that | 11 // FakePeriodicVideoCapturer implements a fake cricket::VideoCapturer that |
| 12 // creates video frames periodically after it has been started. | 12 // creates video frames periodically after it has been started. |
| 13 | 13 |
| 14 #ifndef WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_ | 14 #ifndef WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_ |
| 15 #define WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_ | 15 #define WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_ |
| 16 | 16 |
| 17 #include "webrtc/base/thread.h" | 17 #include "webrtc/base/thread.h" |
| 18 #include "webrtc/media/base/fakevideocapturer.h" | 18 #include "webrtc/media/base/fakevideocapturer.h" |
| 19 | 19 |
| 20 namespace webrtc { | 20 namespace webrtc { |
| 21 | 21 |
| 22 class FakePeriodicVideoCapturer : public cricket::FakeVideoCapturer { | 22 class FakePeriodicVideoCapturer : public cricket::FakeVideoCapturer, |
| 23 public rtc::MessageHandler { |
| 23 public: | 24 public: |
| 24 FakePeriodicVideoCapturer() { | 25 FakePeriodicVideoCapturer() { |
| 25 std::vector<cricket::VideoFormat> formats; | 26 std::vector<cricket::VideoFormat> formats; |
| 26 formats.push_back(cricket::VideoFormat(1280, 720, | 27 formats.push_back(cricket::VideoFormat(1280, 720, |
| 27 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 28 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
| 28 formats.push_back(cricket::VideoFormat(640, 480, | 29 formats.push_back(cricket::VideoFormat(640, 480, |
| 29 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 30 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
| 30 formats.push_back(cricket::VideoFormat(640, 360, | 31 formats.push_back(cricket::VideoFormat(640, 360, |
| 31 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); | 32 cricket::VideoFormat::FpsToInterval(30), cricket::FOURCC_I420)); |
| 32 formats.push_back(cricket::VideoFormat(320, 240, | 33 formats.push_back(cricket::VideoFormat(320, 240, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 48 } | 49 } |
| 49 // Inherited from MesageHandler. | 50 // Inherited from MesageHandler. |
| 50 virtual void OnMessage(rtc::Message* msg) { | 51 virtual void OnMessage(rtc::Message* msg) { |
| 51 if (msg->message_id == MSG_CREATEFRAME) { | 52 if (msg->message_id == MSG_CREATEFRAME) { |
| 52 if (IsRunning()) { | 53 if (IsRunning()) { |
| 53 CaptureFrame(); | 54 CaptureFrame(); |
| 54 rtc::Thread::Current()->PostDelayed(static_cast<int>( | 55 rtc::Thread::Current()->PostDelayed(static_cast<int>( |
| 55 GetCaptureFormat()->interval / rtc::kNumNanosecsPerMillisec), | 56 GetCaptureFormat()->interval / rtc::kNumNanosecsPerMillisec), |
| 56 this, MSG_CREATEFRAME); | 57 this, MSG_CREATEFRAME); |
| 57 } | 58 } |
| 58 } else { | |
| 59 FakeVideoCapturer::OnMessage(msg); | |
| 60 } | 59 } |
| 61 } | 60 } |
| 62 | 61 |
| 63 private: | 62 private: |
| 64 enum { | 63 enum { |
| 65 // Offset 0xFF to make sure this don't collide with base class messages. | 64 // Offset 0xFF to make sure this don't collide with base class messages. |
| 66 MSG_CREATEFRAME = 0xFF | 65 MSG_CREATEFRAME = 0xFF |
| 67 }; | 66 }; |
| 68 }; | 67 }; |
| 69 | 68 |
| 70 } // namespace webrtc | 69 } // namespace webrtc |
| 71 | 70 |
| 72 #endif // WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_ | 71 #endif // WEBRTC_API_TEST_FAKEPERIODICVIDEOCAPTURER_H_ |
| OLD | NEW |