OLD | NEW |
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 <string> | 5 #include <string> |
6 #include <vector> | 6 #include <vector> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/run_loop.h" | 10 #include "base/run_loop.h" |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 int capture_height, | 100 int capture_height, |
101 const blink::WebMediaConstraints& constraints, | 101 const blink::WebMediaConstraints& constraints, |
102 int expected_width, | 102 int expected_width, |
103 int expected_height) { | 103 int expected_height) { |
104 // Expect the source to start capture with the supported resolution. | 104 // Expect the source to start capture with the supported resolution. |
105 blink::WebMediaStreamTrack track = | 105 blink::WebMediaStreamTrack track = |
106 CreateTrackAndStartSource(constraints, capture_width, capture_height, | 106 CreateTrackAndStartSource(constraints, capture_width, capture_height, |
107 30); | 107 30); |
108 | 108 |
109 MockMediaStreamVideoSink sink; | 109 MockMediaStreamVideoSink sink; |
110 MediaStreamVideoSink::AddToVideoTrack(&sink, track); | 110 MediaStreamVideoSink::AddToVideoTrack( |
111 | 111 &sink, sink.GetDeliverFrameCB(), track); |
112 DeliverVideoFrameAndWaitForRenderer(capture_width, capture_height, &sink); | 112 DeliverVideoFrameAndWaitForRenderer(capture_width, capture_height, &sink); |
113 EXPECT_EQ(1, sink.number_of_frames()); | 113 EXPECT_EQ(1, sink.number_of_frames()); |
114 | 114 |
115 // Expect the delivered frame to be cropped. | 115 // Expect the delivered frame to be cropped. |
116 EXPECT_EQ(expected_height, sink.frame_size().height()); | 116 EXPECT_EQ(expected_height, sink.frame_size().height()); |
117 EXPECT_EQ(expected_width, sink.frame_size().width()); | 117 EXPECT_EQ(expected_width, sink.frame_size().width()); |
118 MediaStreamVideoSink::RemoveFromVideoTrack(&sink, track); | 118 MediaStreamVideoSink::RemoveFromVideoTrack(&sink, track); |
119 } | 119 } |
120 | 120 |
121 void DeliverVideoFrameAndWaitForRenderer(int width, int height, | 121 void DeliverVideoFrameAndWaitForRenderer(int width, int height, |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 MockMediaConstraintFactory factory; | 422 MockMediaConstraintFactory factory; |
423 factory.AddOptional(MediaStreamVideoSource::kMaxWidth, 800); | 423 factory.AddOptional(MediaStreamVideoSource::kMaxWidth, 800); |
424 factory.AddOptional(MediaStreamVideoSource::kMaxHeight, 700); | 424 factory.AddOptional(MediaStreamVideoSource::kMaxHeight, 700); |
425 | 425 |
426 // Expect the source to start capture with the supported resolution. | 426 // Expect the source to start capture with the supported resolution. |
427 blink::WebMediaStreamTrack track = | 427 blink::WebMediaStreamTrack track = |
428 CreateTrackAndStartSource(factory.CreateWebMediaConstraints(), | 428 CreateTrackAndStartSource(factory.CreateWebMediaConstraints(), |
429 640, 480, 30); | 429 640, 480, 30); |
430 | 430 |
431 MockMediaStreamVideoSink sink; | 431 MockMediaStreamVideoSink sink; |
432 MediaStreamVideoSink::AddToVideoTrack(&sink, track); | 432 MediaStreamVideoSink::AddToVideoTrack( |
| 433 &sink, sink.GetDeliverFrameCB(), track); |
433 EXPECT_EQ(0, sink.number_of_frames()); | 434 EXPECT_EQ(0, sink.number_of_frames()); |
434 DeliverVideoFrameAndWaitForRenderer(320, 240, &sink); | 435 DeliverVideoFrameAndWaitForRenderer(320, 240, &sink); |
435 EXPECT_EQ(1, sink.number_of_frames()); | 436 EXPECT_EQ(1, sink.number_of_frames()); |
436 // Expect the delivered frame to be passed unchanged since its smaller than | 437 // Expect the delivered frame to be passed unchanged since its smaller than |
437 // max requested. | 438 // max requested. |
438 EXPECT_EQ(320, sink.frame_size().width()); | 439 EXPECT_EQ(320, sink.frame_size().width()); |
439 EXPECT_EQ(240, sink.frame_size().height()); | 440 EXPECT_EQ(240, sink.frame_size().height()); |
440 | 441 |
441 DeliverVideoFrameAndWaitForRenderer(640, 480, &sink); | 442 DeliverVideoFrameAndWaitForRenderer(640, 480, &sink); |
442 EXPECT_EQ(2, sink.number_of_frames()); | 443 EXPECT_EQ(2, sink.number_of_frames()); |
(...skipping 28 matching lines...) Expand all Loading... |
471 EXPECT_TRUE(MediaStreamVideoSource::IsConstraintSupported( | 472 EXPECT_TRUE(MediaStreamVideoSource::IsConstraintSupported( |
472 MediaStreamVideoSource::kMaxAspectRatio)); | 473 MediaStreamVideoSource::kMaxAspectRatio)); |
473 EXPECT_TRUE(MediaStreamVideoSource::IsConstraintSupported( | 474 EXPECT_TRUE(MediaStreamVideoSource::IsConstraintSupported( |
474 MediaStreamVideoSource::kMinAspectRatio)); | 475 MediaStreamVideoSource::kMinAspectRatio)); |
475 | 476 |
476 EXPECT_FALSE(MediaStreamVideoSource::IsConstraintSupported( | 477 EXPECT_FALSE(MediaStreamVideoSource::IsConstraintSupported( |
477 "something unsupported")); | 478 "something unsupported")); |
478 } | 479 } |
479 | 480 |
480 } // namespace content | 481 } // namespace content |
OLD | NEW |