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

Side by Side Diff: content/renderer/media/video_track_recorder_unittest.cc

Issue 1814853006: MediaRecorder: Tune complexity settings for VP9 encoding (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2661
Patch Set: Created 4 years, 9 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/renderer/media/video_track_recorder.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/location.h" 8 #include "base/location.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/memory/ref_counted.h" 10 #include "base/memory/ref_counted.h"
(...skipping 20 matching lines...) Expand all
31 using ::testing::SaveArg; 31 using ::testing::SaveArg;
32 using ::testing::TestWithParam; 32 using ::testing::TestWithParam;
33 using ::testing::ValuesIn; 33 using ::testing::ValuesIn;
34 34
35 namespace content { 35 namespace content {
36 36
37 ACTION_P(RunClosure, closure) { 37 ACTION_P(RunClosure, closure) {
38 closure.Run(); 38 closure.Run();
39 } 39 }
40 40
41 struct TrackRecorderTestParams { 41 const bool kTrackRecorderTestUseVp9OrNot[] = {false, true};
42 const bool use_vp9;
43 const size_t first_encoded_frame_size;
44 const size_t second_encoded_frame_size;
45 const size_t third_encoded_frame_size;
46 };
47 42
48 const TrackRecorderTestParams kTrackRecorderTestParams[] = {{false, 52, 32, 57}, 43 class VideoTrackRecorderTest : public TestWithParam<bool> {
49 {true, 33, 18, 33}};
50
51 class VideoTrackRecorderTest : public TestWithParam<TrackRecorderTestParams> {
52 public: 44 public:
53 VideoTrackRecorderTest() 45 VideoTrackRecorderTest()
54 : mock_source_(new MockMediaStreamVideoSource(false)) { 46 : mock_source_(new MockMediaStreamVideoSource(false)) {
55 const blink::WebString webkit_track_id(base::UTF8ToUTF16("dummy")); 47 const blink::WebString webkit_track_id(base::UTF8ToUTF16("dummy"));
56 blink_source_.initialize(webkit_track_id, 48 blink_source_.initialize(webkit_track_id,
57 blink::WebMediaStreamSource::TypeVideo, 49 blink::WebMediaStreamSource::TypeVideo,
58 webkit_track_id); 50 webkit_track_id);
59 blink_source_.setExtraData(mock_source_); 51 blink_source_.setExtraData(mock_source_);
60 blink_track_.initialize(blink_source_); 52 blink_track_.initialize(blink_source_);
61 53
62 blink::WebMediaConstraints constraints; 54 blink::WebMediaConstraints constraints;
63 constraints.initialize(); 55 constraints.initialize();
64 track_ = new MediaStreamVideoTrack(mock_source_, constraints, 56 track_ = new MediaStreamVideoTrack(mock_source_, constraints,
65 MediaStreamSource::ConstraintsCallback(), 57 MediaStreamSource::ConstraintsCallback(),
66 true /* enabled */); 58 true /* enabled */);
67 blink_track_.setExtraData(track_); 59 blink_track_.setExtraData(track_);
68 60
69 video_track_recorder_.reset(new VideoTrackRecorder( 61 video_track_recorder_.reset(new VideoTrackRecorder(
70 GetParam().use_vp9 /* use_vp9 */, blink_track_, 62 GetParam() /* use_vp9 */, blink_track_,
71 base::Bind(&VideoTrackRecorderTest::OnEncodedVideo, 63 base::Bind(&VideoTrackRecorderTest::OnEncodedVideo,
72 base::Unretained(this)), 64 base::Unretained(this)),
73 0 /* bits_per_second */)); 65 0 /* bits_per_second */));
74 // Paranoia checks. 66 // Paranoia checks.
75 EXPECT_EQ(blink_track_.source().extraData(), blink_source_.extraData()); 67 EXPECT_EQ(blink_track_.source().extraData(), blink_source_.extraData());
76 EXPECT_TRUE(message_loop_.IsCurrent()); 68 EXPECT_TRUE(message_loop_.IsCurrent());
77 } 69 }
78 70
79 ~VideoTrackRecorderTest() { 71 ~VideoTrackRecorderTest() {
80 blink_track_.reset(); 72 blink_track_.reset();
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 153
162 base::StringPiece third_frame_encoded_data; 154 base::StringPiece third_frame_encoded_data;
163 EXPECT_CALL(*this, DoOnEncodedVideo(video_frame2, _, _, true)) 155 EXPECT_CALL(*this, DoOnEncodedVideo(video_frame2, _, _, true))
164 .Times(1) 156 .Times(1)
165 .WillOnce(DoAll(SaveArg<1>(&third_frame_encoded_data), 157 .WillOnce(DoAll(SaveArg<1>(&third_frame_encoded_data),
166 RunClosure(quit_closure))); 158 RunClosure(quit_closure)));
167 Encode(video_frame2, base::TimeTicks::Now()); 159 Encode(video_frame2, base::TimeTicks::Now());
168 160
169 run_loop.Run(); 161 run_loop.Run();
170 162
171 EXPECT_EQ(GetParam().first_encoded_frame_size, 163 const size_t kEncodedSizeThreshold = 18;
172 first_frame_encoded_data.size()); 164 EXPECT_GE(first_frame_encoded_data.size(), kEncodedSizeThreshold);
173 EXPECT_EQ(GetParam().second_encoded_frame_size, 165 EXPECT_GE(second_frame_encoded_data.size(), kEncodedSizeThreshold);
174 second_frame_encoded_data.size()); 166 EXPECT_GE(third_frame_encoded_data.size(), kEncodedSizeThreshold);
175 EXPECT_EQ(GetParam().third_encoded_frame_size,
176 third_frame_encoded_data.size());
177 167
178 Mock::VerifyAndClearExpectations(this); 168 Mock::VerifyAndClearExpectations(this);
179 } 169 }
180 170
181 INSTANTIATE_TEST_CASE_P(, 171 INSTANTIATE_TEST_CASE_P(,
182 VideoTrackRecorderTest, 172 VideoTrackRecorderTest,
183 ValuesIn(kTrackRecorderTestParams)); 173 ValuesIn(kTrackRecorderTestUseVp9OrNot));
184 174
185 } // namespace content 175 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/video_track_recorder.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698