Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / common / gpu / media / fake_video_decode_accelerator.h
bloba669c82387dd622e61a6f045468afeed5053da2e
1 // Copyright 2014 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.
5 #ifndef CONTENT_COMMON_GPU_MEDIA_FAKE_VIDEO_DECODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_FAKE_VIDEO_DECODE_ACCELERATOR_H_
8 #include <queue>
9 #include <vector>
11 #include "base/memory/weak_ptr.h"
12 #include "content/common/content_export.h"
13 #include "media/video/video_decode_accelerator.h"
14 #include "ui/gfx/geometry/size_f.h"
15 #include "ui/gl/gl_context.h"
17 namespace content {
19 class CONTENT_EXPORT FakeVideoDecodeAccelerator
20 : public media::VideoDecodeAccelerator {
21 public:
22 FakeVideoDecodeAccelerator(
23 gfx::GLContext* gl,
24 gfx::Size size,
25 const base::Callback<bool(void)>& make_context_current);
26 ~FakeVideoDecodeAccelerator() override;
28 bool Initialize(media::VideoCodecProfile profile,
29 Client* client) override;
30 void Decode(const media::BitstreamBuffer& bitstream_buffer) override;
31 void AssignPictureBuffers(
32 const std::vector<media::PictureBuffer>& buffers) override;
33 void ReusePictureBuffer(int32 picture_buffer_id) override;
34 void Flush() override;
35 void Reset() override;
36 void Destroy() override;
37 bool CanDecodeOnIOThread() override;
39 private:
40 void DoPictureReady();
42 // The message loop that created the class. Used for all callbacks. This
43 // class expects all calls to this class to be on this message loop (not
44 // checked).
45 const scoped_refptr<base::SingleThreadTaskRunner> child_task_runner_;
47 Client* client_;
49 // Make our context current before running any GL entry points.
50 base::Callback<bool(void)> make_context_current_;
51 gfx::GLContext* gl_;
53 // Output picture size.
54 gfx::Size frame_buffer_size_;
56 // Picture buffer ids that are available for putting fake frames in.
57 std::queue<int> free_output_buffers_;
58 // BitstreamBuffer ids for buffers that contain new data to decode.
59 std::queue<int> queued_bitstream_ids_;
61 bool flushing_;
63 // The WeakPtrFactory for |weak_this_|.
64 base::WeakPtrFactory<FakeVideoDecodeAccelerator> weak_this_factory_;
66 DISALLOW_COPY_AND_ASSIGN(FakeVideoDecodeAccelerator);
69 } // namespace content
71 #endif // CONTENT_COMMON_GPU_MEDIA_FAKE_VIDEO_DECODE_ACCELERATOR_H_