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 // Short / basic implementation to simulate rendering H.264 frames outputs by | |
6 // MF's H.264 decoder to screen. | |
7 | |
8 #ifndef MEDIA_MF_BASIC_RENDERER_H_ | |
9 #define MEDIA_MF_BASIC_RENDERER_H_ | |
10 | |
11 #include <d3d9.h> | |
12 | |
13 #include "base/scoped_ptr.h" | |
14 #include "base/scoped_comptr_win.h" | |
15 #include "media/base/video_frame.h" | |
16 #include "media/mf/mft_h264_decoder.h" | |
17 | |
18 namespace media { | |
19 | |
20 class MftRenderer : public base::RefCountedThreadSafe<MftRenderer> { | |
21 public: | |
22 explicit MftRenderer(MftH264Decoder* decoder) : decoder_(decoder) {} | |
23 virtual ~MftRenderer() {} | |
24 virtual void ProcessFrame(scoped_refptr<VideoFrame> frame) = 0; | |
25 virtual void StartPlayback() = 0; | |
26 virtual void OnDecodeError(MftH264Decoder::Error error) = 0; | |
27 | |
28 protected: | |
29 scoped_refptr<MftH264Decoder> decoder_; | |
30 }; | |
31 | |
32 // This renderer does nothing with the frame except discarding it. | |
33 class NullRenderer : public MftRenderer { | |
34 public: | |
35 explicit NullRenderer(MftH264Decoder* decoder); | |
36 virtual ~NullRenderer(); | |
37 virtual void ProcessFrame(scoped_refptr<VideoFrame> frame); | |
38 virtual void StartPlayback(); | |
39 virtual void OnDecodeError(MftH264Decoder::Error error); | |
40 }; | |
41 | |
42 // This renderer does a basic playback by drawing to |window_|. It tries to | |
43 // respect timing specified in the recevied VideoFrames. | |
44 class BasicRenderer : public MftRenderer { | |
45 public: | |
46 explicit BasicRenderer(MftH264Decoder* decoder, | |
47 HWND window, IDirect3DDevice9* device); | |
48 virtual ~BasicRenderer(); | |
49 virtual void ProcessFrame(scoped_refptr<VideoFrame> frame); | |
50 virtual void StartPlayback(); | |
51 virtual void OnDecodeError(MftH264Decoder::Error error); | |
52 | |
53 private: | |
54 HWND window_; | |
55 ScopedComPtr<IDirect3DDevice9> device_; | |
56 }; | |
57 | |
58 } // namespace media | |
59 | |
60 #endif // MEDIA_MF_BASIC_RENDERER_H_ | |
OLD | NEW |