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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
59 RTCVideoDecoder::BufferData::BufferData() {} | 59 RTCVideoDecoder::BufferData::BufferData() {} |
60 | 60 |
61 RTCVideoDecoder::BufferData::~BufferData() {} | 61 RTCVideoDecoder::BufferData::~BufferData() {} |
62 | 62 |
63 RTCVideoDecoder::RTCVideoDecoder(webrtc::VideoCodecType type, | 63 RTCVideoDecoder::RTCVideoDecoder(webrtc::VideoCodecType type, |
64 media::GpuVideoAcceleratorFactories* factories) | 64 media::GpuVideoAcceleratorFactories* factories) |
65 : vda_error_counter_(0), | 65 : vda_error_counter_(0), |
66 video_codec_type_(type), | 66 video_codec_type_(type), |
67 factories_(factories), | 67 factories_(factories), |
68 decoder_texture_target_(0), | 68 decoder_texture_target_(0), |
69 pixel_format_(media::PIXEL_FORMAT_UNKNOWN), | |
69 next_picture_buffer_id_(0), | 70 next_picture_buffer_id_(0), |
70 state_(UNINITIALIZED), | 71 state_(UNINITIALIZED), |
71 decode_complete_callback_(nullptr), | 72 decode_complete_callback_(nullptr), |
72 num_shm_buffers_(0), | 73 num_shm_buffers_(0), |
73 next_bitstream_buffer_id_(0), | 74 next_bitstream_buffer_id_(0), |
74 reset_bitstream_buffer_id_(ID_INVALID), | 75 reset_bitstream_buffer_id_(ID_INVALID), |
75 weak_factory_(this) { | 76 weak_factory_(this) { |
76 DCHECK(!factories_->GetTaskRunner()->BelongsToCurrentThread()); | 77 DCHECK(!factories_->GetTaskRunner()->BelongsToCurrentThread()); |
77 } | 78 } |
78 | 79 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
304 state_ = RESETTING; | 305 state_ = RESETTING; |
305 factories_->GetTaskRunner()->PostTask( | 306 factories_->GetTaskRunner()->PostTask( |
306 FROM_HERE, | 307 FROM_HERE, |
307 base::Bind(&RTCVideoDecoder::ResetInternal, | 308 base::Bind(&RTCVideoDecoder::ResetInternal, |
308 weak_factory_.GetWeakPtr())); | 309 weak_factory_.GetWeakPtr())); |
309 } | 310 } |
310 return WEBRTC_VIDEO_CODEC_OK; | 311 return WEBRTC_VIDEO_CODEC_OK; |
311 } | 312 } |
312 | 313 |
313 void RTCVideoDecoder::ProvidePictureBuffers(uint32_t count, | 314 void RTCVideoDecoder::ProvidePictureBuffers(uint32_t count, |
315 media::VideoPixelFormat format, | |
314 uint32_t textures_per_buffer, | 316 uint32_t textures_per_buffer, |
315 const gfx::Size& size, | 317 const gfx::Size& size, |
316 uint32_t texture_target) { | 318 uint32_t texture_target) { |
317 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 319 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
318 DVLOG(3) << "ProvidePictureBuffers. texture_target=" << texture_target; | 320 DVLOG(3) << "ProvidePictureBuffers. texture_target=" << texture_target; |
319 DCHECK_EQ(1u, textures_per_buffer); | 321 DCHECK_EQ(1u, textures_per_buffer); |
320 | 322 |
321 if (!vda_) | 323 if (!vda_) |
322 return; | 324 return; |
323 | 325 |
(...skipping 17 matching lines...) Expand all Loading... | |
341 ids.push_back(texture_ids[i]); | 343 ids.push_back(texture_ids[i]); |
342 std::vector<gpu::Mailbox> mailboxes; | 344 std::vector<gpu::Mailbox> mailboxes; |
343 mailboxes.push_back(texture_mailboxes[i]); | 345 mailboxes.push_back(texture_mailboxes[i]); |
344 | 346 |
345 picture_buffers.push_back( | 347 picture_buffers.push_back( |
346 media::PictureBuffer(next_picture_buffer_id_++, size, ids, mailboxes)); | 348 media::PictureBuffer(next_picture_buffer_id_++, size, ids, mailboxes)); |
347 bool inserted = assigned_picture_buffers_.insert(std::make_pair( | 349 bool inserted = assigned_picture_buffers_.insert(std::make_pair( |
348 picture_buffers.back().id(), picture_buffers.back())).second; | 350 picture_buffers.back().id(), picture_buffers.back())).second; |
349 DCHECK(inserted); | 351 DCHECK(inserted); |
350 } | 352 } |
353 | |
354 pixel_format_ = format; | |
355 if (pixel_format_ == media::PIXEL_FORMAT_UNKNOWN) | |
356 pixel_format_ = media::PIXEL_FORMAT_ARGB; | |
Pawel Osciak
2016/05/26 08:54:07
We should probably refuse format change in this cl
| |
351 vda_->AssignPictureBuffers(picture_buffers); | 357 vda_->AssignPictureBuffers(picture_buffers); |
352 } | 358 } |
353 | 359 |
354 void RTCVideoDecoder::DismissPictureBuffer(int32_t id) { | 360 void RTCVideoDecoder::DismissPictureBuffer(int32_t id) { |
355 DVLOG(3) << "DismissPictureBuffer. id=" << id; | 361 DVLOG(3) << "DismissPictureBuffer. id=" << id; |
356 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); | 362 DCheckGpuVideoAcceleratorFactoriesTaskRunnerIsCurrent(); |
357 | 363 |
358 std::map<int32_t, media::PictureBuffer>::iterator it = | 364 std::map<int32_t, media::PictureBuffer>::iterator it = |
359 assigned_picture_buffers_.find(id); | 365 assigned_picture_buffers_.find(id); |
360 if (it == assigned_picture_buffers_.end()) { | 366 if (it == assigned_picture_buffers_.end()) { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 visible_rect = picture.visible_rect(); | 399 visible_rect = picture.visible_rect(); |
394 | 400 |
395 const media::PictureBuffer& pb = it->second; | 401 const media::PictureBuffer& pb = it->second; |
396 if (visible_rect.IsEmpty() || !gfx::Rect(pb.size()).Contains(visible_rect)) { | 402 if (visible_rect.IsEmpty() || !gfx::Rect(pb.size()).Contains(visible_rect)) { |
397 LOG(ERROR) << "Invalid picture size: " << visible_rect.ToString() | 403 LOG(ERROR) << "Invalid picture size: " << visible_rect.ToString() |
398 << " should fit in " << pb.size().ToString(); | 404 << " should fit in " << pb.size().ToString(); |
399 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 405 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
400 return; | 406 return; |
401 } | 407 } |
402 | 408 |
403 media::VideoPixelFormat pixel_format = vda_->GetOutputFormat(); | |
404 if (pixel_format == media::PIXEL_FORMAT_UNKNOWN) | |
405 pixel_format = media::PIXEL_FORMAT_ARGB; | |
406 | |
407 scoped_refptr<media::VideoFrame> frame = | 409 scoped_refptr<media::VideoFrame> frame = |
408 CreateVideoFrame(picture, pb, timestamp, visible_rect, pixel_format); | 410 CreateVideoFrame(picture, pb, timestamp, visible_rect, pixel_format_); |
409 if (!frame) { | 411 if (!frame) { |
410 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); | 412 NotifyError(media::VideoDecodeAccelerator::PLATFORM_FAILURE); |
411 return; | 413 return; |
412 } | 414 } |
413 bool inserted = picture_buffers_at_display_ | 415 bool inserted = picture_buffers_at_display_ |
414 .insert(std::make_pair(picture.picture_buffer_id(), | 416 .insert(std::make_pair(picture.picture_buffer_id(), |
415 pb.texture_ids()[0])) | 417 pb.texture_ids()[0])) |
416 .second; | 418 .second; |
417 DCHECK(inserted); | 419 DCHECK(inserted); |
418 | 420 |
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
877 | 879 |
878 void RTCVideoDecoder::TryResetVDAErrorCounter_Locked() { | 880 void RTCVideoDecoder::TryResetVDAErrorCounter_Locked() { |
879 lock_.AssertAcquired(); | 881 lock_.AssertAcquired(); |
880 | 882 |
881 if (vda_error_counter_ == 0) | 883 if (vda_error_counter_ == 0) |
882 return; | 884 return; |
883 vda_error_counter_ = 0; | 885 vda_error_counter_ = 0; |
884 } | 886 } |
885 | 887 |
886 } // namespace content | 888 } // namespace content |
OLD | NEW |