| Index: content/renderer/media/media_stream_video_source.cc
|
| diff --git a/content/renderer/media/media_stream_video_source.cc b/content/renderer/media/media_stream_video_source.cc
|
| index 491f6f8a570528a83f493f2057fb9e3414fa7c19..19e5dad2eaf994942bdeefc464dd51a1bd5ce147 100644
|
| --- a/content/renderer/media/media_stream_video_source.cc
|
| +++ b/content/renderer/media/media_stream_video_source.cc
|
| @@ -10,6 +10,7 @@
|
|
|
| #include "base/logging.h"
|
| #include "base/strings/string_number_conversions.h"
|
| +#include "content/renderer/media/media_stream_constraints_util.h"
|
| #include "content/renderer/media/media_stream_dependency_factory.h"
|
| #include "content/renderer/media/media_stream_video_track.h"
|
| #include "content/renderer/media/webrtc/webrtc_video_capturer_adapter.h"
|
| @@ -203,34 +204,24 @@ media::VideoCaptureFormats FilterFormats(
|
| return candidates;
|
| }
|
|
|
| -bool GetConstraintValue(const blink::WebMediaConstraints& constraints,
|
| - bool mandatory, const blink::WebString& name,
|
| - int* value) {
|
| - blink::WebString value_str;
|
| - bool ret = mandatory ?
|
| - constraints.getMandatoryConstraintValue(name, value_str) :
|
| - constraints.getOptionalConstraintValue(name, value_str);
|
| - if (ret)
|
| - base::StringToInt(value_str.utf8(), value);
|
| - return ret;
|
| -}
|
| -
|
| // Retrieve the desired max width and height from |constraints|.
|
| void GetDesiredMaxWidthAndHeight(const blink::WebMediaConstraints& constraints,
|
| int* desired_width, int* desired_height) {
|
| - bool mandatory = GetConstraintValue(constraints, true,
|
| - MediaStreamVideoSource::kMaxWidth,
|
| - desired_width);
|
| - mandatory |= GetConstraintValue(constraints, true,
|
| - MediaStreamVideoSource::kMaxHeight,
|
| - desired_height);
|
| + bool mandatory = GetMandatoryConstraintValueAsInteger(
|
| + constraints, MediaStreamVideoSource::kMaxWidth, desired_width);
|
| + mandatory |= GetMandatoryConstraintValueAsInteger(
|
| + constraints, MediaStreamVideoSource::kMaxHeight, desired_height);
|
| + // Skip the optional constraints if any of the mandatory constraint is
|
| + // specified.
|
| if (mandatory)
|
| return;
|
|
|
| - GetConstraintValue(constraints, false, MediaStreamVideoSource::kMaxWidth,
|
| - desired_width);
|
| - GetConstraintValue(constraints, false, MediaStreamVideoSource::kMaxHeight,
|
| - desired_height);
|
| + GetOptionalConstraintValueAsInteger(constraints,
|
| + MediaStreamVideoSource::kMaxWidth,
|
| + desired_width);
|
| + GetOptionalConstraintValueAsInteger(constraints,
|
| + MediaStreamVideoSource::kMaxHeight,
|
| + desired_height);
|
| }
|
|
|
| const media::VideoCaptureFormat& GetBestFormatBasedOnArea(
|
| @@ -324,10 +315,12 @@ void MediaStreamVideoSource::AddTrack(
|
| // Tab capture and Screen capture needs the maximum requested height
|
| // and width to decide on the resolution.
|
| int max_requested_width = 0;
|
| - GetConstraintValue(constraints, true, kMaxWidth, &max_requested_width);
|
| + GetMandatoryConstraintValueAsInteger(constraints, kMaxWidth,
|
| + &max_requested_width);
|
|
|
| int max_requested_height = 0;
|
| - GetConstraintValue(constraints, true, kMaxHeight, &max_requested_height);
|
| + GetMandatoryConstraintValueAsInteger(constraints, kMaxHeight,
|
| + &max_requested_height);
|
|
|
| state_ = RETRIEVING_CAPABILITIES;
|
| GetCurrentSupportedFormats(max_requested_width,
|
|
|