| OLD | NEW |
| 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/recorder/video_track_recorder.h" | 5 #include "content/renderer/media/recorder/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/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "base/sys_info.h" | 13 #include "base/sys_info.h" |
| 14 #include "base/task_runner_util.h" | 14 #include "base/task_runner_util.h" |
| 15 #include "base/threading/thread.h" | 15 #include "base/threading/thread.h" |
| 16 #include "base/threading/thread_task_runner_handle.h" | 16 #include "base/threading/thread_task_runner_handle.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "base/trace_event/trace_event.h" | 18 #include "base/trace_event/trace_event.h" |
| 19 #include "cc/paint/paint_canvas.h" |
| 19 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h" | 20 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h" |
| 20 #include "content/renderer/render_thread_impl.h" | 21 #include "content/renderer/render_thread_impl.h" |
| 21 #include "media/base/bind_to_current_loop.h" | 22 #include "media/base/bind_to_current_loop.h" |
| 22 #include "media/base/video_frame.h" | 23 #include "media/base/video_frame.h" |
| 23 #include "media/base/video_util.h" | 24 #include "media/base/video_util.h" |
| 24 #include "media/filters/context_3d.h" | 25 #include "media/filters/context_3d.h" |
| 25 #include "media/renderers/skcanvas_video_renderer.h" | 26 #include "media/renderers/skcanvas_video_renderer.h" |
| 26 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" | 27 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" |
| 27 #include "skia/ext/platform_canvas.h" | 28 #include "skia/ext/platform_canvas.h" |
| 28 #include "third_party/libyuv/include/libyuv.h" | 29 #include "third_party/libyuv/include/libyuv.h" |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 } | 318 } |
| 318 if (!video_renderer_) | 319 if (!video_renderer_) |
| 319 video_renderer_.reset(new media::SkCanvasVideoRenderer); | 320 video_renderer_.reset(new media::SkCanvasVideoRenderer); |
| 320 | 321 |
| 321 DCHECK(context_provider->ContextGL()); | 322 DCHECK(context_provider->ContextGL()); |
| 322 video_renderer_->Copy(video_frame.get(), surface_->getCanvas(), | 323 video_renderer_->Copy(video_frame.get(), surface_->getCanvas(), |
| 323 media::Context3D(context_provider->ContextGL(), | 324 media::Context3D(context_provider->ContextGL(), |
| 324 context_provider->GrContext())); | 325 context_provider->GrContext())); |
| 325 | 326 |
| 326 SkPixmap pixmap; | 327 SkPixmap pixmap; |
| 327 if (!skia::GetWritablePixels(surface_->getCanvas(), &pixmap)) { | 328 if (!cc::ToPixmap(surface_->getCanvas(), &pixmap)) { |
| 328 DLOG(ERROR) << "Error trying to map SkSurface's pixels"; | 329 DLOG(ERROR) << "Error trying to map SkSurface's pixels"; |
| 329 return; | 330 return; |
| 330 } | 331 } |
| 331 // TODO(mcasas): Use the incoming frame's rotation when | 332 // TODO(mcasas): Use the incoming frame's rotation when |
| 332 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6069 is closed. | 333 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6069 is closed. |
| 333 const libyuv::RotationMode source_rotation = libyuv::kRotate0; | 334 const libyuv::RotationMode source_rotation = libyuv::kRotate0; |
| 334 const uint32 source_pixel_format = | 335 const uint32 source_pixel_format = |
| 335 (kN32_SkColorType == kRGBA_8888_SkColorType) ? libyuv::FOURCC_ABGR | 336 (kN32_SkColorType == kRGBA_8888_SkColorType) ? libyuv::FOURCC_ABGR |
| 336 : libyuv::FOURCC_ARGB; | 337 : libyuv::FOURCC_ARGB; |
| 337 if (libyuv::ConvertToI420(static_cast<uint8*>(pixmap.writable_addr()), | 338 if (libyuv::ConvertToI420(static_cast<uint8*>(pixmap.writable_addr()), |
| (...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1218 encoder_->SetPaused(paused_before_init_); | 1219 encoder_->SetPaused(paused_before_init_); |
| 1219 | 1220 |
| 1220 // StartFrameEncode() will be called on Render IO thread. | 1221 // StartFrameEncode() will be called on Render IO thread. |
| 1221 MediaStreamVideoSink::ConnectToTrack( | 1222 MediaStreamVideoSink::ConnectToTrack( |
| 1222 track_, | 1223 track_, |
| 1223 base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode, encoder_), | 1224 base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode, encoder_), |
| 1224 false); | 1225 false); |
| 1225 } | 1226 } |
| 1226 | 1227 |
| 1227 } // namespace content | 1228 } // namespace content |
| OLD | NEW |