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 "content/renderer/media/media_stream_video_source.h" | 5 #include "content/renderer/media/media_stream_video_source.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 21 matching lines...) Expand all Loading... |
32 MediaStreamVideoSource::kMaxAspectRatio, | 32 MediaStreamVideoSource::kMaxAspectRatio, |
33 MediaStreamVideoSource::kMinAspectRatio, | 33 MediaStreamVideoSource::kMinAspectRatio, |
34 MediaStreamVideoSource::kMaxWidth, | 34 MediaStreamVideoSource::kMaxWidth, |
35 MediaStreamVideoSource::kMinWidth, | 35 MediaStreamVideoSource::kMinWidth, |
36 MediaStreamVideoSource::kMaxHeight, | 36 MediaStreamVideoSource::kMaxHeight, |
37 MediaStreamVideoSource::kMinHeight, | 37 MediaStreamVideoSource::kMinHeight, |
38 MediaStreamVideoSource::kMaxFrameRate, | 38 MediaStreamVideoSource::kMaxFrameRate, |
39 MediaStreamVideoSource::kMinFrameRate, | 39 MediaStreamVideoSource::kMinFrameRate, |
40 }; | 40 }; |
41 | 41 |
42 const int MediaStreamVideoSource::kDefaultWidth = 640; | |
43 const int MediaStreamVideoSource::kDefaultHeight = 480; | |
44 const int MediaStreamVideoSource::kDefaultFrameRate = 30; | |
45 const int MediaStreamVideoSource::kUnknownFrameRate = 0; | |
46 | |
47 namespace { | 42 namespace { |
48 | 43 |
49 // Google-specific key prefix. Constraints with this prefix are ignored if they | 44 // Google-specific key prefix. Constraints with this prefix are ignored if they |
50 // are unknown. | 45 // are unknown. |
51 const char kGooglePrefix[] = "goog"; | 46 const char kGooglePrefix[] = "goog"; |
52 | 47 |
53 // Returns true if |constraint| has mandatory constraints. | 48 // Returns true if |constraint| has mandatory constraints. |
54 bool HasMandatoryConstraints(const blink::WebMediaConstraints& constraints) { | 49 bool HasMandatoryConstraints(const blink::WebMediaConstraints& constraints) { |
55 blink::WebVector<blink::WebMediaConstraint> mandatory_constraints; | 50 blink::WebVector<blink::WebMediaConstraint> mandatory_constraints; |
56 constraints.getMandatoryConstraints(mandatory_constraints); | 51 constraints.getMandatoryConstraints(mandatory_constraints); |
(...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 const blink::WebMediaConstraints& constraints, | 322 const blink::WebMediaConstraints& constraints, |
328 media::VideoCaptureFormat* capture_format) { | 323 media::VideoCaptureFormat* capture_format) { |
329 DCHECK(!formats.empty()); | 324 DCHECK(!formats.empty()); |
330 | 325 |
331 int max_width; | 326 int max_width; |
332 int max_height; | 327 int max_height; |
333 GetDesiredMaxWidthAndHeight(constraints, &max_width, &max_height); | 328 GetDesiredMaxWidthAndHeight(constraints, &max_width, &max_height); |
334 | 329 |
335 *capture_format = GetBestFormatBasedOnArea( | 330 *capture_format = GetBestFormatBasedOnArea( |
336 formats, | 331 formats, |
337 std::min(max_width, MediaStreamVideoSource::kDefaultWidth) * | 332 std::min(max_width, |
338 std::min(max_height, MediaStreamVideoSource::kDefaultHeight)); | 333 static_cast<int>(MediaStreamVideoSource::kDefaultWidth)) * |
| 334 std::min(max_height, |
| 335 static_cast<int>(MediaStreamVideoSource::kDefaultHeight))); |
339 } | 336 } |
340 | 337 |
341 } // anonymous namespace | 338 } // anonymous namespace |
342 | 339 |
343 // static | 340 // static |
344 MediaStreamVideoSource* MediaStreamVideoSource::GetVideoSource( | 341 MediaStreamVideoSource* MediaStreamVideoSource::GetVideoSource( |
345 const blink::WebMediaStreamSource& source) { | 342 const blink::WebMediaStreamSource& source) { |
346 return static_cast<MediaStreamVideoSource*>(source.extraData()); | 343 return static_cast<MediaStreamVideoSource*>(source.extraData()); |
347 } | 344 } |
348 | 345 |
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
618 : track(track), | 615 : track(track), |
619 frame_callback(frame_callback), | 616 frame_callback(frame_callback), |
620 constraints(constraints), | 617 constraints(constraints), |
621 callback(callback) { | 618 callback(callback) { |
622 } | 619 } |
623 | 620 |
624 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() { | 621 MediaStreamVideoSource::RequestedConstraints::~RequestedConstraints() { |
625 } | 622 } |
626 | 623 |
627 } // namespace content | 624 } // namespace content |
OLD | NEW |