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/browser/renderer_host/media/video_capture_controller.h" | 5 #include "content/browser/renderer_host/media/video_capture_controller.h" |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <set> | 8 #include <set> |
| 9 | 9 |
| 10 #include "base/bind.h" | 10 #include "base/bind.h" |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 21 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 22 #include "gpu/command_buffer/common/mailbox_holder.h" | 22 #include "gpu/command_buffer/common/mailbox_holder.h" |
| 23 #include "media/base/video_frame.h" | 23 #include "media/base/video_frame.h" |
| 24 | 24 |
| 25 #if !defined(OS_ANDROID) | 25 #if !defined(OS_ANDROID) |
| 26 #include "content/browser/compositor/image_transport_factory.h" | 26 #include "content/browser/compositor/image_transport_factory.h" |
| 27 #endif | 27 #endif |
| 28 | 28 |
| 29 using media::VideoCaptureFormat; | 29 using media::VideoCaptureFormat; |
| 30 using media::VideoFrame; | 30 using media::VideoFrame; |
| 31 using media::VideoFrameMetadata; | |
| 31 | 32 |
| 32 namespace content { | 33 namespace content { |
| 33 | 34 |
| 34 namespace { | 35 namespace { |
| 35 | 36 |
| 36 static const int kInfiniteRatio = 99999; | 37 static const int kInfiniteRatio = 99999; |
| 37 | 38 |
| 38 #define UMA_HISTOGRAM_ASPECT_RATIO(name, width, height) \ | 39 #define UMA_HISTOGRAM_ASPECT_RATIO(name, width, height) \ |
| 39 UMA_HISTOGRAM_SPARSE_SLOWLY( \ | 40 UMA_HISTOGRAM_SPARSE_SLOWLY( \ |
| 40 name, \ | 41 name, \ |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 227 if (client) { | 228 if (client) { |
| 228 client->session_closed = true; | 229 client->session_closed = true; |
| 229 client->event_handler->OnEnded(client->controller_id); | 230 client->event_handler->OnEnded(client->controller_id); |
| 230 } | 231 } |
| 231 } | 232 } |
| 232 | 233 |
| 233 void VideoCaptureController::ReturnBuffer( | 234 void VideoCaptureController::ReturnBuffer( |
| 234 VideoCaptureControllerID id, | 235 VideoCaptureControllerID id, |
| 235 VideoCaptureControllerEventHandler* event_handler, | 236 VideoCaptureControllerEventHandler* event_handler, |
| 236 int buffer_id, | 237 int buffer_id, |
| 237 uint32 sync_point) { | 238 uint32 sync_point, |
| 239 double consumer_resource_utilization) { | |
| 238 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 240 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 239 | 241 |
| 240 ControllerClient* client = FindClient(id, event_handler, controller_clients_); | 242 ControllerClient* client = FindClient(id, event_handler, controller_clients_); |
| 241 | 243 |
| 242 // If this buffer is not held by this client, or this client doesn't exist | 244 // If this buffer is not held by this client, or this client doesn't exist |
| 243 // in controller, do nothing. | 245 // in controller, do nothing. |
| 244 ControllerClient::ActiveBufferMap::iterator iter; | 246 ControllerClient::ActiveBufferMap::iterator iter; |
| 245 if (!client || (iter = client->active_buffers.find(buffer_id)) == | 247 if (!client || (iter = client->active_buffers.find(buffer_id)) == |
| 246 client->active_buffers.end()) { | 248 client->active_buffers.end()) { |
| 247 NOTREACHED(); | 249 NOTREACHED(); |
| 248 return; | 250 return; |
| 249 } | 251 } |
| 252 | |
| 253 // Set the RESOURCE_UTILIZATION to the maximum of those provided by each | |
|
hubbe
2015/06/04 22:08:53
This comment is confusing me a bit as it seems to
miu
2015/06/06 00:29:22
There are! :) Throughout the VideoCaptureControl
| |
| 254 // consumer. A producer of the VideoFrame may check this value to make | |
| 255 // quality versus performance trade-off decisions. | |
| 250 scoped_refptr<VideoFrame> frame = iter->second; | 256 scoped_refptr<VideoFrame> frame = iter->second; |
| 257 if (std::isfinite(consumer_resource_utilization) && | |
| 258 consumer_resource_utilization >= 0.0) { | |
| 259 double resource_utilization = -1.0; | |
| 260 if (frame->metadata()->GetDouble(VideoFrameMetadata::RESOURCE_UTILIZATION, | |
| 261 &resource_utilization)) { | |
| 262 frame->metadata()->SetDouble(VideoFrameMetadata::RESOURCE_UTILIZATION, | |
| 263 std::max(consumer_resource_utilization, | |
| 264 resource_utilization)); | |
| 265 } else { | |
| 266 frame->metadata()->SetDouble(VideoFrameMetadata::RESOURCE_UTILIZATION, | |
| 267 consumer_resource_utilization); | |
| 268 } | |
| 269 } | |
| 270 | |
| 251 client->active_buffers.erase(iter); | 271 client->active_buffers.erase(iter); |
| 252 buffer_pool_->RelinquishConsumerHold(buffer_id, 1); | 272 buffer_pool_->RelinquishConsumerHold(buffer_id, 1); |
| 253 | 273 |
| 254 #if defined(OS_ANDROID) | 274 #if defined(OS_ANDROID) |
| 255 DCHECK_EQ(0u, sync_point); | 275 DCHECK_EQ(0u, sync_point); |
| 256 #endif | 276 #endif |
| 257 if (sync_point) | 277 if (sync_point) |
| 258 BrowserThread::PostTask(BrowserThread::UI, | 278 BrowserThread::PostTask(BrowserThread::UI, |
| 259 FROM_HERE, | 279 FROM_HERE, |
| 260 base::Bind(&ReturnVideoFrame, frame, sync_point)); | 280 base::Bind(&ReturnVideoFrame, frame, sync_point)); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 DCHECK_CURRENTLY_ON(BrowserThread::IO); | 433 DCHECK_CURRENTLY_ON(BrowserThread::IO); |
| 414 int active_client_count = 0; | 434 int active_client_count = 0; |
| 415 for (ControllerClient* client : controller_clients_) { | 435 for (ControllerClient* client : controller_clients_) { |
| 416 if (!client->paused) | 436 if (!client->paused) |
| 417 ++active_client_count; | 437 ++active_client_count; |
| 418 } | 438 } |
| 419 return active_client_count; | 439 return active_client_count; |
| 420 } | 440 } |
| 421 | 441 |
| 422 } // namespace content | 442 } // namespace content |
| OLD | NEW |