Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/video_capture_impl.h" | 5 #include "content/renderer/media/video_capture_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/stl_util.h" | 8 #include "base/stl_util.h" |
| 9 #include "content/common/child_process.h" | 9 #include "content/common/child_process.h" |
| 10 #include "content/common/media/video_capture_messages.h" | 10 #include "content/common/media/video_capture_messages.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 51 base::MessageLoopProxy* capture_message_loop_proxy, | 51 base::MessageLoopProxy* capture_message_loop_proxy, |
| 52 VideoCaptureMessageFilter* filter) | 52 VideoCaptureMessageFilter* filter) |
| 53 : VideoCapture(), | 53 : VideoCapture(), |
| 54 message_filter_(filter), | 54 message_filter_(filter), |
| 55 capture_message_loop_proxy_(capture_message_loop_proxy), | 55 capture_message_loop_proxy_(capture_message_loop_proxy), |
| 56 io_message_loop_proxy_(ChildProcess::current()->io_message_loop_proxy()), | 56 io_message_loop_proxy_(ChildProcess::current()->io_message_loop_proxy()), |
| 57 device_id_(0), | 57 device_id_(0), |
| 58 video_type_(media::VideoCaptureCapability::kI420), | 58 video_type_(media::VideoCaptureCapability::kI420), |
| 59 device_info_available_(false), | 59 device_info_available_(false), |
| 60 suspended_(false), | 60 suspended_(false), |
| 61 encoding_supported_(false), | |
| 61 state_(VIDEO_CAPTURE_STATE_STOPPED) { | 62 state_(VIDEO_CAPTURE_STATE_STOPPED) { |
| 62 DCHECK(filter); | 63 DCHECK(filter); |
| 63 memset(¤t_params_, 0, sizeof(current_params_)); | 64 memset(¤t_params_, 0, sizeof(current_params_)); |
| 64 memset(&device_info_, 0, sizeof(device_info_)); | 65 memset(&device_info_, 0, sizeof(device_info_)); |
| 65 current_params_.session_id = id; | 66 current_params_.session_id = id; |
| 66 } | 67 } |
| 67 | 68 |
| 68 VideoCaptureImpl::~VideoCaptureImpl() { | 69 VideoCaptureImpl::~VideoCaptureImpl() { |
| 69 STLDeleteValues(&cached_dibs_); | 70 STLDeleteValues(&cached_dibs_); |
| 70 } | 71 } |
| (...skipping 23 matching lines...) Expand all Loading... | |
| 94 base::Bind(&VideoCaptureImpl::DoStartCaptureOnCaptureThread, | 95 base::Bind(&VideoCaptureImpl::DoStartCaptureOnCaptureThread, |
| 95 base::Unretained(this), handler, capability)); | 96 base::Unretained(this), handler, capability)); |
| 96 } | 97 } |
| 97 | 98 |
| 98 void VideoCaptureImpl::StopCapture(media::VideoCapture::EventHandler* handler) { | 99 void VideoCaptureImpl::StopCapture(media::VideoCapture::EventHandler* handler) { |
| 99 capture_message_loop_proxy_->PostTask(FROM_HERE, | 100 capture_message_loop_proxy_->PostTask(FROM_HERE, |
| 100 base::Bind(&VideoCaptureImpl::DoStopCaptureOnCaptureThread, | 101 base::Bind(&VideoCaptureImpl::DoStopCaptureOnCaptureThread, |
| 101 base::Unretained(this), handler)); | 102 base::Unretained(this), handler)); |
| 102 } | 103 } |
| 103 | 104 |
| 105 media::EncodedVideoSource* VideoCaptureImpl::GetEncodedVideoSource() { | |
| 106 return this; | |
|
Ami GONE FROM CHROMIUM
2013/06/08 00:18:01
shouldn't this be conditionalized on encoding_supp
hshi1
2013/06/11 19:51:22
Got rid of this.
| |
| 107 } | |
| 108 | |
| 109 void VideoCaptureImpl::OnCapabilityAvailable( | |
| 110 const media::VideoEncodingCapability& capability) { | |
| 111 CapturedEncodedVideoSourceImpl::OnCapabilityAvailable(capability); | |
|
Ami GONE FROM CHROMIUM
2013/06/08 00:18:01
having to write l.109-139 is usually a code smell
hshi1
2013/06/11 19:51:22
I've flattened the VCImpl - CapturedEncodedVideoCa
| |
| 112 } | |
| 113 | |
| 114 void VideoCaptureImpl::OnBitstreamCreated( | |
| 115 int stream_id, | |
| 116 const media::VideoEncodingParameters& params, | |
| 117 const std::map<int, base::SharedMemoryHandle>& buffers) { | |
| 118 CapturedEncodedVideoSourceImpl::OnBitstreamCreated( | |
| 119 stream_id, params, buffers); | |
| 120 } | |
| 121 | |
| 122 void VideoCaptureImpl::OnBitstreamDestroyed(int stream_id) { | |
| 123 CapturedEncodedVideoSourceImpl::OnBitstreamDestroyed(stream_id); | |
| 124 } | |
| 125 | |
| 126 void VideoCaptureImpl::OnBitstreamConfigChanged( | |
| 127 int stream_id, | |
| 128 const media::RuntimeVideoEncodingParameters& params) { | |
| 129 CapturedEncodedVideoSourceImpl::OnBitstreamConfigChanged(stream_id, params); | |
| 130 } | |
| 131 | |
| 132 void VideoCaptureImpl::OnBitstreamReady( | |
| 133 int stream_id, | |
| 134 int buffer_id, | |
| 135 size_t size, | |
| 136 const media::BufferEncodingMetadata& metadata) { | |
| 137 CapturedEncodedVideoSourceImpl::OnBitstreamReady( | |
| 138 stream_id, buffer_id, size, metadata); | |
| 139 } | |
| 140 | |
| 141 int VideoCaptureImpl::device_id() { | |
| 142 return device_id_; | |
| 143 } | |
| 144 | |
| 145 scoped_refptr<base::MessageLoopProxy> VideoCaptureImpl::app_loop_proxy() { | |
| 146 return capture_message_loop_proxy_; | |
| 147 } | |
| 148 | |
| 149 scoped_refptr<base::MessageLoopProxy> VideoCaptureImpl::io_loop_proxy() { | |
| 150 return io_message_loop_proxy_; | |
| 151 } | |
| 152 | |
| 104 void VideoCaptureImpl::FeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) { | 153 void VideoCaptureImpl::FeedBuffer(scoped_refptr<VideoFrameBuffer> buffer) { |
| 105 capture_message_loop_proxy_->PostTask(FROM_HERE, | 154 capture_message_loop_proxy_->PostTask(FROM_HERE, |
| 106 base::Bind(&VideoCaptureImpl::DoFeedBufferOnCaptureThread, | 155 base::Bind(&VideoCaptureImpl::DoFeedBufferOnCaptureThread, |
| 107 base::Unretained(this), buffer)); | 156 base::Unretained(this), buffer)); |
| 108 } | 157 } |
| 109 | 158 |
| 110 void VideoCaptureImpl::OnBufferCreated( | 159 void VideoCaptureImpl::OnBufferCreated( |
| 111 base::SharedMemoryHandle handle, | 160 base::SharedMemoryHandle handle, |
| 112 int length, int buffer_id) { | 161 int length, int buffer_id) { |
| 113 capture_message_loop_proxy_->PostTask(FROM_HERE, | 162 capture_message_loop_proxy_->PostTask(FROM_HERE, |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 299 it->first->OnBufferReady(this, buffer); | 348 it->first->OnBufferReady(this, buffer); |
| 300 } | 349 } |
| 301 cached_dibs_[buffer_id]->references = clients_.size(); | 350 cached_dibs_[buffer_id]->references = clients_.size(); |
| 302 } | 351 } |
| 303 | 352 |
| 304 void VideoCaptureImpl::DoStateChangedOnCaptureThread(VideoCaptureState state) { | 353 void VideoCaptureImpl::DoStateChangedOnCaptureThread(VideoCaptureState state) { |
| 305 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); | 354 DCHECK(capture_message_loop_proxy_->BelongsToCurrentThread()); |
| 306 | 355 |
| 307 switch (state) { | 356 switch (state) { |
| 308 case VIDEO_CAPTURE_STATE_STARTED: | 357 case VIDEO_CAPTURE_STATE_STARTED: |
| 358 CapturedEncodedVideoSourceImpl::StartFetchCapabilities(); | |
|
Ami GONE FROM CHROMIUM
2013/06/08 00:18:01
why "CapturedEncodedVideoSourceImpl::"?
hshi1
2013/06/11 19:51:22
No longer needed.
| |
| 309 break; | 359 break; |
| 310 case VIDEO_CAPTURE_STATE_STOPPED: | 360 case VIDEO_CAPTURE_STATE_STOPPED: |
| 311 state_ = VIDEO_CAPTURE_STATE_STOPPED; | 361 state_ = VIDEO_CAPTURE_STATE_STOPPED; |
| 312 DVLOG(1) << "OnStateChanged: stopped!, device_id = " << device_id_; | 362 DVLOG(1) << "OnStateChanged: stopped!, device_id = " << device_id_; |
| 313 STLDeleteValues(&cached_dibs_); | 363 STLDeleteValues(&cached_dibs_); |
| 314 if (!clients_.empty() || !clients_pending_on_restart_.empty()) | 364 if (!clients_.empty() || !clients_pending_on_restart_.empty()) |
| 315 RestartCapture(); | 365 RestartCapture(); |
| 316 break; | 366 break; |
| 317 case VIDEO_CAPTURE_STATE_PAUSED: | 367 case VIDEO_CAPTURE_STATE_PAUSED: |
| 318 for (ClientInfo::iterator it = clients_.begin(); | 368 for (ClientInfo::iterator it = clients_.begin(); |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 461 if (it != clients->end()) { | 511 if (it != clients->end()) { |
| 462 handler->OnStopped(this); | 512 handler->OnStopped(this); |
| 463 handler->OnRemoved(this); | 513 handler->OnRemoved(this); |
| 464 clients->erase(it); | 514 clients->erase(it); |
| 465 found = true; | 515 found = true; |
| 466 } | 516 } |
| 467 return found; | 517 return found; |
| 468 } | 518 } |
| 469 | 519 |
| 470 } // namespace content | 520 } // namespace content |
| OLD | NEW |