Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(348)

Side by Side Diff: content/renderer/media/media_stream_video_capturer_source.cc

Issue 442643002: Allow MediaStream constraints to specify higher than 30 FPS tab capture. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix compile whoops. Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_capturer_source.h" 5 #include "content/renderer/media/media_stream_video_capturer_source.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/callback_helpers.h" 8 #include "base/callback_helpers.h"
9 #include "base/location.h" 9 #include "base/location.h"
10 #include "content/renderer/media/video_capture_impl_manager.h" 10 #include "content/renderer/media/video_capture_impl_manager.h"
(...skipping 12 matching lines...) Expand all
23 const SourceVideoResolution kVideoResolutions[] = {{1920, 1080}, 23 const SourceVideoResolution kVideoResolutions[] = {{1920, 1080},
24 {1280, 720}, 24 {1280, 720},
25 {960, 720}, 25 {960, 720},
26 {640, 480}, 26 {640, 480},
27 {640, 360}, 27 {640, 360},
28 {320, 240}, 28 {320, 240},
29 {320, 180}}; 29 {320, 180}};
30 // Frame rates for sources with no support for capability enumeration. 30 // Frame rates for sources with no support for capability enumeration.
31 const int kVideoFrameRates[] = {30, 60}; 31 const int kVideoFrameRates[] = {30, 60};
32 32
33 // Hard upper-bound frame rate for tab/desktop capture.
34 const double kMaxScreenCastFrameRate = 120.0;
35
33 } // namespace 36 } // namespace
34 37
35 namespace content { 38 namespace content {
36 39
37 VideoCapturerDelegate::VideoCapturerDelegate( 40 VideoCapturerDelegate::VideoCapturerDelegate(
38 const StreamDeviceInfo& device_info) 41 const StreamDeviceInfo& device_info)
39 : session_id_(device_info.session_id), 42 : session_id_(device_info.session_id),
40 is_screen_cast_(device_info.device.type == MEDIA_TAB_VIDEO_CAPTURE || 43 is_screen_cast_(device_info.device.type == MEDIA_TAB_VIDEO_CAPTURE ||
41 device_info.device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { 44 device_info.device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) {
42 DVLOG(3) << "VideoCapturerDelegate::ctor"; 45 DVLOG(3) << "VideoCapturerDelegate::ctor";
43 46
44 // NULL in unit test. 47 // NULL in unit test.
45 if (RenderThreadImpl::current()) { 48 if (RenderThreadImpl::current()) {
46 VideoCaptureImplManager* manager = 49 VideoCaptureImplManager* manager =
47 RenderThreadImpl::current()->video_capture_impl_manager(); 50 RenderThreadImpl::current()->video_capture_impl_manager();
48 if (manager) 51 if (manager)
49 release_device_cb_ = manager->UseDevice(session_id_); 52 release_device_cb_ = manager->UseDevice(session_id_);
50 } 53 }
51 } 54 }
52 55
53 VideoCapturerDelegate::~VideoCapturerDelegate() { 56 VideoCapturerDelegate::~VideoCapturerDelegate() {
54 DVLOG(3) << "VideoCapturerDelegate::dtor"; 57 DVLOG(3) << "VideoCapturerDelegate::dtor";
55 if (!release_device_cb_.is_null()) 58 if (!release_device_cb_.is_null())
56 release_device_cb_.Run(); 59 release_device_cb_.Run();
57 } 60 }
58 61
59 void VideoCapturerDelegate::GetCurrentSupportedFormats( 62 void VideoCapturerDelegate::GetCurrentSupportedFormats(
60 int max_requested_width, 63 int max_requested_width,
61 int max_requested_height, 64 int max_requested_height,
65 double max_requested_frame_rate,
62 const VideoCaptureDeviceFormatsCB& callback) { 66 const VideoCaptureDeviceFormatsCB& callback) {
63 DVLOG(3) << "GetCurrentSupportedFormats(" 67 DVLOG(3)
64 << " { max_requested_height = " << max_requested_height << "})" 68 << "GetCurrentSupportedFormats("
65 << " { max_requested_width = " << max_requested_width << "})"; 69 << " { max_requested_height = " << max_requested_height << "})"
70 << " { max_requested_width = " << max_requested_width << "})"
71 << " { max_requested_frame_rate = " << max_requested_frame_rate << "})";
66 72
67 if (is_screen_cast_) { 73 if (is_screen_cast_) {
68 media::VideoCaptureFormats formats;
69 const int width = max_requested_width ? 74 const int width = max_requested_width ?
70 max_requested_width : MediaStreamVideoSource::kDefaultWidth; 75 max_requested_width : MediaStreamVideoSource::kDefaultWidth;
71 const int height = max_requested_height ? 76 const int height = max_requested_height ?
72 max_requested_height : MediaStreamVideoSource::kDefaultHeight; 77 max_requested_height : MediaStreamVideoSource::kDefaultHeight;
73 formats.push_back( 78 callback.Run(media::VideoCaptureFormats(1, media::VideoCaptureFormat(
74 media::VideoCaptureFormat( 79 gfx::Size(width, height),
75 gfx::Size(width, height), 80 static_cast<float>(std::min(kMaxScreenCastFrameRate,
76 MediaStreamVideoSource::kDefaultFrameRate, 81 max_requested_frame_rate)),
77 media::PIXEL_FORMAT_I420)); 82 media::PIXEL_FORMAT_I420)));
78 callback.Run(formats);
79 return; 83 return;
80 } 84 }
81 85
82 // NULL in unit test. 86 // NULL in unit test.
83 if (!RenderThreadImpl::current()) 87 if (!RenderThreadImpl::current())
84 return; 88 return;
85 VideoCaptureImplManager* manager = 89 VideoCaptureImplManager* manager =
86 RenderThreadImpl::current()->video_capture_impl_manager(); 90 RenderThreadImpl::current()->video_capture_impl_manager();
87 if (!manager) 91 if (!manager)
88 return; 92 return;
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 SetDeviceInfo(device_info); 213 SetDeviceInfo(device_info);
210 SetStopCallback(stop_callback); 214 SetStopCallback(stop_callback);
211 } 215 }
212 216
213 MediaStreamVideoCapturerSource::~MediaStreamVideoCapturerSource() { 217 MediaStreamVideoCapturerSource::~MediaStreamVideoCapturerSource() {
214 } 218 }
215 219
216 void MediaStreamVideoCapturerSource::GetCurrentSupportedFormats( 220 void MediaStreamVideoCapturerSource::GetCurrentSupportedFormats(
217 int max_requested_width, 221 int max_requested_width,
218 int max_requested_height, 222 int max_requested_height,
223 double max_requested_frame_rate,
219 const VideoCaptureDeviceFormatsCB& callback) { 224 const VideoCaptureDeviceFormatsCB& callback) {
220 delegate_->GetCurrentSupportedFormats( 225 delegate_->GetCurrentSupportedFormats(
221 max_requested_width, 226 max_requested_width,
222 max_requested_height, 227 max_requested_height,
228 max_requested_frame_rate,
223 callback); 229 callback);
224 } 230 }
225 231
226 void MediaStreamVideoCapturerSource::StartSourceImpl( 232 void MediaStreamVideoCapturerSource::StartSourceImpl(
227 const media::VideoCaptureParams& params, 233 const media::VideoCaptureParams& params,
228 const VideoCaptureDeliverFrameCB& frame_callback) { 234 const VideoCaptureDeliverFrameCB& frame_callback) {
229 media::VideoCaptureParams new_params(params); 235 media::VideoCaptureParams new_params(params);
230 if (device_info().device.type == MEDIA_TAB_VIDEO_CAPTURE || 236 if (device_info().device.type == MEDIA_TAB_VIDEO_CAPTURE ||
231 device_info().device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) { 237 device_info().device.type == MEDIA_DESKTOP_VIDEO_CAPTURE) {
232 new_params.allow_resolution_change = true; 238 new_params.allow_resolution_change = true;
233 } 239 }
234 delegate_->StartCapture( 240 delegate_->StartCapture(
235 new_params, 241 new_params,
236 frame_callback, 242 frame_callback,
237 base::Bind(&MediaStreamVideoCapturerSource::OnStartDone, 243 base::Bind(&MediaStreamVideoCapturerSource::OnStartDone,
238 base::Unretained(this))); 244 base::Unretained(this)));
239 } 245 }
240 246
241 void MediaStreamVideoCapturerSource::StopSourceImpl() { 247 void MediaStreamVideoCapturerSource::StopSourceImpl() {
242 delegate_->StopCapture(); 248 delegate_->StopCapture();
243 } 249 }
244 250
245 } // namespace content 251 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_video_capturer_source.h ('k') | content/renderer/media/media_stream_video_source.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698