| 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 "gpu/command_buffer/common/sync_token.h" | 19 #include "gpu/command_buffer/common/sync_token.h" |
| 20 #include "media/base/overlay_info.h" |
| 20 #include "media/base/pipeline_status.h" | 21 #include "media/base/pipeline_status.h" |
| 21 #include "media/base/surface_manager.h" | 22 #include "media/base/surface_manager.h" |
| 22 #include "media/base/video_decoder.h" | 23 #include "media/base/video_decoder.h" |
| 23 #include "media/video/video_decode_accelerator.h" | 24 #include "media/video/video_decode_accelerator.h" |
| 24 | 25 |
| 25 template <class T> class scoped_refptr; | 26 template <class T> class scoped_refptr; |
| 26 | 27 |
| 27 namespace base { | 28 namespace base { |
| 28 class SharedMemory; | 29 class SharedMemory; |
| 29 } | 30 } |
| (...skipping 10 matching lines...) Expand all Loading... |
| 40 | 41 |
| 41 // GPU-accelerated video decoder implementation. Relies on | 42 // GPU-accelerated video decoder implementation. Relies on |
| 42 // AcceleratedVideoDecoderMsg_Decode and friends. Can be created on any thread | 43 // AcceleratedVideoDecoderMsg_Decode and friends. Can be created on any thread |
| 43 // but must be accessed and destroyed on GpuVideoAcceleratorFactories's | 44 // but must be accessed and destroyed on GpuVideoAcceleratorFactories's |
| 44 // GetMessageLoop(). | 45 // GetMessageLoop(). |
| 45 class MEDIA_EXPORT GpuVideoDecoder | 46 class MEDIA_EXPORT GpuVideoDecoder |
| 46 : public VideoDecoder, | 47 : public VideoDecoder, |
| 47 public VideoDecodeAccelerator::Client { | 48 public VideoDecodeAccelerator::Client { |
| 48 public: | 49 public: |
| 49 GpuVideoDecoder(GpuVideoAcceleratorFactories* factories, | 50 GpuVideoDecoder(GpuVideoAcceleratorFactories* factories, |
| 50 const RequestSurfaceCB& request_surface_cb, | 51 const RequestOverlayInfoCB& request_overlay_info_cb, |
| 51 MediaLog* media_log); | 52 MediaLog* media_log); |
| 52 | 53 |
| 53 // VideoDecoder implementation. | 54 // VideoDecoder implementation. |
| 54 std::string GetDisplayName() const override; | 55 std::string GetDisplayName() const override; |
| 55 void Initialize(const VideoDecoderConfig& config, | 56 void Initialize(const VideoDecoderConfig& config, |
| 56 bool low_delay, | 57 bool low_delay, |
| 57 CdmContext* cdm_context, | 58 CdmContext* cdm_context, |
| 58 const InitCB& init_cb, | 59 const InitCB& init_cb, |
| 59 const OutputCB& output_cb) override; | 60 const OutputCB& output_cb) override; |
| 60 void Decode(const scoped_refptr<DecoderBuffer>& buffer, | 61 void Decode(const scoped_refptr<DecoderBuffer>& buffer, |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 // |profile|, |coded_size|, and |is_encrypted|. | 148 // |profile|, |coded_size|, and |is_encrypted|. |
| 148 bool IsProfileSupported( | 149 bool IsProfileSupported( |
| 149 const VideoDecodeAccelerator::Capabilities& capabilities, | 150 const VideoDecodeAccelerator::Capabilities& capabilities, |
| 150 VideoCodecProfile profile, | 151 VideoCodecProfile profile, |
| 151 const gfx::Size& coded_size, | 152 const gfx::Size& coded_size, |
| 152 bool is_encrypted); | 153 bool is_encrypted); |
| 153 | 154 |
| 154 // Assert the contract that this class is operated on the right thread. | 155 // Assert the contract that this class is operated on the right thread. |
| 155 void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const; | 156 void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const; |
| 156 | 157 |
| 157 // Provided to the |request_surface_cb_| callback given during construction; | 158 // Provided to the |request_overlay_info_cb_| callback given during |
| 158 // sets or changes the output surface. | 159 // construction. Sets or changes the output surface. |
| 159 void OnSurfaceAvailable(int surface_id); | 160 void OnOverlayInfoAvailable( |
| 161 int surface_id, |
| 162 const base::Optional<base::UnguessableToken>& routing_token); |
| 160 | 163 |
| 161 // If the VDA supports external surfaces, we must wait for the surface before | 164 // If the VDA supports external surfaces, we must wait for the surface before |
| 162 // completing initialization. This will be called by OnSurfaceAvailable() once | 165 // completing initialization. This will be called by OnSurfaceAvailable() once |
| 163 // the surface is known or immediately by Initialize() if external surfaces | 166 // the surface is known or immediately by Initialize() if external surfaces |
| 164 // are unsupported. | 167 // are unsupported. |
| 165 void CompleteInitialization(int surface_id); | 168 void CompleteInitialization( |
| 169 int surface_id, |
| 170 const base::Optional<base::UnguessableToken>& token); |
| 166 | 171 |
| 167 bool needs_bitstream_conversion_; | 172 bool needs_bitstream_conversion_; |
| 168 | 173 |
| 169 GpuVideoAcceleratorFactories* factories_; | 174 GpuVideoAcceleratorFactories* factories_; |
| 170 | 175 |
| 171 // For requesting a suface to render to. If this is null the VDA will return | 176 // For requesting a suface to render to. If this is null the VDA will return |
| 172 // normal video frames and not render them to a surface. | 177 // normal video frames and not render them to a surface. |
| 173 RequestSurfaceCB request_surface_cb_; | 178 RequestOverlayInfoCB request_overlay_info_cb_; |
| 174 | 179 |
| 175 MediaLog* media_log_; | 180 MediaLog* media_log_; |
| 176 | 181 |
| 177 // Populated during Initialize() (on success) and unchanged until an error | 182 // Populated during Initialize() (on success) and unchanged until an error |
| 178 // occurs. | 183 // occurs. |
| 179 std::unique_ptr<VideoDecodeAccelerator> vda_; | 184 std::unique_ptr<VideoDecodeAccelerator> vda_; |
| 180 | 185 |
| 181 // Whether |vda_->Initialize()| has been called. This is used to avoid | 186 // Whether |vda_->Initialize()| has been called. This is used to avoid |
| 182 // calling Initialize() again while a deferred initialization is in progress. | 187 // calling Initialize() again while a deferred initialization is in progress. |
| 183 bool vda_initialized_; | 188 bool vda_initialized_; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // Bound to factories_->GetMessageLoop(). | 267 // Bound to factories_->GetMessageLoop(). |
| 263 // NOTE: Weak pointers must be invalidated before all other member variables. | 268 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 264 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; | 269 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; |
| 265 | 270 |
| 266 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); | 271 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); |
| 267 }; | 272 }; |
| 268 | 273 |
| 269 } // namespace media | 274 } // namespace media |
| 270 | 275 |
| 271 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ | 276 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ |
| OLD | NEW |