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