Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / content / public / renderer / video_encode_accelerator.cc
blobe660cbf7df780f69df253a05ceb89367e9f217ab
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "content/public/renderer/video_encode_accelerator.h"
7 #include "base/task_runner_util.h"
8 #include "content/common/gpu/client/gpu_video_encode_accelerator_host.h"
9 #include "content/renderer/render_thread_impl.h"
10 #include "media/renderers/gpu_video_accelerator_factories.h"
12 namespace content {
14 void CreateVideoEncodeAccelerator(
15 const OnCreateVideoEncodeAcceleratorCallback& callback) {
16 DCHECK(!callback.is_null());
18 scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories =
19 RenderThreadImpl::current()->GetGpuFactories();
20 if (!gpu_factories || !gpu_factories->IsGpuVideoAcceleratorEnabled()) {
21 callback.Run(NULL, scoped_ptr<media::VideoEncodeAccelerator>());
22 return;
25 scoped_refptr<base::SingleThreadTaskRunner> encode_task_runner =
26 gpu_factories->GetTaskRunner();
27 base::PostTaskAndReplyWithResult(
28 encode_task_runner.get(),
29 FROM_HERE,
30 base::Bind(
31 &media::GpuVideoAcceleratorFactories::CreateVideoEncodeAccelerator,
32 gpu_factories),
33 base::Bind(callback, encode_task_runner));
36 media::VideoEncodeAccelerator::SupportedProfiles
37 GetSupportedVideoEncodeAcceleratorProfiles() {
38 scoped_refptr<media::GpuVideoAcceleratorFactories> gpu_factories =
39 RenderThreadImpl::current()->GetGpuFactories();
40 if (!gpu_factories || !gpu_factories->IsGpuVideoAcceleratorEnabled())
41 return media::VideoEncodeAccelerator::SupportedProfiles();
42 return gpu_factories->GetVideoEncodeAcceleratorSupportedProfiles();
45 } // namespace content