| 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 42c5b1b4c558aeb7bfcd849c274e95f79d7960a5..8b0d21f6ee2f2a621d313f72e5e18d6fa975ef92 100644
|
| --- a/content/renderer/media/media_stream_video_source.cc
|
| +++ b/content/renderer/media/media_stream_video_source.cc
|
| @@ -220,7 +220,8 @@ void FilterFormatsByConstraint(
|
| // Returns the media::VideoCaptureFormats that matches |constraints|.
|
| media::VideoCaptureFormats FilterFormats(
|
| const blink::WebMediaConstraints& constraints,
|
| - const media::VideoCaptureFormats& supported_formats) {
|
| + const media::VideoCaptureFormats& supported_formats,
|
| + blink::WebString* unsatisfied_constraint) {
|
| if (constraints.isNull()) {
|
| return supported_formats;
|
| }
|
| @@ -270,11 +271,13 @@ media::VideoCaptureFormats FilterFormats(
|
| constraints.getMandatoryConstraints(mandatory);
|
| constraints.getOptionalConstraints(optional);
|
| media::VideoCaptureFormats candidates = supported_formats;
|
| - for (size_t i = 0; i < mandatory.size(); ++i)
|
| + for (size_t i = 0; i < mandatory.size(); ++i) {
|
| FilterFormatsByConstraint(mandatory[i], true, &candidates);
|
| -
|
| - if (candidates.empty())
|
| - return candidates;
|
| + if (candidates.empty()) {
|
| + *unsatisfied_constraint = mandatory[i].m_name;
|
| + return candidates;
|
| + }
|
| + }
|
|
|
| // Ok - all mandatory checked and we still have candidates.
|
| // Let's try filtering using the optional constraints. The optional
|
| @@ -405,7 +408,7 @@ void MediaStreamVideoSource::AddTrack(
|
| case ENDED:
|
| case STARTED: {
|
| // Currently, reconfiguring the source is not supported.
|
| - FinalizeAddTrack();
|
| + FinalizeAddTrack(MEDIA_DEVICE_OK, "");
|
| }
|
| }
|
| }
|
| @@ -457,12 +460,15 @@ void MediaStreamVideoSource::OnSupportedFormats(
|
| DCHECK_EQ(RETRIEVING_CAPABILITIES, state_);
|
|
|
| supported_formats_ = formats;
|
| + blink::WebString unsatisfied_constraint;
|
| if (!FindBestFormatWithConstraints(supported_formats_,
|
| - ¤t_format_)) {
|
| + ¤t_format_,
|
| + &unsatisfied_constraint)) {
|
| SetReadyState(blink::WebMediaStreamSource::ReadyStateEnded);
|
| // This object can be deleted after calling FinalizeAddTrack. See comment
|
| // in the header file.
|
| - FinalizeAddTrack();
|
| + FinalizeAddTrack(MEDIA_DEVICE_CONSTRAINT_NOT_SATISFIED,
|
| + unsatisfied_constraint);
|
| return;
|
| }
|
|
|
| @@ -484,7 +490,8 @@ void MediaStreamVideoSource::OnSupportedFormats(
|
|
|
| bool MediaStreamVideoSource::FindBestFormatWithConstraints(
|
| const media::VideoCaptureFormats& formats,
|
| - media::VideoCaptureFormat* best_format) {
|
| + media::VideoCaptureFormat* best_format,
|
| + blink::WebString* unsatisfied_constraint) {
|
| DCHECK(CalledOnValidThread());
|
| // Find the first constraints that we can fulfill.
|
| for (std::vector<RequestedConstraints>::iterator request_it =
|
| @@ -501,7 +508,7 @@ bool MediaStreamVideoSource::FindBestFormatWithConstraints(
|
| return true;
|
| }
|
| media::VideoCaptureFormats filtered_formats =
|
| - FilterFormats(requested_constraints, formats);
|
| + FilterFormats(requested_constraints, formats, unsatisfied_constraint);
|
| if (filtered_formats.size() > 0) {
|
| // A request with constraints that can be fulfilled.
|
| GetBestCaptureFormat(filtered_formats,
|
| @@ -513,10 +520,10 @@ bool MediaStreamVideoSource::FindBestFormatWithConstraints(
|
| return false;
|
| }
|
|
|
| -void MediaStreamVideoSource::OnStartDone(bool success) {
|
| +void MediaStreamVideoSource::OnStartDone(MediaStreamRequestResult result) {
|
| DCHECK(CalledOnValidThread());
|
| - DVLOG(3) << "OnStartDone({success =" << success << "})";
|
| - if (success) {
|
| + DVLOG(3) << "OnStartDone({result =" << result << "})";
|
| + if (result == MEDIA_DEVICE_OK) {
|
| DCHECK_EQ(STARTING, state_);
|
| state_ = STARTED;
|
| SetReadyState(blink::WebMediaStreamSource::ReadyStateLive);
|
| @@ -526,10 +533,12 @@ void MediaStreamVideoSource::OnStartDone(bool success) {
|
|
|
| // This object can be deleted after calling FinalizeAddTrack. See comment in
|
| // the header file.
|
| - FinalizeAddTrack();
|
| + FinalizeAddTrack(result, "");
|
| }
|
|
|
| -void MediaStreamVideoSource::FinalizeAddTrack() {
|
| +void MediaStreamVideoSource::FinalizeAddTrack(
|
| + MediaStreamRequestResult result,
|
| + const blink::WebString& result_name) {
|
| DCHECK(CalledOnValidThread());
|
| media::VideoCaptureFormats formats;
|
| formats.push_back(current_format_);
|
| @@ -538,17 +547,7 @@ void MediaStreamVideoSource::FinalizeAddTrack() {
|
| callbacks.swap(requested_constraints_);
|
| for (std::vector<RequestedConstraints>::iterator it = callbacks.begin();
|
| it != callbacks.end(); ++it) {
|
| - // The track has been added successfully if the source has started and
|
| - // there are either no mandatory constraints and the source doesn't expose
|
| - // its format capabilities, or the constraints and the format match.
|
| - // For example, a remote source doesn't expose its format capabilities.
|
| - bool success =
|
| - state_ == STARTED &&
|
| - ((!current_format_.IsValid() && !HasMandatoryConstraints(
|
| - it->constraints)) ||
|
| - !FilterFormats(it->constraints, formats).empty());
|
| -
|
| - if (success) {
|
| + if (result == MEDIA_DEVICE_OK) {
|
| int max_width;
|
| int max_height;
|
| GetDesiredMaxWidthAndHeight(it->constraints, &max_width, &max_height);
|
| @@ -572,10 +571,10 @@ void MediaStreamVideoSource::FinalizeAddTrack() {
|
| on_mute_callback);
|
| }
|
|
|
| - DVLOG(3) << "FinalizeAddTrack() success " << success;
|
| + DVLOG(3) << "FinalizeAddTrack() result " << result;
|
|
|
| if (!it->callback.is_null())
|
| - it->callback.Run(this, success);
|
| + it->callback.Run(this, result, result_name);
|
| }
|
| }
|
|
|
|
|