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

Side by Side Diff: content/common/gpu/media/gpu_video_encode_accelerator.cc

Issue 1476523005: Verify returned frames from media::VideoFrame::Wrap*() methods (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: LOG in video_Frame and CHECK/return outside. Created 5 years 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
OLDNEW
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 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
268 268
269 if (!map_offset.IsValid() || !map_size.IsValid()) { 269 if (!map_offset.IsValid() || !map_size.IsValid()) {
270 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode():" 270 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode():"
271 << " invalid (buffer_offset,buffer_size)"; 271 << " invalid (buffer_offset,buffer_size)";
272 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); 272 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError);
273 return; 273 return;
274 } 274 }
275 275
276 if (!shm->MapAt(map_offset.ValueOrDie(), map_size.ValueOrDie())) { 276 if (!shm->MapAt(map_offset.ValueOrDie(), map_size.ValueOrDie())) {
277 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): " 277 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): "
278 "could not map frame_id=" << params.frame_id; 278 << "could not map frame_id=" << params.frame_id;
279 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); 279 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError);
280 return; 280 return;
281 } 281 }
282 282
283 uint8* shm_memory = reinterpret_cast<uint8*>(shm->memory()) + aligned_offset; 283 uint8* shm_memory = reinterpret_cast<uint8*>(shm->memory()) + aligned_offset;
284 scoped_refptr<media::VideoFrame> frame = 284 scoped_refptr<media::VideoFrame> frame =
285 media::VideoFrame::WrapExternalSharedMemory( 285 media::VideoFrame::WrapExternalSharedMemory(
286 input_format_, 286 input_format_,
287 input_coded_size_, 287 input_coded_size_,
288 gfx::Rect(input_visible_size_), 288 gfx::Rect(input_visible_size_),
289 input_visible_size_, 289 input_visible_size_,
290 shm_memory, 290 shm_memory,
291 params.buffer_size, 291 params.buffer_size,
292 params.buffer_handle, 292 params.buffer_handle,
293 params.buffer_offset, 293 params.buffer_offset,
294 params.timestamp); 294 params.timestamp);
295 if (!frame.get()) { 295 if (!frame) {
296 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): " 296 DLOG(ERROR) << "GpuVideoEncodeAccelerator::OnEncode(): "
297 << "could not create a frame"; 297 << "could not create a frame";
298 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError); 298 NotifyError(media::VideoEncodeAccelerator::kPlatformFailureError);
299 return; 299 return;
300 } 300 }
301 frame->AddDestructionObserver( 301 frame->AddDestructionObserver(
302 media::BindToCurrentLoop( 302 media::BindToCurrentLoop(
303 base::Bind(&GpuVideoEncodeAccelerator::EncodeFrameFinished, 303 base::Bind(&GpuVideoEncodeAccelerator::EncodeFrameFinished,
304 weak_this_factory_.GetWeakPtr(), 304 weak_this_factory_.GetWeakPtr(),
305 params.frame_id, 305 params.frame_id,
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 stub_->channel()->Send(message); 452 stub_->channel()->Send(message);
453 } 453 }
454 454
455 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message, 455 void GpuVideoEncodeAccelerator::SendCreateEncoderReply(IPC::Message* message,
456 bool succeeded) { 456 bool succeeded) {
457 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded); 457 GpuCommandBufferMsg_CreateVideoEncoder::WriteReplyParams(message, succeeded);
458 Send(message); 458 Send(message);
459 } 459 }
460 460
461 } // namespace content 461 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698