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

Side by Side Diff: content/renderer/media/webrtc/webrtc_video_capturer_adapter_unittest.cc

Issue 246433006: Change MediaStreamVideoSource to output different resolutions to different tracks depending on the … (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h" 7 #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h"
8 #include "media/base/video_frame.h" 8 #include "media/base/video_frame.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 namespace content { 11 namespace content {
12 12
13 class WebRtcVideoCapturerAdapterTest 13 class WebRtcVideoCapturerAdapterTest
14 : public sigslot::has_slots<>, 14 : public sigslot::has_slots<>,
15 public ::testing::Test { 15 public ::testing::Test {
16 public: 16 public:
17 WebRtcVideoCapturerAdapterTest() 17 WebRtcVideoCapturerAdapterTest()
18 : adapter_(false), 18 : adapter_(false),
19 output_frame_width_(0), 19 output_frame_width_(0),
20 output_frame_height_(0) { 20 output_frame_height_(0) {
21 adapter_.SignalFrameCaptured.connect( 21 adapter_.SignalFrameCaptured.connect(
22 this, &WebRtcVideoCapturerAdapterTest::OnFrameCaptured); 22 this, &WebRtcVideoCapturerAdapterTest::OnFrameCaptured);
23 } 23 }
24 virtual ~WebRtcVideoCapturerAdapterTest() {} 24 virtual ~WebRtcVideoCapturerAdapterTest() {}
25 25
26 void TestSourceCropFrame(int capture_width, 26 void TestSourceCropFrame(int capture_width,
27 int capture_height, 27 int capture_height,
28 int expected_width, 28 int cropped_width,
29 int expected_height) { 29 int cropped_height,
30 const int visible_width = std::min(capture_width, expected_width); 30 int natural_width,
31 const int horiz_crop = ((capture_width - visible_width) / 2); 31 int natural_height) {
32 const int visible_height = std::min(capture_height, expected_height); 32 const int horiz_crop = ((capture_width - cropped_width) / 2);
33 const int vert_crop = ((expected_height - visible_height) / 2); 33 const int vert_crop = ((capture_height - cropped_height) / 2);
34 34
35 gfx::Size coded_size(capture_width, capture_height); 35 gfx::Size coded_size(capture_width, capture_height);
36 gfx::Rect view_rect(horiz_crop, vert_crop, visible_width, visible_height); 36 gfx::Size natural_size(natural_width, natural_height);
37 gfx::Rect view_rect(horiz_crop, vert_crop, cropped_width, cropped_height);
37 scoped_refptr<media::VideoFrame> frame = 38 scoped_refptr<media::VideoFrame> frame =
38 media::VideoFrame::CreateFrame(media::VideoFrame::I420, 39 media::VideoFrame::CreateFrame(media::VideoFrame::I420,
39 coded_size, view_rect, coded_size, 40 coded_size, view_rect, natural_size,
40 base::TimeDelta()); 41 base::TimeDelta());
41 adapter_.OnFrameCaptured(frame); 42 adapter_.OnFrameCaptured(frame);
42 EXPECT_EQ(expected_width, output_frame_width_); 43 EXPECT_EQ(natural_width, output_frame_width_);
43 EXPECT_EQ(expected_height, output_frame_height_); 44 EXPECT_EQ(natural_height, output_frame_height_);
44 } 45 }
45 protected: 46 protected:
46 void OnFrameCaptured(cricket::VideoCapturer* capturer, 47 void OnFrameCaptured(cricket::VideoCapturer* capturer,
47 const cricket::CapturedFrame* frame) { 48 const cricket::CapturedFrame* frame) {
48 output_frame_width_ = frame->width; 49 output_frame_width_ = frame->width;
49 output_frame_height_ = frame->height; 50 output_frame_height_ = frame->height;
50 } 51 }
51 52
52 private: 53 private:
53 WebRtcVideoCapturerAdapter adapter_; 54 WebRtcVideoCapturerAdapter adapter_;
54 int output_frame_width_; 55 int output_frame_width_;
55 int output_frame_height_; 56 int output_frame_height_;
56 }; 57 };
57 58
58 TEST_F(WebRtcVideoCapturerAdapterTest, CropFrameTo640360) { 59 TEST_F(WebRtcVideoCapturerAdapterTest, CropFrameTo640360) {
59 TestSourceCropFrame(640, 480, 640, 360); 60 TestSourceCropFrame(640, 480, 640, 360, 640, 360);
60 } 61 }
61 62
62 TEST_F(WebRtcVideoCapturerAdapterTest, CropFrameTo732489) { 63 TEST_F(WebRtcVideoCapturerAdapterTest, CropFrameTo320320) {
63 TestSourceCropFrame(1280, 720, 731, 489); 64 TestSourceCropFrame(640, 480, 480, 480, 320, 320);
64 } 65 }
65 66
67 TEST_F(WebRtcVideoCapturerAdapterTest, Scale720To640360) {
68 TestSourceCropFrame(1280, 720, 1280, 720, 640, 360);
69 }
70
mcasas 2014/05/07 14:10:43 Variate these new tests for I420 and YV12? i.e. a
perkj_chrome 2014/05/08 11:29:47 I don't think that is necessary. On 2014/05/07 1
71
72
mcasas 2014/05/07 14:10:43 Too many empty lines.
perkj_chrome 2014/05/08 11:29:47 Done.
66 } // namespace content 73 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698