| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 RTCVideoDecoder::BufferData::BufferData() {} | 53 RTCVideoDecoder::BufferData::BufferData() {} |
| 54 | 54 |
| 55 RTCVideoDecoder::BufferData::~BufferData() {} | 55 RTCVideoDecoder::BufferData::~BufferData() {} |
| 56 | 56 |
| 57 RTCVideoDecoder::RTCVideoDecoder(webrtc::VideoCodecType type, | 57 RTCVideoDecoder::RTCVideoDecoder(webrtc::VideoCodecType type, |
| 58 media::GpuVideoAcceleratorFactories* factories) | 58 media::GpuVideoAcceleratorFactories* factories) |
| 59 : vda_error_counter_(0), | 59 : vda_error_counter_(0), |
| 60 video_codec_type_(type), | 60 video_codec_type_(type), |
| 61 factories_(factories), | 61 factories_(factories), |
| 62 decoder_texture_target_(0), | 62 decoder_texture_target_(0), |
| 63 pixel_format_(media::PIXEL_FORMAT_UNKNOWN), |
| 63 next_picture_buffer_id_(0), | 64 next_picture_buffer_id_(0), |
| 64 state_(UNINITIALIZED), | 65 state_(UNINITIALIZED), |
| 65 decode_complete_callback_(nullptr), | 66 decode_complete_callback_(nullptr), |
| 66 num_shm_buffers_(0), | 67 num_shm_buffers_(0), |
| 67 next_bitstream_buffer_id_(0), | 68 next_bitstream_buffer_id_(0), |
| 68 reset_bitstream_buffer_id_(ID_INVALID), | 69 reset_bitstream_buffer_id_(ID_INVALID), |
| 69 weak_factory_(this) { | 70 weak_factory_(this) { |
| 70 DCHECK(!factories_->GetTaskRunner()->BelongsToCurrentThread()); | 71 DCHECK(!factories_->GetTaskRunner()->BelongsToCurrentThread()); |
| 71 } | 72 } |
| 72 | 73 |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 state_ = RESETTING; | 289 state_ = RESETTING; |
| 289 factories_->GetTaskRunner()->PostTask( | 290 factories_->GetTaskRunner()->PostTask( |
| 290 FROM_HERE, | 291 FROM_HERE, |
| 291 base::Bind(&RTCVideoDecoder::ResetInternal, | 292 base::Bind(&RTCVideoDecoder::ResetInternal, |
| 292 weak_factory_.GetWeakPtr())); | 293 weak_factory_.GetWeakPtr())); |
| 293 } | 294 } |
| 294 return WEBRTC_VIDEO_CODEC_OK; | 295 return WEBRTC_VIDEO_CODEC_OK; |
| 295 } | 296 } |
| 296 | 297 |
| 297 void RTCVideoDecoder::ProvidePictureBuffers(uint32_t count, | 298 void RTCVideoDecoder::ProvidePictureBuffers(uint32_t count, |
| 299 media::VideoPixelFormat format, |
| 298 uint32_t textures_per_buffer, | 300 uint32_t textures_per_buffer, |
| 299 const gfx::Size& size, | 301 const gfx::Size& size, |
| 300 uint32_t texture_target) { | 302 uint32_t texture_target) { |
| 301 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 303 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 302 DVLOG(3) << "ProvidePictureBuffers. texture_target=" << texture_target; | 304 DVLOG(3) << "ProvidePictureBuffers. texture_target=" << texture_target; |
| 303 DCHECK_EQ(1u, textures_per_buffer); | 305 DCHECK_EQ(1u, textures_per_buffer); |
| 304 | 306 |
| 305 if (!vda_) | 307 if (!vda_) |
| 306 return; | 308 return; |
| 307 | 309 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 325 ids.push_back(texture_ids[i]); | 327 ids.push_back(texture_ids[i]); |
| 326 std::vector<gpu::Mailbox> mailboxes; | 328 std::vector<gpu::Mailbox> mailboxes; |
| 327 mailboxes.push_back(texture_mailboxes[i]); | 329 mailboxes.push_back(texture_mailboxes[i]); |
| 328 | 330 |
| 329 picture_buffers.push_back( | 331 picture_buffers.push_back( |
| 330 media::PictureBuffer(next_picture_buffer_id_++, size, ids, mailboxes)); | 332 media::PictureBuffer(next_picture_buffer_id_++, size, ids, mailboxes)); |
| 331 bool inserted = assigned_picture_buffers_.insert(std::make_pair( | 333 bool inserted = assigned_picture_buffers_.insert(std::make_pair( |
| 332 picture_buffers.back().id(), picture_buffers.back())).second; | 334 picture_buffers.back().id(), picture_buffers.back())).second; |
| 333 DCHECK(inserted); | 335 DCHECK(inserted); |
| 334 } | 336 } |
| 337 |
| 338 pixel_format_ = format; |
| 339 if (pixel_format_ == media::PIXEL_FORMAT_UNKNOWN) |
| 340 pixel_format_ = media::PIXEL_FORMAT_ARGB; |
| 335 vda_->AssignPictureBuffers(picture_buffers); | 341 vda_->AssignPictureBuffers(picture_buffers); |
| 336 } | 342 } |
| 337 | 343 |
| 338 void RTCVideoDecoder::DismissPictureBuffer(int32_t id) { | 344 void RTCVideoDecoder::DismissPictureBuffer(int32_t id) { |
| 339 DVLOG(3) << "DismissPictureBuffer. id=" << id; | 345 DVLOG(3) << "DismissPictureBuffer. id=" << id; |
| 340 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 346 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
| 341 | 347 |
| 342 std::map<int32_t, media::PictureBuffer>::iterator it = | 348 std::map<int32_t, media::PictureBuffer>::iterator it = |
| 343 assigned_picture_buffers_.find(id); | 349 assigned_picture_buffers_.find(id); |
| 344 if (it == assigned_picture_buffers_.end()) { | 350 if (it == assigned_picture_buffers_.end()) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 377 visible_rect = picture.visible_rect(); | 383 visible_rect = picture.visible_rect(); |
| 378 | 384 |
| 379 const media::PictureBuffer& pb = it->second; | 385 const media::PictureBuffer& pb = it->second; |
| 380 if (visible_rect.IsEmpty() || !gfx::Rect(pb.size()).Contains(visible_rect)) { | 386 if (visible_rect.IsEmpty() || !gfx::Rect(pb.size()).Contains(visible_rect)) { |
| 381 LOG(ERROR) << "Invalid picture size: " << visible_rect.ToString() | 387 LOG(ERROR) << "Invalid picture size: " << visible_rect.ToString() |
| 382 << " should fit in " << pb.size().ToString(); | 388 << " should fit in " << pb.size().ToString(); |
| 383 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 389 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 384 return; | 390 return; |
| 385 } | 391 } |
| 386 | 392 |
| 387 media::VideoPixelFormat pixel_format = vda_->GetOutputFormat(); | |
| 388 if (pixel_format == media::PIXEL_FORMAT_UNKNOWN) | |
| 389 pixel_format = media::PIXEL_FORMAT_ARGB; | |
| 390 | |
| 391 scoped_refptr<media::VideoFrame> frame = | 393 scoped_refptr<media::VideoFrame> frame = |
| 392 CreateVideoFrame(picture, pb, timestamp, visible_rect, pixel_format); | 394 CreateVideoFrame(picture, pb, timestamp, visible_rect, pixel_format_); |
| 393 if (!frame) { | 395 if (!frame) { |
| 394 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 396 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
| 395 return; | 397 return; |
| 396 } | 398 } |
| 397 bool inserted = picture_buffers_at_display_ | 399 bool inserted = picture_buffers_at_display_ |
| 398 .insert(std::make_pair(picture.picture_buffer_id(), | 400 .insert(std::make_pair(picture.picture_buffer_id(), |
| 399 pb.texture_ids()[0])) | 401 pb.texture_ids()[0])) |
| 400 .second; | 402 .second; |
| 401 DCHECK(inserted); | 403 DCHECK(inserted); |
| 402 | 404 |
| (...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 861 | 863 |
| 862 void RTCVideoDecoder::TryResetVDAErrorCounter_Locked() { | 864 void RTCVideoDecoder::TryResetVDAErrorCounter_Locked() { |
| 863 lock_.AssertAcquired(); | 865 lock_.AssertAcquired(); |
| 864 | 866 |
| 865 if (vda_error_counter_ == 0) | 867 if (vda_error_counter_ == 0) |
| 866 return; | 868 return; |
| 867 vda_error_counter_ = 0; | 869 vda_error_counter_ = 0; |
| 868 } | 870 } |
| 869 | 871 |
| 870 } // namespace content | 872 } // namespace content |
| OLD | NEW |