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

Side by Side Diff: content/browser/renderer_host/media/video_capture_buffer_pool.h

Issue 1267883002: Pass GpuMemoryBuffer backed VideoFrame from browser to renderer processes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@gmbtracker-multiple
Patch Set: Rebase Created 5 years, 3 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_POOL_H_ 5 #ifndef CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_POOL_H_
6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_POOL_H_ 6 #define CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_POOL_H_
7 7
8 #include <map> 8 #include <map>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 class CONTENT_EXPORT VideoCaptureBufferPool 44 class CONTENT_EXPORT VideoCaptureBufferPool
45 : public base::RefCountedThreadSafe<VideoCaptureBufferPool> { 45 : public base::RefCountedThreadSafe<VideoCaptureBufferPool> {
46 public: 46 public:
47 static const int kInvalidId; 47 static const int kInvalidId;
48 48
49 // Abstraction of a pool's buffer data buffer and size for clients. 49 // Abstraction of a pool's buffer data buffer and size for clients.
50 // TODO(emircan): See https://crbug.com/521059, refactor this class. 50 // TODO(emircan): See https://crbug.com/521059, refactor this class.
51 class BufferHandle { 51 class BufferHandle {
52 public: 52 public:
53 virtual ~BufferHandle() {} 53 virtual ~BufferHandle() {}
54 virtual size_t size() const = 0; 54 virtual gfx::Size dimensions() const = 0;
55 virtual size_t mapped_size() const = 0;
55 virtual void* data(int plane) = 0; 56 virtual void* data(int plane) = 0;
56 virtual ClientBuffer AsClientBuffer(int plane) = 0; 57 virtual ClientBuffer AsClientBuffer(int plane) = 0;
57 #if defined(OS_POSIX) 58 #if defined(OS_POSIX)
58 virtual base::FileDescriptor AsPlatformFile() = 0; 59 virtual base::FileDescriptor AsPlatformFile() = 0;
59 #endif 60 #endif
60 }; 61 };
61 62
62 explicit VideoCaptureBufferPool(int count); 63 explicit VideoCaptureBufferPool(int count);
63 64
64 // One-time (per client/per-buffer) initialization to share a particular 65 // One-time (per client/per-buffer) initialization to share a particular
65 // buffer to a process. The size of the allocation is returned as 66 // buffer to a process. The shared handle is returned as |new_handle|.
66 // |memory_size|. 67 bool ShareToProcess(int buffer_id,
67 base::SharedMemoryHandle ShareToProcess(int buffer_id, 68 base::ProcessHandle process_handle,
68 base::ProcessHandle process_handle, 69 base::SharedMemoryHandle* new_handle);
69 size_t* memory_size); 70 bool ShareToProcess2(int buffer_id,
71 int plane,
72 base::ProcessHandle process_handle,
73 gfx::GpuMemoryBufferHandle* new_handle);
70 74
71 // Try and obtain a BufferHandle for |buffer_id|. 75 // Try and obtain a BufferHandle for |buffer_id|.
72 scoped_ptr<BufferHandle> GetBufferHandle(int buffer_id); 76 scoped_ptr<BufferHandle> GetBufferHandle(int buffer_id);
73 77
74 // Reserve or allocate a buffer to support a packed frame of |dimensions| of 78 // Reserve or allocate a buffer to support a packed frame of |dimensions| of
75 // pixel |format| and return its id. This will fail (returning kInvalidId) if 79 // pixel |format| and return its id. This will fail (returning kInvalidId) if
76 // the pool already is at its |count| limit of the number of allocations, and 80 // the pool already is at its |count| limit of the number of allocations, and
77 // all allocated buffers are in use by the producer and/or consumers. 81 // all allocated buffers are in use by the producer and/or consumers.
78 // 82 //
79 // If successful, the reserved buffer remains reserved (and writable by the 83 // If successful, the reserved buffer remains reserved (and writable by the
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 storage_type_ = storage_type; 141 storage_type_ = storage_type;
138 } 142 }
139 bool held_by_producer() const { return held_by_producer_; } 143 bool held_by_producer() const { return held_by_producer_; }
140 void set_held_by_producer(bool value) { held_by_producer_ = value; } 144 void set_held_by_producer(bool value) { held_by_producer_ = value; }
141 int consumer_hold_count() const { return consumer_hold_count_; } 145 int consumer_hold_count() const { return consumer_hold_count_; }
142 void set_consumer_hold_count(int value) { consumer_hold_count_ = value; } 146 void set_consumer_hold_count(int value) { consumer_hold_count_ = value; }
143 147
144 // Returns a handle to the underlying storage, be that a block of Shared 148 // Returns a handle to the underlying storage, be that a block of Shared
145 // Memory, or a GpuMemoryBuffer. 149 // Memory, or a GpuMemoryBuffer.
146 virtual scoped_ptr<BufferHandle> GetBufferHandle() = 0; 150 virtual scoped_ptr<BufferHandle> GetBufferHandle() = 0;
147 // The actual size of the underlying backing resource.
148 virtual size_t mapped_size() const = 0;
149 151
150 virtual bool ShareToProcess(base::ProcessHandle process_handle, 152 virtual bool ShareToProcess(base::ProcessHandle process_handle,
151 base::SharedMemoryHandle* new_handle) = 0; 153 base::SharedMemoryHandle* new_handle) = 0;
154 virtual bool ShareToProcess2(int plane,
155 base::ProcessHandle process_handle,
156 gfx::GpuMemoryBufferHandle* new_handle) = 0;
152 157
153 private: 158 private:
154 size_t pixel_count_; 159 size_t pixel_count_;
155 media::VideoCapturePixelFormat pixel_format_; 160 media::VideoCapturePixelFormat pixel_format_;
156 media::VideoPixelStorage storage_type_; 161 media::VideoPixelStorage storage_type_;
157 // Indicates whether this Tracker is currently referenced by the producer. 162 // Indicates whether this Tracker is currently referenced by the producer.
158 bool held_by_producer_; 163 bool held_by_producer_;
159 // Number of consumer processes which hold this Tracker. 164 // Number of consumer processes which hold this Tracker.
160 int consumer_hold_count_; 165 int consumer_hold_count_;
161 }; 166 };
(...skipping 20 matching lines...) Expand all
182 // The buffers, indexed by the first parameter, a buffer id. 187 // The buffers, indexed by the first parameter, a buffer id.
183 using TrackerMap = std::map<int, Tracker*>; 188 using TrackerMap = std::map<int, Tracker*>;
184 TrackerMap trackers_; 189 TrackerMap trackers_;
185 190
186 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureBufferPool); 191 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureBufferPool);
187 }; 192 };
188 193
189 } // namespace content 194 } // namespace content
190 195
191 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_POOL_H_ 196 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698