| 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 19 matching lines...) Expand all Loading... |
| 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); | 138 size_t size); |
| 145 | 139 |
| 146 // Resets VDA. | 140 // Resets VDA. |
| 147 void ResetInternal(); | 141 void ResetInternal(); |
| 148 | 142 |
| 149 // Static method is to allow it to run even after RVD is deleted. | 143 // Static method is to allow it to run even after RVD is deleted. |
| 150 static void ReleaseMailbox( | 144 static void ReleaseMailbox( |
| 151 base::WeakPtr<RTCVideoDecoder> decoder, | 145 base::WeakPtr<RTCVideoDecoder> decoder, |
| 152 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories, | 146 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories, |
| 153 int64 picture_buffer_id, | 147 int64 picture_buffer_id, |
| (...skipping 15 matching lines...) Expand all Loading... |
| 169 | 163 |
| 170 // Returns a shared-memory segment to the available pool. | 164 // Returns a shared-memory segment to the available pool. |
| 171 void PutSHM_Locked(scoped_ptr<SHMBuffer> shm_buffer); | 165 void PutSHM_Locked(scoped_ptr<SHMBuffer> shm_buffer); |
| 172 | 166 |
| 173 // Allocates |number| shared memory of at least |min_size| bytes. | 167 // Allocates |number| shared memory of at least |min_size| bytes. |
| 174 void CreateSHM(int number, size_t min_size); | 168 void CreateSHM(int number, size_t min_size); |
| 175 | 169 |
| 176 // Stores the buffer metadata to |input_buffer_data_|. | 170 // Stores the buffer metadata to |input_buffer_data_|. |
| 177 void RecordBufferData(const BufferData& buffer_data); | 171 void RecordBufferData(const BufferData& buffer_data); |
| 178 // Gets the buffer metadata from |input_buffer_data_|. | 172 // Gets the buffer metadata from |input_buffer_data_|. |
| 179 void GetBufferData(int32 bitstream_buffer_id, | 173 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 | 174 |
| 185 // Records the result of InitDecode to UMA and returns |status|. | 175 // Records the result of InitDecode to UMA and returns |status|. |
| 186 int32_t RecordInitDecodeUMA(int32_t status); | 176 int32_t RecordInitDecodeUMA(int32_t status); |
| 187 | 177 |
| 188 // Assert the contract that this class is operated on the right thread. | 178 // Assert the contract that this class is operated on the right thread. |
| 189 void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const; | 179 void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const; |
| 190 | 180 |
| 191 enum State { | 181 enum State { |
| 192 UNINITIALIZED, // The decoder has not initialized. | 182 UNINITIALIZED, // The decoder has not initialized. |
| 193 INITIALIZED, // The decoder has initialized. | 183 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_| | 258 // Must be destroyed, or invalidated, on |vda_loop_proxy_| |
| 269 // NOTE: Weak pointers must be invalidated before all other member variables. | 259 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 270 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; | 260 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; |
| 271 | 261 |
| 272 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); | 262 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); |
| 273 }; | 263 }; |
| 274 | 264 |
| 275 } // namespace content | 265 } // namespace content |
| 276 | 266 |
| 277 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ | 267 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ |
| OLD | NEW |