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

Side by Side Diff: content/renderer/media/video_track_recorder.cc

Issue 2523673004: [NOT FOR COMMIT] Fully replace SkCanvas uses.
Patch Set: Support Android build. Created 4 years 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 2015 The Chromium Authors. All rights reserved. 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 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/renderer/media/video_track_recorder.h" 5 #include "content/renderer/media/video_track_recorder.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/sys_info.h" 12 #include "base/sys_info.h"
13 #include "base/task_runner_util.h" 13 #include "base/task_runner_util.h"
14 #include "base/threading/thread.h" 14 #include "base/threading/thread.h"
15 #include "base/threading/thread_task_runner_handle.h" 15 #include "base/threading/thread_task_runner_handle.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "base/trace_event/trace_event.h" 17 #include "base/trace_event/trace_event.h"
18 #include "content/common/gpu/client/context_provider_command_buffer.h" 18 #include "content/common/gpu/client/context_provider_command_buffer.h"
19 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h" 19 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h"
20 #include "content/renderer/render_thread_impl.h" 20 #include "content/renderer/render_thread_impl.h"
21 #include "media/base/bind_to_current_loop.h" 21 #include "media/base/bind_to_current_loop.h"
22 #include "media/base/video_frame.h" 22 #include "media/base/video_frame.h"
23 #include "media/base/video_util.h" 23 #include "media/base/video_util.h"
24 #include "media/filters/context_3d.h" 24 #include "media/filters/context_3d.h"
25 #include "media/renderers/skcanvas_video_renderer.h" 25 #include "media/renderers/skcanvas_video_renderer.h"
26 #include "skia/ext/cdl_surface.h"
26 #include "skia/ext/platform_canvas.h" 27 #include "skia/ext/platform_canvas.h"
27 #include "third_party/libyuv/include/libyuv.h" 28 #include "third_party/libyuv/include/libyuv.h"
28 #include "third_party/skia/include/core/SkCanvas.h" 29 #include "third_party/skia/include/core/SkCanvas.h"
29 #include "third_party/skia/include/core/SkSurface.h" 30 #include "third_party/skia/include/core/SkSurface.h"
30 #include "ui/gfx/geometry/size.h" 31 #include "ui/gfx/geometry/size.h"
31 32
32 #if BUILDFLAG(RTC_USE_H264) 33 #if BUILDFLAG(RTC_USE_H264)
33 #include "third_party/openh264/src/codec/api/svc/codec_api.h" 34 #include "third_party/openh264/src/codec/api/svc/codec_api.h"
34 #include "third_party/openh264/src/codec/api/svc/codec_app_def.h" 35 #include "third_party/openh264/src/codec/api/svc/codec_app_def.h"
35 #include "third_party/openh264/src/codec/api/svc/codec_def.h" 36 #include "third_party/openh264/src/codec/api/svc/codec_def.h"
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 181
181 // This callback should be exercised on IO thread. 182 // This callback should be exercised on IO thread.
182 const OnEncodedVideoCB on_encoded_video_callback_; 183 const OnEncodedVideoCB on_encoded_video_callback_;
183 184
184 // Target bitrate for video encoding. If 0, a standard bitrate is used. 185 // Target bitrate for video encoding. If 0, a standard bitrate is used.
185 const int32_t bits_per_second_; 186 const int32_t bits_per_second_;
186 187
187 // Used to retrieve incoming opaque VideoFrames (i.e. VideoFrames backed by 188 // Used to retrieve incoming opaque VideoFrames (i.e. VideoFrames backed by
188 // textures). Created on-demand on |main_task_runner_|. 189 // textures). Created on-demand on |main_task_runner_|.
189 std::unique_ptr<media::SkCanvasVideoRenderer> video_renderer_; 190 std::unique_ptr<media::SkCanvasVideoRenderer> video_renderer_;
190 sk_sp<SkSurface> surface_; 191 sk_sp<CdlSurface> surface_;
191 192
192 DISALLOW_COPY_AND_ASSIGN(Encoder); 193 DISALLOW_COPY_AND_ASSIGN(Encoder);
193 }; 194 };
194 195
195 void VideoTrackRecorder::Encoder::StartFrameEncode( 196 void VideoTrackRecorder::Encoder::StartFrameEncode(
196 const scoped_refptr<VideoFrame>& video_frame, 197 const scoped_refptr<VideoFrame>& video_frame,
197 base::TimeTicks capture_timestamp) { 198 base::TimeTicks capture_timestamp) {
198 // Cache the thread sending frames on first frame arrival. 199 // Cache the thread sending frames on first frame arrival.
199 if (!origin_task_runner_.get()) 200 if (!origin_task_runner_.get())
200 origin_task_runner_ = base::ThreadTaskRunnerHandle::Get(); 201 origin_task_runner_ = base::ThreadTaskRunnerHandle::Get();
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 video_frame->visible_rect(), video_frame->natural_size(), 254 video_frame->visible_rect(), video_frame->natural_size(),
254 video_frame->timestamp()); 255 video_frame->timestamp());
255 256
256 const SkImageInfo info = SkImageInfo::MakeN32( 257 const SkImageInfo info = SkImageInfo::MakeN32(
257 frame->visible_rect().width(), frame->visible_rect().height(), 258 frame->visible_rect().width(), frame->visible_rect().height(),
258 kOpaque_SkAlphaType); 259 kOpaque_SkAlphaType);
259 260
260 // Create |surface_| if it doesn't exist or incoming resolution has changed. 261 // Create |surface_| if it doesn't exist or incoming resolution has changed.
261 if (!surface_ || surface_->width() != info.width() || 262 if (!surface_ || surface_->width() != info.width() ||
262 surface_->height() != info.height()) { 263 surface_->height() != info.height()) {
263 surface_ = SkSurface::MakeRaster(info); 264 surface_ = CdlSurface::MakeRaster(info);
264 } 265 }
265 if (!video_renderer_) 266 if (!video_renderer_)
266 video_renderer_.reset(new media::SkCanvasVideoRenderer); 267 video_renderer_.reset(new media::SkCanvasVideoRenderer);
267 268
268 DCHECK(context_provider->ContextGL()); 269 DCHECK(context_provider->ContextGL());
269 video_renderer_->Copy(video_frame.get(), surface_->getCanvas(), 270 video_renderer_->Copy(video_frame.get(), surface_->getCanvas(),
270 media::Context3D(context_provider->ContextGL(), 271 media::Context3D(context_provider->ContextGL(),
271 context_provider->GrContext())); 272 context_provider->GrContext()));
272 273
273 SkPixmap pixmap; 274 SkPixmap pixmap;
(...skipping 875 matching lines...) Expand 10 before | Expand all | Expand 10 after
1149 encoder_->SetPaused(paused_before_init_); 1150 encoder_->SetPaused(paused_before_init_);
1150 1151
1151 // StartFrameEncode() will be called on Render IO thread. 1152 // StartFrameEncode() will be called on Render IO thread.
1152 MediaStreamVideoSink::ConnectToTrack( 1153 MediaStreamVideoSink::ConnectToTrack(
1153 track_, 1154 track_,
1154 base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode, encoder_), 1155 base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode, encoder_),
1155 false); 1156 false);
1156 } 1157 }
1157 1158
1158 } // namespace content 1159 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/image_capture_frame_grabber.cc ('k') | content/renderer/media/webmediaplayer_ms.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698