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

Unified Diff: content/renderer/media/video_capture_impl.cc

Issue 2721113002: getUserMedia: handle the device starting status report. (Closed)
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
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 089fcbc8f8209a7c4dde23c17406fe30ad92787e..8e1548c27a976b7eeabdb016165993395898755e 100644
--- a/content/renderer/media/video_capture_impl.cc
+++ b/content/renderer/media/video_capture_impl.cc
@@ -70,6 +70,7 @@ VideoCaptureImpl::VideoCaptureImpl(media::VideoCaptureSessionId session_id)
video_capture_host_for_testing_(nullptr),
observer_binding_(this),
state_(VIDEO_CAPTURE_STATE_STOPPED),
+ maybe_refresh_frame_(false),
weak_factory_(this) {
io_thread_checker_.DetachFromThread();
@@ -113,9 +114,6 @@ void VideoCaptureImpl::StartCapture(
clients_.count(client_id)) {
DLOG(FATAL) << __func__ << " This client has already started.";
} else {
- // Note: |state_| might not be started at this point. But we tell
- // client that we have started.
- state_update_cb.Run(VIDEO_CAPTURE_STATE_STARTED);
if (state_ == VIDEO_CAPTURE_STATE_STARTED) {
clients_[client_id] = client_info;
// TODO(sheu): Allowing resolution change will require that all
@@ -188,8 +186,13 @@ void VideoCaptureImpl::OnStateChanged(mojom::VideoCaptureState state) {
switch (state) {
case mojom::VideoCaptureState::STARTED:
- // Capture has started in the browser process. Since we have already
- // told all clients that we have started there's nothing to do.
+ state_ = VIDEO_CAPTURE_STATE_STARTED;
+ for (const auto& client : clients_)
+ client.second.state_update_cb.Run(VIDEO_CAPTURE_STATE_STARTED);
+ if (maybe_refresh_frame_) {
+ RequestRefreshFrame();
+ maybe_refresh_frame_ = false;
+ }
break;
case mojom::VideoCaptureState::STOPPED:
state_ = VIDEO_CAPTURE_STATE_STOPPED;
@@ -228,9 +231,6 @@ void VideoCaptureImpl::OnBufferCreated(int32_t buffer_id,
DCHECK(io_thread_checker_.CalledOnValidThread());
DCHECK(handle.is_valid());
- if (state_ != VIDEO_CAPTURE_STATE_STARTED)
- return;
-
base::SharedMemoryHandle memory_handle;
size_t memory_size = 0;
bool read_only_flag = false;
@@ -260,6 +260,8 @@ void VideoCaptureImpl::OnBufferReady(int32_t buffer_id,
DCHECK(io_thread_checker_.CalledOnValidThread());
bool consume_buffer = state_ == VIDEO_CAPTURE_STATE_STARTED;
+ if (!consume_buffer && first_frame_ref_time_.is_null())
+ maybe_refresh_frame_ = true;
if ((info->pixel_format != media::PIXEL_FORMAT_I420 &&
info->pixel_format != media::PIXEL_FORMAT_Y16) ||
info->storage_type != media::PIXEL_STORAGE_CPU) {
@@ -382,7 +384,6 @@ void VideoCaptureImpl::StartCaptureInternal() {
GetVideoCaptureHost()->Start(device_id_, session_id_, params_,
observer_binding_.CreateInterfacePtrAndBind());
- state_ = VIDEO_CAPTURE_STATE_STARTED;
}
void VideoCaptureImpl::OnDeviceSupportedFormats(

Powered by Google App Engine
This is Rietveld 408576698