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

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

Issue 48113011: Remove media::VideoFrame from media::VideoCaptureDevice::Client interface (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: 5b80a5e9 scoped_refptr-ization. Created 7 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) 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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 static const int kInvalidId; 49 static const int kInvalidId;
50 explicit VideoCaptureBufferPool(int count); 50 explicit VideoCaptureBufferPool(int count);
51 51
52 // One-time (per client/per-buffer) initialization to share a particular 52 // One-time (per client/per-buffer) initialization to share a particular
53 // buffer to a process. The size of the allocation is returned as 53 // buffer to a process. The size of the allocation is returned as
54 // |memory_size|. 54 // |memory_size|.
55 base::SharedMemoryHandle ShareToProcess(int buffer_id, 55 base::SharedMemoryHandle ShareToProcess(int buffer_id,
56 base::ProcessHandle process_handle, 56 base::ProcessHandle process_handle,
57 size_t* memory_size); 57 size_t* memory_size);
58 58
59 // Query the memory parameters of |buffer_id|. Fills in parameters in the
60 // pointer arguments, and returns true iff the buffer exists.
61 bool GetBufferInfo(int buffer_id, void** memory, size_t* size);
62
59 // Reserve or allocate a buffer of at least |size| bytes and return its id. 63 // Reserve or allocate a buffer of at least |size| bytes and return its id.
60 // This will fail (returning kInvalidId) if the pool already is at its |count| 64 // This will fail (returning kInvalidId) if the pool already is at its |count|
61 // limit of the number of allocations, and all allocated buffers are in use by 65 // limit of the number of allocations, and all allocated buffers are in use by
62 // the producer and/or consumers. 66 // the producer and/or consumers.
63 // 67 //
64 // If successful, the reserved buffer remains reserved (and writable by the 68 // If successful, the reserved buffer remains reserved (and writable by the
65 // producer) until ownership is transferred either to the consumer via 69 // producer) until ownership is transferred either to the consumer via
66 // HoldForConsumers(), or back to the pool with 70 // HoldForConsumers(), or back to the pool with
67 // RelinquishProducerReservation(). 71 // RelinquishProducerReservation().
68 // 72 //
(...skipping 10 matching lines...) Expand all
79 // Transfer a buffer from producer to consumer ownership. 83 // Transfer a buffer from producer to consumer ownership.
80 // |buffer_id| must be a buffer index previously returned by 84 // |buffer_id| must be a buffer index previously returned by
81 // ReserveForProducer(), and not already passed to HoldForConsumers(). 85 // ReserveForProducer(), and not already passed to HoldForConsumers().
82 void HoldForConsumers(int buffer_id, int num_clients); 86 void HoldForConsumers(int buffer_id, int num_clients);
83 87
84 // Indicate that one or more consumers are done with a particular buffer. This 88 // Indicate that one or more consumers are done with a particular buffer. This
85 // effectively is the opposite of HoldForConsumers(). Once the consumers are 89 // effectively is the opposite of HoldForConsumers(). Once the consumers are
86 // done, a buffer is returned to the pool for reuse. 90 // done, a buffer is returned to the pool for reuse.
87 void RelinquishConsumerHold(int buffer_id, int num_clients); 91 void RelinquishConsumerHold(int buffer_id, int num_clients);
88 92
89 // Detect whether a particular SharedMemoryHandle is exported by a buffer that 93 // Detect whether a particular memory pointer is exported by a buffer that
90 // belongs to this pool -- that is, whether it was reserved by an earlier call 94 // belongs to this pool -- that is, whether it was reserved by an earlier call
91 // to ReserveForProducer(). If so, return its buffer_id. If not, return 95 // to ReserveForProducer(). If so, return its buffer_id. If not, return
92 // kInvalidId, indicating the buffer is not recognized (it may be a valid 96 // kInvalidId, indicating the buffer is not recognized (it may be a valid
93 // frame, but we didn't allocate it). 97 // frame, but we didn't allocate it).
94 int RecognizeReservedBuffer(base::SharedMemoryHandle maybe_belongs_to_pool); 98 int RecognizeReservedBuffer(const void* maybe_belongs_to_pool);
95
96 // Return a buffer wrapped in a useful type. If a reallocation occurred, the
97 // ID of the destroyed buffer is returned via |buffer_id_to_drop|.
98 scoped_refptr<media::VideoFrame> ReserveI420VideoFrame(
99 const gfx::Size& size,
100 int rotation,
101 int* buffer_id_to_drop);
102 99
103 int count() const { return count_; } 100 int count() const { return count_; }
104 101
105 private: 102 private:
106 friend class base::RefCountedThreadSafe<VideoCaptureBufferPool>; 103 friend class base::RefCountedThreadSafe<VideoCaptureBufferPool>;
107 104
108 // Per-buffer state. 105 // Per-buffer state.
109 struct Buffer { 106 struct Buffer {
110 Buffer(); 107 Buffer();
111 108
112 // The memory created to be shared with renderer processes. 109 // The memory created to be shared with renderer processes.
113 base::SharedMemory shared_memory; 110 base::SharedMemory shared_memory;
114 111
115 // Rotation in degrees of the buffer.
116 //
117 // TODO(jiayl): Move this out of this class. Clients can track rotation
118 // state themselves by means of a map keyed by buffer_id.
119 int rotation;
120
121 // Tracks whether this buffer is currently referenced by the producer. 112 // Tracks whether this buffer is currently referenced by the producer.
122 bool held_by_producer; 113 bool held_by_producer;
123 114
124 // Number of consumer processes which hold this shared memory. 115 // Number of consumer processes which hold this shared memory.
125 int consumer_hold_count; 116 int consumer_hold_count;
126 }; 117 };
127 118
128 typedef std::map<int, Buffer*> BufferMap; 119 typedef std::map<int, Buffer*> BufferMap;
129 120
130 virtual ~VideoCaptureBufferPool(); 121 virtual ~VideoCaptureBufferPool();
(...skipping 13 matching lines...) Expand all
144 135
145 // The buffers, indexed by |buffer_id|. 136 // The buffers, indexed by |buffer_id|.
146 BufferMap buffers_; 137 BufferMap buffers_;
147 138
148 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureBufferPool); 139 DISALLOW_IMPLICIT_CONSTRUCTORS(VideoCaptureBufferPool);
149 }; 140 };
150 141
151 } // namespace content 142 } // namespace content
152 143
153 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_POOL_H_ 144 #endif // CONTENT_BROWSER_RENDERER_HOST_MEDIA_VIDEO_CAPTURE_BUFFER_POOL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698