| 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" |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 269 |
| 270 if (!map_offset.IsValid() || !map_size.IsValid()) { | 270 if (!map_offset.IsValid() || !map_size.IsValid()) { |
| 271 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode():" | 271 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode():" |
| 272 << " invalid (buffer_offset,buffer_size)"; | 272 << " invalid (buffer_offset,buffer_size)"; |
| 273 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); | 273 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); |
| 274 return; | 274 return; |
| 275 } | 275 } |
| 276 | 276 |
| 277 if (!shm->MapAt(map_offset.ValueOrDie(), map_size.ValueOrDie())) { | 277 if (!shm->MapAt(map_offset.ValueOrDie(), map_size.ValueOrDie())) { |
| 278 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): " | 278 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): " |
| 279 "could not map frame_id=" << params.frame_id; | 279 << "could not map frame_id=" << params.frame_id; |
| 280 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); | 280 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); |
| 281 return; | 281 return; |
| 282 } | 282 } |
| 283 | 283 |
| 284 uint8_t* shm_memory = | 284 uint8_t* shm_memory = |
| 285 reinterpret_cast<uint8_t*>(shm->memory()) + aligned_offset; | 285 reinterpret_cast<uint8_t*>(shm->memory()) + aligned_offset; |
| 286 scoped_refptr<media::VideoFrame> frame = | 286 scoped_refptr<media::VideoFrame> frame = |
| 287 media::VideoFrame::WrapExternalSharedMemory( | 287 media::VideoFrame::WrapExternalSharedMemory( |
| 288 input_format_, | 288 input_format_, |
| 289 input_coded_size_, | 289 input_coded_size_, |
| 290 gfx::Rect(input_visible_size_), | 290 gfx::Rect(input_visible_size_), |
| 291 input_visible_size_, | 291 input_visible_size_, |
| 292 shm_memory, | 292 shm_memory, |
| 293 params.buffer_size, | 293 params.buffer_size, |
| 294 params.buffer_handle, | 294 params.buffer_handle, |
| 295 params.buffer_offset, | 295 params.buffer_offset, |
| 296 params.timestamp); | 296 params.timestamp); |
| 297 if (!frame.get()) { | 297 if (!frame) { |
| 298 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): " | 298 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): " |
| 299 << "could not create a frame"; | 299 << "could not create a frame"; |
| 300 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); | 300 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); |
| 301 return; | 301 return; |
| 302 } | 302 } |
| 303 frame->AddDestructionObserver( | 303 frame->AddDestructionObserver( |
| 304 media::BindToCurrentLoop( | 304 media::BindToCurrentLoop( |
| 305 base::Bind(&GpuVideoEncodeAccelerator::EncodeFrameFinished, | 305 base::Bind(&GpuVideoEncodeAccelerator::EncodeFrameFinished, |
| 306 weak_this_factory_.GetWeakPtr(), | 306 weak_this_factory_.GetWeakPtr(), |
| 307 params.frame_id, | 307 params.frame_id, |
| (...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 454 stub_->channel()->Send(message); | 454 stub_->channel()->Send(message); |
| 455 } | 455 } |
| 456 | 456 |
| 457 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, | 457 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, |
| 458 bool succeeded) { | 458 bool succeeded) { |
| 459 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); | 459 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); |
| 460 Send(message); | 460 Send(message); |
| 461 } | 461 } |
| 462 | 462 |
| 463 } // namespace content | 463 } // namespace content |
| OLD | NEW |