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 414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 static_cast<uint32_t>(capture_time_us * 90 / 1000); | 425 static_cast<uint32_t>(capture_time_us * 90 / 1000); |
426 | 426 |
427 scoped_ptr<webrtc::EncodedImage> image(new webrtc::EncodedImage( | 427 scoped_ptr<webrtc::EncodedImage> image(new webrtc::EncodedImage( |
428 reinterpret_cast<uint8_t*>(output_buffer->memory()), | 428 reinterpret_cast<uint8_t*>(output_buffer->memory()), |
429 payload_size, | 429 payload_size, |
430 output_buffer->mapped_size())); | 430 output_buffer->mapped_size())); |
431 image->_encodedWidth = input_visible_size_.width(); | 431 image->_encodedWidth = input_visible_size_.width(); |
432 image->_encodedHeight = input_visible_size_.height(); | 432 image->_encodedHeight = input_visible_size_.height(); |
433 image->_timeStamp = rtp_timestamp; | 433 image->_timeStamp = rtp_timestamp; |
434 image->capture_time_ms_ = capture_time_ms; | 434 image->capture_time_ms_ = capture_time_ms; |
435 image->_frameType = (key_frame ? webrtc::kKeyFrame : webrtc::kDeltaFrame); | 435 image->_frameType = |
| 436 (key_frame ? webrtc::kVideoFrameKey : webrtc::kVideoFrameDelta); |
436 image->_completeFrame = true; | 437 image->_completeFrame = true; |
437 | 438 |
438 encoder_task_runner_->PostTask( | 439 encoder_task_runner_->PostTask( |
439 FROM_HERE, | 440 FROM_HERE, |
440 base::Bind(&RTCVideoEncoder::ReturnEncodedImage, weak_encoder_, | 441 base::Bind(&RTCVideoEncoder::ReturnEncodedImage, weak_encoder_, |
441 base::Passed(&image), bitstream_buffer_id, picture_id_)); | 442 base::Passed(&image), bitstream_buffer_id, picture_id_)); |
442 // Picture ID must wrap after reaching the maximum. | 443 // Picture ID must wrap after reaching the maximum. |
443 picture_id_ = (picture_id_ + 1) & 0x7FFF; | 444 picture_id_ = (picture_id_ + 1) & 0x7FFF; |
444 } | 445 } |
445 | 446 |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 | 617 |
617 // webrtc::VideoEncoder expects this call to be synchronous. | 618 // webrtc::VideoEncoder expects this call to be synchronous. |
618 initialization_waiter.Wait(); | 619 initialization_waiter.Wait(); |
619 RecordInitEncodeUMA(initialization_retval, profile); | 620 RecordInitEncodeUMA(initialization_retval, profile); |
620 return initialization_retval; | 621 return initialization_retval; |
621 } | 622 } |
622 | 623 |
623 int32_t RTCVideoEncoder::Encode( | 624 int32_t RTCVideoEncoder::Encode( |
624 const webrtc::VideoFrame& input_image, | 625 const webrtc::VideoFrame& input_image, |
625 const webrtc::CodecSpecificInfo* codec_specific_info, | 626 const webrtc::CodecSpecificInfo* codec_specific_info, |
626 const std::vector<webrtc::VideoFrameType>* frame_types) { | 627 const std::vector<webrtc::FrameType>* frame_types) { |
627 DVLOG(3) << "Encode()"; | 628 DVLOG(3) << "Encode()"; |
628 if (!impl_.get()) { | 629 if (!impl_.get()) { |
629 DVLOG(3) << "Encode(): returning impl_status_=" << impl_status_; | 630 DVLOG(3) << "Encode(): returning impl_status_=" << impl_status_; |
630 return impl_status_; | 631 return impl_status_; |
631 } | 632 } |
632 | 633 |
633 const bool want_key_frame = frame_types && frame_types->size() && | 634 const bool want_key_frame = frame_types && frame_types->size() && |
634 frame_types->front() == webrtc::kKeyFrame; | 635 frame_types->front() == webrtc::kVideoFrameKey; |
635 base::WaitableEvent encode_waiter(true, false); | 636 base::WaitableEvent encode_waiter(true, false); |
636 int32_t encode_retval = WEBRTC_VIDEO_CODEC_UNINITIALIZED; | 637 int32_t encode_retval = WEBRTC_VIDEO_CODEC_UNINITIALIZED; |
637 gpu_factories_->GetTaskRunner()->PostTask( | 638 gpu_factories_->GetTaskRunner()->PostTask( |
638 FROM_HERE, | 639 FROM_HERE, |
639 base::Bind(&RTCVideoEncoder::Impl::Enqueue, | 640 base::Bind(&RTCVideoEncoder::Impl::Enqueue, |
640 impl_, | 641 impl_, |
641 &input_image, | 642 &input_image, |
642 want_key_frame, | 643 want_key_frame, |
643 &encode_waiter, | 644 &encode_waiter, |
644 &encode_retval)); | 645 &encode_retval)); |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", | 776 UMA_HISTOGRAM_BOOLEAN("Media.RTCVideoEncoderInitEncodeSuccess", |
776 init_retval == WEBRTC_VIDEO_CODEC_OK); | 777 init_retval == WEBRTC_VIDEO_CODEC_OK); |
777 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { | 778 if (init_retval == WEBRTC_VIDEO_CODEC_OK) { |
778 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", | 779 UMA_HISTOGRAM_ENUMERATION("Media.RTCVideoEncoderProfile", |
779 profile, | 780 profile, |
780 media::VIDEO_CODEC_PROFILE_MAX + 1); | 781 media::VIDEO_CODEC_PROFILE_MAX + 1); |
781 } | 782 } |
782 } | 783 } |
783 | 784 |
784 } // namespace content | 785 } // namespace content |
OLD | NEW |