| Index: media/gpu/ipc/service/gpu_video_encode_accelerator.cc
|
| diff --git a/content/common/gpu/media/gpu_video_encode_accelerator.cc b/media/gpu/ipc/service/gpu_video_encode_accelerator.cc
|
| similarity index 86%
|
| rename from content/common/gpu/media/gpu_video_encode_accelerator.cc
|
| rename to media/gpu/ipc/service/gpu_video_encode_accelerator.cc
|
| index 6381658e7287dab0adb97d45c93ea7bcb4199f4e..3287d7b6832188bfb47eeedf776f872de628259d 100644
|
| --- a/content/common/gpu/media/gpu_video_encode_accelerator.cc
|
| +++ b/media/gpu/ipc/service/gpu_video_encode_accelerator.cc
|
| @@ -2,7 +2,7 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#include "content/common/gpu/media/gpu_video_encode_accelerator.h"
|
| +#include "media/gpu/ipc/service/gpu_video_encode_accelerator.h"
|
|
|
| #include <memory>
|
|
|
| @@ -21,23 +21,23 @@
|
| #include "media/base/bind_to_current_loop.h"
|
| #include "media/base/limits.h"
|
| #include "media/base/video_frame.h"
|
| -#include "media/gpu/ipc/common/gpu_video_accelerator_util.h"
|
| +#include "media/gpu/gpu_video_accelerator_util.h"
|
| #include "media/gpu/ipc/common/media_messages.h"
|
|
|
| #if defined(OS_CHROMEOS)
|
| #if defined(USE_V4L2_CODEC)
|
| -#include "content/common/gpu/media/v4l2_video_encode_accelerator.h"
|
| +#include "media/gpu/v4l2_video_encode_accelerator.h"
|
| #endif
|
| #if defined(ARCH_CPU_X86_FAMILY)
|
| -#include "content/common/gpu/media/vaapi_video_encode_accelerator.h"
|
| +#include "media/gpu/vaapi_video_encode_accelerator.h"
|
| #endif
|
| #elif defined(OS_ANDROID) && defined(ENABLE_WEBRTC)
|
| -#include "content/common/gpu/media/android_video_encode_accelerator.h"
|
| +#include "media/gpu/android_video_encode_accelerator.h"
|
| #elif defined(OS_MACOSX)
|
| -#include "content/common/gpu/media/vt_video_encode_accelerator_mac.h"
|
| +#include "media/gpu/vt_video_encode_accelerator_mac.h"
|
| #endif
|
|
|
| -namespace content {
|
| +namespace media {
|
|
|
| static bool MakeDecoderContextCurrent(
|
| const base::WeakPtr<gpu::GpuCommandBufferStub> stub) {
|
| @@ -79,7 +79,8 @@ bool GpuVideoEncodeAccelerator::Initialize(
|
| media::VideoCodecProfile output_profile,
|
| uint32_t initial_bitrate) {
|
| DVLOG(2) << "GpuVideoEncodeAccelerator::Initialize(): "
|
| - "input_format=" << input_format
|
| + "input_format="
|
| + << input_format
|
| << ", input_visible_size=" << input_visible_size.ToString()
|
| << ", output_profile=" << output_profile
|
| << ", initial_bitrate=" << initial_bitrate;
|
| @@ -95,8 +96,8 @@ bool GpuVideoEncodeAccelerator::Initialize(
|
| input_visible_size.height() > media::limits::kMaxDimension ||
|
| input_visible_size.GetArea() > media::limits::kMaxCanvas) {
|
| DLOG(ERROR) << "GpuVideoEncodeAccelerator::Initialize(): "
|
| - "input_visible_size " << input_visible_size.ToString()
|
| - << " too large";
|
| + "input_visible_size "
|
| + << input_visible_size.ToString() << " too large";
|
| return false;
|
| }
|
|
|
| @@ -108,11 +109,9 @@ bool GpuVideoEncodeAccelerator::Initialize(
|
| // Try all possible encoders and use the first successful encoder.
|
| for (size_t i = 0; i < create_vea_fps.size(); ++i) {
|
| encoder_ = (*create_vea_fps[i])();
|
| - if (encoder_ && encoder_->Initialize(input_format,
|
| - input_visible_size,
|
| - output_profile,
|
| - initial_bitrate,
|
| - this)) {
|
| + if (encoder_ &&
|
| + encoder_->Initialize(input_format, input_visible_size, output_profile,
|
| + initial_bitrate, this)) {
|
| input_format_ = input_format;
|
| input_visible_size_ = input_visible_size;
|
| return true;
|
| @@ -271,7 +270,8 @@ void GpuVideoEncodeAccelerator::OnEncode(
|
|
|
| if (params.frame_id < 0) {
|
| DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): invalid "
|
| - "frame_id=" << params.frame_id;
|
| + "frame_id="
|
| + << params.frame_id;
|
| NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError);
|
| return;
|
| }
|
| @@ -301,27 +301,18 @@ void GpuVideoEncodeAccelerator::OnEncode(
|
| reinterpret_cast<uint8_t*>(shm->memory()) + aligned_offset;
|
| scoped_refptr<media::VideoFrame> frame =
|
| media::VideoFrame::WrapExternalSharedMemory(
|
| - input_format_,
|
| - input_coded_size_,
|
| - gfx::Rect(input_visible_size_),
|
| - input_visible_size_,
|
| - shm_memory,
|
| - params.buffer_size,
|
| - params.buffer_handle,
|
| - params.buffer_offset,
|
| - params.timestamp);
|
| + input_format_, input_coded_size_, gfx::Rect(input_visible_size_),
|
| + input_visible_size_, shm_memory, params.buffer_size,
|
| + params.buffer_handle, params.buffer_offset, params.timestamp);
|
| if (!frame) {
|
| DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): "
|
| << "could not create a frame";
|
| NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError);
|
| return;
|
| }
|
| - frame->AddDestructionObserver(
|
| - media::BindToCurrentLoop(
|
| - base::Bind(&GpuVideoEncodeAccelerator::EncodeFrameFinished,
|
| - weak_this_factory_.GetWeakPtr(),
|
| - params.frame_id,
|
| - base::Passed(&shm))));
|
| + frame->AddDestructionObserver(media::BindToCurrentLoop(base::Bind(
|
| + &GpuVideoEncodeAccelerator::EncodeFrameFinished,
|
| + weak_this_factory_.GetWeakPtr(), params.frame_id, base::Passed(&shm))));
|
| encoder_->Encode(frame, params.force_keyframe);
|
| }
|
|
|
| @@ -329,8 +320,8 @@ void GpuVideoEncodeAccelerator::OnEncode2(
|
| const AcceleratedVideoEncoderMsg_Encode_Params2& params) {
|
| DVLOG(3) << "GpuVideoEncodeAccelerator::OnEncode2: frame_id = "
|
| << params.frame_id << ", size=" << params.size.ToString()
|
| - << ", force_keyframe=" << params.force_keyframe << ", handle type="
|
| - << params.gpu_memory_buffer_handles[0].type;
|
| + << ", force_keyframe=" << params.force_keyframe
|
| + << ", handle type=" << params.gpu_memory_buffer_handles[0].type;
|
| // Encoding GpuMemoryBuffer backed frames is not supported.
|
| NOTREACHED();
|
| }
|
| @@ -340,19 +331,21 @@ void GpuVideoEncodeAccelerator::OnUseOutputBitstreamBuffer(
|
| base::SharedMemoryHandle buffer_handle,
|
| uint32_t buffer_size) {
|
| DVLOG(3) << "GpuVideoEncodeAccelerator::OnUseOutputBitstreamBuffer(): "
|
| - "buffer_id=" << buffer_id
|
| - << ", buffer_size=" << buffer_size;
|
| + "buffer_id="
|
| + << buffer_id << ", buffer_size=" << buffer_size;
|
| if (!encoder_)
|
| return;
|
| if (buffer_id < 0) {
|
| DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnUseOutputBitstreamBuffer(): "
|
| - "invalid buffer_id=" << buffer_id;
|
| + "invalid buffer_id="
|
| + << buffer_id;
|
| NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError);
|
| return;
|
| }
|
| if (buffer_size < output_buffer_size_) {
|
| DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnUseOutputBitstreamBuffer(): "
|
| - "buffer too small for buffer_id=" << buffer_id;
|
| + "buffer too small for buffer_id="
|
| + << buffer_id;
|
| NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError);
|
| return;
|
| }
|
| @@ -369,8 +362,8 @@ void GpuVideoEncodeAccelerator::OnRequestEncodingParametersChange(
|
| uint32_t bitrate,
|
| uint32_t framerate) {
|
| DVLOG(2) << "GpuVideoEncodeAccelerator::OnRequestEncodingParametersChange(): "
|
| - "bitrate=" << bitrate
|
| - << ", framerate=" << framerate;
|
| + "bitrate="
|
| + << bitrate << ", framerate=" << framerate;
|
| if (!encoder_)
|
| return;
|
| encoder_->RequestEncodingParametersChange(bitrate, framerate);
|
| @@ -388,4 +381,4 @@ void GpuVideoEncodeAccelerator::Send(IPC::Message* message) {
|
| stub_->channel()->Send(message);
|
| }
|
|
|
| -} // namespace content
|
| +} // namespace media
|
|
|