| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_GPU_GPU_VIDEO_DECODER_MFT_H_ | |
| 6 #define CHROME_GPU_GPU_VIDEO_DECODER_MFT_H_ | |
| 7 | |
| 8 #include "build/build_config.h" // For OS_WIN. | |
| 9 | |
| 10 #if defined(OS_WIN) | |
| 11 | |
| 12 #include <d3d9.h> | |
| 13 #include <dxva2api.h> | |
| 14 #include <evr.h> | |
| 15 #include <initguid.h> | |
| 16 #include <mfapi.h> | |
| 17 #include <mferror.h> | |
| 18 #include <mfidl.h> | |
| 19 #include <shlwapi.h> | |
| 20 #include <wmcodecdsp.h> | |
| 21 | |
| 22 #include <deque> | |
| 23 | |
| 24 #include "base/scoped_comptr_win.h" | |
| 25 #include "chrome/gpu/gpu_video_decoder.h" | |
| 26 | |
| 27 class GpuVideoDecoderMFT : public GpuVideoDecoder { | |
| 28 public: | |
| 29 virtual bool DoInitialize(const GpuVideoDecoderInitParam& init_param, | |
| 30 GpuVideoDecoderInitDoneParam* done_param); | |
| 31 virtual bool DoUninitialize(); | |
| 32 virtual void DoFlush(); | |
| 33 virtual void DoEmptyThisBuffer(const GpuVideoDecoderInputBufferParam& buffer); | |
| 34 virtual void DoFillThisBuffer(const GpuVideoDecoderOutputBufferParam& frame); | |
| 35 virtual void DoFillThisBufferDoneACK(); | |
| 36 | |
| 37 private: | |
| 38 GpuVideoDecoderMFT(const GpuVideoDecoderInfoParam* param, | |
| 39 GpuChannel* channel_, | |
| 40 base::ProcessHandle handle); | |
| 41 | |
| 42 friend class GpuVideoService; | |
| 43 | |
| 44 // TODO(jiesun): Find a way to move all these to GpuVideoService.. | |
| 45 static bool StartupComLibraries(); | |
| 46 static void ShutdownComLibraries(); | |
| 47 bool CreateD3DDevManager(HWND video_window); | |
| 48 | |
| 49 // helper. | |
| 50 bool InitMediaFoundation(); | |
| 51 bool InitDecoder(); | |
| 52 bool CheckDecoderDxvaSupport(); | |
| 53 | |
| 54 bool SetDecoderMediaTypes(); | |
| 55 bool SetDecoderInputMediaType(); | |
| 56 bool SetDecoderOutputMediaType(const GUID subtype); | |
| 57 bool SendMFTMessage(MFT_MESSAGE_TYPE msg); | |
| 58 bool GetStreamsInfoAndBufferReqs(); | |
| 59 | |
| 60 // Help function to create IMFSample* out of input buffer. | |
| 61 // data are copied into IMFSample's own IMFMediaBuffer. | |
| 62 // Client should Release() the IMFSample*. | |
| 63 static IMFSample* CreateInputSample(uint8* data, | |
| 64 int32 size, | |
| 65 int64 timestamp, | |
| 66 int64 duration, | |
| 67 int32 min_size); | |
| 68 | |
| 69 bool DoDecode(); | |
| 70 | |
| 71 ScopedComPtr<IDirect3D9> d3d9_; | |
| 72 ScopedComPtr<IDirect3DDevice9> device_; | |
| 73 ScopedComPtr<IDirect3DDeviceManager9> device_manager_; | |
| 74 ScopedComPtr<IMFTransform> decoder_; | |
| 75 | |
| 76 MFT_INPUT_STREAM_INFO input_stream_info_; | |
| 77 MFT_OUTPUT_STREAM_INFO output_stream_info_; | |
| 78 | |
| 79 std::deque<ScopedComPtr<IMFSample> > input_buffer_queue_; | |
| 80 bool output_transfer_buffer_busy_; | |
| 81 | |
| 82 typedef enum { | |
| 83 kNormal, // normal playing state. | |
| 84 kFlushing, // upon received Flush(), before FlushDone() | |
| 85 kEosFlush, // upon input EOS received. | |
| 86 kStopped, // upon output EOS received. | |
| 87 } State; | |
| 88 State state_; | |
| 89 | |
| 90 int32 pending_request_; | |
| 91 | |
| 92 DISALLOW_COPY_AND_ASSIGN(GpuVideoDecoderMFT); | |
| 93 }; | |
| 94 | |
| 95 #endif | |
| 96 | |
| 97 #endif // CHROME_GPU_GPU_VIDEO_DECODER_MFT_H_ | |
| 98 | |
| OLD | NEW |