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_GPU_RTC_VIDEO_DECODER_H_ | 5 #ifndef CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_DECODER_H_ |
6 #define CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_DECODER_H_ | 6 #define CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_DECODER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
(...skipping 25 matching lines...) Expand all Loading... |
36 class GpuVideoAcceleratorFactories; | 36 class GpuVideoAcceleratorFactories; |
37 } | 37 } |
38 | 38 |
39 namespace gpu { | 39 namespace gpu { |
40 struct SyncToken; | 40 struct SyncToken; |
41 } | 41 } |
42 | 42 |
43 namespace content { | 43 namespace content { |
44 | 44 |
45 // This class uses hardware accelerated video decoder to decode video for | 45 // This class uses hardware accelerated video decoder to decode video for |
46 // WebRTC. |vda_message_loop_| is the message loop proxy of the media thread, | 46 // WebRTC. Lives on the media thread, where VDA::Client methods run on. |
47 // which VDA::Client methods run on. webrtc::VideoDecoder methods run on WebRTC | 47 // webrtc::VideoDecoder methods run on WebRTC DecodingThread or |
48 // DecodingThread or Chrome_libJingle_WorkerThread, which are trampolined to | 48 // Chrome_libJingle_WorkerThread, which are trampolined to the media thread. |
49 // |vda_message_loop_|. Decode() is non-blocking and queues the buffers. Decoded | 49 // Decode() is non-blocking and queues the buffers. Decoded frames are |
50 // frames are delivered to WebRTC on |vda_message_loop_|. | 50 // delivered to WebRTC on the media task runner. |
51 class CONTENT_EXPORT RTCVideoDecoder | 51 class CONTENT_EXPORT RTCVideoDecoder |
52 : NON_EXPORTED_BASE(public webrtc::VideoDecoder), | 52 : NON_EXPORTED_BASE(public webrtc::VideoDecoder), |
53 public media::VideoDecodeAccelerator::Client { | 53 public media::VideoDecodeAccelerator::Client { |
54 public: | 54 public: |
55 ~RTCVideoDecoder() override; | 55 ~RTCVideoDecoder() override; |
56 | 56 |
57 // Creates a RTCVideoDecoder on the message loop of |factories|. Returns NULL | 57 // Creates a RTCVideoDecoder on the message loop of |factories|. Returns NULL |
58 // if failed. The video decoder will run on the message loop of |factories|. | 58 // if failed. The video decoder will run on the message loop of |factories|. |
59 static std::unique_ptr<RTCVideoDecoder> Create( | 59 static std::unique_ptr<RTCVideoDecoder> Create( |
60 webrtc::VideoCodecType type, | 60 webrtc::VideoCodecType type, |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
156 | 156 |
157 // Static method is to allow it to run even after RVD is deleted. | 157 // Static method is to allow it to run even after RVD is deleted. |
158 static void ReleaseMailbox(base::WeakPtr<RTCVideoDecoder> decoder, | 158 static void ReleaseMailbox(base::WeakPtr<RTCVideoDecoder> decoder, |
159 media::GpuVideoAcceleratorFactories* factories, | 159 media::GpuVideoAcceleratorFactories* factories, |
160 int64_t picture_buffer_id, | 160 int64_t picture_buffer_id, |
161 uint32_t texture_id, | 161 uint32_t texture_id, |
162 const gpu::SyncToken& release_sync_token); | 162 const gpu::SyncToken& release_sync_token); |
163 // Tells VDA that a picture buffer can be recycled. | 163 // Tells VDA that a picture buffer can be recycled. |
164 void ReusePictureBuffer(int64_t picture_buffer_id); | 164 void ReusePictureBuffer(int64_t picture_buffer_id); |
165 | 165 |
166 // Creates |vda_| on |vda_loop_proxy_|. | 166 // Creates |vda_| on the media thread. |
167 void CreateVDA(media::VideoCodecProfile profile, base::WaitableEvent* waiter); | 167 void CreateVDA(media::VideoCodecProfile profile, base::WaitableEvent* waiter); |
168 | 168 |
169 void DestroyTextures(); | 169 void DestroyTextures(); |
170 void DestroyVDA(); | 170 void DestroyVDA(); |
171 | 171 |
172 // Gets a shared-memory segment of at least |min_size| bytes from | 172 // Gets a shared-memory segment of at least |min_size| bytes from |
173 // |available_shm_segments_|. Returns NULL if there is no buffer or the | 173 // |available_shm_segments_|. Returns NULL if there is no buffer or the |
174 // buffer is not big enough. | 174 // buffer is not big enough. |
175 std::unique_ptr<base::SharedMemory> GetSHM_Locked(size_t min_size); | 175 std::unique_ptr<base::SharedMemory> GetSHM_Locked(size_t min_size); |
176 | 176 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 int32_t next_bitstream_buffer_id_; | 287 int32_t next_bitstream_buffer_id_; |
288 | 288 |
289 // A buffer that has an id less than this should be dropped because Reset or | 289 // A buffer that has an id less than this should be dropped because Reset or |
290 // Release has been called. Guarded by |lock_|. | 290 // Release has been called. Guarded by |lock_|. |
291 int32_t reset_bitstream_buffer_id_; | 291 int32_t reset_bitstream_buffer_id_; |
292 | 292 |
293 // Minimum and maximum supported resolutions for the current profile/VDA. | 293 // Minimum and maximum supported resolutions for the current profile/VDA. |
294 gfx::Size min_resolution_; | 294 gfx::Size min_resolution_; |
295 gfx::Size max_resolution_; | 295 gfx::Size max_resolution_; |
296 | 296 |
297 // Must be destroyed, or invalidated, on |vda_loop_proxy_| | 297 // Must be destroyed, or invalidated, on the media thread. |
298 // NOTE: Weak pointers must be invalidated before all other member variables. | 298 // NOTE: Weak pointers must be invalidated before all other member variables. |
299 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; | 299 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; |
300 | 300 |
301 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); | 301 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); |
302 }; | 302 }; |
303 | 303 |
304 } // namespace content | 304 } // namespace content |
305 | 305 |
306 #endif // CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_DECODER_H_ | 306 #endif // CONTENT_RENDERER_MEDIA_GPU_RTC_VIDEO_DECODER_H_ |
OLD | NEW |