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

Side by Side Diff: content/common/gpu/gl_surface_encoder.cc

Issue 16693005: Add ExynosVideoEncodeAccelerator (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screencast_cl_5
Patch Set: a1d2f2c4 Bitrate settings. Created 7 years, 6 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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
Ami GONE FROM CHROMIUM 2013/06/18 01:09:25 Can you include a teaser of perf #'s for video enc
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 #include "content/common/gpu/gl_surface_encoder.h" 5 #include "content/common/gpu/gl_surface_encoder.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "content/common/gpu/gpu_channel.h" 10 #include "content/common/gpu/gpu_channel.h"
11 #include "content/common/gpu/gpu_messages.h" 11 #include "content/common/gpu/gpu_messages.h"
12 #include "media/base/video_frame.h" 12 #include "media/base/video_frame.h"
13 #include "ui/gl/gl_surface.h" 13 #include "ui/gl/gl_surface.h"
14 14
15 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
16 #include "content/common/gpu/media/exynos_video_encode_accelerator.h"
17 #include "ui/gl/gl_surface_egl.h"
18 #endif
19
15 namespace content { 20 namespace content {
16 21
17 namespace { 22 namespace {
18 23
24 bool MakeEncoderContextCurrent(
25 const base::WeakPtr<GpuCommandBufferStub> stub) {
26 if (!stub) {
27 DLOG(ERROR) << "Stub is gone; won't MakeCurrent().";
28 return false;
29 }
30
31 if (!stub->decoder()->MakeCurrent()) {
32 DLOG(ERROR) << "Failed to MakeCurrent()";
33 return false;
34 }
35
36 return true;
37 }
38
19 void DoNothingWithSurface(gfx::GLSurface* surface) { 39 void DoNothingWithSurface(gfx::GLSurface* surface) {
20 } 40 }
21 41
22 } // anonymous namespace 42 } // anonymous namespace
23 43
24 GLSurfaceEncoder::GLSurfaceEncoder(int32 host_route_id, 44 GLSurfaceEncoder::GLSurfaceEncoder(int32 host_route_id,
25 GpuCommandBufferStub* stub) 45 GpuCommandBufferStub* stub)
26 : host_route_id_(host_route_id), 46 : host_route_id_(host_route_id),
27 stub_(stub) { 47 stub_(stub) {
28 DCHECK(stub_); 48 DCHECK(stub_);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 DCHECK(stub_); 130 DCHECK(stub_);
111 return stub_->channel()->Send(message); 131 return stub_->channel()->Send(message);
112 } 132 }
113 133
114 // static 134 // static
115 scoped_ptr<media::VideoEncodeAccelerator> GLSurfaceEncoder::CreateEncoder( 135 scoped_ptr<media::VideoEncodeAccelerator> GLSurfaceEncoder::CreateEncoder(
116 GpuCommandBufferStub* stub, 136 GpuCommandBufferStub* stub,
117 media::VideoEncodeAccelerator::Client* client) { 137 media::VideoEncodeAccelerator::Client* client) {
118 scoped_ptr<media::VideoEncodeAccelerator> encoder; 138 scoped_ptr<media::VideoEncodeAccelerator> encoder;
119 139
120 // TODO(sheu): actually create an encoder. 140 base::Callback<bool(void)> make_current =
141 base::Bind(&MakeEncoderContextCurrent, stub->AsWeakPtr());
142
143 #if defined(OS_CHROMEOS) && defined(ARCH_CPU_ARMEL)
144 encoder.reset(new ExynosVideoEncodeAccelerator(
145 gfx::GLSurfaceEGL::GetHardwareDisplay(),
Ami GONE FROM CHROMIUM 2013/06/18 01:09:25 Any reason not to do this in the EVDA ctor itself?
146 client,
147 make_current,
148 true));
149 #endif
150
121 return encoder.Pass(); 151 return encoder.Pass();
122 } 152 }
123 153
124 void GLSurfaceEncoder::OnEncodeCurrentContents(bool force_keyframe) { 154 void GLSurfaceEncoder::OnEncodeCurrentContents(bool force_keyframe) {
125 gfx::GLSurface* surface = stub_->surface(); 155 gfx::GLSurface* surface = stub_->surface();
126 scoped_refptr<media::VideoFrame> frame(media::VideoFrame::WrapNativeSurface( 156 scoped_refptr<media::VideoFrame> frame(media::VideoFrame::WrapNativeSurface(
127 surface->GetHandle(), 157 surface->GetHandle(),
128 surface->GetSize(), 158 surface->GetSize(),
129 base::Time::Now() - start_time_, 159 base::Time::Now() - start_time_,
130 base::Bind(&DoNothingWithSurface, make_scoped_refptr(surface)))); 160 base::Bind(&DoNothingWithSurface, make_scoped_refptr(surface))));
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 void GLSurfaceEncoder::OnRequestEncodingParameterChange( 194 void GLSurfaceEncoder::OnRequestEncodingParameterChange(
165 int32 bitrate) { 195 int32 bitrate) {
166 encoder_->RequestEncodingParameterChange(bitrate); 196 encoder_->RequestEncodingParameterChange(bitrate);
167 } 197 }
168 198
169 void GLSurfaceEncoder::OnDestroy() { 199 void GLSurfaceEncoder::OnDestroy() {
170 delete this; 200 delete this;
171 } 201 }
172 202
173 } // namespace content 203 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698