| 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 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 return video_capture_format_; | 349 return video_capture_format_; |
| 350 } | 350 } |
| 351 | 351 |
| 352 VideoCaptureController::~VideoCaptureController() { | 352 VideoCaptureController::~VideoCaptureController() { |
| 353 STLDeleteContainerPointers(controller_clients_.begin(), | 353 STLDeleteContainerPointers(controller_clients_.begin(), |
| 354 controller_clients_.end()); | 354 controller_clients_.end()); |
| 355 } | 355 } |
| 356 | 356 |
| 357 void VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread( | 357 void VideoCaptureController::DoIncomingCapturedVideoFrameOnIOThread( |
| 358 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer, | 358 std::unique_ptr<media::VideoCaptureDevice::Client::Buffer> buffer, |
| 359 const scoped_refptr<VideoFrame>& frame, | 359 const scoped_refptr<VideoFrame>& frame) { |
| 360 const base::TimeTicks& timestamp) { | |
| 361 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 360 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 362 const int buffer_id = buffer->id(); | 361 const int buffer_id = buffer->id(); |
| 363 DCHECK_NE(buffer_id, VideoCaptureBufferPool::kInvalidId); | 362 DCHECK_NE(buffer_id, VideoCaptureBufferPool::kInvalidId); |
| 364 | 363 |
| 365 int count = 0; | 364 int count = 0; |
| 366 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { | 365 if (state_ == VIDEO_CAPTURE_STATE_STARTED) { |
| 367 if (!frame->metadata()->HasKey(VideoFrameMetadata::FRAME_RATE)) { | 366 if (!frame->metadata()->HasKey(VideoFrameMetadata::FRAME_RATE)) { |
| 368 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, | 367 frame->metadata()->SetDouble(VideoFrameMetadata::FRAME_RATE, |
| 369 video_capture_format_.frame_rate); | 368 video_capture_format_.frame_rate); |
| 370 } | 369 } |
| (...skipping 18 matching lines...) Expand all Loading... |
| 389 | 388 |
| 390 for (const auto& client : controller_clients_) { | 389 for (const auto& client : controller_clients_) { |
| 391 if (client->session_closed || client->paused) | 390 if (client->session_closed || client->paused) |
| 392 continue; | 391 continue; |
| 393 | 392 |
| 394 // On the first use of a buffer on a client, share the memory handles. | 393 // On the first use of a buffer on a client, share the memory handles. |
| 395 const bool is_new_buffer = client->known_buffers.insert(buffer_id).second; | 394 const bool is_new_buffer = client->known_buffers.insert(buffer_id).second; |
| 396 if (is_new_buffer) | 395 if (is_new_buffer) |
| 397 DoNewBufferOnIOThread(client, buffer.get(), frame); | 396 DoNewBufferOnIOThread(client, buffer.get(), frame); |
| 398 | 397 |
| 399 client->event_handler->OnBufferReady(client->controller_id, | 398 client->event_handler->OnBufferReady(client->controller_id, buffer_id, |
| 400 buffer_id, | 399 frame); |
| 401 frame, | |
| 402 timestamp); | |
| 403 const bool inserted = | 400 const bool inserted = |
| 404 client->active_buffers.insert(std::make_pair(buffer_id, frame)) | 401 client->active_buffers.insert(std::make_pair(buffer_id, frame)) |
| 405 .second; | 402 .second; |
| 406 DCHECK(inserted) << "Unexpected duplicate buffer: " << buffer_id; | 403 DCHECK(inserted) << "Unexpected duplicate buffer: " << buffer_id; |
| 407 count++; | 404 count++; |
| 408 } | 405 } |
| 409 } | 406 } |
| 410 | 407 |
| 411 if (!has_received_frames_) { | 408 if (!has_received_frames_) { |
| 412 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.Width", | 409 UMA_HISTOGRAM_COUNTS("Media.VideoCapture.Width", |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 int session_id, | 507 int session_id, |
| 511 const ControllerClients& clients) { | 508 const ControllerClients& clients) { |
| 512 for (auto client : clients) { | 509 for (auto client : clients) { |
| 513 if (client->session_id == session_id) | 510 if (client->session_id == session_id) |
| 514 return client; | 511 return client; |
| 515 } | 512 } |
| 516 return NULL; | 513 return NULL; |
| 517 } | 514 } |
| 518 | 515 |
| 519 } // namespace content | 516 } // namespace content |
| OLD | NEW |