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

Side by Side Diff: content/browser/renderer_host/media/video_capture_controller.cc

Issue 2442193002: Removing gpu::SyncToken usage from video capture pipeline, part 1.
Patch Set: Removing gpu::SyncToken usage from video capture pipeline, part 2. Created 4 years, 1 month 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 unified diff | Download patch
OLDNEW
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 28 matching lines...) Expand all
39 39
40 namespace { 40 namespace {
41 41
42 static const int kInfiniteRatio = 99999; 42 static const int kInfiniteRatio = 99999;
43 43
44 #define UMA_HISTOGRAM_ASPECT_RATIO(name, width, height) \ 44 #define UMA_HISTOGRAM_ASPECT_RATIO(name, width, height) \
45 UMA_HISTOGRAM_SPARSE_SLOWLY( \ 45 UMA_HISTOGRAM_SPARSE_SLOWLY( \
46 name, \ 46 name, \
47 (height) ? ((width) * 100) / (height) : kInfiniteRatio); 47 (height) ? ((width) * 100) / (height) : kInfiniteRatio);
48 48
49 class SyncTokenClientImpl : public VideoFrame::SyncTokenClient { 49 class SyncTokenClientImpl : public VideoFrame::SyncTokenClient {
emircan 2016/10/24 21:45:28 Remove this class as well.
50 public: 50 public:
51 explicit SyncTokenClientImpl(display_compositor::GLHelper* gl_helper) 51 explicit SyncTokenClientImpl(display_compositor::GLHelper* gl_helper)
52 : gl_helper_(gl_helper) {} 52 : gl_helper_(gl_helper) {}
53 ~SyncTokenClientImpl() override {} 53 ~SyncTokenClientImpl() override {}
54 void GenerateSyncToken(gpu::SyncToken* sync_token) override { 54 void GenerateSyncToken(gpu::SyncToken* sync_token) override {
55 gl_helper_->GenerateSyncToken(sync_token); 55 gl_helper_->GenerateSyncToken(sync_token);
56 } 56 }
57 void WaitSyncToken(const gpu::SyncToken& sync_token) override { 57 void WaitSyncToken(const gpu::SyncToken& sync_token) override {
58 gl_helper_->WaitSyncToken(sync_token); 58 gl_helper_->WaitSyncToken(sync_token);
59 } 59 }
60 60
61 private: 61 private:
62 display_compositor::GLHelper* gl_helper_; 62 display_compositor::GLHelper* gl_helper_;
63 }; 63 };
64 64
65 void ReturnVideoFrame(const scoped_refptr<VideoFrame>& video_frame, 65 void ReturnVideoFrame(const scoped_refptr<VideoFrame>& video_frame,
emircan 2016/10/24 21:45:28 Remove this method as well.
66 const gpu::SyncToken& sync_token) { 66 const gpu::SyncToken& sync_token) {
67 DCHECK_CURRENTLY_ON(BrowserThread::UI); 67 DCHECK_CURRENTLY_ON(BrowserThread::UI);
68 #if defined(OS_ANDROID) 68 #if defined(OS_ANDROID)
69 NOTREACHED(); 69 NOTREACHED();
70 #else 70 #else
71 display_compositor::GLHelper* gl_helper = 71 display_compositor::GLHelper* gl_helper =
72 ImageTransportFactory::GetInstance()->GetGLHelper(); 72 ImageTransportFactory::GetInstance()->GetGLHelper();
73 // UpdateReleaseSyncToken() creates a new sync_token using |gl_helper|, so 73 // UpdateReleaseSyncToken() creates a new sync_token using |gl_helper|, so
74 // wait the given |sync_token| using |gl_helper|. 74 // wait the given |sync_token| using |gl_helper|.
75 if (gl_helper) { 75 if (gl_helper) {
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
342 if (client) { 342 if (client) {
343 client->session_closed = true; 343 client->session_closed = true;
344 client->event_handler->OnEnded(client->controller_id); 344 client->event_handler->OnEnded(client->controller_id);
345 } 345 }
346 } 346 }
347 347
348 void VideoCaptureController::ReturnBuffer( 348 void VideoCaptureController::ReturnBuffer(
349 VideoCaptureControllerID id, 349 VideoCaptureControllerID id,
350 VideoCaptureControllerEventHandler* event_handler, 350 VideoCaptureControllerEventHandler* event_handler,
351 int buffer_id, 351 int buffer_id,
352 const gpu::SyncToken& sync_token,
353 double consumer_resource_utilization) { 352 double consumer_resource_utilization) {
354 DCHECK_CURRENTLY_ON(BrowserThread::IO); 353 DCHECK_CURRENTLY_ON(BrowserThread::IO);
355 354
356 ControllerClient* client = FindClient(id, event_handler, controller_clients_); 355 ControllerClient* client = FindClient(id, event_handler, controller_clients_);
357 356
358 // If this buffer is not held by this client, or this client doesn't exist 357 // If this buffer is not held by this client, or this client doesn't exist
359 // in controller, do nothing. 358 // in controller, do nothing.
360 ControllerClient::ActiveBufferMap::iterator iter; 359 ControllerClient::ActiveBufferMap::iterator iter;
361 if (!client || (iter = client->active_buffers.find(buffer_id)) == 360 if (!client || (iter = client->active_buffers.find(buffer_id)) ==
362 client->active_buffers.end()) { 361 client->active_buffers.end()) {
(...skipping 16 matching lines...) Expand all
379 std::max(consumer_resource_utilization, 378 std::max(consumer_resource_utilization,
380 resource_utilization)); 379 resource_utilization));
381 } else { 380 } else {
382 frame->metadata()->SetDouble(VideoFrameMetadata::RESOURCE_UTILIZATION, 381 frame->metadata()->SetDouble(VideoFrameMetadata::RESOURCE_UTILIZATION,
383 consumer_resource_utilization); 382 consumer_resource_utilization);
384 } 383 }
385 } 384 }
386 385
387 client->active_buffers.erase(iter); 386 client->active_buffers.erase(iter);
388 buffer_pool_->RelinquishConsumerHold(buffer_id, 1); 387 buffer_pool_->RelinquishConsumerHold(buffer_id, 1);
389
390 #if defined(OS_ANDROID)
391 DCHECK(!sync_token.HasData());
392 #endif
393 if (sync_token.HasData())
394 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE,
395 base::Bind(&ReturnVideoFrame, frame, sync_token));
396 } 388 }
397 389
398 const media::VideoCaptureFormat& 390 const media::VideoCaptureFormat&
399 VideoCaptureController::GetVideoCaptureFormat() const { 391 VideoCaptureController::GetVideoCaptureFormat() const {
400 DCHECK_CURRENTLY_ON(BrowserThread::IO); 392 DCHECK_CURRENTLY_ON(BrowserThread::IO);
401 return video_capture_format_; 393 return video_capture_format_;
402 } 394 }
403 395
404 VideoCaptureController::~VideoCaptureController() { 396 VideoCaptureController::~VideoCaptureController() {
405 } 397 }
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 int session_id, 526 int session_id,
535 const ControllerClients& clients) { 527 const ControllerClients& clients) {
536 for (const auto& client : clients) { 528 for (const auto& client : clients) {
537 if (client->session_id == session_id) 529 if (client->session_id == session_id)
538 return client.get(); 530 return client.get();
539 } 531 }
540 return nullptr; 532 return nullptr;
541 } 533 }
542 534
543 } // namespace content 535 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698