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, |
| 112 sink.GetDeliverFrameCB(), |
| 113 track); |
112 DeliverVideoFrameAndWaitForRenderer(capture_width, capture_height, &sink); | 114 DeliverVideoFrameAndWaitForRenderer(capture_width, capture_height, &sink); |
113 EXPECT_EQ(1, sink.number_of_frames()); | 115 EXPECT_EQ(1, sink.number_of_frames()); |
114 | 116 |
115 // Expect the delivered frame to be cropped. | 117 // Expect the delivered frame to be cropped. |
116 EXPECT_EQ(expected_height, sink.frame_size().height()); | 118 EXPECT_EQ(expected_height, sink.frame_size().height()); |
117 EXPECT_EQ(expected_width, sink.frame_size().width()); | 119 EXPECT_EQ(expected_width, sink.frame_size().width()); |
118 MediaStreamVideoSink::RemoveFromVideoTrack(&sink, track); | 120 MediaStreamVideoSink::RemoveFromVideoTrack(&sink, track); |
119 } | 121 } |
120 | 122 |
121 void DeliverVideoFrameAndWaitForRenderer(int width, int height, | 123 void DeliverVideoFrameAndWaitForRenderer(int width, int height, |
(...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
422 MockMediaConstraintFactory factory; | 424 MockMediaConstraintFactory factory; |
423 factory.AddOptional(MediaStreamVideoSource::kMaxWidth, 800); | 425 factory.AddOptional(MediaStreamVideoSource::kMaxWidth, 800); |
424 factory.AddOptional(MediaStreamVideoSource::kMaxHeight, 700); | 426 factory.AddOptional(MediaStreamVideoSource::kMaxHeight, 700); |
425 | 427 |
426 // Expect the source to start capture with the supported resolution. | 428 // Expect the source to start capture with the supported resolution. |
427 blink::WebMediaStreamTrack track = | 429 blink::WebMediaStreamTrack track = |
428 CreateTrackAndStartSource(factory.CreateWebMediaConstraints(), | 430 CreateTrackAndStartSource(factory.CreateWebMediaConstraints(), |
429 640, 480, 30); | 431 640, 480, 30); |
430 | 432 |
431 MockMediaStreamVideoSink sink; | 433 MockMediaStreamVideoSink sink; |
432 MediaStreamVideoSink::AddToVideoTrack(&sink, track); | 434 MediaStreamVideoSink::AddToVideoTrack( |
| 435 &sink, |
| 436 sink.GetDeliverFrameCB(), |
| 437 track); |
433 EXPECT_EQ(0, sink.number_of_frames()); | 438 EXPECT_EQ(0, sink.number_of_frames()); |
434 DeliverVideoFrameAndWaitForRenderer(320, 240, &sink); | 439 DeliverVideoFrameAndWaitForRenderer(320, 240, &sink); |
435 EXPECT_EQ(1, sink.number_of_frames()); | 440 EXPECT_EQ(1, sink.number_of_frames()); |
436 // Expect the delivered frame to be passed unchanged since its smaller than | 441 // Expect the delivered frame to be passed unchanged since its smaller than |
437 // max requested. | 442 // max requested. |
438 EXPECT_EQ(320, sink.frame_size().width()); | 443 EXPECT_EQ(320, sink.frame_size().width()); |
439 EXPECT_EQ(240, sink.frame_size().height()); | 444 EXPECT_EQ(240, sink.frame_size().height()); |
440 | 445 |
441 DeliverVideoFrameAndWaitForRenderer(640, 480, &sink); | 446 DeliverVideoFrameAndWaitForRenderer(640, 480, &sink); |
442 EXPECT_EQ(2, sink.number_of_frames()); | 447 EXPECT_EQ(2, sink.number_of_frames()); |
(...skipping 28 matching lines...) Expand all Loading... |
471 EXPECT_TRUE(MediaStreamVideoSource::IsConstraintSupported( | 476 EXPECT_TRUE(MediaStreamVideoSource::IsConstraintSupported( |
472 MediaStreamVideoSource::kMaxAspectRatio)); | 477 MediaStreamVideoSource::kMaxAspectRatio)); |
473 EXPECT_TRUE(MediaStreamVideoSource::IsConstraintSupported( | 478 EXPECT_TRUE(MediaStreamVideoSource::IsConstraintSupported( |
474 MediaStreamVideoSource::kMinAspectRatio)); | 479 MediaStreamVideoSource::kMinAspectRatio)); |
475 | 480 |
476 EXPECT_FALSE(MediaStreamVideoSource::IsConstraintSupported( | 481 EXPECT_FALSE(MediaStreamVideoSource::IsConstraintSupported( |
477 "something unsupported")); | 482 "something unsupported")); |
478 } | 483 } |
479 | 484 |
480 } // namespace content | 485 } // namespace content |
OLD | NEW |