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

Side by Side Diff: content/renderer/media/renderer_gpu_video_accelerator_factories.h

Issue 20632002: Add media::VideoEncodeAccelerator with WebRTC integration (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@git-svn
Patch Set: 7fd9dbd5 More debugging statements, some fixes Created 7 years, 4 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
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_DECODER_FACTORIES_H_ 5 #ifndef CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
6 #define CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_DECODER_FACTORIES_H_ 6 #define CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
7 7
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/memory/ref_counted.h" 11 #include "base/memory/ref_counted.h"
12 #include "base/memory/weak_ptr.h" 12 #include "base/memory/weak_ptr.h"
13 #include "base/synchronization/waitable_event.h" 13 #include "base/synchronization/waitable_event.h"
14 #include "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 #include "media/filters/gpu_video_decoder_factories.h" 15 #include "media/filters/gpu_video_accelerator_factories.h"
16 #include "third_party/skia/include/core/SkBitmap.h" 16 #include "third_party/skia/include/core/SkBitmap.h"
17 #include "ui/gfx/size.h" 17 #include "ui/gfx/size.h"
18 18
19 namespace base { 19 namespace base {
20 class MessageLoopProxy; 20 class MessageLoopProxy;
21 class WaitableEvent; 21 class WaitableEvent;
22 } 22 }
23 23
24 namespace content { 24 namespace content {
25 class GpuChannelHost; 25 class GpuChannelHost;
26 class WebGraphicsContext3DCommandBufferImpl; 26 class WebGraphicsContext3DCommandBufferImpl;
27 27
28 // Glue code to expose functionality needed by media::GpuVideoDecoder to 28 // Glue code to expose functionality needed by media::GpuVideoAccelerator to
29 // RenderViewImpl. This class is entirely an implementation detail of 29 // RenderViewImpl. This class is entirely an implementation detail of
30 // RenderViewImpl and only has its own header to allow extraction of its 30 // RenderViewImpl and only has its own header to allow extraction of its
31 // implementation from render_view_impl.cc which is already far too large. 31 // implementation from render_view_impl.cc which is already far too large.
32 // 32 //
33 // The public methods of the class can be called from any thread, and are 33 // The public methods of the class can be called from any thread, and are
34 // internally trampolined to the appropriate thread. GPU/GL-related calls go to 34 // internally trampolined to the appropriate thread. GPU/GL-related calls go to
35 // the constructor-argument loop (the media thread), and shmem-related calls go 35 // the constructor-argument loop (the media thread), and shmem-related calls go
36 // to the render thread. 36 // to the render thread.
37 class CONTENT_EXPORT RendererGpuVideoDecoderFactories 37 class CONTENT_EXPORT RendererGpuVideoAcceleratorFactories
38 : public media::GpuVideoDecoderFactories { 38 : public media::GpuVideoAcceleratorFactories {
39 public: 39 public:
40 // Takes a ref on |gpu_channel_host| and tests |context| for loss before each 40 // Takes a ref on |gpu_channel_host| and tests |context| for loss before each
41 // use. 41 // use.
42 RendererGpuVideoDecoderFactories( 42 RendererGpuVideoAcceleratorFactories(
43 GpuChannelHost* gpu_channel_host, 43 GpuChannelHost* gpu_channel_host,
44 const scoped_refptr<base::MessageLoopProxy>& message_loop, 44 const scoped_refptr<base::MessageLoopProxy>& message_loop,
45 WebGraphicsContext3DCommandBufferImpl* wgc3dcbi); 45 WebGraphicsContext3DCommandBufferImpl* wgc3dcbi);
46 46
47 // media::GpuVideoDecoderFactories implementation. 47 // media::GpuVideoAcceleratorFactories implementation.
48 virtual media::VideoDecodeAccelerator* CreateVideoDecodeAccelerator( 48 virtual scoped_ptr<media::VideoDecodeAccelerator>
49 media::VideoCodecProfile profile, 49 CreateVideoDecodeAccelerator(
50 media::VideoDecodeAccelerator::Client* client) OVERRIDE; 50 media::VideoCodecProfile profile,
51 media::VideoDecodeAccelerator::Client* client) OVERRIDE;
52 virtual scoped_ptr<media::VideoEncodeAccelerator>
53 CreateVideoEncodeAccelerator(
54 media::VideoEncodeAccelerator::Client* client) OVERRIDE;
51 // Creates textures and produces them into mailboxes. Returns a sync point to 55 // Creates textures and produces them into mailboxes. Returns a sync point to
52 // wait on before using the mailboxes, or 0 on failure. 56 // wait on before using the mailboxes, or 0 on failure.
53 virtual uint32 CreateTextures( 57 virtual uint32 CreateTextures(int32 count,
54 int32 count, const gfx::Size& size, 58 const gfx::Size& size,
55 std::vector<uint32>* texture_ids, 59 std::vector<uint32>* texture_ids,
56 std::vector<gpu::Mailbox>* texture_mailboxes, 60 std::vector<gpu::Mailbox>* texture_mailboxes,
57 uint32 texture_target) OVERRIDE; 61 uint32 texture_target) OVERRIDE;
58 virtual void DeleteTexture(uint32 texture_id) OVERRIDE; 62 virtual void DeleteTexture(uint32 texture_id) OVERRIDE;
59 virtual void WaitSyncPoint(uint32 sync_point) OVERRIDE; 63 virtual void WaitSyncPoint(uint32 sync_point) OVERRIDE;
60 virtual void ReadPixels(uint32 texture_id, 64 virtual void ReadPixels(uint32 texture_id,
61 uint32 texture_target, 65 uint32 texture_target,
62 const gfx::Size& size, 66 const gfx::Size& size,
63 const SkBitmap& pixels) OVERRIDE; 67 const SkBitmap& pixels) OVERRIDE;
64 virtual base::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE; 68 virtual base::SharedMemory* CreateSharedMemory(size_t size) OVERRIDE;
65 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE; 69 virtual scoped_refptr<base::MessageLoopProxy> GetMessageLoop() OVERRIDE;
66 virtual void Abort() OVERRIDE; 70 virtual void Abort() OVERRIDE;
67 virtual bool IsAborted() OVERRIDE; 71 virtual bool IsAborted() OVERRIDE;
68 72 scoped_refptr<media::GpuVideoAcceleratorFactories> Clone() OVERRIDE;
69 // Makes a copy of |this|.
70 scoped_refptr<media::GpuVideoDecoderFactories> Clone();
71 73
72 protected: 74 protected:
73 friend class base::RefCountedThreadSafe<RendererGpuVideoDecoderFactories>; 75 friend class base::RefCountedThreadSafe<RendererGpuVideoAcceleratorFactories>;
74 virtual ~RendererGpuVideoDecoderFactories(); 76 virtual ~RendererGpuVideoAcceleratorFactories();
75 77
76 private: 78 private:
77 RendererGpuVideoDecoderFactories(); 79 RendererGpuVideoAcceleratorFactories();
78 80
79 // Helper for the constructor to acquire the ContentGLContext on 81 // Helper for the constructor to acquire the ContentGLContext on
80 // |message_loop_|. 82 // |message_loop_|.
81 void AsyncGetContext(WebGraphicsContext3DCommandBufferImpl* context); 83 void AsyncGetContext(WebGraphicsContext3DCommandBufferImpl* context);
82 84
83 // Async versions of the public methods. They use output parameters instead 85 // Async versions of the public methods. They use output parameters instead
84 // of return values and each takes a WaitableEvent* param to signal completion 86 // of return values and each takes a WaitableEvent* param to signal completion
85 // (except for DeleteTexture, which is fire-and-forget). 87 // (except for DeleteTexture, which is fire-and-forget).
86 // AsyncCreateSharedMemory runs on the renderer thread and the rest run on 88 // AsyncCreateSharedMemory runs on the renderer thread and the rest run on
87 // |message_loop_|. 89 // |message_loop_|.
88 // The AsyncCreateVideoDecodeAccelerator returns its output in the vda_ 90 // AsyncCreateVideoDecodeAccelerator returns its output in the vda_ member.
89 // member. 91 // AsyncCreateVideoEncodeAccelerator returns its ouptu tin the vea_ member.
90 void AsyncCreateVideoDecodeAccelerator( 92 void AsyncCreateVideoDecodeAccelerator(
91 media::VideoCodecProfile profile, 93 media::VideoCodecProfile profile,
92 media::VideoDecodeAccelerator::Client* client); 94 media::VideoDecodeAccelerator::Client* client);
93 void AsyncCreateTextures(int32 count, const gfx::Size& size, 95 void AsyncCreateVideoEncodeAccelerator(
94 uint32 texture_target, uint32* sync_point); 96 media::VideoEncodeAccelerator::Client* client);
97 void AsyncCreateTextures(int32 count,
98 const gfx::Size& size,
99 uint32 texture_target,
100 uint32* sync_point);
95 void AsyncDeleteTexture(uint32 texture_id); 101 void AsyncDeleteTexture(uint32 texture_id);
96 void AsyncWaitSyncPoint(uint32 sync_point); 102 void AsyncWaitSyncPoint(uint32 sync_point);
97 void AsyncReadPixels(uint32 texture_id, uint32 texture_target, 103 void AsyncReadPixels(uint32 texture_id,
104 uint32 texture_target,
98 const gfx::Size& size); 105 const gfx::Size& size);
99 void AsyncCreateSharedMemory(size_t size); 106 void AsyncCreateSharedMemory(size_t size);
100 void AsyncDestroyVideoDecodeAccelerator(); 107 void AsyncDestroyVideoDecodeAccelerator();
108 void AsyncDestroyVideoEncodeAccelerator();
101 109
102 scoped_refptr<base::MessageLoopProxy> message_loop_; 110 scoped_refptr<base::MessageLoopProxy> message_loop_;
103 scoped_refptr<base::MessageLoopProxy> main_message_loop_; 111 scoped_refptr<base::MessageLoopProxy> main_message_loop_;
104 scoped_refptr<GpuChannelHost> gpu_channel_host_; 112 scoped_refptr<GpuChannelHost> gpu_channel_host_;
105 base::WeakPtr<WebGraphicsContext3DCommandBufferImpl> context_; 113 base::WeakPtr<WebGraphicsContext3DCommandBufferImpl> context_;
106 114
107 // This event is signaled if we have been asked to Abort(). 115 // This event is signaled if we have been asked to Abort().
108 base::WaitableEvent aborted_waiter_; 116 base::WaitableEvent aborted_waiter_;
109 117
110 // This event is signaled by asynchronous tasks posted to |message_loop_| to 118 // This event is signaled by asynchronous tasks posted to |message_loop_| to
111 // indicate their completion. 119 // indicate their completion.
112 // e.g. AsyncCreateVideoDecodeAccelerator()/AsyncCreateTextures() etc. 120 // e.g. AsyncCreateVideoDecodeAccelerator()/AsyncCreateTextures() etc.
113 base::WaitableEvent message_loop_async_waiter_; 121 base::WaitableEvent message_loop_async_waiter_;
114 122
115 // This event is signaled by asynchronous tasks posted to the renderer thread 123 // This event is signaled by asynchronous tasks posted to the renderer thread
116 // message loop to indicate their completion. e.g. AsyncCreateSharedMemory. 124 // message loop to indicate their completion. e.g. AsyncCreateSharedMemory.
117 base::WaitableEvent render_thread_async_waiter_; 125 base::WaitableEvent render_thread_async_waiter_;
118 126
119 // The vda returned by the CreateVideoAcclelerator function. 127 // The vda returned by the CreateVideoDecodeAccelerator function.
120 scoped_ptr<media::VideoDecodeAccelerator> vda_; 128 scoped_ptr<media::VideoDecodeAccelerator> vda_;
121 129
130 // The vea returned by the CreateVideoEncodeAccelerator function.
131 scoped_ptr<media::VideoEncodeAccelerator> vea_;
132
122 // Shared memory segment which is returned by the CreateSharedMemory() 133 // Shared memory segment which is returned by the CreateSharedMemory()
123 // function. 134 // function.
124 scoped_ptr<base::SharedMemory> shared_memory_segment_; 135 scoped_ptr<base::SharedMemory> shared_memory_segment_;
125 136
126 // Bitmap returned by ReadPixels(). 137 // Bitmap returned by ReadPixels().
127 SkBitmap read_pixels_bitmap_; 138 SkBitmap read_pixels_bitmap_;
128 139
129 // Textures returned by the CreateTexture() function. 140 // Textures returned by the CreateTexture() function.
130 std::vector<uint32> created_textures_; 141 std::vector<uint32> created_textures_;
131 std::vector<gpu::Mailbox> created_texture_mailboxes_; 142 std::vector<gpu::Mailbox> created_texture_mailboxes_;
132 143
133 DISALLOW_COPY_AND_ASSIGN(RendererGpuVideoDecoderFactories); 144 DISALLOW_COPY_AND_ASSIGN(RendererGpuVideoAcceleratorFactories);
134 }; 145 };
135 146
136 } // namespace content 147 } // namespace content
137 148
138 #endif // CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_DECODER_FACTORIES_H_ 149 #endif // CONTENT_RENDERER_MEDIA_RENDERER_GPU_VIDEO_ACCELERATOR_FACTORIES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698