Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(221)

Side by Side Diff: webrtc/video/video_capture_input_unittest.cc

Issue 1569853002: Measure encoding time on encode callbacks. (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: remove unused variable Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 30 matching lines...) Expand all
41 bool EqualFrames(const VideoFrame& frame1, const VideoFrame& frame2); 41 bool EqualFrames(const VideoFrame& frame1, const VideoFrame& frame2);
42 bool EqualTextureFrames(const VideoFrame& frame1, const VideoFrame& frame2); 42 bool EqualTextureFrames(const VideoFrame& frame1, const VideoFrame& frame2);
43 bool EqualBufferFrames(const VideoFrame& frame1, const VideoFrame& frame2); 43 bool EqualBufferFrames(const VideoFrame& frame1, const VideoFrame& frame2);
44 bool EqualFramesVector(const ScopedVector<VideoFrame>& frames1, 44 bool EqualFramesVector(const ScopedVector<VideoFrame>& frames1,
45 const ScopedVector<VideoFrame>& frames2); 45 const ScopedVector<VideoFrame>& frames2);
46 VideoFrame* CreateVideoFrame(uint8_t length); 46 VideoFrame* CreateVideoFrame(uint8_t length);
47 47
48 class VideoCaptureInputTest : public ::testing::Test { 48 class VideoCaptureInputTest : public ::testing::Test {
49 protected: 49 protected:
50 VideoCaptureInputTest() 50 VideoCaptureInputTest()
51 : mock_process_thread_(new NiceMock<MockProcessThread>), 51 : stats_proxy_(Clock::GetRealTimeClock(),
52 webrtc::VideoSendStream::Config(nullptr),
53 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo),
52 mock_frame_callback_(new NiceMock<MockVideoCaptureCallback>), 54 mock_frame_callback_(new NiceMock<MockVideoCaptureCallback>),
53 output_frame_event_(false, false), 55 output_frame_event_(false, false) {}
54 stats_proxy_(Clock::GetRealTimeClock(),
55 webrtc::VideoSendStream::Config(nullptr),
56 webrtc::VideoEncoderConfig::ContentType::kRealtimeVideo) {}
57 56
58 virtual void SetUp() { 57 virtual void SetUp() {
59 EXPECT_CALL(*mock_frame_callback_, DeliverFrame(_)) 58 EXPECT_CALL(*mock_frame_callback_, DeliverFrame(_))
60 .WillRepeatedly( 59 .WillRepeatedly(
61 WithArg<0>(Invoke(this, &VideoCaptureInputTest::AddOutputFrame))); 60 WithArg<0>(Invoke(this, &VideoCaptureInputTest::AddOutputFrame)));
62 61
63 input_.reset(new internal::VideoCaptureInput( 62 overuse_detector_.reset(
64 mock_process_thread_.get(), mock_frame_callback_.get(), nullptr, 63 new OveruseFrameDetector(Clock::GetRealTimeClock(), CpuOveruseOptions(),
65 &stats_proxy_, nullptr, nullptr)); 64 nullptr, nullptr, &stats_proxy_));
66 } 65 input_.reset(new internal::VideoCaptureInput(mock_frame_callback_.get(),
67 66 nullptr, &stats_proxy_,
68 virtual void TearDown() { 67 overuse_detector_.get()));
69 // VideoCaptureInput accesses |mock_process_thread_| in destructor and
70 // should
71 // be deleted first.
72 input_.reset();
73 } 68 }
74 69
75 void AddInputFrame(VideoFrame* frame) { 70 void AddInputFrame(VideoFrame* frame) {
76 input_->IncomingCapturedFrame(*frame); 71 input_->IncomingCapturedFrame(*frame);
77 } 72 }
78 73
79 void AddOutputFrame(const VideoFrame& frame) { 74 void AddOutputFrame(const VideoFrame& frame) {
80 if (frame.native_handle() == NULL) 75 if (frame.native_handle() == NULL)
81 output_frame_ybuffers_.push_back(frame.buffer(kYPlane)); 76 output_frame_ybuffers_.push_back(frame.buffer(kYPlane));
82 output_frames_.push_back(new VideoFrame(frame)); 77 output_frames_.push_back(new VideoFrame(frame));
83 output_frame_event_.Set(); 78 output_frame_event_.Set();
84 } 79 }
85 80
86 void WaitOutputFrame() { 81 void WaitOutputFrame() {
87 EXPECT_TRUE(output_frame_event_.Wait(FRAME_TIMEOUT_MS)); 82 EXPECT_TRUE(output_frame_event_.Wait(FRAME_TIMEOUT_MS));
88 } 83 }
89 84
90 rtc::scoped_ptr<MockProcessThread> mock_process_thread_; 85 SendStatisticsProxy stats_proxy_;
86
91 rtc::scoped_ptr<MockVideoCaptureCallback> mock_frame_callback_; 87 rtc::scoped_ptr<MockVideoCaptureCallback> mock_frame_callback_;
92 88
89 rtc::scoped_ptr<OveruseFrameDetector> overuse_detector_;
90
93 // Used to send input capture frames to VideoCaptureInput. 91 // Used to send input capture frames to VideoCaptureInput.
94 rtc::scoped_ptr<internal::VideoCaptureInput> input_; 92 rtc::scoped_ptr<internal::VideoCaptureInput> input_;
95 93
96 // Input capture frames of VideoCaptureInput. 94 // Input capture frames of VideoCaptureInput.
97 ScopedVector<VideoFrame> input_frames_; 95 ScopedVector<VideoFrame> input_frames_;
98 96
99 // Indicate an output frame has arrived. 97 // Indicate an output frame has arrived.
100 rtc::Event output_frame_event_; 98 rtc::Event output_frame_event_;
101 99
102 // Output delivered frames of VideoCaptureInput. 100 // Output delivered frames of VideoCaptureInput.
103 ScopedVector<VideoFrame> output_frames_; 101 ScopedVector<VideoFrame> output_frames_;
104 102
105 // The pointers of Y plane buffers of output frames. This is used to verify 103 // The pointers of Y plane buffers of output frames. This is used to verify
106 // the frame are swapped and not copied. 104 // the frame are swapped and not copied.
107 std::vector<const uint8_t*> output_frame_ybuffers_; 105 std::vector<const uint8_t*> output_frame_ybuffers_;
108 SendStatisticsProxy stats_proxy_;
109 }; 106 };
110 107
111 TEST_F(VideoCaptureInputTest, DoesNotRetainHandleNorCopyBuffer) { 108 TEST_F(VideoCaptureInputTest, DoesNotRetainHandleNorCopyBuffer) {
112 // Indicate an output frame has arrived. 109 // Indicate an output frame has arrived.
113 rtc::Event frame_destroyed_event(false, false); 110 rtc::Event frame_destroyed_event(false, false);
114 class TestBuffer : public webrtc::I420Buffer { 111 class TestBuffer : public webrtc::I420Buffer {
115 public: 112 public:
116 explicit TestBuffer(rtc::Event* event) : I420Buffer(5, 5), event_(event) {} 113 explicit TestBuffer(rtc::Event* event) : I420Buffer(5, 5), event_(event) {}
117 114
118 private: 115 private:
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
294 const int kSizeY = width * height * 2; 291 const int kSizeY = width * height * 2;
295 uint8_t buffer[kSizeY]; 292 uint8_t buffer[kSizeY];
296 memset(buffer, data, kSizeY); 293 memset(buffer, data, kSizeY);
297 frame->CreateFrame(buffer, buffer, buffer, width, height, width, width / 2, 294 frame->CreateFrame(buffer, buffer, buffer, width, height, width, width / 2,
298 width / 2); 295 width / 2);
299 frame->set_render_time_ms(data); 296 frame->set_render_time_ms(data);
300 return frame; 297 return frame;
301 } 298 }
302 299
303 } // namespace webrtc 300 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698