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_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" |
| 11 #include "base/message_loop/message_loop_proxy.h" | 11 #include "base/message_loop/message_loop_proxy.h" |
| 12 #include "base/metrics/histogram.h" | 12 #include "base/metrics/histogram.h" |
| 13 #include "base/rand_util.h" | 13 #include "base/rand_util.h" |
| 14 #include "base/synchronization/waitable_event.h" | 14 #include "base/synchronization/waitable_event.h" |
| 15 #include "content/renderer/media/rtc_video_encoder_factory.h" | |
| 15 #include "media/base/bitstream_buffer.h" | 16 #include "media/base/bitstream_buffer.h" |
| 16 #include "media/base/video_frame.h" | 17 #include "media/base/video_frame.h" |
| 17 #include "media/base/video_util.h" | 18 #include "media/base/video_util.h" |
| 18 #include "media/filters/gpu_video_accelerator_factories.h" | 19 #include "media/filters/gpu_video_accelerator_factories.h" |
| 19 #include "media/filters/h264_parser.h" | 20 #include "media/filters/h264_parser.h" |
| 20 #include "media/video/video_encode_accelerator.h" | 21 #include "media/video/video_encode_accelerator.h" |
| 21 #include "third_party/webrtc/system_wrappers/interface/tick_util.h" | 22 #include "third_party/webrtc/system_wrappers/interface/tick_util.h" |
| 22 | 23 |
| 23 #define NOTIFY_ERROR(x) \ | 24 #define NOTIFY_ERROR(x) \ |
| 24 do { \ | 25 do { \ |
| (...skipping 514 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 539 #undef NOTIFY_ERROR | 540 #undef NOTIFY_ERROR |
| 540 | 541 |
| 541 //////////////////////////////////////////////////////////////////////////////// | 542 //////////////////////////////////////////////////////////////////////////////// |
| 542 // | 543 // |
| 543 // RTCVideoEncoder | 544 // RTCVideoEncoder |
| 544 // | 545 // |
| 545 //////////////////////////////////////////////////////////////////////////////// | 546 //////////////////////////////////////////////////////////////////////////////// |
| 546 | 547 |
| 547 RTCVideoEncoder::RTCVideoEncoder( | 548 RTCVideoEncoder::RTCVideoEncoder( |
| 548 webrtc::VideoCodecType type, | 549 webrtc::VideoCodecType type, |
| 549 media::VideoCodecProfile profile, | |
| 550 const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories) | 550 const scoped_refptr<media::GpuVideoAcceleratorFactories>& gpu_factories) |
| 551 : video_codec_type_(type), | 551 : video_codec_type_(type), |
| 552 video_codec_profile_(profile), | |
| 553 gpu_factories_(gpu_factories), | 552 gpu_factories_(gpu_factories), |
| 554 encoded_image_callback_(NULL), | 553 encoded_image_callback_(NULL), |
| 555 impl_status_(WEBRTC_VIDEO_CODEC_UNINITIALIZED), | 554 impl_status_(WEBRTC_VIDEO_CODEC_UNINITIALIZED), |
| 556 weak_factory_(this) { | 555 weak_factory_(this) { |
| 557 DVLOG(1) << "RTCVideoEncoder(): profile=" << profile; | 556 DVLOG(1) << "RTCVideoEncoder(): type=" << type; |
|
Pawel Osciak
2014/10/25 01:23:04
s/type/codec type/
hshi1
2014/10/25 01:36:51
Done.
| |
| 558 } | 557 } |
| 559 | 558 |
| 560 RTCVideoEncoder::~RTCVideoEncoder() { | 559 RTCVideoEncoder::~RTCVideoEncoder() { |
| 561 DVLOG(3) << "~RTCVideoEncoder"; | 560 DVLOG(3) << "~RTCVideoEncoder"; |
| 562 DCHECK(thread_checker_.CalledOnValidThread()); | 561 DCHECK(thread_checker_.CalledOnValidThread()); |
| 563 Release(); | 562 Release(); |
| 564 DCHECK(!impl_.get()); | 563 DCHECK(!impl_.get()); |
| 565 } | 564 } |
| 566 | 565 |
| 567 int32_t RTCVideoEncoder::InitEncode(const webrtc::VideoCodec* codec_settings, | 566 int32_t RTCVideoEncoder::InitEncode(const webrtc::VideoCodec* codec_settings, |
| 568 int32_t number_of_cores, | 567 int32_t number_of_cores, |
| 569 uint32_t max_payload_size) { | 568 uint32_t max_payload_size) { |
| 570 DVLOG(1) << "InitEncode(): codecType=" << codec_settings->codecType | 569 DVLOG(1) << "InitEncode(): codecType=" << codec_settings->codecType |
| 571 << ", width=" << codec_settings->width | 570 << ", width=" << codec_settings->width |
| 572 << ", height=" << codec_settings->height | 571 << ", height=" << codec_settings->height |
| 573 << ", startBitrate=" << codec_settings->startBitrate; | 572 << ", startBitrate=" << codec_settings->startBitrate; |
| 574 DCHECK(thread_checker_.CalledOnValidThread()); | 573 DCHECK(thread_checker_.CalledOnValidThread()); |
| 575 DCHECK(!impl_.get()); | 574 DCHECK(!impl_.get()); |
| 576 | 575 |
| 576 video_codec_profile_ = RTCVideoEncoderFactory::GetCodecProfile( | |
|
Pawel Osciak
2014/10/25 01:23:04
video_codec_profile_ could just be a local variabl
hshi1
2014/10/25 01:36:51
Done.
| |
| 577 video_codec_type_, codec_settings); | |
| 578 | |
| 577 weak_factory_.InvalidateWeakPtrs(); | 579 weak_factory_.InvalidateWeakPtrs(); |
| 578 impl_ = new Impl(weak_factory_.GetWeakPtr(), gpu_factories_); | 580 impl_ = new Impl(weak_factory_.GetWeakPtr(), gpu_factories_); |
| 579 base::WaitableEvent initialization_waiter(true, false); | 581 base::WaitableEvent initialization_waiter(true, false); |
| 580 int32_t initialization_retval = WEBRTC_VIDEO_CODEC_UNINITIALIZED; | 582 int32_t initialization_retval = WEBRTC_VIDEO_CODEC_UNINITIALIZED; |
| 581 gpu_factories_->GetTaskRunner()->PostTask( | 583 gpu_factories_->GetTaskRunner()->PostTask( |
| 582 FROM_HERE, | 584 FROM_HERE, |
| 583 base::Bind(&RTCVideoEncoder::Impl::CreateAndInitializeVEA, | 585 base::Bind(&RTCVideoEncoder::Impl::CreateAndInitializeVEA, |
| 584 impl_, | 586 impl_, |
| 585 gfx::Size(codec_settings->width, codec_settings->height), | 587 gfx::Size(codec_settings->width, codec_settings->height), |
| 586 codec_settings->startBitrate, | 588 codec_settings->startBitrate, |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 749 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", | 751 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", |
| 750 init_retval == WEBRTC_VIDEO_CODEC_OK); | 752 init_retval == WEBRTC_VIDEO_CODEC_OK); |
| 751 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { | 753 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { |
| 752 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", | 754 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", |
| 753 video_codec_profile_, | 755 video_codec_profile_, |
| 754 media::VIDEO_CODEC_PROFILE_MAX + 1); | 756 media::VIDEO_CODEC_PROFILE_MAX + 1); |
| 755 } | 757 } |
| 756 } | 758 } |
| 757 | 759 |
| 758 } // namespace content | 760 } // namespace content |
| OLD | NEW |