1 // Copyright 2015 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_GPU_JPEG_DECODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_
8 #include "base/memory/ref_counted.h"
9 #include "base/memory/weak_ptr.h"
10 #include "base/synchronization/waitable_event.h"
11 #include "base/threading/non_thread_safe.h"
12 #include "ipc/ipc_listener.h"
13 #include "ipc/ipc_sender.h"
14 #include "media/video/jpeg_decode_accelerator.h"
17 class SingleThreadTaskRunner
;
23 class GpuJpegDecodeAccelerator
25 public base::NonThreadSafe
,
26 public base::SupportsWeakPtr
<GpuJpegDecodeAccelerator
> {
28 // |channel| must outlive this object.
29 GpuJpegDecodeAccelerator(
31 const scoped_refptr
<base::SingleThreadTaskRunner
>& io_task_runner
);
32 ~GpuJpegDecodeAccelerator() override
;
34 void AddClient(int32 route_id
, IPC::Message
* reply_msg
);
36 void NotifyDecodeStatus(int32 route_id
,
37 int32_t bitstream_buffer_id
,
38 media::JpegDecodeAccelerator::Error error
);
40 // Function to delegate sending to actual sender.
41 bool Send(IPC::Message
* message
) override
;
43 // Static query for JPEG supported. This query calls the appropriate
44 // platform-specific version.
45 static bool IsSupported();
48 using CreateJDAFp
= scoped_ptr
<media::JpegDecodeAccelerator
> (*)(
49 const scoped_refptr
<base::SingleThreadTaskRunner
>&);
56 static scoped_ptr
<media::JpegDecodeAccelerator
> CreateV4L2JDA(
57 const scoped_refptr
<base::SingleThreadTaskRunner
>& io_task_runner
);
58 static scoped_ptr
<media::JpegDecodeAccelerator
> CreateVaapiJDA(
59 const scoped_refptr
<base::SingleThreadTaskRunner
>& io_task_runner
);
61 // The lifetime of objects of this class is managed by a GpuChannel. The
62 // GpuChannels destroy all the GpuJpegDecodeAccelerator that they own when
63 // they are destroyed. So a raw pointer is safe.
66 // The message filter to run JpegDecodeAccelerator::Decode on IO thread.
67 scoped_refptr
<MessageFilter
> filter_
;
69 // GPU child task runner.
70 scoped_refptr
<base::SingleThreadTaskRunner
> child_task_runner_
;
72 // GPU IO task runner.
73 scoped_refptr
<base::SingleThreadTaskRunner
> io_task_runner_
;
75 // Number of clients added to |filter_|.
78 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuJpegDecodeAccelerator
);
81 } // namespace content
83 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_