| 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 ~GpuVideoDecoder() override; | 53 ~GpuVideoDecoder() override; |
| 53 | 54 |
| 54 // VideoDecoder implementation. | 55 // VideoDecoder implementation. |
| 55 std::string GetDisplayName() const override; | 56 std::string GetDisplayName() const override; |
| 56 void Initialize(const VideoDecoderConfig& config, | 57 void Initialize(const VideoDecoderConfig& config, |
| 57 bool low_delay, | 58 bool low_delay, |
| 58 CdmContext* cdm_context, | 59 CdmContext* cdm_context, |
| 59 const InitCB& init_cb, | 60 const InitCB& init_cb, |
| 60 const OutputCB& output_cb) override; | 61 const OutputCB& output_cb) override; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 // |profile|, |coded_size|, and |is_encrypted|. | 146 // |profile|, |coded_size|, and |is_encrypted|. |
| 146 bool IsProfileSupported( | 147 bool IsProfileSupported( |
| 147 const VideoDecodeAccelerator::Capabilities& capabilities, | 148 const VideoDecodeAccelerator::Capabilities& capabilities, |
| 148 VideoCodecProfile profile, | 149 VideoCodecProfile profile, |
| 149 const gfx::Size& coded_size, | 150 const gfx::Size& coded_size, |
| 150 bool is_encrypted); | 151 bool is_encrypted); |
| 151 | 152 |
| 152 // Assert the contract that this class is operated on the right thread. | 153 // Assert the contract that this class is operated on the right thread. |
| 153 void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const; | 154 void DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent() const; |
| 154 | 155 |
| 155 // Provided to the |request_surface_cb_| callback given during construction; | 156 // Provided to the |request_overlay_info_cb_| callback given during |
| 156 // sets or changes the output surface. | 157 // construction. Sets or changes the output surface. |
| 157 void OnSurfaceAvailable(int surface_id); | 158 void OnOverlayInfoAvailable( |
| 159 int surface_id, |
| 160 const base::Optional<base::UnguessableToken>& routing_token); |
| 158 | 161 |
| 159 // If the VDA supports external surfaces, we must wait for the surface before | 162 // If the VDA supports external surfaces, we must wait for the surface before |
| 160 // completing initialization. This will be called by OnSurfaceAvailable() once | 163 // completing initialization. This will be called by OnSurfaceAvailable() once |
| 161 // the surface is known or immediately by Initialize() if external surfaces | 164 // the surface is known or immediately by Initialize() if external surfaces |
| 162 // are unsupported. | 165 // are unsupported. |
| 163 void CompleteInitialization(int surface_id); | 166 void CompleteInitialization( |
| 167 int surface_id, |
| 168 const base::Optional<base::UnguessableToken>& token); |
| 164 | 169 |
| 165 bool needs_bitstream_conversion_; | 170 bool needs_bitstream_conversion_; |
| 166 | 171 |
| 167 GpuVideoAcceleratorFactories* factories_; | 172 GpuVideoAcceleratorFactories* factories_; |
| 168 | 173 |
| 169 // For requesting a suface to render to. If this is null the VDA will return | 174 // For requesting a suface to render to. If this is null the VDA will return |
| 170 // normal video frames and not render them to a surface. | 175 // normal video frames and not render them to a surface. |
| 171 RequestSurfaceCB request_surface_cb_; | 176 RequestOverlayInfoCB request_overlay_info_cb_; |
| 172 | 177 |
| 173 MediaLog* media_log_; | 178 MediaLog* media_log_; |
| 174 | 179 |
| 175 // Populated during Initialize() (on success) and unchanged until an error | 180 // Populated during Initialize() (on success) and unchanged until an error |
| 176 // occurs. | 181 // occurs. |
| 177 std::unique_ptr<VideoDecodeAccelerator> vda_; | 182 std::unique_ptr<VideoDecodeAccelerator> vda_; |
| 178 | 183 |
| 179 // Whether |vda_->Initialize()| has been called. This is used to avoid | 184 // Whether |vda_->Initialize()| has been called. This is used to avoid |
| 180 // calling Initialize() again while a deferred initialization is in progress. | 185 // calling Initialize() again while a deferred initialization is in progress. |
| 181 bool vda_initialized_; | 186 bool vda_initialized_; |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 260 // Bound to factories_->GetMessageLoop(). | 265 // Bound to factories_->GetMessageLoop(). |
| 261 // NOTE: Weak pointers must be invalidated before all other member variables. | 266 // NOTE: Weak pointers must be invalidated before all other member variables. |
| 262 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; | 267 base::WeakPtrFactory<GpuVideoDecoder> weak_factory_; |
| 263 | 268 |
| 264 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); | 269 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoder); |
| 265 }; | 270 }; |
| 266 | 271 |
| 267 } // namespace media | 272 } // namespace media |
| 268 | 273 |
| 269 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ | 274 #endif // MEDIA_FILTERS_GPU_VIDEO_DECODER_H_ |
| OLD | NEW |