Index: content/renderer/media/media_stream_video_capturer_source.cc |
diff --git a/content/renderer/media/media_stream_video_capturer_source.cc b/content/renderer/media/media_stream_video_capturer_source.cc |
index 722844bdbdf806429d3903c34cbcf552a7296ac5..40af0de46f115ac638379cc45b77ddb7a659f97e 100644 |
--- a/content/renderer/media/media_stream_video_capturer_source.cc |
+++ b/content/renderer/media/media_stream_video_capturer_source.cc |
@@ -74,18 +74,10 @@ void VideoCapturerDelegate::GetCurrentSupportedFormats( |
return; |
} |
- // This delegate implementation doesn't support capability enumeration. |
- // We need to guess what it supports. |
- media::VideoCaptureFormats formats; |
- for (size_t i = 0; i < arraysize(kVideoFormats); ++i) { |
- formats.push_back( |
- media::VideoCaptureFormat( |
- gfx::Size(kVideoFormats[i].width, |
- kVideoFormats[i].height), |
- kVideoFormats[i].frame_rate, |
- media::PIXEL_FORMAT_I420)); |
- } |
- callback.Run(formats); |
+ DCHECK(source_formats_callback_.is_null()); |
+ source_formats_callback_ = callback; |
+ capture_engine_->GetDeviceFormatsInUse(base::Bind( |
+ &VideoCapturerDelegate::OnDeviceFormatsInUseReceived, this)); |
} |
void VideoCapturerDelegate::StartDeliver( |
@@ -111,6 +103,7 @@ void VideoCapturerDelegate::StopDeliver() { |
capture_engine_->StopCapture(this); |
new_frame_callback_.Reset(); |
started_callback_.Reset(); |
+ source_formats_callback_.Reset(); |
} |
void VideoCapturerDelegate::OnStarted(media::VideoCapture* capture) { |
@@ -172,6 +165,42 @@ void VideoCapturerDelegate::OnErrorOnCaptureThread( |
started_callback_.Run(false); |
} |
+void VideoCapturerDelegate::OnDeviceFormatsInUseReceived( |
+ const media::VideoCaptureFormats& formats_in_use) { |
+ DVLOG(3) << "OnDeviceFormatsInUseReceived: " << formats_in_use.size(); |
+ if (!formats_in_use.empty()) { |
+ if (!source_formats_callback_.is_null()) |
+ source_formats_callback_.Run(formats_in_use); |
+ } else { |
+ DCHECK(!source_formats_callback_.is_null()); |
+ // If there are no formats in use, try to retrieve the whole list of them. |
+ capture_engine_->GetDeviceSupportedFormats(base::Bind( |
+ &VideoCapturerDelegate::OnDeviceSupportedFormatsEnumerated, this)); |
+ } |
+} |
+ |
+void VideoCapturerDelegate::OnDeviceSupportedFormatsEnumerated( |
+ const media::VideoCaptureFormats& formats) { |
+ DVLOG(3) << "OnDeviceSupportedFormatsEnumerated: " << formats.size() |
+ << " received"; |
+ if (formats.size()) { |
+ if (!source_formats_callback_.is_null()) |
+ source_formats_callback_.Run(formats); |
+ } else { |
+ // The capture device doesn't seem to support capability enumeration, |
+ // compose a fallback list of capabilities. |
+ media::VideoCaptureFormats default_formats; |
+ for (size_t i = 0; i < arraysize(kVideoFormats); ++i) { |
+ default_formats.push_back(media::VideoCaptureFormat( |
+ gfx::Size(kVideoFormats[i].width, kVideoFormats[i].height), |
+ kVideoFormats[i].frame_rate, |
+ media::PIXEL_FORMAT_I420)); |
+ } |
+ if (!source_formats_callback_.is_null()) |
+ source_formats_callback_.Run(default_formats); |
tommi (sloooow) - chröme
2014/03/13 17:19:38
whenever we call source_formats_callback_.Run(), s
mcasas
2014/03/14 08:06:39
There should only be one call back, so Reset() is
|
+ } |
+} |
+ |
MediaStreamVideoCapturerSource::MediaStreamVideoCapturerSource( |
const StreamDeviceInfo& device_info, |
const SourceStoppedCallback& stop_callback, |