summaryrefslogtreecommitdiffstats
path: root/media/mf/basic_renderer.h
blob: 97711c2b849364d1a7de1ad3bd82965ccb8bc787 (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
// 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.
//
// Short / basic implementation to simulate rendering H.264 frames outputs by
// MF's H.264 decoder to screen.

#ifndef MEDIA_MF_BASIC_RENDERER_H_
#define MEDIA_MF_BASIC_RENDERER_H_

#include <d3d9.h>

#include "base/scoped_ptr.h"
#include "base/scoped_comptr_win.h"
#include "media/base/video_frame.h"
#include "media/mf/mft_h264_decoder.h"

namespace media {

class MftRenderer : public base::RefCountedThreadSafe<MftRenderer> {
 public:
  explicit MftRenderer(MftH264Decoder* decoder) : decoder_(decoder) {}
  virtual ~MftRenderer() {}
  virtual void ProcessFrame(scoped_refptr<VideoFrame> frame) = 0;
  virtual void StartPlayback() = 0;
  virtual void StopPlayback() = 0;

 protected:
  scoped_refptr<MftH264Decoder> decoder_;
};

// This renderer does nothing with the frame except discarding it.
class NullRenderer : public MftRenderer {
 public:
  explicit NullRenderer(MftH264Decoder* decoder);
  virtual ~NullRenderer();
  virtual void ProcessFrame(scoped_refptr<VideoFrame> frame);
  virtual void StartPlayback();
  virtual void StopPlayback();
};

// This renderer does a basic playback by drawing to |window_|. It tries to
// respect timing specified in the recevied VideoFrames.
class BasicRenderer : public MftRenderer {
 public:
  explicit BasicRenderer(MftH264Decoder* decoder,
                         HWND window, IDirect3DDevice9* device);
  virtual ~BasicRenderer();
  virtual void ProcessFrame(scoped_refptr<VideoFrame> frame);
  virtual void StartPlayback();
  virtual void StopPlayback();

 private:
  HWND window_;
  ScopedComPtr<IDirect3DDevice9> device_;
};

}  // namespace media

#endif  // MEDIA_MF_BASIC_RENDERER_H_