Index: content/renderer/media/video_capture_impl.cc |
diff --git a/content/renderer/media/video_capture_impl.cc b/content/renderer/media/video_capture_impl.cc |
index 8fd24f86b39fa08a7d6d23573af1607e3a6bb226..30b43ddfcf4d41c46782c4b7229a354ab60218b4 100644 |
--- a/content/renderer/media/video_capture_impl.cc |
+++ b/content/renderer/media/video_capture_impl.cc |
@@ -10,6 +10,7 @@ |
#include "content/common/media/video_capture_messages.h" |
#include "media/base/bind_to_loop.h" |
#include "media/base/limits.h" |
+#include "media/base/video_frame.h" |
namespace content { |
@@ -159,24 +160,23 @@ void VideoCaptureImpl::DoStartCaptureOnCaptureThread( |
clients_[handler] = params; |
} else if (state_ == VIDEO_CAPTURE_STATE_STOPPING) { |
clients_pending_on_restart_[handler] = params; |
- DVLOG(1) << "StartCapture: Got new resolution (" |
- << params.requested_format.width << ", " |
- << params.requested_format.height << ") " |
- << ", during stopping."; |
+ DVLOG(1) << "StartCapture: Got new resolution " |
+ << params.requested_format.frame_size.ToString() |
+ << " during stopping."; |
} else { |
- DCHECK_EQ(params.session_id, 0); |
+ // TODO(sheu): Allowing resolution change will require that all |
+ // outstanding clients of a capture session support resolution change. |
+ DCHECK(!params.allow_resolution_change); |
clients_[handler] = params; |
DCHECK_EQ(1ul, clients_.size()); |
params_ = params; |
- params_.session_id = session_id_; |
if (params_.requested_format.frame_rate > |
media::limits::kMaxFramesPerSecond) { |
params_.requested_format.frame_rate = |
media::limits::kMaxFramesPerSecond; |
} |
- DVLOG(1) << "StartCapture: starting with first resolution (" |
- << params_.requested_format.width << "," |
- << params_.requested_format.height << ")"; |
+ DVLOG(1) << "StartCapture: starting with first resolution " |
+ << params_.requested_format.frame_size.ToString(); |
StartCaptureInternal(); |
} |
@@ -252,7 +252,6 @@ void VideoCaptureImpl::DoBufferReceivedOnCaptureThread( |
} |
last_frame_format_ = format; |
- gfx::Size size(format.width, format.height); |
ClientBufferMap::iterator iter = client_buffers_.find(buffer_id); |
DCHECK(iter != client_buffers_.end()); |
@@ -260,9 +259,9 @@ void VideoCaptureImpl::DoBufferReceivedOnCaptureThread( |
scoped_refptr<media::VideoFrame> frame = |
media::VideoFrame::WrapExternalPackedMemory( |
media::VideoFrame::I420, |
- size, |
- gfx::Rect(size), |
- size, |
+ last_frame_format_.frame_size, |
+ gfx::Rect(last_frame_format_.frame_size), |
+ last_frame_format_.frame_size, |
reinterpret_cast<uint8*>(buffer->buffer->memory()), |
buffer->buffer_size, |
buffer->buffer->handle(), |
@@ -360,7 +359,7 @@ void VideoCaptureImpl::StopDevice() { |
if (state_ == VIDEO_CAPTURE_STATE_STARTED) { |
state_ = VIDEO_CAPTURE_STATE_STOPPING; |
Send(new VideoCaptureHostMsg_Stop(device_id_)); |
- params_.requested_format.width = params_.requested_format.height = 0; |
+ params_.requested_format.frame_size.SetSize(0, 0); |
} |
} |
@@ -372,20 +371,19 @@ void VideoCaptureImpl::RestartCapture() { |
int height = 0; |
for (ClientInfo::iterator it = clients_.begin(); |
it != clients_.end(); ++it) { |
- width = std::max(width, it->second.requested_format.width); |
- height = std::max(height, it->second.requested_format.height); |
+ width = std::max(width, it->second.requested_format.frame_size.width()); |
+ height = std::max(height, it->second.requested_format.frame_size.height()); |
} |
for (ClientInfo::iterator it = clients_pending_on_restart_.begin(); |
it != clients_pending_on_restart_.end(); ) { |
- width = std::max(width, it->second.requested_format.width); |
- height = std::max(height, it->second.requested_format.height); |
+ width = std::max(width, it->second.requested_format.frame_size.width()); |
+ height = std::max(height, it->second.requested_format.frame_size.height()); |
clients_[it->first] = it->second; |
clients_pending_on_restart_.erase(it++); |
} |
- params_.requested_format.width = width; |
- params_.requested_format.height = height; |
- DVLOG(1) << "RestartCapture, " << params_.requested_format.width << ", " |
- << params_.requested_format.height; |
+ params_.requested_format.frame_size.SetSize(width, height); |
+ DVLOG(1) << "RestartCapture, " |
+ << params_.requested_format.frame_size.ToString(); |
StartCaptureInternal(); |
} |
@@ -393,7 +391,7 @@ void VideoCaptureImpl::StartCaptureInternal() { |
DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
DCHECK(device_id_); |
- Send(new VideoCaptureHostMsg_Start(device_id_, params_)); |
+ Send(new VideoCaptureHostMsg_Start(device_id_, session_id_, params_)); |
state_ = VIDEO_CAPTURE_STATE_STARTED; |
} |