| 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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 bool CaptureFrame() { | 59 bool CaptureFrame() { |
| 60 if (!GetCaptureFormat()) { | 60 if (!GetCaptureFormat()) { |
| 61 return false; | 61 return false; |
| 62 } | 62 } |
| 63 return CaptureCustomFrame(GetCaptureFormat()->width, | 63 return CaptureCustomFrame(GetCaptureFormat()->width, |
| 64 GetCaptureFormat()->height, | 64 GetCaptureFormat()->height, |
| 65 GetCaptureFormat()->interval, | 65 GetCaptureFormat()->interval, |
| 66 GetCaptureFormat()->fourcc); | 66 GetCaptureFormat()->fourcc); |
| 67 } | 67 } |
| 68 bool CaptureCustomFrame(int width, int height, uint32_t fourcc) { | 68 bool CaptureCustomFrame(int width, int height, uint32_t fourcc) { |
| 69 // Default to 30fps. | 69 // default to 30fps |
| 70 return CaptureCustomFrame(width, height, rtc::kNumNanosecsPerSec / 30, | 70 return CaptureCustomFrame(width, height, 33333333, fourcc); |
| 71 fourcc); | |
| 72 } | 71 } |
| 73 bool CaptureCustomFrame(int width, | 72 bool CaptureCustomFrame(int width, |
| 74 int height, | 73 int height, |
| 75 int64_t timestamp_interval, | 74 int64_t timestamp_interval, |
| 76 uint32_t fourcc) { | 75 uint32_t fourcc) { |
| 77 if (!running_) { | 76 if (!running_) { |
| 78 return false; | 77 return false; |
| 79 } | 78 } |
| 80 RTC_CHECK(fourcc == FOURCC_I420); | 79 RTC_CHECK(fourcc == FOURCC_I420); |
| 81 RTC_CHECK(width > 0); | 80 RTC_CHECK(width > 0); |
| 82 RTC_CHECK(height > 0); | 81 RTC_CHECK(height > 0); |
| 83 | 82 |
| 84 int adapted_width; | 83 int adapted_width; |
| 85 int adapted_height; | 84 int adapted_height; |
| 86 int crop_width; | 85 int crop_width; |
| 87 int crop_height; | 86 int crop_height; |
| 88 int crop_x; | 87 int crop_x; |
| 89 int crop_y; | 88 int crop_y; |
| 90 | 89 |
| 91 // TODO(nisse): It's a bit silly to have this logic in a fake | 90 // TODO(nisse): It's a bit silly to have this logic in a fake |
| 92 // class. Child classes of VideoCapturer are expected to call | 91 // class. Child classes of VideoCapturer are expected to call |
| 93 // AdaptFrame, and the test case | 92 // AdaptFrame, and the test case |
| 94 // VideoCapturerTest.SinkWantsMaxPixelAndMaxPixelCountStepUp | 93 // VideoCapturerTest.SinkWantsMaxPixelAndMaxPixelCountStepUp |
| 95 // depends on this. | 94 // depends on this. |
| 96 if (AdaptFrame(width, height, | 95 if (AdaptFrame(width, height, 0, 0, &adapted_width, &adapted_height, |
| 97 next_timestamp_ / rtc::kNumNanosecsPerMicrosec, | 96 &crop_width, &crop_height, &crop_x, &crop_y, nullptr)) { |
| 98 next_timestamp_ / rtc::kNumNanosecsPerMicrosec, | |
| 99 &adapted_width, &adapted_height, &crop_width, &crop_height, | |
| 100 &crop_x, &crop_y, nullptr)) { | |
| 101 rtc::scoped_refptr<webrtc::I420Buffer> buffer( | 97 rtc::scoped_refptr<webrtc::I420Buffer> buffer( |
| 102 webrtc::I420Buffer::Create(adapted_width, adapted_height)); | 98 webrtc::I420Buffer::Create(adapted_width, adapted_height)); |
| 103 buffer->InitializeData(); | 99 buffer->InitializeData(); |
| 104 | 100 |
| 105 OnFrame(webrtc::VideoFrame( | 101 OnFrame(webrtc::VideoFrame( |
| 106 buffer, rotation_, | 102 buffer, rotation_, |
| 107 next_timestamp_ / rtc::kNumNanosecsPerMicrosec), | 103 next_timestamp_ / rtc::kNumNanosecsPerMicrosec), |
| 108 width, height); | 104 width, height); |
| 109 } | 105 } |
| 110 next_timestamp_ += timestamp_interval; | 106 next_timestamp_ += timestamp_interval; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 bool running_; | 139 bool running_; |
| 144 int64_t initial_timestamp_; | 140 int64_t initial_timestamp_; |
| 145 int64_t next_timestamp_; | 141 int64_t next_timestamp_; |
| 146 const bool is_screencast_; | 142 const bool is_screencast_; |
| 147 webrtc::VideoRotation rotation_; | 143 webrtc::VideoRotation rotation_; |
| 148 }; | 144 }; |
| 149 | 145 |
| 150 } // namespace cricket | 146 } // namespace cricket |
| 151 | 147 |
| 152 #endif // WEBRTC_MEDIA_BASE_FAKEVIDEOCAPTURER_H_ | 148 #endif // WEBRTC_MEDIA_BASE_FAKEVIDEOCAPTURER_H_ |
| OLD | NEW |