Chromium Code Reviews| 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/renderer/media/rtc_video_decoder.h" | 5 #include "content/renderer/media/rtc_video_decoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/memory/ref_counted.h" | 9 #include "base/memory/ref_counted.h" |
| 10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
| (...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 363 const media::PictureBuffer& pb = it->second; | 363 const media::PictureBuffer& pb = it->second; |
| 364 if (visible_rect.IsEmpty() || !gfx::Rect(pb.size()).Contains(visible_rect)) { | 364 if (visible_rect.IsEmpty() || !gfx::Rect(pb.size()).Contains(visible_rect)) { |
| 365 LOG(ERROR) << "Invalid picture size: " << visible_rect.ToString() | 365 LOG(ERROR) << "Invalid picture size: " << visible_rect.ToString() |
| 366 << " should fit in " << pb.size().ToString(); | 366 << " should fit in " << pb.size().ToString(); |
| 367 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 367 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 368 return; | 368 return; |
| 369 } | 369 } |
| 370 | 370 |
| 371 scoped_refptr<media::VideoFrame> frame = | 371 scoped_refptr<media::VideoFrame> frame = |
| 372 CreateVideoFrame(picture, pb, timestamp, visible_rect); | 372 CreateVideoFrame(picture, pb, timestamp, visible_rect); |
| 373 if (!frame) { | |
| 374 LOG(ERROR) << "Couldn't create video frame"; | |
| 375 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | |
| 376 return; | |
| 377 } | |
| 373 bool inserted = | 378 bool inserted = |
| 374 picture_buffers_at_display_.insert(std::make_pair( | 379 picture_buffers_at_display_.insert(std::make_pair( |
| 375 picture.picture_buffer_id(), | 380 picture.picture_buffer_id(), |
| 376 pb.texture_id())).second; | 381 pb.texture_id())).second; |
| 377 DCHECK(inserted); | 382 DCHECK(inserted); |
| 378 | 383 |
| 379 // Create a WebRTC video frame. | 384 // Create a WebRTC video frame. |
| 380 webrtc::VideoFrame decoded_image( | 385 webrtc::VideoFrame decoded_image( |
| 381 new rtc::RefCountedObject<WebRtcVideoFrameAdapter>(frame), timestamp, 0, | 386 new rtc::RefCountedObject<WebRtcVideoFrameAdapter>(frame), timestamp, 0, |
| 382 webrtc::kVideoRotation_0); | 387 webrtc::kVideoRotation_0); |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 398 uint32_t timestamp, | 403 uint32_t timestamp, |
| 399 const gfx::Rect& visible_rect) { | 404 const gfx::Rect& visible_rect) { |
| 400 DCHECK(decoder_texture_target_); | 405 DCHECK(decoder_texture_target_); |
| 401 // Convert timestamp from 90KHz to ms. | 406 // Convert timestamp from 90KHz to ms. |
| 402 base::TimeDelta timestamp_ms = base::TimeDelta::FromInternalValue( | 407 base::TimeDelta timestamp_ms = base::TimeDelta::FromInternalValue( |
| 403 base::checked_cast<uint64_t>(timestamp) * 1000 / 90); | 408 base::checked_cast<uint64_t>(timestamp) * 1000 / 90); |
| 404 // TODO(mcasas): The incoming data is actually a YUV format, but is labelled | 409 // TODO(mcasas): The incoming data is actually a YUV format, but is labelled |
| 405 // as ARGB. This prevents the compositor from messing with it, since the | 410 // as ARGB. This prevents the compositor from messing with it, since the |
| 406 // underlying platform can handle the former format natively. Make sure the | 411 // underlying platform can handle the former format natively. Make sure the |
| 407 // correct format is used and everyone down the line understands it. | 412 // correct format is used and everyone down the line understands it. |
| 408 scoped_refptr<media::VideoFrame> frame(media::VideoFrame::WrapNativeTexture( | 413 scoped_refptr<media::VideoFrame> frame = media::VideoFrame::WrapNativeTexture( |
| 409 media::PIXEL_FORMAT_ARGB, | 414 media::PIXEL_FORMAT_ARGB, |
| 410 gpu::MailboxHolder(pb.texture_mailbox(), gpu::SyncToken(), | 415 gpu::MailboxHolder(pb.texture_mailbox(), gpu::SyncToken(), |
| 411 decoder_texture_target_), | 416 decoder_texture_target_), |
| 412 media::BindToCurrentLoop(base::Bind( | 417 media::BindToCurrentLoop(base::Bind( |
| 413 &RTCVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(), | 418 &RTCVideoDecoder::ReleaseMailbox, weak_factory_.GetWeakPtr(), |
| 414 factories_, picture.picture_buffer_id(), pb.texture_id())), | 419 factories_, picture.picture_buffer_id(), pb.texture_id())), |
| 415 pb.size(), visible_rect, visible_rect.size(), timestamp_ms)); | 420 pb.size(), visible_rect, visible_rect.size(), timestamp_ms); |
| 416 if (picture.allow_overlay()) { | 421 if (frame && picture.allow_overlay()) { |
|
Pawel Osciak
2015/11/26 01:19:03
Could we perhaps have an error path here logging t
emircan
2015/12/04 04:20:09
Done. It returns a nullptr and l.374 logs it as we
| |
| 417 frame->metadata()->SetBoolean(media::VideoFrameMetadata::ALLOW_OVERLAY, | 422 frame->metadata()->SetBoolean(media::VideoFrameMetadata::ALLOW_OVERLAY, |
| 418 true); | 423 true); |
| 419 } | 424 } |
| 420 return frame; | 425 return frame; |
| 421 } | 426 } |
| 422 | 427 |
| 423 void RTCVideoDecoder::NotifyEndOfBitstreamBuffer(int32 id) { | 428 void RTCVideoDecoder::NotifyEndOfBitstreamBuffer(int32 id) { |
| 424 DVLOG(3) << "NotifyEndOfBitstreamBuffer. id=" << id; | 429 DVLOG(3) << "NotifyEndOfBitstreamBuffer. id=" << id; |
| 425 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 430 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 426 | 431 |
| (...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 803 } | 808 } |
| 804 | 809 |
| 805 void RTCVideoDecoder::ClearPendingBuffers() { | 810 void RTCVideoDecoder::ClearPendingBuffers() { |
| 806 // Delete WebRTC input buffers. | 811 // Delete WebRTC input buffers. |
| 807 for (const auto& pending_buffer : pending_buffers_) | 812 for (const auto& pending_buffer : pending_buffers_) |
| 808 delete[] pending_buffer.first._buffer; | 813 delete[] pending_buffer.first._buffer; |
| 809 pending_buffers_.clear(); | 814 pending_buffers_.clear(); |
| 810 } | 815 } |
| 811 | 816 |
| 812 } // namespace content | 817 } // namespace content |
| OLD | NEW |