OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ | 5 #ifndef MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ |
6 #define MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ | 6 #define MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <list> | 11 #include <list> |
12 #include <map> | 12 #include <map> |
13 #include <set> | 13 #include <set> |
14 #include <utility> | 14 #include <utility> |
15 #include <vector> | 15 #include <vector> |
16 | 16 |
17 #include "base/macros.h" | 17 #include "base/macros.h" |
18 #include "base/memory/weak_ptr.h" | 18 #include "base/memory/weak_ptr.h" |
19 #include "media/base/pipeline_status.h" | 19 #include "media/base/pipeline_status.h" |
| 20 #include "media/base/surface_manager.h" |
20 #include "media/base/video_decoder.h" | 21 #include "media/base/video_decoder.h" |
21 #include "media/video/video_decode_accelerator.h" | 22 #include "media/video/video_decode_accelerator.h" |
22 | 23 |
23 template <class T> class scoped_refptr; | 24 template <class T> class scoped_refptr; |
24 | 25 |
25 namespace base { | 26 namespace base { |
26 class SharedMemory; | 27 class SharedMemory; |
27 class SingleThreadTaskRunner; | 28 class SingleThreadTaskRunner; |
28 } | 29 } |
29 | 30 |
30 namespace gpu { | 31 namespace gpu { |
31 struct SyncToken; | 32 struct SyncToken; |
32 } | 33 } |
33 | 34 |
34 namespace media { | 35 namespace media { |
35 | 36 |
36 class DecoderBuffer; | 37 class DecoderBuffer; |
37 class GpuVideoAcceleratorFactories; | 38 class GpuVideoAcceleratorFactories; |
38 class MediaLog; | 39 class MediaLog; |
39 | 40 |
40 // GPU-accelerated video decoder implementation. Relies on | 41 // GPU-accelerated video decoder implementation. Relies on |
41 // AcceleratedVideoDecoderMsg_Decode and friends. Can be created on any thread | 42 // AcceleratedVideoDecoderMsg_Decode and friends. Can be created on any thread |
42 // but must be accessed and destroyed on GpuVideoAcceleratorFactories's | 43 // but must be accessed and destroyed on GpuVideoAcceleratorFactories's |
43 // GetMessageLoop(). | 44 // GetMessageLoop(). |
44 class MEDIA_EXPORT GpuVideoDecoder | 45 class MEDIA_EXPORT GpuVideoDecoder |
45 : public VideoDecoder, | 46 : public VideoDecoder, |
46 public VideoDecodeAccelerator::Client { | 47 public VideoDecodeAccelerator::Client { |
47 public: | 48 public: |
48 explicit GpuVideoDecoder(GpuVideoAcceleratorFactories* factories); | 49 explicit GpuVideoDecoder(GpuVideoAcceleratorFactories* factories, |
| 50 const RequestSurfaceCB& request_surface_cb); |
49 | 51 |
50 // VideoDecoder implementation. | 52 // VideoDecoder implementation. |
51 std::string GetDisplayName() const override; | 53 std::string GetDisplayName() const override; |
52 void Initialize(const VideoDecoderConfig& config, | 54 void Initialize(const VideoDecoderConfig& config, |
53 bool low_delay, | 55 bool low_delay, |
54 CdmContext* cdm_context, | 56 CdmContext* cdm_context, |
55 const InitCB& init_cb, | 57 const InitCB& init_cb, |
56 const OutputCB& output_cb) override; | 58 const OutputCB& output_cb) override; |
| 59 void CompleteInitialization(int cdm_id, int surface_id); |
57 void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 60 void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
58 const DecodeCB& decode_cb) override; | 61 const DecodeCB& decode_cb) override; |
59 void Reset(const base::Closure& closure) override; | 62 void Reset(const base::Closure& closure) override; |
60 bool NeedsBitstreamConversion() const override; | 63 bool NeedsBitstreamConversion() const override; |
61 bool CanReadWithoutStalling() const override; | 64 bool CanReadWithoutStalling() const override; |
62 int GetMaxDecodeRequests() const override; | 65 int GetMaxDecodeRequests() const override; |
63 | 66 |
64 // VideoDecodeAccelerator::Client implementation. | 67 // VideoDecodeAccelerator::Client implementation. |
65 void NotifyCdmAttached(bool success) override; | 68 void NotifyCdmAttached(bool success) override; |
66 void ProvidePictureBuffers(uint32_t count, | 69 void ProvidePictureBuffers(uint32_t count, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 | 163 |
161 DecodeCB eos_decode_cb_; | 164 DecodeCB eos_decode_cb_; |
162 | 165 |
163 // Not null only during reset. | 166 // Not null only during reset. |
164 base::Closure pending_reset_cb_; | 167 base::Closure pending_reset_cb_; |
165 | 168 |
166 State state_; | 169 State state_; |
167 | 170 |
168 VideoDecoderConfig config_; | 171 VideoDecoderConfig config_; |
169 | 172 |
| 173 // For requesting a suface to render to. If this is null the VDA will return |
| 174 // normal video frames and not render them to a surface. |
| 175 RequestSurfaceCB request_surface_cb_; |
| 176 |
170 // Shared-memory buffer pool. Since allocating SHM segments requires a | 177 // Shared-memory buffer pool. Since allocating SHM segments requires a |
171 // round-trip to the browser process, we keep allocation out of the | 178 // round-trip to the browser process, we keep allocation out of the |
172 // steady-state of the decoder. | 179 // steady-state of the decoder. |
173 std::vector<SHMBuffer*> available_shm_segments_; | 180 std::vector<SHMBuffer*> available_shm_segments_; |
174 | 181 |
175 std::map<int32_t, PendingDecoderBuffer> bitstream_buffers_in_decoder_; | 182 std::map<int32_t, PendingDecoderBuffer> bitstream_buffers_in_decoder_; |
176 PictureBufferMap assigned_picture_buffers_; | 183 PictureBufferMap assigned_picture_buffers_; |
177 // PictureBuffers given to us by VDA via PictureReady, which we sent forward | 184 // PictureBuffers given to us by VDA via PictureReady, which we sent forward |
178 // as VideoFrames to be rendered via decode_cb_, and which will be returned | 185 // as VideoFrames to be rendered via decode_cb_, and which will be returned |
179 // to us via ReusePictureBuffer. | 186 // to us via ReusePictureBuffer. |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 // Bound to factories_->GetMessageLoop(). | 222 // Bound to factories_->GetMessageLoop(). |
216 // NOTE: Weak pointers must be invalidated before all other member variables. | 223 // NOTE: Weak pointers must be invalidated before all other member variables. |
217 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; | 224 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; |
218 | 225 |
219 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); | 226 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); |
220 }; | 227 }; |
221 | 228 |
222 } // namespace media | 229 } // namespace media |
223 | 230 |
224 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ | 231 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ |
OLD | NEW |