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_
11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop/message_loop_proxy.h"
13 #include "content/common/content_export.h"
14 #include "media/video/video_decode_accelerator.h"
15 #include "ui/gfx/geometry/size_f.h"
16 #include "ui/gl/gl_context.h"
20 class CONTENT_EXPORT FakeVideoDecodeAccelerator
21 : public media::VideoDecodeAccelerator
{
23 FakeVideoDecodeAccelerator(
26 const base::Callback
<bool(void)>& make_context_current
);
27 ~FakeVideoDecodeAccelerator() override
;
29 bool Initialize(media::VideoCodecProfile profile
,
30 Client
* client
) override
;
31 void Decode(const media::BitstreamBuffer
& bitstream_buffer
) override
;
32 void AssignPictureBuffers(
33 const std::vector
<media::PictureBuffer
>& buffers
) override
;
34 void ReusePictureBuffer(int32 picture_buffer_id
) override
;
35 void Flush() override
;
36 void Reset() override
;
37 void Destroy() override
;
38 bool CanDecodeOnIOThread() override
;
41 void DoPictureReady();
43 // The message loop that created the class. Used for all callbacks. This
44 // class expects all calls to this class to be on this message loop (not
46 const scoped_refptr
<base::MessageLoopProxy
> child_message_loop_proxy_
;
50 // Make our context current before running any GL entry points.
51 base::Callback
<bool(void)> make_context_current_
;
54 // Output picture size.
55 gfx::Size frame_buffer_size_
;
57 // Picture buffer ids that are available for putting fake frames in.
58 std::queue
<int> free_output_buffers_
;
59 // BitstreamBuffer ids for buffers that contain new data to decode.
60 std::queue
<int> queued_bitstream_ids_
;
64 // The WeakPtrFactory for |weak_this_|.
65 base::WeakPtrFactory
<FakeVideoDecodeAccelerator
> weak_this_factory_
;
67 DISALLOW_COPY_AND_ASSIGN(FakeVideoDecodeAccelerator
);
70 } // namespace content
72 #endif // CONTENT_COMMON_GPU_MEDIA_FAKE_VIDEO_DECODE_ACCELERATOR_H_