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 503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
514 : video_codec_type_(type), | 514 : video_codec_type_(type), |
515 video_codec_profile_(profile), | 515 video_codec_profile_(profile), |
516 gpu_factories_(gpu_factories), | 516 gpu_factories_(gpu_factories), |
517 encoded_image_callback_(NULL), | 517 encoded_image_callback_(NULL), |
518 impl_status_(WEBRTC_VIDEO_CODEC_UNINITIALIZED), | 518 impl_status_(WEBRTC_VIDEO_CODEC_UNINITIALIZED), |
519 weak_factory_(this) { | 519 weak_factory_(this) { |
520 DVLOG(1) << "RTCVideoEncoder(): profile=" << profile; | 520 DVLOG(1) << "RTCVideoEncoder(): profile=" << profile; |
521 } | 521 } |
522 | 522 |
523 RTCVideoEncoder::~RTCVideoEncoder() { | 523 RTCVideoEncoder::~RTCVideoEncoder() { |
| 524 DVLOG(3) << "~RTCVideoEncoder"; |
524 DCHECK(thread_checker_.CalledOnValidThread()); | 525 DCHECK(thread_checker_.CalledOnValidThread()); |
525 Release(); | 526 Release(); |
526 DCHECK(!impl_); | 527 DCHECK(!impl_); |
527 } | 528 } |
528 | 529 |
529 int32_t RTCVideoEncoder::InitEncode(const webrtc::VideoCodec* codec_settings, | 530 int32_t RTCVideoEncoder::InitEncode(const webrtc::VideoCodec* codec_settings, |
530 int32_t number_of_cores, | 531 int32_t number_of_cores, |
531 uint32_t max_payload_size) { | 532 uint32_t max_payload_size) { |
532 DVLOG(1) << "InitEncode(): codecType=" << codec_settings->codecType | 533 DVLOG(1) << "InitEncode(): codecType=" << codec_settings->codecType |
533 << ", width=" << codec_settings->width | 534 << ", width=" << codec_settings->width |
(...skipping 20 matching lines...) Expand all Loading... |
554 initialization_waiter.Wait(); | 555 initialization_waiter.Wait(); |
555 RecordInitEncodeUMA(initialization_retval); | 556 RecordInitEncodeUMA(initialization_retval); |
556 return initialization_retval; | 557 return initialization_retval; |
557 } | 558 } |
558 | 559 |
559 int32_t RTCVideoEncoder::Encode( | 560 int32_t RTCVideoEncoder::Encode( |
560 const webrtc::I420VideoFrame& input_image, | 561 const webrtc::I420VideoFrame& input_image, |
561 const webrtc::CodecSpecificInfo* codec_specific_info, | 562 const webrtc::CodecSpecificInfo* codec_specific_info, |
562 const std::vector<webrtc::VideoFrameType>* frame_types) { | 563 const std::vector<webrtc::VideoFrameType>* frame_types) { |
563 DVLOG(3) << "Encode()"; | 564 DVLOG(3) << "Encode()"; |
564 // TODO(sheu): figure out why this check fails. | |
565 // DCHECK(thread_checker_.CalledOnValidThread()); | |
566 if (!impl_) { | 565 if (!impl_) { |
567 DVLOG(3) << "Encode(): returning impl_status_=" << impl_status_; | 566 DVLOG(3) << "Encode(): returning impl_status_=" << impl_status_; |
568 return impl_status_; | 567 return impl_status_; |
569 } | 568 } |
570 | 569 |
571 bool want_key_frame = frame_types && frame_types->size() && | 570 bool want_key_frame = frame_types && frame_types->size() && |
572 frame_types->front() == webrtc::kKeyFrame; | 571 frame_types->front() == webrtc::kKeyFrame; |
573 base::WaitableEvent encode_waiter(true, false); | 572 base::WaitableEvent encode_waiter(true, false); |
574 int32_t encode_retval = WEBRTC_VIDEO_CODEC_UNINITIALIZED; | 573 int32_t encode_retval = WEBRTC_VIDEO_CODEC_UNINITIALIZED; |
575 gpu_factories_->GetTaskRunner()->PostTask( | 574 gpu_factories_->GetTaskRunner()->PostTask( |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
610 impl_ = NULL; | 609 impl_ = NULL; |
611 weak_factory_.InvalidateWeakPtrs(); | 610 weak_factory_.InvalidateWeakPtrs(); |
612 impl_status_ = WEBRTC_VIDEO_CODEC_UNINITIALIZED; | 611 impl_status_ = WEBRTC_VIDEO_CODEC_UNINITIALIZED; |
613 } | 612 } |
614 return WEBRTC_VIDEO_CODEC_OK; | 613 return WEBRTC_VIDEO_CODEC_OK; |
615 } | 614 } |
616 | 615 |
617 int32_t RTCVideoEncoder::SetChannelParameters(uint32_t packet_loss, int rtt) { | 616 int32_t RTCVideoEncoder::SetChannelParameters(uint32_t packet_loss, int rtt) { |
618 DVLOG(3) << "SetChannelParameters(): packet_loss=" << packet_loss | 617 DVLOG(3) << "SetChannelParameters(): packet_loss=" << packet_loss |
619 << ", rtt=" << rtt; | 618 << ", rtt=" << rtt; |
620 DCHECK(thread_checker_.CalledOnValidThread()); | |
621 // Ignored. | 619 // Ignored. |
622 return WEBRTC_VIDEO_CODEC_OK; | 620 return WEBRTC_VIDEO_CODEC_OK; |
623 } | 621 } |
624 | 622 |
625 int32_t RTCVideoEncoder::SetRates(uint32_t new_bit_rate, uint32_t frame_rate) { | 623 int32_t RTCVideoEncoder::SetRates(uint32_t new_bit_rate, uint32_t frame_rate) { |
626 DVLOG(3) << "SetRates(): new_bit_rate=" << new_bit_rate | 624 DVLOG(3) << "SetRates(): new_bit_rate=" << new_bit_rate |
627 << ", frame_rate=" << frame_rate; | 625 << ", frame_rate=" << frame_rate; |
628 DCHECK(thread_checker_.CalledOnValidThread()); | |
629 if (!impl_) { | 626 if (!impl_) { |
630 DVLOG(3) << "SetRates(): returning " << impl_status_; | 627 DVLOG(3) << "SetRates(): returning " << impl_status_; |
631 return impl_status_; | 628 return impl_status_; |
632 } | 629 } |
633 | 630 |
634 gpu_factories_->GetTaskRunner()->PostTask( | 631 gpu_factories_->GetTaskRunner()->PostTask( |
635 FROM_HERE, | 632 FROM_HERE, |
636 base::Bind(&RTCVideoEncoder::Impl::RequestEncodingParametersChange, | 633 base::Bind(&RTCVideoEncoder::Impl::RequestEncodingParametersChange, |
637 impl_, | 634 impl_, |
638 new_bit_rate, | 635 new_bit_rate, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
698 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", | 695 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", |
699 init_retval == WEBRTC_VIDEO_CODEC_OK); | 696 init_retval == WEBRTC_VIDEO_CODEC_OK); |
700 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { | 697 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { |
701 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", | 698 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", |
702 video_codec_profile_, | 699 video_codec_profile_, |
703 media::VIDEO_CODEC_PROFILE_MAX + 1); | 700 media::VIDEO_CODEC_PROFILE_MAX + 1); |
704 } | 701 } |
705 } | 702 } |
706 | 703 |
707 } // namespace content | 704 } // namespace content |
OLD | NEW |