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" |
21 #include "media/video/video_decode_accelerator.h" | 22 #include "media/video/video_decode_accelerator.h" |
22 | 23 |
23 interface IMFSample; | 24 interface IMFSample; |
24 interface IDirect3DSurface9; | 25 interface IDirect3DSurface9; |
25 | 26 |
26 namespace content { | 27 namespace content { |
27 | 28 |
28 // Class to provide a DXVA 2.0 based accelerator using the Microsoft Media | 29 // Class to provide a DXVA 2.0 based accelerator using the Microsoft Media |
29 // foundation APIs via the VideoDecodeAccelerator interface. | 30 // foundation APIs via the VideoDecodeAccelerator interface. |
30 // This class lives on a single thread and DCHECKs that it is never accessed | 31 // This class lives on a single thread and DCHECKs that it is never accessed |
31 // from any other. | 32 // from any other. |
32 class CONTENT_EXPORT DXVAVideoDecodeAccelerator | 33 class CONTENT_EXPORT DXVAVideoDecodeAccelerator |
33 : public media::VideoDecodeAccelerator, | 34 : public VideoDecodeAcceleratorImpl, |
34 NON_EXPORTED_BASE(public base::NonThreadSafe) { | 35 NON_EXPORTED_BASE(public base::NonThreadSafe) { |
35 public: | 36 public: |
36 enum State { | 37 enum State { |
37 kUninitialized, // un-initialized. | 38 kUninitialized, // un-initialized. |
38 kNormal, // normal playing state. | 39 kNormal, // normal playing state. |
39 kResetting, // upon received Reset(), before ResetDone() | 40 kResetting, // upon received Reset(), before ResetDone() |
40 kStopped, // upon output EOS received. | 41 kStopped, // upon output EOS received. |
41 kFlushing, // upon flush request received. | 42 kFlushing, // upon flush request received. |
42 }; | 43 }; |
43 | 44 |
44 // Does not take ownership of |client| which must outlive |*this|. | 45 // Does not take ownership of |client| which must outlive |*this|. |
45 explicit DXVAVideoDecodeAccelerator( | 46 explicit DXVAVideoDecodeAccelerator( |
46 const base::Callback<bool(void)>& make_context_current); | 47 const base::Callback<bool(void)>& make_context_current); |
47 virtual ~DXVAVideoDecodeAccelerator(); | 48 virtual ~DXVAVideoDecodeAccelerator(); |
48 | 49 |
49 // media::VideoDecodeAccelerator implementation. | 50 // media::VideoDecodeAccelerator implementation. |
50 virtual bool Initialize(media::VideoCodecProfile profile, | 51 virtual bool Initialize(media::VideoCodecProfile profile, |
51 Client* client) OVERRIDE; | 52 Client* client) OVERRIDE; |
52 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; | 53 virtual void Decode(const media::BitstreamBuffer& bitstream_buffer) OVERRIDE; |
53 virtual void AssignPictureBuffers( | 54 virtual void AssignPictureBuffers( |
54 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; | 55 const std::vector<media::PictureBuffer>& buffers) OVERRIDE; |
55 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; | 56 virtual void ReusePictureBuffer(int32 picture_buffer_id) OVERRIDE; |
56 virtual void Flush() OVERRIDE; | 57 virtual void Flush() OVERRIDE; |
57 virtual void Reset() OVERRIDE; | 58 virtual void Reset() OVERRIDE; |
58 virtual void Destroy() OVERRIDE; | 59 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 |