OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/common/gpu/media/gpu_video_encode_accelerator.h" | 5 #include "content/common/gpu/media/gpu_video_encode_accelerator.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/memory/shared_memory.h" | 10 #include "base/memory/shared_memory.h" |
11 #include "base/numerics/safe_math.h" | 11 #include "base/numerics/safe_math.h" |
12 #include "base/sys_info.h" | 12 #include "base/sys_info.h" |
13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
14 #include "content/common/gpu/gpu_channel.h" | 14 #include "gpu/ipc/client/gpu_memory_buffer_impl.h" |
15 #include "content/common/gpu/gpu_channel_manager.h" | 15 #include "gpu/ipc/service/gpu_channel.h" |
| 16 #include "gpu/ipc/service/gpu_channel_manager.h" |
16 #include "ipc/ipc_message_macros.h" | 17 #include "ipc/ipc_message_macros.h" |
17 #include "media/base/bind_to_current_loop.h" | 18 #include "media/base/bind_to_current_loop.h" |
18 #include "media/base/limits.h" | 19 #include "media/base/limits.h" |
19 #include "media/base/video_frame.h" | 20 #include "media/base/video_frame.h" |
20 #include "media/gpu/ipc/common/gpu_video_accelerator_util.h" | 21 #include "media/gpu/ipc/common/gpu_video_accelerator_util.h" |
21 #include "media/gpu/ipc/common/media_messages.h" | 22 #include "media/gpu/ipc/common/media_messages.h" |
22 | 23 |
23 #if defined(OS_CHROMEOS) | 24 #if defined(OS_CHROMEOS) |
24 #if defined(USE_V4L2_CODEC) | 25 #if defined(USE_V4L2_CODEC) |
25 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" | 26 #include "content/common/gpu/media/v4l2_video_encode_accelerator.h" |
26 #endif | 27 #endif |
27 #if defined(ARCH_CPU_X86_FAMILY) | 28 #if defined(ARCH_CPU_X86_FAMILY) |
28 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" | 29 #include "content/common/gpu/media/vaapi_video_encode_accelerator.h" |
29 #endif | 30 #endif |
30 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) | 31 #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC) |
31 #include "content/common/gpu/media/android_video_encode_accelerator.h" | 32 #include "content/common/gpu/media/android_video_encode_accelerator.h" |
32 #elif defined(OS_MACOSX) | 33 #elif defined(OS_MACOSX) |
33 #include "content/common/gpu/media/vt_video_encode_accelerator_mac.h" | 34 #include "content/common/gpu/media/vt_video_encode_accelerator_mac.h" |
34 #endif | 35 #endif |
35 | 36 |
36 namespace content { | 37 namespace content { |
37 | 38 |
38 static bool MakeDecoderContextCurrent( | 39 static bool MakeDecoderContextCurrent( |
39 const base::WeakPtr<GpuCommandBufferStub> stub) { | 40 const base::WeakPtr<gpu::GpuCommandBufferStub> stub) { |
40 if (!stub) { | 41 if (!stub) { |
41 DLOG(ERROR) << "Stub is gone; won't MakeCurrent()."; | 42 DLOG(ERROR) << "Stub is gone; won't MakeCurrent()."; |
42 return false; | 43 return false; |
43 } | 44 } |
44 | 45 |
45 if (!stub->decoder()->MakeCurrent()) { | 46 if (!stub->decoder()->MakeCurrent()) { |
46 DLOG(ERROR) << "Failed to MakeCurrent()"; | 47 DLOG(ERROR) << "Failed to MakeCurrent()"; |
47 return false; | 48 return false; |
48 } | 49 } |
49 | 50 |
50 return true; | 51 return true; |
51 } | 52 } |
52 | 53 |
53 GpuVideoEncodeAccelerator::GpuVideoEncodeAccelerator(int32_t host_route_id, | 54 GpuVideoEncodeAccelerator::GpuVideoEncodeAccelerator( |
54 GpuCommandBufferStub* stub) | 55 int32_t host_route_id, |
| 56 gpu::GpuCommandBufferStub* stub) |
55 : host_route_id_(host_route_id), | 57 : host_route_id_(host_route_id), |
56 stub_(stub), | 58 stub_(stub), |
57 input_format_(media::PIXEL_FORMAT_UNKNOWN), | 59 input_format_(media::PIXEL_FORMAT_UNKNOWN), |
58 output_buffer_size_(0), | 60 output_buffer_size_(0), |
59 weak_this_factory_(this) { | 61 weak_this_factory_(this) { |
60 stub_->AddDestructionObserver(this); | 62 stub_->AddDestructionObserver(this); |
61 make_context_current_ = | 63 make_context_current_ = |
62 base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); | 64 base::Bind(&MakeDecoderContextCurrent, stub_->AsWeakPtr()); |
63 } | 65 } |
64 | 66 |
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
377 Send(new AcceleratedVideoEncoderHostMsg_NotifyInputDone(host_route_id_, | 379 Send(new AcceleratedVideoEncoderHostMsg_NotifyInputDone(host_route_id_, |
378 frame_id)); | 380 frame_id)); |
379 // Just let |shm| fall out of scope. | 381 // Just let |shm| fall out of scope. |
380 } | 382 } |
381 | 383 |
382 void GpuVideoEncodeAccelerator::Send(IPC::Message* message) { | 384 void GpuVideoEncodeAccelerator::Send(IPC::Message* message) { |
383 stub_->channel()->Send(message); | 385 stub_->channel()->Send(message); |
384 } | 386 } |
385 | 387 |
386 } // namespace content | 388 } // namespace content |
OLD | NEW |