| 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_encoder.h" | 5 #include "content/renderer/media/rtc_video_encoder.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_vector.h" | 10 #include "base/memory/scoped_vector.h" |
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 505 | 505 |
| 506 RTCVideoEncoder::RTCVideoEncoder( | 506 RTCVideoEncoder::RTCVideoEncoder( |
| 507 webrtc::VideoCodecType type, | 507 webrtc::VideoCodecType type, |
| 508 media::VideoCodecProfile profile, | 508 media::VideoCodecProfile profile, |
| 509 const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories) | 509 const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories) |
| 510 : video_codec_type_(type), | 510 : video_codec_type_(type), |
| 511 video_codec_profile_(profile), | 511 video_codec_profile_(profile), |
| 512 gpu_factories_(gpu_factories), | 512 gpu_factories_(gpu_factories), |
| 513 encoded_image_callback_(NULL), | 513 encoded_image_callback_(NULL), |
| 514 impl_status_(WEBRTC_VIDEO_CODEC_UNINITIALIZED), | 514 impl_status_(WEBRTC_VIDEO_CODEC_UNINITIALIZED), |
| 515 weak_this_factory_(this) { | 515 weak_factory_(this) { |
| 516 DVLOG(1) << "RTCVideoEncoder(): profile=" << profile; | 516 DVLOG(1) << "RTCVideoEncoder(): profile=" << profile; |
| 517 } | 517 } |
| 518 | 518 |
| 519 RTCVideoEncoder::~RTCVideoEncoder() { | 519 RTCVideoEncoder::~RTCVideoEncoder() { |
| 520 DCHECK(thread_checker_.CalledOnValidThread()); | 520 DCHECK(thread_checker_.CalledOnValidThread()); |
| 521 Release(); | 521 Release(); |
| 522 DCHECK(!impl_); | 522 DCHECK(!impl_); |
| 523 } | 523 } |
| 524 | 524 |
| 525 int32_t RTCVideoEncoder::InitEncode(const webrtc::VideoCodec* codec_settings, | 525 int32_t RTCVideoEncoder::InitEncode(const webrtc::VideoCodec* codec_settings, |
| 526 int32_t number_of_cores, | 526 int32_t number_of_cores, |
| 527 uint32_t max_payload_size) { | 527 uint32_t max_payload_size) { |
| 528 DVLOG(1) << "InitEncode(): codecType=" << codec_settings->codecType | 528 DVLOG(1) << "InitEncode(): codecType=" << codec_settings->codecType |
| 529 << ", width=" << codec_settings->width | 529 << ", width=" << codec_settings->width |
| 530 << ", height=" << codec_settings->height | 530 << ", height=" << codec_settings->height |
| 531 << ", startBitrate=" << codec_settings->startBitrate; | 531 << ", startBitrate=" << codec_settings->startBitrate; |
| 532 DCHECK(thread_checker_.CalledOnValidThread()); | 532 DCHECK(thread_checker_.CalledOnValidThread()); |
| 533 DCHECK(!impl_); | 533 DCHECK(!impl_); |
| 534 | 534 |
| 535 weak_this_factory_.InvalidateWeakPtrs(); | 535 weak_factory_.InvalidateWeakPtrs(); |
| 536 impl_ = new Impl(weak_this_factory_.GetWeakPtr(), gpu_factories_); | 536 impl_ = new Impl(weak_factory_.GetWeakPtr(), gpu_factories_); |
| 537 base::WaitableEvent initialization_waiter(true, false); | 537 base::WaitableEvent initialization_waiter(true, false); |
| 538 int32_t initialization_retval = WEBRTC_VIDEO_CODEC_UNINITIALIZED; | 538 int32_t initialization_retval = WEBRTC_VIDEO_CODEC_UNINITIALIZED; |
| 539 gpu_factories_->GetTaskRunner()->PostTask( | 539 gpu_factories_->GetTaskRunner()->PostTask( |
| 540 FROM_HERE, | 540 FROM_HERE, |
| 541 base::Bind(&RTCVideoEncoder::Impl::CreateAndInitializeVEA, | 541 base::Bind(&RTCVideoEncoder::Impl::CreateAndInitializeVEA, |
| 542 impl_, | 542 impl_, |
| 543 gfx::Size(codec_settings->width, codec_settings->height), | 543 gfx::Size(codec_settings->width, codec_settings->height), |
| 544 codec_settings->startBitrate, | 544 codec_settings->startBitrate, |
| 545 video_codec_profile_, | 545 video_codec_profile_, |
| 546 &initialization_waiter, | 546 &initialization_waiter, |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 595 } | 595 } |
| 596 | 596 |
| 597 int32_t RTCVideoEncoder::Release() { | 597 int32_t RTCVideoEncoder::Release() { |
| 598 DVLOG(3) << "Release()"; | 598 DVLOG(3) << "Release()"; |
| 599 DCHECK(thread_checker_.CalledOnValidThread()); | 599 DCHECK(thread_checker_.CalledOnValidThread()); |
| 600 | 600 |
| 601 if (impl_) { | 601 if (impl_) { |
| 602 gpu_factories_->GetTaskRunner()->PostTask( | 602 gpu_factories_->GetTaskRunner()->PostTask( |
| 603 FROM_HERE, base::Bind(&RTCVideoEncoder::Impl::Destroy, impl_)); | 603 FROM_HERE, base::Bind(&RTCVideoEncoder::Impl::Destroy, impl_)); |
| 604 impl_ = NULL; | 604 impl_ = NULL; |
| 605 weak_this_factory_.InvalidateWeakPtrs(); | 605 weak_factory_.InvalidateWeakPtrs(); |
| 606 impl_status_ = WEBRTC_VIDEO_CODEC_UNINITIALIZED; | 606 impl_status_ = WEBRTC_VIDEO_CODEC_UNINITIALIZED; |
| 607 } | 607 } |
| 608 return WEBRTC_VIDEO_CODEC_OK; | 608 return WEBRTC_VIDEO_CODEC_OK; |
| 609 } | 609 } |
| 610 | 610 |
| 611 int32_t RTCVideoEncoder::SetChannelParameters(uint32_t packet_loss, int rtt) { | 611 int32_t RTCVideoEncoder::SetChannelParameters(uint32_t packet_loss, int rtt) { |
| 612 DVLOG(3) << "SetChannelParameters(): packet_loss=" << packet_loss | 612 DVLOG(3) << "SetChannelParameters(): packet_loss=" << packet_loss |
| 613 << ", rtt=" << rtt; | 613 << ", rtt=" << rtt; |
| 614 DCHECK(thread_checker_.CalledOnValidThread()); | 614 DCHECK(thread_checker_.CalledOnValidThread()); |
| 615 // Ignored. | 615 // Ignored. |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", | 690 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", |
| 691 init_retval == WEBRTC_VIDEO_CODEC_OK); | 691 init_retval == WEBRTC_VIDEO_CODEC_OK); |
| 692 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { | 692 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { |
| 693 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", | 693 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", |
| 694 video_codec_profile_, | 694 video_codec_profile_, |
| 695 media::VIDEO_CODEC_PROFILE_MAX + 1); | 695 media::VIDEO_CODEC_PROFILE_MAX + 1); |
| 696 } | 696 } |
| 697 } | 697 } |
| 698 | 698 |
| 699 } // namespace content | 699 } // namespace content |
| OLD | NEW |