Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Side by Side Diff: content/common/gpu/media/gpu_jpeg_decode_accelerator.h

Issue 1016773002: MJPEG acceleration for video capture using VAAPI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix many thread issues Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #ifndef CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_
6 #define CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_
7
8 #include <map>
9 #include <vector>
10
11 #include "base/compiler_specific.h"
12 #include "base/memory/ref_counted.h"
13 #include "base/memory/shared_memory.h"
14 #include "base/synchronization/waitable_event.h"
15 #include "ipc/ipc_listener.h"
16 #include "ipc/ipc_sender.h"
17 #include "media/video/jpeg_decode_accelerator.h"
18 #include "ui/gfx/geometry/size.h"
19
20 struct AcceleratedJpegDecoderMsg_Decode_Params;
21
22 namespace base {
23 class MessageLoopProxy;
24 }
25
26 namespace content {
27 class GpuChannel;
28
29 class GpuJpegDecodeAccelerator
30 : public IPC::Listener,
31 public IPC::Sender,
32 public media::JpegDecodeAccelerator::Client {
33 public:
34 // Each of the arguments to the constructor must outlive this object.
35 // |stub->decoder()| will be made current around any operation that touches
36 // the underlying VDA so that it can make GL calls safely.
37 GpuJpegDecodeAccelerator(
38 GpuChannel* channel,
39 int32 host_route_id,
40 const scoped_refptr<base::MessageLoopProxy>& io_message_loop);
41
42 void Destroy();
43
44 // IPC::Listener implementation.
45 bool OnMessageReceived(const IPC::Message& message) override;
46
47 // media::JpegDecodeAccelerator::Client implementation.
48 void VideoFrameReady(int32_t bitstream_buffer_id) override;
49 void NotifyError(int32_t bitstream_buffer_id,
50 media::JpegDecodeAccelerator::Error error) override;
51
52
53 // Function to delegate sending to actual sender.
54 bool Send(IPC::Message* message) override;
55
56 bool Initialize();
57
58 private:
59 ~GpuJpegDecodeAccelerator();
60 class MessageFilter;
61
62 // Handlers for IPC messages.
63 void OnDecode(const AcceleratedJpegDecoderMsg_Decode_Params& params);
64 void OnDestroy();
65
66 // Called on IO thread when |filter_| has been removed.
67 void OnFilterRemoved();
68
69 // The lifetime of objects of this class is managed by a GpuChannel. The
70 // GpuChannels destroy all the GpuCommandBufferStubs that they own when they
71 // are destroyed. So a raw pointer is safe.
72 GpuChannel* channel_;
73
74 // Route ID to communicate with the host.
75 int32 host_route_id_;
76
77 // The underlying JpegDecodeAccelerator.
78 scoped_ptr<media::JpegDecodeAccelerator> jpeg_decode_accelerator_;
79
80 // The message filter to run VDA::Decode on IO thread if VDA supports it.
81 scoped_refptr<MessageFilter> filter_;
82
83 // Used to wait on for |filter_| to be removed, before we can safely
84 // destroy the VDA.
85 base::WaitableEvent filter_removed_;
86
87 // GPU child message loop.
88 scoped_refptr<base::MessageLoopProxy> child_message_loop_;
89
90 // GPU IO message loop.
91 scoped_refptr<base::MessageLoopProxy> io_message_loop_;
92
93 DISALLOW_IMPLICIT_CONSTRUCTORS(GpuJpegDecodeAccelerator);
94 };
95
96 } // namespace content
97
98 namespace base {
99
100 template <class T>
101 struct DefaultDeleter;
102
103 // Specialize DefaultDeleter so that scoped_ptr<GpuJpegDecodeAccelerator> always
104 // uses "Destroy()" instead of trying to use the destructor.
105 template <>
106 struct MEDIA_EXPORT DefaultDeleter<content::GpuJpegDecodeAccelerator> {
107 public:
108 void operator()(void* jpeg_decode_accelerator) const;
109 };
110
111 } // namespace base
112
113 #endif // CONTENT_COMMON_GPU_MEDIA_GPU_JPEG_DECODE_ACCELERATOR_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698