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

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

Issue 2775453003: Fix multiple Initialize() calls and reenable VEA usage in MediaRecorder for Win8 (Closed)
Patch Set: Initialize once Created 3 years, 9 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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_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 "cc/paint/paint_canvas.h"
20 #include "cc/paint/paint_surface.h" 20 #include "cc/paint/paint_surface.h"
21 #include "content/child/child_process.h"
21 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h" 22 #include "content/renderer/media/renderer_gpu_video_accelerator_factories.h"
22 #include "content/renderer/render_thread_impl.h" 23 #include "content/renderer/render_thread_impl.h"
23 #include "media/base/bind_to_current_loop.h" 24 #include "media/base/bind_to_current_loop.h"
24 #include "media/base/video_frame.h" 25 #include "media/base/video_frame.h"
25 #include "media/base/video_util.h" 26 #include "media/base/video_util.h"
26 #include "media/filters/context_3d.h" 27 #include "media/filters/context_3d.h"
27 #include "media/renderers/skcanvas_video_renderer.h" 28 #include "media/renderers/skcanvas_video_renderer.h"
28 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h" 29 #include "services/ui/public/cpp/gpu/context_provider_command_buffer.h"
29 #include "skia/ext/platform_canvas.h" 30 #include "skia/ext/platform_canvas.h"
30 #include "third_party/libyuv/include/libyuv.h" 31 #include "third_party/libyuv/include/libyuv.h"
31 #include "ui/gfx/geometry/size.h" 32 #include "ui/gfx/geometry/size.h"
32 33
33 #if defined(OS_WIN)
34 #include "base/win/windows_version.h"
35 #endif
36
37 #if BUILDFLAG(RTC_USE_H264) 34 #if BUILDFLAG(RTC_USE_H264)
38 #include "third_party/openh264/src/codec/api/svc/codec_api.h" 35 #include "third_party/openh264/src/codec/api/svc/codec_api.h"
39 #include "third_party/openh264/src/codec/api/svc/codec_app_def.h" 36 #include "third_party/openh264/src/codec/api/svc/codec_app_def.h"
40 #include "third_party/openh264/src/codec/api/svc/codec_def.h" 37 #include "third_party/openh264/src/codec/api/svc/codec_def.h"
41 #endif // #if BUILDFLAG(RTC_USE_H264) 38 #endif // #if BUILDFLAG(RTC_USE_H264)
42 39
43 extern "C" { 40 extern "C" {
44 // VPX_CODEC_DISABLE_COMPAT excludes parts of the libvpx API that provide 41 // VPX_CODEC_DISABLE_COMPAT excludes parts of the libvpx API that provide
45 // backwards compatibility for legacy applications using the library. 42 // backwards compatibility for legacy applications using the library.
46 #define VPX_CODEC_DISABLE_COMPAT 1 43 #define VPX_CODEC_DISABLE_COMPAT 1
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 #if defined(OS_CHROMEOS) 111 #if defined(OS_CHROMEOS)
115 // See https://crbug.com/616659. 112 // See https://crbug.com/616659.
116 return; 113 return;
117 #endif 114 #endif
118 115
119 #if defined(OS_ANDROID) 116 #if defined(OS_ANDROID)
120 // See https://crbug.com/653864. 117 // See https://crbug.com/653864.
121 return; 118 return;
122 #endif 119 #endif
123 120
124 #if defined(OS_WIN)
125 // See https://crbug.com/698441.
126 if (base::win::GetVersion() < base::win::VERSION_WIN10)
127 return;
128 #endif
129
130 content::RenderThreadImpl* const render_thread_impl = 121 content::RenderThreadImpl* const render_thread_impl =
131 content::RenderThreadImpl::current(); 122 content::RenderThreadImpl::current();
132 if (!render_thread_impl) { 123 if (!render_thread_impl) {
133 DVLOG(2) << "Couldn't access the render thread"; 124 DVLOG(2) << "Couldn't access the render thread";
134 return; 125 return;
135 } 126 }
136 127
137 media::GpuVideoAcceleratorFactories* const gpu_factories = 128 media::GpuVideoAcceleratorFactories* const gpu_factories =
138 render_thread_impl->GetGpuFactories(); 129 render_thread_impl->GetGpuFactories();
139 if (!gpu_factories || !gpu_factories->IsGpuVideoAcceleratorEnabled()) { 130 if (!gpu_factories || !gpu_factories->IsGpuVideoAcceleratorEnabled()) {
(...skipping 1156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 1287
1297 void VideoTrackRecorder::InitializeEncoder( 1288 void VideoTrackRecorder::InitializeEncoder(
1298 CodecId codec, 1289 CodecId codec,
1299 const OnEncodedVideoCB& on_encoded_video_callback, 1290 const OnEncodedVideoCB& on_encoded_video_callback,
1300 int32_t bits_per_second, 1291 int32_t bits_per_second,
1301 const scoped_refptr<media::VideoFrame>& frame, 1292 const scoped_refptr<media::VideoFrame>& frame,
1302 base::TimeTicks capture_time) { 1293 base::TimeTicks capture_time) {
1303 DVLOG(3) << __func__ << frame->visible_rect().size().ToString(); 1294 DVLOG(3) << __func__ << frame->visible_rect().size().ToString();
1304 DCHECK(main_render_thread_checker_.CalledOnValidThread()); 1295 DCHECK(main_render_thread_checker_.CalledOnValidThread());
1305 1296
1297 if (encoder_) {
1298 auto* const child_process = ChildProcess::current();
1299 if (child_process) {
1300 child_process->io_task_runner()->PostTask(
1301 FROM_HERE, base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode,
1302 encoder_, frame, capture_time));
1303 }
1304 return;
1305 }
mcasas 2017/03/23 21:14:08 I'd do: // Avoid reinitializing |encoder_|, htt
emircan 2017/03/24 18:14:11 Done. RenderThreadImpl directly calls ChildProcess
1306
1306 MediaStreamVideoSink::DisconnectFromTrack(); 1307 MediaStreamVideoSink::DisconnectFromTrack();
1307 1308
1308 const gfx::Size& input_size = frame->visible_rect().size(); 1309 const gfx::Size& input_size = frame->visible_rect().size();
1309 const auto& vea_supported_profile = 1310 const auto& vea_supported_profile =
1310 GetCodecEnumerator()->CodecIdToVEAProfile(codec); 1311 GetCodecEnumerator()->CodecIdToVEAProfile(codec);
1311 if (vea_supported_profile != media::VIDEO_CODEC_PROFILE_UNKNOWN && 1312 if (vea_supported_profile != media::VIDEO_CODEC_PROFILE_UNKNOWN &&
1312 input_size.width() >= kVEAEncoderMinResolutionWidth && 1313 input_size.width() >= kVEAEncoderMinResolutionWidth &&
1313 input_size.height() >= kVEAEncoderMinResolutionHeight) { 1314 input_size.height() >= kVEAEncoderMinResolutionHeight) {
1314 encoder_ = new VEAEncoder(on_encoded_video_callback, bits_per_second, 1315 encoder_ = new VEAEncoder(on_encoded_video_callback, bits_per_second,
1315 vea_supported_profile, input_size); 1316 vea_supported_profile, input_size);
(...skipping 24 matching lines...) Expand all
1340 base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode, encoder_), 1341 base::Bind(&VideoTrackRecorder::Encoder::StartFrameEncode, encoder_),
1341 false); 1342 false);
1342 } 1343 }
1343 1344
1344 bool VideoTrackRecorder::CanEncodeAlphaChannelForTesting() { 1345 bool VideoTrackRecorder::CanEncodeAlphaChannelForTesting() {
1345 DCHECK(encoder_); 1346 DCHECK(encoder_);
1346 return encoder_->CanEncodeAlphaChannel(); 1347 return encoder_->CanEncodeAlphaChannel();
1347 } 1348 }
1348 1349
1349 } // namespace content 1350 } // namespace content
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698