| 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 CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ | 5 #ifndef CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ |
| 6 #define CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ | 6 #define CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ |
| 7 | 7 |
| 8 #include <d3d11.h> | 8 #include <d3d11.h> |
| 9 #include <d3d9.h> | 9 #include <d3d9.h> |
| 10 #include <stdint.h> | 10 #include <stdint.h> |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 | 22 |
| 23 #include "base/compiler_specific.h" | 23 #include "base/compiler_specific.h" |
| 24 #include "base/macros.h" | 24 #include "base/macros.h" |
| 25 #include "base/memory/linked_ptr.h" | 25 #include "base/memory/linked_ptr.h" |
| 26 #include "base/memory/weak_ptr.h" | 26 #include "base/memory/weak_ptr.h" |
| 27 #include "base/synchronization/lock.h" | 27 #include "base/synchronization/lock.h" |
| 28 #include "base/threading/non_thread_safe.h" | 28 #include "base/threading/non_thread_safe.h" |
| 29 #include "base/threading/thread.h" | 29 #include "base/threading/thread.h" |
| 30 #include "base/win/scoped_comptr.h" | 30 #include "base/win/scoped_comptr.h" |
| 31 #include "content/common/content_export.h" | 31 #include "content/common/content_export.h" |
| 32 #include "content/public/common/gpu_video_decode_accelerator_helpers.h" |
| 32 #include "media/video/video_decode_accelerator.h" | 33 #include "media/video/video_decode_accelerator.h" |
| 33 | 34 |
| 34 interface IMFSample; | 35 interface IMFSample; |
| 35 interface IDirect3DSurface9; | 36 interface IDirect3DSurface9; |
| 36 | 37 |
| 37 namespace gfx { | 38 namespace gfx { |
| 38 class GLContext; | 39 class GLContext; |
| 39 } | 40 } |
| 40 | 41 |
| 41 typedef HRESULT (WINAPI* CreateDXGIDeviceManager)( | 42 typedef HRESULT (WINAPI* CreateDXGIDeviceManager)( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 53 public: | 54 public: |
| 54 enum State { | 55 enum State { |
| 55 kUninitialized, // un-initialized. | 56 kUninitialized, // un-initialized. |
| 56 kNormal, // normal playing state. | 57 kNormal, // normal playing state. |
| 57 kResetting, // upon received Reset(), before ResetDone() | 58 kResetting, // upon received Reset(), before ResetDone() |
| 58 kStopped, // upon output EOS received. | 59 kStopped, // upon output EOS received. |
| 59 kFlushing, // upon flush request received. | 60 kFlushing, // upon flush request received. |
| 60 }; | 61 }; |
| 61 | 62 |
| 62 // Does not take ownership of |client| which must outlive |*this|. | 63 // Does not take ownership of |client| which must outlive |*this|. |
| 63 explicit DXVAVideoDecodeAccelerator( | 64 DXVAVideoDecodeAccelerator( |
| 64 const base::Callback<bool(void)>& make_context_current, | 65 const gpu_vda_helpers::GetGLContextCb& get_gl_context_cb, |
| 65 gfx::GLContext* gl_context); | 66 const gpu_vda_helpers::MakeGLContextCurrentCb& make_context_current_cb); |
| 66 ~DXVAVideoDecodeAccelerator() override; | 67 ~DXVAVideoDecodeAccelerator() override; |
| 67 | 68 |
| 68 // media::VideoDecodeAccelerator implementation. | 69 // media::VideoDecodeAccelerator implementation. |
| 69 bool Initialize(const Config& config, Client* client) override; | 70 bool Initialize(const Config& config, Client* client) override; |
| 70 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; | 71 void Decode(const media::BitstreamBuffer& bitstream_buffer) override; |
| 71 void AssignPictureBuffers( | 72 void AssignPictureBuffers( |
| 72 const std::vector<media::PictureBuffer>& buffers) override; | 73 const std::vector<media::PictureBuffer>& buffers) override; |
| 73 void ReusePictureBuffer(int32_t picture_buffer_id) override; | 74 void ReusePictureBuffer(int32_t picture_buffer_id) override; |
| 74 void Flush() override; | 75 void Flush() override; |
| 75 void Reset() override; | 76 void Reset() override; |
| 76 void Destroy() override; | 77 void Destroy() override; |
| 77 bool CanDecodeOnIOThread() override; | 78 bool TryInitializeDecodeOnSeparateThread( |
| 79 const base::WeakPtr<Client>& decode_client, |
| 80 const scoped_refptr<base::SingleThreadTaskRunner>& decode_task_runner) |
| 81 override; |
| 78 GLenum GetSurfaceInternalFormat() const override; | 82 GLenum GetSurfaceInternalFormat() const override; |
| 79 | 83 |
| 80 static media::VideoDecodeAccelerator::SupportedProfiles | 84 static media::VideoDecodeAccelerator::SupportedProfiles |
| 81 GetSupportedProfiles(); | 85 GetSupportedProfiles(); |
| 82 | 86 |
| 83 // Preload dlls required for decoding. | 87 // Preload dlls required for decoding. |
| 84 static void PreSandboxInitialization(); | 88 static void PreSandboxInitialization(); |
| 85 | 89 |
| 86 private: | 90 private: |
| 87 typedef void* EGLConfig; | 91 typedef void* EGLConfig; |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 339 |
| 336 // Set to true when the drain message is sent to the decoder during a flush | 340 // Set to true when the drain message is sent to the decoder during a flush |
| 337 // operation. Used to ensure the message is only sent once after | 341 // operation. Used to ensure the message is only sent once after |
| 338 // |pending_input_buffers_| is drained. Protected by |decoder_lock_|. | 342 // |pending_input_buffers_| is drained. Protected by |decoder_lock_|. |
| 339 bool sent_drain_message_; | 343 bool sent_drain_message_; |
| 340 | 344 |
| 341 // List of input samples waiting to be processed. | 345 // List of input samples waiting to be processed. |
| 342 typedef std::list<base::win::ScopedComPtr<IMFSample>> PendingInputs; | 346 typedef std::list<base::win::ScopedComPtr<IMFSample>> PendingInputs; |
| 343 PendingInputs pending_input_buffers_; | 347 PendingInputs pending_input_buffers_; |
| 344 | 348 |
| 349 // Callback to get current GLContext. |
| 350 gpu_vda_helpers::GetGLContextCb get_gl_context_cb_; |
| 345 // Callback to set the correct gl context. | 351 // Callback to set the correct gl context. |
| 346 base::Callback<bool(void)> make_context_current_; | 352 gpu_vda_helpers::MakeGLContextCurrentCb make_context_current_cb_; |
| 347 | 353 |
| 348 // Which codec we are decoding with hardware acceleration. | 354 // Which codec we are decoding with hardware acceleration. |
| 349 media::VideoCodec codec_; | 355 media::VideoCodec codec_; |
| 350 // Thread on which the decoder operations like passing input frames, | 356 // Thread on which the decoder operations like passing input frames, |
| 351 // getting output frames are performed. One instance of this thread | 357 // getting output frames are performed. One instance of this thread |
| 352 // is created per decoder instance. | 358 // is created per decoder instance. |
| 353 base::Thread decoder_thread_; | 359 base::Thread decoder_thread_; |
| 354 | 360 |
| 355 // Task runner to be used for posting tasks to the decoder thread. | 361 // Task runner to be used for posting tasks to the decoder thread. |
| 356 scoped_refptr<base::SingleThreadTaskRunner> decoder_thread_task_runner_; | 362 scoped_refptr<base::SingleThreadTaskRunner> decoder_thread_task_runner_; |
| (...skipping 19 matching lines...) Expand all Loading... |
| 376 bool use_dx11_; | 382 bool use_dx11_; |
| 377 | 383 |
| 378 // True if we should use DXGI keyed mutexes to synchronize between the two | 384 // True if we should use DXGI keyed mutexes to synchronize between the two |
| 379 // contexts. | 385 // contexts. |
| 380 bool use_keyed_mutex_; | 386 bool use_keyed_mutex_; |
| 381 | 387 |
| 382 // Set to true if the DX11 video format converter input media types need to | 388 // Set to true if the DX11 video format converter input media types need to |
| 383 // be initialized. Defaults to true. | 389 // be initialized. Defaults to true. |
| 384 bool dx11_video_format_converter_media_type_needs_init_; | 390 bool dx11_video_format_converter_media_type_needs_init_; |
| 385 | 391 |
| 386 // The GLContext to be used by the decoder. | |
| 387 scoped_refptr<gfx::GLContext> gl_context_; | |
| 388 | |
| 389 // Set to true if we are sharing ANGLE's device. | 392 // Set to true if we are sharing ANGLE's device. |
| 390 bool using_angle_device_; | 393 bool using_angle_device_; |
| 391 | 394 |
| 392 // WeakPtrFactory for posting tasks back to |this|. | 395 // WeakPtrFactory for posting tasks back to |this|. |
| 393 base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_; | 396 base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_; |
| 394 | 397 |
| 395 // Function pointer for the MFCreateDXGIDeviceManager API. | 398 // Function pointer for the MFCreateDXGIDeviceManager API. |
| 396 static CreateDXGIDeviceManager create_dxgi_device_manager_; | 399 static CreateDXGIDeviceManager create_dxgi_device_manager_; |
| 397 | 400 |
| 398 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); | 401 DISALLOW_COPY_AND_ASSIGN(DXVAVideoDecodeAccelerator); |
| 399 }; | 402 }; |
| 400 | 403 |
| 401 } // namespace content | 404 } // namespace content |
| 402 | 405 |
| 403 #endif // CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ | 406 #endif // CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ |
| OLD | NEW |