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 <map> | 9 #include <map> |
10 #include <set> | 10 #include <set> |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "media/video/picture.h" | 23 #include "media/video/picture.h" |
24 #include "media/video/video_decode_accelerator.h" | 24 #include "media/video/video_decode_accelerator.h" |
25 #include "third_party/webrtc/modules/video_coding/codecs/interface/video_codec_i
nterface.h" | 25 #include "third_party/webrtc/modules/video_coding/codecs/interface/video_codec_i
nterface.h" |
26 | 26 |
27 namespace base { | 27 namespace base { |
28 class MessageLoopProxy; | 28 class MessageLoopProxy; |
29 }; | 29 }; |
30 | 30 |
31 namespace media { | 31 namespace media { |
32 class DecoderBuffer; | 32 class DecoderBuffer; |
33 class GpuVideoAcceleratorFactories; | 33 class GpuVideoDecoderFactories; |
34 } | 34 } |
35 | 35 |
36 namespace content { | 36 namespace content { |
37 | 37 |
38 // This class uses hardware accelerated video decoder to decode video for | 38 // This class uses hardware accelerated video decoder to decode video for |
39 // WebRTC. |vda_message_loop_| is the message loop proxy of the media thread, | 39 // WebRTC. |vda_message_loop_| is the message loop proxy of the media thread, |
40 // which VDA::Client methods run on. webrtc::VideoDecoder methods run on WebRTC | 40 // which VDA::Client methods run on. webrtc::VideoDecoder methods run on WebRTC |
41 // DecodingThread or Chrome_libJingle_WorkerThread, which are trampolined to | 41 // DecodingThread or Chrome_libJingle_WorkerThread, which are trampolined to |
42 // |vda_message_loop_|. Decode() is non-blocking and queues the buffers. Decoded | 42 // |vda_message_loop_|. Decode() is non-blocking and queues the buffers. Decoded |
43 // frames are delivered to WebRTC on |vda_message_loop_|. | 43 // frames are delivered to WebRTC on |vda_message_loop_|. |
44 class CONTENT_EXPORT RTCVideoDecoder | 44 class CONTENT_EXPORT RTCVideoDecoder |
45 : NON_EXPORTED_BASE(public webrtc::VideoDecoder), | 45 : NON_EXPORTED_BASE(public webrtc::VideoDecoder), |
46 public media::VideoDecodeAccelerator::Client, | 46 public media::VideoDecodeAccelerator::Client, |
47 public base::MessageLoop::DestructionObserver { | 47 public base::MessageLoop::DestructionObserver { |
48 public: | 48 public: |
49 virtual ~RTCVideoDecoder(); | 49 virtual ~RTCVideoDecoder(); |
50 | 50 |
51 // Creates a RTCVideoDecoder. Returns NULL if failed. The video decoder will | 51 // Creates a RTCVideoDecoder. Returns NULL if failed. The video decoder will |
52 // run on the message loop of |factories|. | 52 // run on the message loop of |factories|. |
53 static scoped_ptr<RTCVideoDecoder> Create( | 53 static scoped_ptr<RTCVideoDecoder> Create( |
54 webrtc::VideoCodecType type, | 54 webrtc::VideoCodecType type, |
55 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories); | 55 const scoped_refptr<media::GpuVideoDecoderFactories>& factories); |
56 | 56 |
57 // webrtc::VideoDecoder implementation. | 57 // webrtc::VideoDecoder implementation. |
58 // Called on WebRTC DecodingThread. | 58 // Called on WebRTC DecodingThread. |
59 virtual int32_t InitDecode(const webrtc::VideoCodec* codecSettings, | 59 virtual int32_t InitDecode(const webrtc::VideoCodec* codecSettings, |
60 int32_t numberOfCores) OVERRIDE; | 60 int32_t numberOfCores) OVERRIDE; |
61 // Called on WebRTC DecodingThread. | 61 // Called on WebRTC DecodingThread. |
62 virtual int32_t Decode( | 62 virtual int32_t Decode( |
63 const webrtc::EncodedImage& inputImage, | 63 const webrtc::EncodedImage& inputImage, |
64 bool missingFrames, | 64 bool missingFrames, |
65 const webrtc::RTPFragmentationHeader* fragmentation, | 65 const webrtc::RTPFragmentationHeader* fragmentation, |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 uint32_t timestamp; // in 90KHz | 106 uint32_t timestamp; // in 90KHz |
107 uint32_t width; | 107 uint32_t width; |
108 uint32_t height; | 108 uint32_t height; |
109 size_t size; // buffer size | 109 size_t size; // buffer size |
110 }; | 110 }; |
111 | 111 |
112 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, IsBufferAfterReset); | 112 FRIEND_TEST_ALL_PREFIXES(RTCVideoDecoderTest, IsBufferAfterReset); |
113 | 113 |
114 // The meessage loop of |factories| will be saved to |vda_loop_proxy_|. | 114 // The meessage loop of |factories| will be saved to |vda_loop_proxy_|. |
115 RTCVideoDecoder( | 115 RTCVideoDecoder( |
116 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories); | 116 const scoped_refptr<media::GpuVideoDecoderFactories>& factories); |
117 | 117 |
118 void Initialize(base::WaitableEvent* waiter); | 118 void Initialize(base::WaitableEvent* waiter); |
119 | 119 |
120 // Requests a buffer to be decoded by VDA. | 120 // Requests a buffer to be decoded by VDA. |
121 void RequestBufferDecode(); | 121 void RequestBufferDecode(); |
122 | 122 |
123 bool CanMoreDecodeWorkBeDone(); | 123 bool CanMoreDecodeWorkBeDone(); |
124 | 124 |
125 // Returns true if bitstream buffer id |id_buffer| comes after |id_reset|. | 125 // Returns true if bitstream buffer id |id_buffer| comes after |id_reset|. |
126 // This handles the wraparound. | 126 // This handles the wraparound. |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 // The hardware video decoder. | 190 // The hardware video decoder. |
191 scoped_ptr<media::VideoDecodeAccelerator> vda_; | 191 scoped_ptr<media::VideoDecodeAccelerator> vda_; |
192 | 192 |
193 // The size of the incoming video frames. | 193 // The size of the incoming video frames. |
194 gfx::Size frame_size_; | 194 gfx::Size frame_size_; |
195 | 195 |
196 // The weak pointer should live and die on the |vda_loop_proxy_|; | 196 // The weak pointer should live and die on the |vda_loop_proxy_|; |
197 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; | 197 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; |
198 base::WeakPtr<RTCVideoDecoder> weak_this_; | 198 base::WeakPtr<RTCVideoDecoder> weak_this_; |
199 | 199 |
200 scoped_refptr<media::GpuVideoAcceleratorFactories> factories_; | 200 scoped_refptr<media::GpuVideoDecoderFactories> factories_; |
201 | 201 |
202 // The message loop to run callbacks on. This is from |factories_|. | 202 // The message loop to run callbacks on. This is from |factories_|. |
203 scoped_refptr<base::MessageLoopProxy> vda_loop_proxy_; | 203 scoped_refptr<base::MessageLoopProxy> vda_loop_proxy_; |
204 | 204 |
205 // The texture target used for decoded pictures. | 205 // The texture target used for decoded pictures. |
206 uint32 decoder_texture_target_; | 206 uint32 decoder_texture_target_; |
207 | 207 |
208 // Metadata of the buffers that have been sent for decode. | 208 // Metadata of the buffers that have been sent for decode. |
209 std::list<BufferData> input_buffer_data_; | 209 std::list<BufferData> input_buffer_data_; |
210 | 210 |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 // A buffer that has an id less than this should be dropped because Reset or | 260 // A buffer that has an id less than this should be dropped because Reset or |
261 // Release has been called. Guarded by |lock_|. | 261 // Release has been called. Guarded by |lock_|. |
262 int32 reset_bitstream_buffer_id_; | 262 int32 reset_bitstream_buffer_id_; |
263 | 263 |
264 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); | 264 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); |
265 }; | 265 }; |
266 | 266 |
267 } // namespace content | 267 } // namespace content |
268 | 268 |
269 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ | 269 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ |
OLD | NEW |