diff options
12 files changed, 44 insertions, 16 deletions
diff --git a/content/renderer/media/media_stream_video_capturer_source.cc b/content/renderer/media/media_stream_video_capturer_source.cc index 1266853..d322eb4 100644 --- a/content/renderer/media/media_stream_video_capturer_source.cc +++ b/content/renderer/media/media_stream_video_capturer_source.cc @@ -30,6 +30,9 @@ const SourceVideoResolution kVideoResolutions[] = {{1920, 1080}, // Frame rates for sources with no support for capability enumeration. const int kVideoFrameRates[] = {30, 60}; +// Hard upper-bound frame rate for tab/desktop capture. +const double kMaxScreenCastFrameRate = 120.0; + } // namespace namespace content { @@ -59,23 +62,24 @@ VideoCapturerDelegate::~VideoCapturerDelegate() { void VideoCapturerDelegate::GetCurrentSupportedFormats( int max_requested_width, int max_requested_height, + double max_requested_frame_rate, const VideoCaptureDeviceFormatsCB& callback) { - DVLOG(3) << "GetCurrentSupportedFormats(" - << " { max_requested_height = " << max_requested_height << "})" - << " { max_requested_width = " << max_requested_width << "})"; + DVLOG(3) + << "GetCurrentSupportedFormats(" + << " { max_requested_height = " << max_requested_height << "})" + << " { max_requested_width = " << max_requested_width << "})" + << " { max_requested_frame_rate = " << max_requested_frame_rate << "})"; if (is_screen_cast_) { - media::VideoCaptureFormats formats; const int width = max_requested_width ? max_requested_width : MediaStreamVideoSource::kDefaultWidth; const int height = max_requested_height ? max_requested_height : MediaStreamVideoSource::kDefaultHeight; - formats.push_back( - media::VideoCaptureFormat( - gfx::Size(width, height), - MediaStreamVideoSource::kDefaultFrameRate, - media::PIXEL_FORMAT_I420)); - callback.Run(formats); + callback.Run(media::VideoCaptureFormats(1, media::VideoCaptureFormat( + gfx::Size(width, height), + static_cast<float>(std::min(kMaxScreenCastFrameRate, + max_requested_frame_rate)), + media::PIXEL_FORMAT_I420))); return; } @@ -216,10 +220,12 @@ MediaStreamVideoCapturerSource::~MediaStreamVideoCapturerSource() { void MediaStreamVideoCapturerSource::GetCurrentSupportedFormats( int max_requested_width, int max_requested_height, + double max_requested_frame_rate, const VideoCaptureDeviceFormatsCB& callback) { delegate_->GetCurrentSupportedFormats( max_requested_width, max_requested_height, + max_requested_frame_rate, callback); } diff --git a/content/renderer/media/media_stream_video_capturer_source.h b/content/renderer/media/media_stream_video_capturer_source.h index 3b9588a..fff2dcc 100644 --- a/content/renderer/media/media_stream_video_capturer_source.h +++ b/content/renderer/media/media_stream_video_capturer_source.h @@ -28,12 +28,14 @@ class CONTENT_EXPORT VideoCapturerDelegate const StreamDeviceInfo& device_info); // Collects the formats that can currently be used. - // |max_requested_height| and |max_requested_width| is used by Tab and Screen - // capture to decide what resolution to generate. - // |callback| is triggered when the formats have been collected. + // |max_requested_height|, |max_requested_width|, and + // |max_requested_frame_rate| is used by Tab and Screen capture to decide what + // resolution/framerate to generate. |callback| is triggered when the formats + // have been collected. virtual void GetCurrentSupportedFormats( int max_requested_width, int max_requested_height, + double max_requested_frame_rate, const VideoCaptureDeviceFormatsCB& callback); // Starts capturing frames using the resolution in |params|. @@ -102,6 +104,7 @@ class CONTENT_EXPORT MediaStreamVideoCapturerSource virtual void GetCurrentSupportedFormats( int max_requested_width, int max_requested_height, + double max_requested_frame_rate, const VideoCaptureDeviceFormatsCB& callback) OVERRIDE; virtual void StartSourceImpl( diff --git a/content/renderer/media/media_stream_video_source.cc b/content/renderer/media/media_stream_video_source.cc index 42c5b1b..d6f8b8a4 100644 --- a/content/renderer/media/media_stream_video_source.cc +++ b/content/renderer/media/media_stream_video_source.cc @@ -173,9 +173,9 @@ bool UpdateFormatForConstraint( } else if (constraint_name == MediaStreamVideoSource::kMaxHeight) { return value > 0.0; } else if (constraint_name == MediaStreamVideoSource::kMinFrameRate) { - return (value <= format->frame_rate); + return (value > 0.0) && (value <= format->frame_rate); } else if (constraint_name == MediaStreamVideoSource::kMaxFrameRate) { - if (value == 0.0) { + if (value <= 0.0) { // The frame rate is set by constraint. // Don't allow 0 as frame rate if it is a mandatory constraint. // Set the frame rate to 1 if it is not mandatory. @@ -387,10 +387,17 @@ void MediaStreamVideoSource::AddTrack( GetMandatoryConstraintValueAsInteger(constraints, kMaxHeight, &max_requested_height); + double max_requested_frame_rate; + if (!GetConstraintValueAsDouble(constraints, kMaxFrameRate, + &max_requested_frame_rate)) { + max_requested_frame_rate = kDefaultFrameRate; + } + state_ = RETRIEVING_CAPABILITIES; GetCurrentSupportedFormats( max_requested_width, max_requested_height, + max_requested_frame_rate, base::Bind(&MediaStreamVideoSource::OnSupportedFormats, weak_factory_.GetWeakPtr())); diff --git a/content/renderer/media/media_stream_video_source.h b/content/renderer/media/media_stream_video_source.h index c2f6f17..19f000e 100644 --- a/content/renderer/media/media_stream_video_source.h +++ b/content/renderer/media/media_stream_video_source.h @@ -100,6 +100,7 @@ class CONTENT_EXPORT MediaStreamVideoSource virtual void GetCurrentSupportedFormats( int max_requested_width, int max_requested_height, + double max_requested_frame_rate, const VideoCaptureDeviceFormatsCB& callback) = 0; // An implementation must start capture frames using the resolution in diff --git a/content/renderer/media/mock_media_stream_video_source.cc b/content/renderer/media/mock_media_stream_video_source.cc index b1e58f3..2e9b6a1 100644 --- a/content/renderer/media/mock_media_stream_video_source.cc +++ b/content/renderer/media/mock_media_stream_video_source.cc @@ -15,6 +15,7 @@ MockMediaStreamVideoSource::MockMediaStreamVideoSource( : manual_get_supported_formats_(manual_get_supported_formats), max_requested_height_(0), max_requested_width_(0), + max_requested_frame_rate_(0.0), attempted_to_start_(false) { supported_formats_.push_back( media::VideoCaptureFormat( @@ -46,10 +47,12 @@ void MockMediaStreamVideoSource::CompleteGetSupportedFormats() { void MockMediaStreamVideoSource::GetCurrentSupportedFormats( int max_requested_height, int max_requested_width, + double max_requested_frame_rate, const VideoCaptureDeviceFormatsCB& callback) { DCHECK(formats_callback_.is_null()); max_requested_height_ = max_requested_height; max_requested_width_ = max_requested_width; + max_requested_frame_rate_ = max_requested_frame_rate; if (manual_get_supported_formats_) { formats_callback_ = callback; diff --git a/content/renderer/media/mock_media_stream_video_source.h b/content/renderer/media/mock_media_stream_video_source.h index 0786798..449adbd 100644 --- a/content/renderer/media/mock_media_stream_video_source.h +++ b/content/renderer/media/mock_media_stream_video_source.h @@ -42,6 +42,7 @@ class MockMediaStreamVideoSource : public MediaStreamVideoSource { const media::VideoCaptureParams& start_params() const { return params_; } int max_requested_height() const { return max_requested_height_; } int max_requested_width() const { return max_requested_width_; } + double max_requested_frame_rate() const { return max_requested_frame_rate_; } void SetMutedState(bool muted_state) { MediaStreamVideoSource::SetMutedState(muted_state); @@ -58,6 +59,7 @@ class MockMediaStreamVideoSource : public MediaStreamVideoSource { virtual void GetCurrentSupportedFormats( int max_requested_height, int max_requested_width, + double max_requested_frame_rate, const VideoCaptureDeviceFormatsCB& callback) OVERRIDE; virtual void StartSourceImpl( const media::VideoCaptureParams& params, @@ -70,6 +72,7 @@ class MockMediaStreamVideoSource : public MediaStreamVideoSource { bool manual_get_supported_formats_; int max_requested_height_; int max_requested_width_; + double max_requested_frame_rate_; bool attempted_to_start_; VideoCaptureDeviceFormatsCB formats_callback_; VideoCaptureDeliverFrameCB frame_callback_; diff --git a/content/renderer/media/webrtc/media_stream_remote_video_source.cc b/content/renderer/media/webrtc/media_stream_remote_video_source.cc index 3b93cdf..74dbbb2 100644 --- a/content/renderer/media/webrtc/media_stream_remote_video_source.cc +++ b/content/renderer/media/webrtc/media_stream_remote_video_source.cc @@ -138,6 +138,7 @@ MediaStreamRemoteVideoSource::~MediaStreamRemoteVideoSource() { void MediaStreamRemoteVideoSource::GetCurrentSupportedFormats( int max_requested_width, int max_requested_height, + double max_requested_frame_rate, const VideoCaptureDeviceFormatsCB& callback) { DCHECK(thread_checker_.CalledOnValidThread()); media::VideoCaptureFormats formats; diff --git a/content/renderer/media/webrtc/media_stream_remote_video_source.h b/content/renderer/media/webrtc/media_stream_remote_video_source.h index 76041ee..f598190 100644 --- a/content/renderer/media/webrtc/media_stream_remote_video_source.h +++ b/content/renderer/media/webrtc/media_stream_remote_video_source.h @@ -30,6 +30,7 @@ class CONTENT_EXPORT MediaStreamRemoteVideoSource virtual void GetCurrentSupportedFormats( int max_requested_width, int max_requested_height, + double max_requested_frame_rate, const VideoCaptureDeviceFormatsCB& callback) OVERRIDE; virtual void StartSourceImpl( diff --git a/content/renderer/media/webrtc/video_destination_handler.cc b/content/renderer/media/webrtc/video_destination_handler.cc index 84594bb..bd388be 100644 --- a/content/renderer/media/webrtc/video_destination_handler.cc +++ b/content/renderer/media/webrtc/video_destination_handler.cc @@ -83,6 +83,7 @@ PpFrameWriter::~PpFrameWriter() { void PpFrameWriter::GetCurrentSupportedFormats( int max_requested_width, int max_requested_height, + double max_requested_frame_rate, const VideoCaptureDeviceFormatsCB& callback) { DCHECK(CalledOnValidThread()); DVLOG(3) << "PpFrameWriter::GetCurrentSupportedFormats()"; diff --git a/content/renderer/media/webrtc/video_destination_handler.h b/content/renderer/media/webrtc/video_destination_handler.h index e84fdd6..fa558a9 100644 --- a/content/renderer/media/webrtc/video_destination_handler.h +++ b/content/renderer/media/webrtc/video_destination_handler.h @@ -52,6 +52,7 @@ class CONTENT_EXPORT PpFrameWriter virtual void GetCurrentSupportedFormats( int max_requested_width, int max_requested_height, + double max_requested_frame_rate, const VideoCaptureDeviceFormatsCB& callback) OVERRIDE; virtual void StartSourceImpl( const media::VideoCaptureParams& params, @@ -89,4 +90,3 @@ class CONTENT_EXPORT VideoDestinationHandler { } // namespace content #endif // CONTENT_RENDERER_MEDIA_VIDEO_DESTINATION_HANDLER_H_ - diff --git a/content/renderer/pepper/pepper_media_stream_video_track_host.cc b/content/renderer/pepper/pepper_media_stream_video_track_host.cc index 5df6f2d..604d827 100644 --- a/content/renderer/pepper/pepper_media_stream_video_track_host.cc +++ b/content/renderer/pepper/pepper_media_stream_video_track_host.cc @@ -426,6 +426,7 @@ void PepperMediaStreamVideoTrackHost::OnVideoFrame( void PepperMediaStreamVideoTrackHost::GetCurrentSupportedFormats( int max_requested_width, int max_requested_height, + double max_requested_frame_rate, const VideoCaptureDeviceFormatsCB& callback) { if (type_ != kWrite) { DVLOG(1) << "GetCurrentSupportedFormats is only supported in output mode."; diff --git a/content/renderer/pepper/pepper_media_stream_video_track_host.h b/content/renderer/pepper/pepper_media_stream_video_track_host.h index 178eaef..b51f3ea 100644 --- a/content/renderer/pepper/pepper_media_stream_video_track_host.h +++ b/content/renderer/pepper/pepper_media_stream_video_track_host.h @@ -63,6 +63,7 @@ class PepperMediaStreamVideoTrackHost : public PepperMediaStreamTrackHostBase, virtual void GetCurrentSupportedFormats( int max_requested_width, int max_requested_height, + double max_requested_frame_rate, const VideoCaptureDeviceFormatsCB& callback) OVERRIDE; virtual void StartSourceImpl( |