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

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

Issue 312803002: Android media: VideoFrame should not store so many sync points. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address danakj@'s concern Created 6 years, 6 months 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 <map> 7 #include <map>
8 #include <set> 8 #include <set>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 : Buffer(buffer_id, data, size), pool_(pool) { 46 : Buffer(buffer_id, data, size), pool_(pool) {
47 DCHECK(pool_); 47 DCHECK(pool_);
48 } 48 }
49 49
50 private: 50 private:
51 virtual ~PoolBuffer() { pool_->RelinquishProducerReservation(id()); } 51 virtual ~PoolBuffer() { pool_->RelinquishProducerReservation(id()); }
52 52
53 const scoped_refptr<VideoCaptureBufferPool> pool_; 53 const scoped_refptr<VideoCaptureBufferPool> pool_;
54 }; 54 };
55 55
56 class SyncPointProviderImpl : public media::VideoFrame::SyncPointProvider {
57 public:
58 explicit SyncPointProviderImpl(uint32 sync_point) : sync_point_(sync_point) {}
59 virtual ~SyncPointProviderImpl();
60 virtual uint32 InsertSyncPoint();
61 virtual void WaitSyncPoint(uint32 sync_point);
62
63 private:
64 uint32 sync_point_;
65 };
66
67 SyncPointProviderImpl::~SyncPointProviderImpl() {
68 }
69
70 uint32 SyncPointProviderImpl::InsertSyncPoint() {
71 return sync_point_;
72 }
73
74 void SyncPointProviderImpl::WaitSyncPoint(uint32 sync_point) {
danakj 2014/06/19 15:56:26 Why is this ok to drop the current sync point in t
dshwang 2014/06/23 18:33:20 I misunderstood that this file is used by only uni
75 }
76
56 } // anonymous namespace 77 } // anonymous namespace
57 78
58 struct VideoCaptureController::ControllerClient { 79 struct VideoCaptureController::ControllerClient {
59 ControllerClient(const VideoCaptureControllerID& id, 80 ControllerClient(const VideoCaptureControllerID& id,
60 VideoCaptureControllerEventHandler* handler, 81 VideoCaptureControllerEventHandler* handler,
61 base::ProcessHandle render_process, 82 base::ProcessHandle render_process,
62 media::VideoCaptureSessionId session_id, 83 media::VideoCaptureSessionId session_id,
63 const media::VideoCaptureParams& params) 84 const media::VideoCaptureParams& params)
64 : controller_id(id), 85 : controller_id(id),
65 event_handler(handler), 86 event_handler(handler),
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
242 if (client) { 263 if (client) {
243 client->session_closed = true; 264 client->session_closed = true;
244 client->event_handler->OnEnded(client->controller_id); 265 client->event_handler->OnEnded(client->controller_id);
245 } 266 }
246 } 267 }
247 268
248 void VideoCaptureController::ReturnBuffer( 269 void VideoCaptureController::ReturnBuffer(
249 const VideoCaptureControllerID& id, 270 const VideoCaptureControllerID& id,
250 VideoCaptureControllerEventHandler* event_handler, 271 VideoCaptureControllerEventHandler* event_handler,
251 int buffer_id, 272 int buffer_id,
252 const std::vector<uint32>& sync_points) { 273 uint32 sync_point) {
253 DCHECK_CURRENTLY_ON(BrowserThread::IO); 274 DCHECK_CURRENTLY_ON(BrowserThread::IO);
254 275
255 ControllerClient* client = FindClient(id, event_handler, controller_clients_); 276 ControllerClient* client = FindClient(id, event_handler, controller_clients_);
256 277
257 // If this buffer is not held by this client, or this client doesn't exist 278 // If this buffer is not held by this client, or this client doesn't exist
258 // in controller, do nothing. 279 // in controller, do nothing.
259 ControllerClient::ActiveBufferMap::iterator iter; 280 ControllerClient::ActiveBufferMap::iterator iter;
260 if (!client || (iter = client->active_buffers.find(buffer_id)) == 281 if (!client || (iter = client->active_buffers.find(buffer_id)) ==
261 client->active_buffers.end()) { 282 client->active_buffers.end()) {
262 NOTREACHED(); 283 NOTREACHED();
263 return; 284 return;
264 } 285 }
265 scoped_refptr<media::VideoFrame> frame = iter->second; 286 scoped_refptr<media::VideoFrame> frame = iter->second;
266 client->active_buffers.erase(iter); 287 client->active_buffers.erase(iter);
267 288
268 if (frame->format() == media::VideoFrame::NATIVE_TEXTURE) { 289 SyncPointProviderImpl provider(sync_point);
269 for (size_t i = 0; i < sync_points.size(); i++) 290 frame->UpdateReleaseSyncPoint(provider);
270 frame->AppendReleaseSyncPoint(sync_points[i]);
271 }
272 291
273 buffer_pool_->RelinquishConsumerHold(buffer_id, 1); 292 buffer_pool_->RelinquishConsumerHold(buffer_id, 1);
274 } 293 }
275 294
276 const media::VideoCaptureFormat& 295 const media::VideoCaptureFormat&
277 VideoCaptureController::GetVideoCaptureFormat() const { 296 VideoCaptureController::GetVideoCaptureFormat() const {
278 DCHECK_CURRENTLY_ON(BrowserThread::IO); 297 DCHECK_CURRENTLY_ON(BrowserThread::IO);
279 return video_capture_format_; 298 return video_capture_format_;
280 } 299 }
281 300
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after
641 } 660 }
642 return NULL; 661 return NULL;
643 } 662 }
644 663
645 int VideoCaptureController::GetClientCount() { 664 int VideoCaptureController::GetClientCount() {
646 DCHECK_CURRENTLY_ON(BrowserThread::IO); 665 DCHECK_CURRENTLY_ON(BrowserThread::IO);
647 return controller_clients_.size(); 666 return controller_clients_.size();
648 } 667 }
649 668
650 } // namespace content 669 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698