| 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/browser/renderer_host/media/video_capture_controller.h" | 5 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <map> | 10 #include <map> |
| (...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 141 media::VideoFrameConsumerFeedbackObserver::kNoUtilizationRecorded; | 141 media::VideoFrameConsumerFeedbackObserver::kNoUtilizationRecorded; |
| 142 } | 142 } |
| 143 } | 143 } |
| 144 | 144 |
| 145 bool VideoCaptureController::BufferState::HasZeroConsumerHoldCount() { | 145 bool VideoCaptureController::BufferState::HasZeroConsumerHoldCount() { |
| 146 return consumer_hold_count_ == 0; | 146 return consumer_hold_count_ == 0; |
| 147 } | 147 } |
| 148 | 148 |
| 149 void VideoCaptureController::BufferState::SetConsumerFeedbackObserver( | 149 void VideoCaptureController::BufferState::SetConsumerFeedbackObserver( |
| 150 media::VideoFrameConsumerFeedbackObserver* consumer_feedback_observer) { | 150 media::VideoFrameConsumerFeedbackObserver* consumer_feedback_observer) { |
| 151 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 151 consumer_feedback_observer_ = consumer_feedback_observer; | 152 consumer_feedback_observer_ = consumer_feedback_observer; |
| 152 } | 153 } |
| 153 | 154 |
| 154 void VideoCaptureController::BufferState::SetFrameBufferPool( | 155 void VideoCaptureController::BufferState::SetFrameBufferPool( |
| 155 media::FrameBufferPool* frame_buffer_pool) { | 156 media::FrameBufferPool* frame_buffer_pool) { |
| 157 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 156 frame_buffer_pool_ = frame_buffer_pool; | 158 frame_buffer_pool_ = frame_buffer_pool; |
| 157 } | 159 } |
| 158 | 160 |
| 159 VideoCaptureController::VideoCaptureController() | 161 VideoCaptureController::VideoCaptureController() |
| 160 : frame_buffer_pool_(nullptr), | 162 : frame_buffer_pool_(nullptr), |
| 161 consumer_feedback_observer_(nullptr), | 163 consumer_feedback_observer_(nullptr), |
| 162 state_(VIDEO_CAPTURE_STATE_STARTED), | 164 state_(VIDEO_CAPTURE_STATE_STARTED), |
| 163 has_received_frames_(false), | 165 has_received_frames_(false), |
| 164 weak_ptr_factory_(this) { | 166 weak_ptr_factory_(this) { |
| 165 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 167 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| (...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 const media::VideoCaptureFormat& | 367 const media::VideoCaptureFormat& |
| 366 VideoCaptureController::GetVideoCaptureFormat() const { | 368 VideoCaptureController::GetVideoCaptureFormat() const { |
| 367 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 369 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 368 return video_capture_format_; | 370 return video_capture_format_; |
| 369 } | 371 } |
| 370 | 372 |
| 371 void VideoCaptureController::OnIncomingCapturedVideoFrame( | 373 void VideoCaptureController::OnIncomingCapturedVideoFrame( |
| 372 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer, | 374 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer, |
| 373 scoped_refptr<VideoFrame> frame) { | 375 scoped_refptr<VideoFrame> frame) { |
| 374 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 376 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 375 DCHECK(frame_buffer_pool_); | 377 if (!frame_buffer_pool_) |
| 378 return; |
| 379 |
| 376 const int buffer_id = buffer->id(); | 380 const int buffer_id = buffer->id(); |
| 377 DCHECK_NE(buffer_id, media::VideoCaptureBufferPool::kInvalidId); | 381 DCHECK_NE(buffer_id, media::VideoCaptureBufferPool::kInvalidId); |
| 378 | 382 |
| 379 // Insert if not exists. | 383 // Insert if not exists. |
| 380 const auto it = | 384 const auto it = |
| 381 buffer_id_to_state_map_ | 385 buffer_id_to_state_map_ |
| 382 .insert(std::make_pair( | 386 .insert(std::make_pair( |
| 383 buffer_id, BufferState(buffer_id, buffer->frame_feedback_id(), | 387 buffer_id, BufferState(buffer_id, buffer->frame_feedback_id(), |
| 384 consumer_feedback_observer_.get(), | 388 consumer_feedback_observer_.get(), |
| 385 frame_buffer_pool_.get(), frame))) | 389 frame_buffer_pool_.get(), frame))) |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 468 } | 472 } |
| 469 } | 473 } |
| 470 | 474 |
| 471 void VideoCaptureController::OnLog(const std::string& message) { | 475 void VideoCaptureController::OnLog(const std::string& message) { |
| 472 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 476 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 473 MediaStreamManager::SendMessageToNativeLog("Video capture: " + message); | 477 MediaStreamManager::SendMessageToNativeLog("Video capture: " + message); |
| 474 } | 478 } |
| 475 | 479 |
| 476 void VideoCaptureController::OnBufferDestroyed(int buffer_id_to_drop) { | 480 void VideoCaptureController::OnBufferDestroyed(int buffer_id_to_drop) { |
| 477 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 481 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 478 DCHECK(frame_buffer_pool_); | |
| 479 | 482 |
| 480 for (const auto& client : controller_clients_) { | 483 for (const auto& client : controller_clients_) { |
| 481 if (client->session_closed) | 484 if (client->session_closed) |
| 482 continue; | 485 continue; |
| 483 | 486 |
| 484 auto known_buffers_entry_iter = | 487 auto known_buffers_entry_iter = |
| 485 std::find(std::begin(client->known_buffers), | 488 std::find(std::begin(client->known_buffers), |
| 486 std::end(client->known_buffers), buffer_id_to_drop); | 489 std::end(client->known_buffers), buffer_id_to_drop); |
| 487 if (known_buffers_entry_iter != std::end(client->known_buffers)) { | 490 if (known_buffers_entry_iter != std::end(client->known_buffers)) { |
| 488 client->known_buffers.erase(known_buffers_entry_iter); | 491 client->known_buffers.erase(known_buffers_entry_iter); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 524 int session_id, | 527 int session_id, |
| 525 const ControllerClients& clients) { | 528 const ControllerClients& clients) { |
| 526 for (const auto& client : clients) { | 529 for (const auto& client : clients) { |
| 527 if (client->session_id == session_id) | 530 if (client->session_id == session_id) |
| 528 return client.get(); | 531 return client.get(); |
| 529 } | 532 } |
| 530 return nullptr; | 533 return nullptr; |
| 531 } | 534 } |
| 532 | 535 |
| 533 } // namespace content | 536 } // namespace content |
| OLD | NEW |