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..069703a2478175be7eb46a5be51d21e2213f4910 100644 |
--- a/content/renderer/media/media_stream_video_capturer_source.cc |
+++ b/content/renderer/media/media_stream_video_capturer_source.cc |
@@ -20,13 +20,13 @@ struct SourceVideoFormat { |
// List of formats used if the source doesn't support capability enumeration. |
const SourceVideoFormat kVideoFormats[] = { |
- {1920, 1080, 30}, |
- {1280, 720, 30}, |
- {960, 720, 30}, |
- {640, 480, 30}, |
- {640, 360, 30}, |
- {320, 240, 30}, |
- {320, 180, 30} |
+ {1920, 1080, 30}, |
perkj_chrome
2014/03/14 14:29:33
I think the previous indentation was correct excep
mcasas
2014/03/16 10:18:02
Reformatted according to clang-format chromium.
|
+ {1280, 720, 30}, |
+ {960, 720, 30}, |
+ {640, 480, 30}, |
+ {640, 360, 30}, |
+ {320, 240, 30}, |
+ {320, 180, 30} |
}; |
perkj_chrome
2014/03/14 14:29:33
}; should probably be on the previous line.
mcasas
2014/03/16 10:18:02
See above.
|
} // namespace |
@@ -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,45 @@ void VideoCapturerDelegate::OnErrorOnCaptureThread( |
started_callback_.Run(false); |
} |
+void VideoCapturerDelegate::OnDeviceFormatsInUseReceived( |
+ const media::VideoCaptureFormats& formats_in_use) { |
+ DVLOG(3) << "OnDeviceFormatsInUseReceived: " << formats_in_use.size(); |
perkj_chrome
2014/03/14 14:29:33
if (source_formats_callback_.is_null())
return;
mcasas
2014/03/16 10:18:02
Done.
|
+ if (!formats_in_use.empty()) { |
+ if (!source_formats_callback_.is_null()) { |
+ source_formats_callback_.Run(formats_in_use); |
+ source_formats_callback_.Reset(); |
+ } |
+ } else { |
+ DCHECK(!source_formats_callback_.is_null()); |
perkj_chrome
2014/03/14 14:29:33
remove this DCHECK
mcasas
2014/03/16 10:18:02
Done.
|
+ // 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"; |
perkj_chrome
2014/03/14 14:29:33
use early exist
if (source_formats_callback_.is_nu
mcasas
2014/03/16 10:18:02
Done.
|
+ 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); |
+ } |
+ source_formats_callback_.Reset(); |
+} |
+ |
MediaStreamVideoCapturerSource::MediaStreamVideoCapturerSource( |
const StreamDeviceInfo& device_info, |
const SourceStoppedCallback& stop_callback, |