| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 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 #include "webrtc/video/video_capture_input.h" | 10 #include "webrtc/video/video_capture_input.h" |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 WaitOutputFrame(); | 132 WaitOutputFrame(); |
| 133 | 133 |
| 134 EXPECT_EQ(output_frames_[0]->video_frame_buffer().get(), | 134 EXPECT_EQ(output_frames_[0]->video_frame_buffer().get(), |
| 135 frame.video_frame_buffer().get()); | 135 frame.video_frame_buffer().get()); |
| 136 output_frames_.clear(); | 136 output_frames_.clear(); |
| 137 frame.Reset(); | 137 frame.Reset(); |
| 138 EXPECT_EQ(kEventSignaled, frame_destroyed_event->Wait(FRAME_TIMEOUT_MS)); | 138 EXPECT_EQ(kEventSignaled, frame_destroyed_event->Wait(FRAME_TIMEOUT_MS)); |
| 139 } | 139 } |
| 140 | 140 |
| 141 TEST_F(VideoCaptureInputTest, TestNtpTimeStampSetIfRenderTimeSet) { | 141 TEST_F(VideoCaptureInputTest, TestNtpTimeStampSetIfRenderTimeSet) { |
| 142 input_frames_.push_back(CreateVideoFrame(static_cast<uint8_t>(0))); | 142 input_frames_.push_back(CreateVideoFrame(0)); |
| 143 input_frames_[0]->set_render_time_ms(5); | 143 input_frames_[0]->set_render_time_ms(5); |
| 144 input_frames_[0]->set_ntp_time_ms(0); | 144 input_frames_[0]->set_ntp_time_ms(0); |
| 145 | 145 |
| 146 AddInputFrame(input_frames_[0]); | 146 AddInputFrame(input_frames_[0]); |
| 147 WaitOutputFrame(); | 147 WaitOutputFrame(); |
| 148 EXPECT_GT(output_frames_[0]->ntp_time_ms(), | 148 EXPECT_GT(output_frames_[0]->ntp_time_ms(), |
| 149 input_frames_[0]->render_time_ms()); | 149 input_frames_[0]->render_time_ms()); |
| 150 } | 150 } |
| 151 | 151 |
| 152 TEST_F(VideoCaptureInputTest, TestRtpTimeStampSet) { | 152 TEST_F(VideoCaptureInputTest, TestRtpTimeStampSet) { |
| 153 input_frames_.push_back(CreateVideoFrame(static_cast<uint8_t>(0))); | 153 input_frames_.push_back(CreateVideoFrame(0)); |
| 154 input_frames_[0]->set_render_time_ms(0); | 154 input_frames_[0]->set_render_time_ms(0); |
| 155 input_frames_[0]->set_ntp_time_ms(1); | 155 input_frames_[0]->set_ntp_time_ms(1); |
| 156 input_frames_[0]->set_timestamp(0); | 156 input_frames_[0]->set_timestamp(0); |
| 157 | 157 |
| 158 AddInputFrame(input_frames_[0]); | 158 AddInputFrame(input_frames_[0]); |
| 159 WaitOutputFrame(); | 159 WaitOutputFrame(); |
| 160 EXPECT_EQ(output_frames_[0]->timestamp(), | 160 EXPECT_EQ(output_frames_[0]->timestamp(), |
| 161 input_frames_[0]->ntp_time_ms() * 90); | 161 input_frames_[0]->ntp_time_ms() * 90); |
| 162 } | 162 } |
| 163 | 163 |
| 164 TEST_F(VideoCaptureInputTest, DropsFramesWithSameOrOldNtpTimestamp) { |
| 165 input_frames_.push_back(CreateVideoFrame(0)); |
| 166 |
| 167 input_frames_[0]->set_ntp_time_ms(17); |
| 168 AddInputFrame(input_frames_[0]); |
| 169 WaitOutputFrame(); |
| 170 EXPECT_EQ(output_frames_[0]->timestamp(), |
| 171 input_frames_[0]->ntp_time_ms() * 90); |
| 172 |
| 173 // Repeat frame with the same NTP timestamp should drop. |
| 174 AddInputFrame(input_frames_[0]); |
| 175 EXPECT_EQ(kEventTimeout, output_frame_event_->Wait(FRAME_TIMEOUT_MS)); |
| 176 |
| 177 // As should frames with a decreased NTP timestamp. |
| 178 input_frames_[0]->set_ntp_time_ms(input_frames_[0]->ntp_time_ms() - 1); |
| 179 AddInputFrame(input_frames_[0]); |
| 180 EXPECT_EQ(kEventTimeout, output_frame_event_->Wait(FRAME_TIMEOUT_MS)); |
| 181 |
| 182 // But delivering with an increased NTP timestamp should succeed. |
| 183 input_frames_[0]->set_ntp_time_ms(4711); |
| 184 AddInputFrame(input_frames_[0]); |
| 185 WaitOutputFrame(); |
| 186 EXPECT_EQ(output_frames_[1]->timestamp(), |
| 187 input_frames_[0]->ntp_time_ms() * 90); |
| 188 } |
| 189 |
| 164 TEST_F(VideoCaptureInputTest, TestTextureFrames) { | 190 TEST_F(VideoCaptureInputTest, TestTextureFrames) { |
| 165 const int kNumFrame = 3; | 191 const int kNumFrame = 3; |
| 166 for (int i = 0 ; i < kNumFrame; ++i) { | 192 for (int i = 0 ; i < kNumFrame; ++i) { |
| 167 test::FakeNativeHandle* dummy_handle = new test::FakeNativeHandle(); | 193 test::FakeNativeHandle* dummy_handle = new test::FakeNativeHandle(); |
| 168 // Add one to |i| so that width/height > 0. | 194 // Add one to |i| so that width/height > 0. |
| 169 input_frames_.push_back(new VideoFrame(test::CreateFakeNativeHandleFrame( | 195 input_frames_.push_back(new VideoFrame(test::CreateFakeNativeHandleFrame( |
| 170 dummy_handle, i + 1, i + 1, i + 1, i + 1, webrtc::kVideoRotation_0))); | 196 dummy_handle, i + 1, i + 1, i + 1, i + 1, webrtc::kVideoRotation_0))); |
| 171 AddInputFrame(input_frames_[i]); | 197 AddInputFrame(input_frames_[i]); |
| 172 WaitOutputFrame(); | 198 WaitOutputFrame(); |
| 173 EXPECT_EQ(dummy_handle, output_frames_[i]->native_handle()); | 199 EXPECT_EQ(dummy_handle, output_frames_[i]->native_handle()); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 const int kSizeY = width * height * 2; | 297 const int kSizeY = width * height * 2; |
| 272 uint8_t buffer[kSizeY]; | 298 uint8_t buffer[kSizeY]; |
| 273 memset(buffer, data, kSizeY); | 299 memset(buffer, data, kSizeY); |
| 274 frame->CreateFrame(buffer, buffer, buffer, width, height, width, width / 2, | 300 frame->CreateFrame(buffer, buffer, buffer, width, height, width, width / 2, |
| 275 width / 2); | 301 width / 2); |
| 276 frame->set_render_time_ms(data); | 302 frame->set_render_time_ms(data); |
| 277 return frame; | 303 return frame; |
| 278 } | 304 } |
| 279 | 305 |
| 280 } // namespace webrtc | 306 } // namespace webrtc |
| OLD | NEW |