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

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

Issue 1154153003: Relanding 1143663007: VideoFrame: Separate Pixel Format from Storage Type. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added NV12 support in CrOS Created 5 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) 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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 void HoldForConsumers(int buffer_id, int num_clients); 95 void HoldForConsumers(int buffer_id, int num_clients);
96 96
97 // Indicate that one or more consumers are done with a particular buffer. This 97 // Indicate that one or more consumers are done with a particular buffer. This
98 // effectively is the opposite of HoldForConsumers(). Once the consumers are 98 // effectively is the opposite of HoldForConsumers(). Once the consumers are
99 // done, a buffer is returned to the pool for reuse. 99 // done, a buffer is returned to the pool for reuse.
100 void RelinquishConsumerHold(int buffer_id, int num_clients); 100 void RelinquishConsumerHold(int buffer_id, int num_clients);
101 101
102 private: 102 private:
103 class GpuMemoryBufferTracker; 103 class GpuMemoryBufferTracker;
104 class SharedMemTracker; 104 class SharedMemTracker;
105 // Generic class to keep track of the state of a given mappable resource. 105 // Generic class to keep track of the state of a given mappable resource. Each
106 // Tracker carries indication of pixel format and storage type.
106 class Tracker { 107 class Tracker {
107 public: 108 public:
108 static scoped_ptr<Tracker> CreateTracker(bool use_gmb); 109 static scoped_ptr<Tracker> CreateTracker(bool use_gmb);
109 110
110 Tracker() 111 Tracker()
111 : pixel_count_(0), held_by_producer_(false), consumer_hold_count_(0) {} 112 : pixel_count_(0), held_by_producer_(false), consumer_hold_count_(0) {}
112 virtual bool Init(media::VideoFrame::Format format, 113 virtual bool Init(media::VideoFrame::Format format,
114 media::VideoFrame::StorageType storage_type,
113 const gfx::Size& dimensions) = 0; 115 const gfx::Size& dimensions) = 0;
114 virtual ~Tracker(); 116 virtual ~Tracker();
115 117
116 size_t pixel_count() const { return pixel_count_; } 118 size_t pixel_count() const { return pixel_count_; }
117 void set_pixel_count(size_t count) { pixel_count_ = count; } 119 void set_pixel_count(size_t count) { pixel_count_ = count; }
118 media::VideoFrame::Format pixel_format() const { return pixel_format_; } 120 media::VideoFrame::Format pixel_format() const { return pixel_format_; }
119 void set_pixel_format(media::VideoFrame::Format format) { 121 void set_pixel_format(media::VideoFrame::Format format) {
120 pixel_format_ = format; 122 pixel_format_ = format;
121 } 123 }
124 media::VideoFrame::StorageType storage_type() const {
125 return storage_type_;
126 }
127 void set_storage_type(media::VideoFrame::StorageType storage_type) {
128 storage_type_ = storage_type;
129 }
122 bool held_by_producer() const { return held_by_producer_; } 130 bool held_by_producer() const { return held_by_producer_; }
123 void set_held_by_producer(bool value) { held_by_producer_ = value; } 131 void set_held_by_producer(bool value) { held_by_producer_ = value; }
124 int consumer_hold_count() const { return consumer_hold_count_; } 132 int consumer_hold_count() const { return consumer_hold_count_; }
125 void set_consumer_hold_count(int value) { consumer_hold_count_ = value; } 133 void set_consumer_hold_count(int value) { consumer_hold_count_ = value; }
126 134
127 // Returns a handle to the underlying storage, be that a block of Shared 135 // Returns a handle to the underlying storage, be that a block of Shared
128 // Memory, or a GpuMemoryBuffer. 136 // Memory, or a GpuMemoryBuffer.
129 virtual scoped_ptr<BufferHandle> GetBufferHandle() = 0; 137 virtual scoped_ptr<BufferHandle> GetBufferHandle() = 0;
130 // The actual size of the underlying backing resource. 138 // The actual size of the underlying backing resource.
131 virtual size_t mapped_size() const = 0; 139 virtual size_t mapped_size() const = 0;
132 140
133 virtual bool ShareToProcess(base::ProcessHandle process_handle, 141 virtual bool ShareToProcess(base::ProcessHandle process_handle,
134 base::SharedMemoryHandle* new_handle) = 0; 142 base::SharedMemoryHandle* new_handle) = 0;
135 143
136 private: 144 private:
137 size_t pixel_count_; 145 size_t pixel_count_;
138 media::VideoFrame::Format pixel_format_; 146 media::VideoFrame::Format pixel_format_;
147 media::VideoFrame::StorageType storage_type_;
139 // Indicates whether this Tracker is currently referenced by the producer. 148 // Indicates whether this Tracker is currently referenced by the producer.
140 bool held_by_producer_; 149 bool held_by_producer_;
141 // Number of consumer processes which hold this Tracker. 150 // Number of consumer processes which hold this Tracker.
142 int consumer_hold_count_; 151 int consumer_hold_count_;
143 }; 152 };
144 153
145 friend class base::RefCountedThreadSafe<VideoCaptureBufferPool>; 154 friend class base::RefCountedThreadSafe<VideoCaptureBufferPool>;
146 virtual ~VideoCaptureBufferPool(); 155 virtual ~VideoCaptureBufferPool();
147 156
148 int ReserveForProducerInternal(media::VideoPixelFormat format, 157 int ReserveForProducerInternal(media::VideoPixelFormat format,
(...skipping 14 matching lines...) Expand all
163 // The buffers, indexed by the first parameter, a buffer id. 172 // The buffers, indexed by the first parameter, a buffer id.
164 using TrackerMap = std::map<int, Tracker*>; 173 using TrackerMap = std::map<int, Tracker*>;
165 TrackerMap trackers_; 174 TrackerMap trackers_;
166 175
167 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureBufferPool); 176 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureBufferPool);
168 }; 177 };
169 178
170 } // namespace content 179 } // namespace content
171 180
172 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_POOL_H_ 181 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698