blob: 61e3c655af698a581421eee743a2213426a17224 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// MFT H.264 decoder.
#ifndef MEDIA_MF_MFT_H264_DECODER_H_
#define MEDIA_MF_MFT_H264_DECODER_H_
#include "build/build_config.h" // For OS_WIN.
#if defined(OS_WIN)
#include <d3d9.h>
#include <dxva2api.h>
#include <mfidl.h>
#include "base/gtest_prod_util.h"
#include "base/scoped_comptr_win.h"
#include "media/video/video_decode_engine.h"
class MessageLoop;
namespace media {
class MftH264Decoder : public media::VideoDecodeEngine {
public:
typedef enum {
kUninitialized, // un-initialized.
kNormal, // normal playing state.
kFlushing, // upon received Flush(), before FlushDone()
kEosDrain, // upon input EOS received.
kStopped, // upon output EOS received.
} State;
explicit MftH264Decoder(bool use_dxva, HWND draw_window);
~MftH264Decoder();
virtual void Initialize(MessageLoop* message_loop,
media::VideoDecodeEngine::EventHandler* event_handler,
const VideoCodecConfig& config);
virtual void Uninitialize();
virtual void Flush();
virtual void Seek();
virtual void ConsumeVideoSample(scoped_refptr<Buffer> buffer);
virtual void ProduceVideoFrame(scoped_refptr<VideoFrame> frame);
bool use_dxva() const { return use_dxva_; }
IDirect3DDevice9* device() const { return device_.get(); }
State state() const { return state_; }
private:
friend class MftH264DecoderTest;
FRIEND_TEST_ALL_PREFIXES(MftH264DecoderTest, LibraryInit);
// TODO(jiesun): Find a way to move all these to GpuVideoService..
static bool StartupComLibraries();
static void ShutdownComLibraries();
bool CreateD3DDevManager();
bool InitInternal();
bool InitDecoder();
bool CheckDecoderDxvaSupport();
bool SetDecoderMediaTypes();
bool SetDecoderInputMediaType();
bool SetDecoderOutputMediaType(const GUID subtype);
bool SendMFTMessage(MFT_MESSAGE_TYPE msg);
bool GetStreamsInfoAndBufferReqs();
bool DoDecode();
bool use_dxva_;
ScopedComPtr<IDirect3D9> d3d9_;
ScopedComPtr<IDirect3DDevice9> device_;
ScopedComPtr<IDirect3DDeviceManager9> device_manager_;
HWND draw_window_;
ScopedComPtr<IMFTransform> decoder_;
MFT_INPUT_STREAM_INFO input_stream_info_;
MFT_OUTPUT_STREAM_INFO output_stream_info_;
State state_;
VideoDecodeEngine::EventHandler* event_handler_;
VideoCodecConfig config_;
VideoCodecInfo info_;
DISALLOW_COPY_AND_ASSIGN(MftH264Decoder);
};
} // namespace media
#endif // defined(OS_WIN)
#endif // MEDIA_MF_MFT_H264_DECODER_H_
|