OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ |
6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ | 6 #define CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ |
7 | 7 |
8 #include <deque> | 8 #include <deque> |
9 #include <list> | 9 #include <list> |
10 #include <map> | 10 #include <map> |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 virtual void NotifyFlushDone() OVERRIDE; | 84 virtual void NotifyFlushDone() OVERRIDE; |
85 virtual void NotifyResetDone() OVERRIDE; | 85 virtual void NotifyResetDone() OVERRIDE; |
86 virtual void NotifyError(media::VideoDecodeAccelerator::Error error) OVERRIDE; | 86 virtual void NotifyError(media::VideoDecodeAccelerator::Error error) OVERRIDE; |
87 | 87 |
88 private: | 88 private: |
89 class SHMBuffer; | 89 class SHMBuffer; |
90 // Metadata of a bitstream buffer. | 90 // Metadata of a bitstream buffer. |
91 struct BufferData { | 91 struct BufferData { |
92 BufferData(int32 bitstream_buffer_id, | 92 BufferData(int32 bitstream_buffer_id, |
93 uint32_t timestamp, | 93 uint32_t timestamp, |
94 int width, | |
95 int height, | |
96 size_t size); | 94 size_t size); |
97 BufferData(); | 95 BufferData(); |
98 ~BufferData(); | 96 ~BufferData(); |
99 int32 bitstream_buffer_id; | 97 int32 bitstream_buffer_id; |
100 uint32_t timestamp; // in 90KHz | 98 uint32_t timestamp; // in 90KHz |
101 uint32_t width; | |
102 uint32_t height; | |
103 size_t size; // buffer size | 99 size_t size; // buffer size |
104 }; | 100 }; |
105 | 101 |
106 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, IsBufferAfterReset); | 102 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, IsBufferAfterReset); |
107 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, IsFirstBufferAfterReset); | 103 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, IsFirstBufferAfterReset); |
108 | 104 |
109 RTCVideoDecoder( | 105 RTCVideoDecoder( |
110 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories); | 106 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories); |
111 | 107 |
112 // Requests a buffer to be decoded by VDA. | 108 // Requests a buffer to be decoded by VDA. |
(...skipping 18 matching lines...) Expand all Loading... |
131 // Returns true on success. | 127 // Returns true on success. |
132 bool SaveToPendingBuffers_Locked(const webrtc::EncodedImage& input_image, | 128 bool SaveToPendingBuffers_Locked(const webrtc::EncodedImage& input_image, |
133 const BufferData& buffer_data); | 129 const BufferData& buffer_data); |
134 | 130 |
135 // Gets SHM and moves pending buffers to decode buffers. | 131 // Gets SHM and moves pending buffers to decode buffers. |
136 void MovePendingBuffersToDecodeBuffers(); | 132 void MovePendingBuffersToDecodeBuffers(); |
137 | 133 |
138 scoped_refptr<media::VideoFrame> CreateVideoFrame( | 134 scoped_refptr<media::VideoFrame> CreateVideoFrame( |
139 const media::Picture& picture, | 135 const media::Picture& picture, |
140 const media::PictureBuffer& pb, | 136 const media::PictureBuffer& pb, |
141 uint32_t timestamp, | 137 uint32_t timestamp); |
142 uint32_t width, | |
143 uint32_t height, | |
144 size_t size); | |
145 | 138 |
146 // Resets VDA. | 139 // Resets VDA. |
147 void ResetInternal(); | 140 void ResetInternal(); |
148 | 141 |
149 // Static method is to allow it to run even after RVD is deleted. | 142 // Static method is to allow it to run even after RVD is deleted. |
150 static void ReleaseMailbox( | 143 static void ReleaseMailbox( |
151 base::WeakPtr<RTCVideoDecoder> decoder, | 144 base::WeakPtr<RTCVideoDecoder> decoder, |
152 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories, | 145 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories, |
153 int64 picture_buffer_id, | 146 int64 picture_buffer_id, |
154 uint32 texture_id, | 147 uint32 texture_id, |
(...skipping 14 matching lines...) Expand all Loading... |
169 | 162 |
170 // Returns a shared-memory segment to the available pool. | 163 // Returns a shared-memory segment to the available pool. |
171 void PutSHM_Locked(scoped_ptr<SHMBuffer> shm_buffer); | 164 void PutSHM_Locked(scoped_ptr<SHMBuffer> shm_buffer); |
172 | 165 |
173 // Allocates |number| shared memory of at least |min_size| bytes. | 166 // Allocates |number| shared memory of at least |min_size| bytes. |
174 void CreateSHM(int number, size_t min_size); | 167 void CreateSHM(int number, size_t min_size); |
175 | 168 |
176 // Stores the buffer metadata to |input_buffer_data_|. | 169 // Stores the buffer metadata to |input_buffer_data_|. |
177 void RecordBufferData(const BufferData& buffer_data); | 170 void RecordBufferData(const BufferData& buffer_data); |
178 // Gets the buffer metadata from |input_buffer_data_|. | 171 // Gets the buffer metadata from |input_buffer_data_|. |
179 void GetBufferData(int32 bitstream_buffer_id, | 172 void GetBufferData(int32 bitstream_buffer_id, uint32_t* timestamp); |
180 uint32_t* timestamp, | |
181 uint32_t* width, | |
182 uint32_t* height, | |
183 size_t* size); | |
184 | 173 |
185 // Records the result of InitDecode to UMA and returns |status|. | 174 // Records the result of InitDecode to UMA and returns |status|. |
186 int32_t RecordInitDecodeUMA(int32_t status); | 175 int32_t RecordInitDecodeUMA(int32_t status); |
187 | 176 |
188 // Assert the contract that this class is operated on the right thread. | 177 // Assert the contract that this class is operated on the right thread. |
189 void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const; | 178 void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const; |
190 | 179 |
191 enum State { | 180 enum State { |
192 UNINITIALIZED, // The decoder has not initialized. | 181 UNINITIALIZED, // The decoder has not initialized. |
193 INITIALIZED, // The decoder has initialized. | 182 INITIALIZED, // The decoder has initialized. |
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 // Must be destroyed, or invalidated, on |vda_loop_proxy_| | 257 // Must be destroyed, or invalidated, on |vda_loop_proxy_| |
269 // NOTE: Weak pointers must be invalidated before all other member variables. | 258 // NOTE: Weak pointers must be invalidated before all other member variables. |
270 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; | 259 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; |
271 | 260 |
272 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); | 261 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); |
273 }; | 262 }; |
274 | 263 |
275 } // namespace content | 264 } // namespace content |
276 | 265 |
277 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ | 266 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ |
OLD | NEW |