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

Side by Side Diff: content/browser/media/capture/video_capture_oracle_unittest.cc

Issue 1183553002: Adjust VideoCaptureOracle wrt. out of order captures. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
« no previous file with comments | « content/browser/media/capture/video_capture_oracle.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/media/capture/video_capture_oracle.h" 5 #include "content/browser/media/capture/video_capture_oracle.h"
6 6
7 #include "base/strings/stringprintf.h" 7 #include "base/strings/stringprintf.h"
8 #include "testing/gtest/include/gtest/gtest.h" 8 #include "testing/gtest/include/gtest/gtest.h"
9 9
10 namespace content { 10 namespace content {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 t = furthest_event_time; 46 t = furthest_event_time;
47 for (int i = 0; i < 10; ++i) { 47 for (int i = 0; i < 10; ++i) {
48 t += event_increment; 48 t += event_increment;
49 ASSERT_TRUE(oracle.ObserveEventAndDecideCapture( 49 ASSERT_TRUE(oracle.ObserveEventAndDecideCapture(
50 VideoCaptureOracle::kCompositorUpdate, 50 VideoCaptureOracle::kCompositorUpdate,
51 damage_rect, t)); 51 damage_rect, t));
52 } 52 }
53 } 53 }
54 54
55 // Tests that VideoCaptureOracle is enforcing the requirement that captured 55 // Tests that VideoCaptureOracle is enforcing the requirement that
56 // frames are delivered in order. Otherwise, downstream consumers could be 56 // successfully captured frames are delivered in order. Otherwise, downstream
57 // tripped-up by out-of-order frames or frame timestamps. 57 // consumers could be tripped-up by out-of-order frames or frame timestamps.
58 TEST(VideoCaptureOracleTest, EnforcesFramesDeliveredInOrder) { 58 TEST(VideoCaptureOracleTest, EnforcesFramesDeliveredInOrder) {
59 const base::TimeDelta min_capture_period = 59 const base::TimeDelta min_capture_period =
60 base::TimeDelta::FromSeconds(1) / 30; 60 base::TimeDelta::FromSeconds(1) / 30;
61 const gfx::Rect damage_rect(0, 0, 1280, 720); 61 const gfx::Rect damage_rect(0, 0, 1280, 720);
62 const base::TimeDelta event_increment = min_capture_period * 2; 62 const base::TimeDelta event_increment = min_capture_period * 2;
63 63
64 VideoCaptureOracle oracle(min_capture_period); 64 VideoCaptureOracle oracle(min_capture_period);
65 65
66 // Most basic scenario: Frames delivered one at a time, with no additional 66 // Most basic scenario: Frames delivered one at a time, with no additional
67 // captures in-between deliveries. 67 // captures in-between deliveries.
(...skipping 18 matching lines...) Expand all
86 VideoCaptureOracle::kCompositorUpdate, 86 VideoCaptureOracle::kCompositorUpdate,
87 damage_rect, t)); 87 damage_rect, t));
88 last_frame_number = oracle.RecordCapture(); 88 last_frame_number = oracle.RecordCapture();
89 } 89 }
90 for (int j = num_in_flight - 1; j >= 0; --j) { 90 for (int j = num_in_flight - 1; j >= 0; --j) {
91 ASSERT_TRUE( 91 ASSERT_TRUE(
92 oracle.CompleteCapture(last_frame_number - j, true, &ignored)); 92 oracle.CompleteCapture(last_frame_number - j, true, &ignored));
93 } 93 }
94 } 94 }
95 95
96 // Pipelined scenario with out-of-order delivery attempts rejected. 96 // Pipelined scenario with successful out-of-order delivery attempts
97 // rejected.
97 for (int i = 0; i < 50; ++i) { 98 for (int i = 0; i < 50; ++i) {
98 const int num_in_flight = 1 + i % 3; 99 const int num_in_flight = 1 + i % 3;
99 for (int j = 0; j < num_in_flight; ++j) { 100 for (int j = 0; j < num_in_flight; ++j) {
100 t += event_increment; 101 t += event_increment;
101 ASSERT_TRUE(oracle.ObserveEventAndDecideCapture( 102 ASSERT_TRUE(oracle.ObserveEventAndDecideCapture(
102 VideoCaptureOracle::kCompositorUpdate, 103 VideoCaptureOracle::kCompositorUpdate,
103 damage_rect, t)); 104 damage_rect, t));
104 last_frame_number = oracle.RecordCapture(); 105 last_frame_number = oracle.RecordCapture();
105 } 106 }
106 ASSERT_TRUE(oracle.CompleteCapture(last_frame_number, true, &ignored)); 107 ASSERT_TRUE(oracle.CompleteCapture(last_frame_number, true, &ignored));
107 for (int j = 1; j < num_in_flight; ++j) { 108 for (int j = 1; j < num_in_flight; ++j) {
108 ASSERT_FALSE( 109 ASSERT_FALSE(
109 oracle.CompleteCapture(last_frame_number - j, true, &ignored)); 110 oracle.CompleteCapture(last_frame_number - j, true, &ignored));
110 } 111 }
111 } 112 }
113
114 // Pipelined scenario with successful delivery attempts accepted after an
115 // unsuccessful out of order delivery attempt.
116 for (int i = 0; i < 50; ++i) {
117 const int num_in_flight = 1 + i % 3;
118 for (int j = 0; j < num_in_flight; ++j) {
119 t += event_increment;
120 ASSERT_TRUE(oracle.ObserveEventAndDecideCapture(
121 VideoCaptureOracle::kCompositorUpdate,
122 damage_rect, t));
123 last_frame_number = oracle.RecordCapture();
124 }
125 // Report the last frame as an out of order failure.
126 ASSERT_FALSE(oracle.CompleteCapture(last_frame_number, false, &ignored));
127 for (int j = 1; j < num_in_flight - 1; ++j) {
128 ASSERT_TRUE(
129 oracle.CompleteCapture(last_frame_number - j, true, &ignored));
130 }
131
132 }
112 } 133 }
113 134
114 // Tests that VideoCaptureOracle transitions between using its two samplers in a 135 // Tests that VideoCaptureOracle transitions between using its two samplers in a
115 // way that does not introduce severe jank, pauses, etc. 136 // way that does not introduce severe jank, pauses, etc.
116 TEST(VideoCaptureOracleTest, TransitionsSmoothlyBetweenSamplers) { 137 TEST(VideoCaptureOracleTest, TransitionsSmoothlyBetweenSamplers) {
117 const base::TimeDelta min_capture_period = 138 const base::TimeDelta min_capture_period =
118 base::TimeDelta::FromSeconds(1) / 30; 139 base::TimeDelta::FromSeconds(1) / 30;
119 const gfx::Rect animation_damage_rect(0, 0, 1280, 720); 140 const gfx::Rect animation_damage_rect(0, 0, 1280, 720);
120 const base::TimeDelta event_increment = min_capture_period * 2; 141 const base::TimeDelta event_increment = min_capture_period * 2;
121 142
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 ASSERT_GT(10, i) << "BUG: Seems like it'll never happen!"; 281 ASSERT_GT(10, i) << "BUG: Seems like it'll never happen!";
261 t += timer_interval; 282 t += timer_interval;
262 if (oracle.ObserveEventAndDecideCapture( 283 if (oracle.ObserveEventAndDecideCapture(
263 VideoCaptureOracle::kTimerPoll, gfx::Rect(), t)) { 284 VideoCaptureOracle::kTimerPoll, gfx::Rect(), t)) {
264 break; 285 break;
265 } 286 }
266 } 287 }
267 } 288 }
268 289
269 } // namespace content 290 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/media/capture/video_capture_oracle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698