summaryrefslogtreecommitdiffstats
path: root/chrome/gpu/media/fake_gl_video_decode_engine.h
blob: 24d3b3385ca6dc234108d2316f777561db240f30 (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
// 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.

#ifndef CHROME_GPU_MEDIA_FAKE_GL_VIDEO_DECODE_ENGINE_H_
#define CHROME_GPU_MEDIA_FAKE_GL_VIDEO_DECODE_ENGINE_H_

#include <queue>
#include <vector>

#include "base/scoped_ptr.h"
#include "media/video/video_decode_engine.h"

namespace media {
class VideoDecodeContext;
class VideoFrame;
}  // namespace media

class FakeGlVideoDecodeEngine : public media::VideoDecodeEngine {
 public:
  FakeGlVideoDecodeEngine();
  virtual ~FakeGlVideoDecodeEngine();

  virtual void Initialize(
      MessageLoop* message_loop,
      media::VideoDecodeEngine::EventHandler* event_handler,
      media::VideoDecodeContext* context,
      const media::VideoCodecConfig& config);

  virtual void Uninitialize();
  virtual void Flush();
  virtual void Seek();
  virtual void ConsumeVideoSample(scoped_refptr<media::Buffer> buffer);
  virtual void ProduceVideoFrame(scoped_refptr<media::VideoFrame> frame);

 private:
  // This method is called when video frames allocation is completed by
  // VideoDecodeContext.
  void AllocationCompleteTask();

  // This method is called by VideoDecodeContext when uploading to a VideoFrame
  // has completed.
  void UploadCompleteTask(scoped_refptr<media::VideoFrame> frame);

  int width_;
  int height_;
  media::VideoDecodeEngine::EventHandler* handler_;
  media::VideoDecodeContext* context_;

  // Internal video frame that is to be uploaded through VideoDecodeContext.
  scoped_refptr<media::VideoFrame> internal_frame_;

  // VideoFrame(s) allocated through VideoDecodeContext. These frames are
  // opaque to us. And we need an extra upload step.
  std::vector<scoped_refptr<media::VideoFrame> > external_frames_;

  // These are the video frames that are waiting for input buffer to generate
  // fake pattern in them.
  std::queue<scoped_refptr<media::VideoFrame> > pending_frames_;

  DISALLOW_COPY_AND_ASSIGN(FakeGlVideoDecodeEngine);
};

#endif  // CHROME_GPU_MEDIA_FAKE_GL_VIDEO_DECODE_ENGINE_H_