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 27 matching lines...) Expand all Loading... |
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: | 47 public: |
48 virtual ~RTCVideoDecoder(); | 48 ~RTCVideoDecoder() override; |
49 | 49 |
50 // Creates a RTCVideoDecoder. Returns NULL if failed. The video decoder will | 50 // Creates a RTCVideoDecoder. Returns NULL if failed. The video decoder will |
51 // run on the message loop of |factories|. | 51 // run on the message loop of |factories|. |
52 static scoped_ptr<RTCVideoDecoder> Create( | 52 static scoped_ptr<RTCVideoDecoder> Create( |
53 webrtc::VideoCodecType type, | 53 webrtc::VideoCodecType type, |
54 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories); | 54 const scoped_refptr<media::GpuVideoAcceleratorFactories>& factories); |
55 | 55 |
56 // webrtc::VideoDecoder implementation. | 56 // webrtc::VideoDecoder implementation. |
57 // Called on WebRTC DecodingThread. | 57 // Called on WebRTC DecodingThread. |
58 virtual int32_t InitDecode(const webrtc::VideoCodec* codecSettings, | 58 int32_t InitDecode(const webrtc::VideoCodec* codecSettings, |
59 int32_t numberOfCores) override; | 59 int32_t numberOfCores) override; |
60 // Called on WebRTC DecodingThread. | 60 // Called on WebRTC DecodingThread. |
61 virtual int32_t Decode( | 61 int32_t Decode(const webrtc::EncodedImage& inputImage, |
62 const webrtc::EncodedImage& inputImage, | 62 bool missingFrames, |
63 bool missingFrames, | 63 const webrtc::RTPFragmentationHeader* fragmentation, |
64 const webrtc::RTPFragmentationHeader* fragmentation, | 64 const webrtc::CodecSpecificInfo* codecSpecificInfo = NULL, |
65 const webrtc::CodecSpecificInfo* codecSpecificInfo = NULL, | 65 int64_t renderTimeMs = -1) override; |
66 int64_t renderTimeMs = -1) override; | |
67 // Called on WebRTC DecodingThread. | 66 // Called on WebRTC DecodingThread. |
68 virtual int32_t RegisterDecodeCompleteCallback( | 67 int32_t RegisterDecodeCompleteCallback( |
69 webrtc::DecodedImageCallback* callback) override; | 68 webrtc::DecodedImageCallback* callback) override; |
70 // Called on Chrome_libJingle_WorkerThread. The child thread is blocked while | 69 // Called on Chrome_libJingle_WorkerThread. The child thread is blocked while |
71 // this runs. | 70 // this runs. |
72 virtual int32_t Release() override; | 71 int32_t Release() override; |
73 // Called on Chrome_libJingle_WorkerThread. The child thread is blocked while | 72 // Called on Chrome_libJingle_WorkerThread. The child thread is blocked while |
74 // this runs. | 73 // this runs. |
75 virtual int32_t Reset() override; | 74 int32_t Reset() override; |
76 | 75 |
77 // VideoDecodeAccelerator::Client implementation. | 76 // VideoDecodeAccelerator::Client implementation. |
78 virtual void ProvidePictureBuffers(uint32 count, | 77 void ProvidePictureBuffers(uint32 count, |
79 const gfx::Size& size, | 78 const gfx::Size& size, |
80 uint32 texture_target) override; | 79 uint32 texture_target) override; |
81 virtual void DismissPictureBuffer(int32 id) override; | 80 void DismissPictureBuffer(int32 id) override; |
82 virtual void PictureReady(const media::Picture& picture) override; | 81 void PictureReady(const media::Picture& picture) override; |
83 virtual void NotifyEndOfBitstreamBuffer(int32 id) override; | 82 void NotifyEndOfBitstreamBuffer(int32 id) override; |
84 virtual void NotifyFlushDone() override; | 83 void NotifyFlushDone() override; |
85 virtual void NotifyResetDone() override; | 84 void NotifyResetDone() override; |
86 virtual void NotifyError(media::VideoDecodeAccelerator::Error error) override; | 85 void NotifyError(media::VideoDecodeAccelerator::Error error) override; |
87 | 86 |
88 private: | 87 private: |
89 class SHMBuffer; | 88 class SHMBuffer; |
90 // Metadata of a bitstream buffer. | 89 // Metadata of a bitstream buffer. |
91 struct BufferData { | 90 struct BufferData { |
92 BufferData(int32 bitstream_buffer_id, | 91 BufferData(int32 bitstream_buffer_id, |
93 uint32_t timestamp, | 92 uint32_t timestamp, |
94 size_t size); | 93 size_t size); |
95 BufferData(); | 94 BufferData(); |
96 ~BufferData(); | 95 ~BufferData(); |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 // Must be destroyed, or invalidated, on |vda_loop_proxy_| | 260 // Must be destroyed, or invalidated, on |vda_loop_proxy_| |
262 // NOTE: Weak pointers must be invalidated before all other member variables. | 261 // NOTE: Weak pointers must be invalidated before all other member variables. |
263 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; | 262 base::WeakPtrFactory<RTCVideoDecoder> weak_factory_; |
264 | 263 |
265 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); | 264 DISALLOW_COPY_AND_ASSIGN(RTCVideoDecoder); |
266 }; | 265 }; |
267 | 266 |
268 } // namespace content | 267 } // namespace content |
269 | 268 |
270 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ | 269 #endif // CONTENT_RENDERER_MEDIA_RTC_VIDEO_DECODER_H_ |
OLD | NEW |