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 <d3d9.h> | 8 #include <d3d9.h> |
9 #include <dxva2api.h> | 9 #include <dxva2api.h> |
10 #include <list> | 10 #include <list> |
11 #include <map> | 11 #include <map> |
12 #include <mfidl.h> | 12 #include <mfidl.h> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/compiler_specific.h" | 15 #include "base/compiler_specific.h" |
16 #include "base/memory/linked_ptr.h" | 16 #include "base/memory/linked_ptr.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
18 #include "base/threading/non_thread_safe.h" | 18 #include "base/threading/non_thread_safe.h" |
19 #include "base/win/scoped_comptr.h" | 19 #include "base/win/scoped_comptr.h" |
20 #include "content/common/content_export.h" | 20 #include "content/common/content_export.h" |
21 #include "content/common/gpu/media/video_decode_accelerator_impl.h" | |
22 #include "media/video/video_decode_accelerator.h" | 21 #include "media/video/video_decode_accelerator.h" |
23 | 22 |
24 interface IMFSample; | 23 interface IMFSample; |
25 interface IDirect3DSurface9; | 24 interface IDirect3DSurface9; |
26 | 25 |
27 namespace content { | 26 namespace content { |
28 | 27 |
29 // Class to provide a DXVA 2.0 based accelerator using the Microsoft Media | 28 // Class to provide a DXVA 2.0 based accelerator using the Microsoft Media |
30 // foundation APIs via the VideoDecodeAccelerator interface. | 29 // foundation APIs via the VideoDecodeAccelerator interface. |
31 // This class lives on a single thread and DCHECKs that it is never accessed | 30 // This class lives on a single thread and DCHECKs that it is never accessed |
32 // from any other. | 31 // from any other. |
33 class CONTENT_EXPORT DXVAVideoDecodeAccelerator | 32 class CONTENT_EXPORT DXVAVideoDecodeAccelerator |
34 : public VideoDecodeAcceleratorImpl, | 33 : public media::VideoDecodeAccelerator, |
35 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 34 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
36 public: | 35 public: |
37 enum State { | 36 enum State { |
38 kUninitialized, // un-initialized. | 37 kUninitialized, // un-initialized. |
39 kNormal, // normal playing state. | 38 kNormal, // normal playing state. |
40 kResetting, // upon received Reset(), before ResetDone() | 39 kResetting, // upon received Reset(), before ResetDone() |
41 kStopped, // upon output EOS received. | 40 kStopped, // upon output EOS received. |
42 kFlushing, // upon flush request received. | 41 kFlushing, // upon flush request received. |
43 }; | 42 }; |
44 | 43 |
45 // Does not take ownership of |client| which must outlive |*this|. | 44 // Does not take ownership of |client| which must outlive |*this|. |
46 explicit DXVAVideoDecodeAccelerator( | 45 explicit DXVAVideoDecodeAccelerator( |
47 const base::Callback<bool(void)>& make_context_current); | 46 const base::Callback<bool(void)>& make_context_current); |
48 virtual ~DXVAVideoDecodeAccelerator(); | 47 virtual ~DXVAVideoDecodeAccelerator(); |
49 | 48 |
50 // media::VideoDecodeAccelerator implementation. | 49 // media::VideoDecodeAccelerator implementation. |
51 virtual bool Initialize(media::VideoCodecProfile profile, | 50 virtual bool Initialize(media::VideoCodecProfile profile, |
52 Client* client) OVERRIDE; | 51 Client* client) OVERRIDE; |
53 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 52 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
54 virtual void AssignPictureBuffers( | 53 virtual void AssignPictureBuffers( |
55 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; | 54 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; |
56 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | 55 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
57 virtual void Flush() OVERRIDE; | 56 virtual void Flush() OVERRIDE; |
58 virtual void Reset() OVERRIDE; | 57 virtual void Reset() OVERRIDE; |
59 virtual void Destroy() OVERRIDE; | 58 virtual void Destroy() OVERRIDE; |
| 59 virtual bool CanDecodeOnIOThread() OVERRIDE; |
60 | 60 |
61 private: | 61 private: |
62 typedef void* EGLConfig; | 62 typedef void* EGLConfig; |
63 typedef void* EGLSurface; | 63 typedef void* EGLSurface; |
64 // Creates and initializes an instance of the D3D device and the | 64 // Creates and initializes an instance of the D3D device and the |
65 // corresponding device manager. The device manager instance is eventually | 65 // corresponding device manager. The device manager instance is eventually |
66 // passed to the IMFTransform interface implemented by the h.264 decoder. | 66 // passed to the IMFTransform interface implemented by the h.264 decoder. |
67 bool CreateD3DDevManager(); | 67 bool CreateD3DDevManager(); |
68 | 68 |
69 // Creates, initializes and sets the media types for the h.264 decoder. | 69 // Creates, initializes and sets the media types for the h.264 decoder. |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 // Callback to set the correct gl context. | 205 // Callback to set the correct gl context. |
206 base::Callback<bool(void)> make_context_current_; | 206 base::Callback<bool(void)> make_context_current_; |
207 | 207 |
208 // WeakPtrFactory for posting tasks back to |this|. | 208 // WeakPtrFactory for posting tasks back to |this|. |
209 base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_; | 209 base::WeakPtrFactory<DXVAVideoDecodeAccelerator> weak_this_factory_; |
210 }; | 210 }; |
211 | 211 |
212 } // namespace content | 212 } // namespace content |
213 | 213 |
214 #endif // CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ | 214 #endif // CONTENT_COMMON_GPU_MEDIA_DXVA_VIDEO_DECODE_ACCELERATOR_H_ |
OLD | NEW |