| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2014 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 #include "webrtc/media/engine/constants.h" | 24 #include "webrtc/media/engine/constants.h" |
| 25 #include "webrtc/media/engine/simulcast.h" | 25 #include "webrtc/media/engine/simulcast.h" |
| 26 #include "webrtc/media/engine/webrtcmediaengine.h" | 26 #include "webrtc/media/engine/webrtcmediaengine.h" |
| 27 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" | 27 #include "webrtc/media/engine/webrtcvideoencoderfactory.h" |
| 28 #include "webrtc/media/engine/webrtcvideoframe.h" | 28 #include "webrtc/media/engine/webrtcvideoframe.h" |
| 29 #include "webrtc/media/engine/webrtcvoiceengine.h" | 29 #include "webrtc/media/engine/webrtcvoiceengine.h" |
| 30 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" | 30 #include "webrtc/modules/video_coding/codecs/h264/include/h264.h" |
| 31 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h" | 31 #include "webrtc/modules/video_coding/codecs/vp8/simulcast_encoder_adapter.h" |
| 32 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" | 32 #include "webrtc/modules/video_coding/codecs/vp9/include/vp9.h" |
| 33 #include "webrtc/system_wrappers/include/field_trial.h" | 33 #include "webrtc/system_wrappers/include/field_trial.h" |
| 34 #include "webrtc/system_wrappers/include/metrics.h" |
| 34 #include "webrtc/video_decoder.h" | 35 #include "webrtc/video_decoder.h" |
| 35 #include "webrtc/video_encoder.h" | 36 #include "webrtc/video_encoder.h" |
| 36 | 37 |
| 37 namespace cricket { | 38 namespace cricket { |
| 38 namespace { | 39 namespace { |
| 39 | 40 |
| 40 // Wrap cricket::WebRtcVideoEncoderFactory as a webrtc::VideoEncoderFactory. | 41 // Wrap cricket::WebRtcVideoEncoderFactory as a webrtc::VideoEncoderFactory. |
| 41 class EncoderFactoryAdapter : public webrtc::VideoEncoderFactory { | 42 class EncoderFactoryAdapter : public webrtc::VideoEncoderFactory { |
| 42 public: | 43 public: |
| 43 // EncoderFactoryAdapter doesn't take ownership of |factory|, which is owned | 44 // EncoderFactoryAdapter doesn't take ownership of |factory|, which is owned |
| (...skipping 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions, | 1570 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions, |
| 1570 // TODO(deadbeef): Don't duplicate information between send_params, | 1571 // TODO(deadbeef): Don't duplicate information between send_params, |
| 1571 // rtp_extensions, options, etc. | 1572 // rtp_extensions, options, etc. |
| 1572 const VideoSendParameters& send_params) | 1573 const VideoSendParameters& send_params) |
| 1573 : worker_thread_(rtc::Thread::Current()), | 1574 : worker_thread_(rtc::Thread::Current()), |
| 1574 ssrcs_(sp.ssrcs), | 1575 ssrcs_(sp.ssrcs), |
| 1575 ssrc_groups_(sp.ssrc_groups), | 1576 ssrc_groups_(sp.ssrc_groups), |
| 1576 call_(call), | 1577 call_(call), |
| 1577 cpu_restricted_counter_(0), | 1578 cpu_restricted_counter_(0), |
| 1578 number_of_cpu_adapt_changes_(0), | 1579 number_of_cpu_adapt_changes_(0), |
| 1580 frame_count_(0), |
| 1581 cpu_restricted_frame_count_(0), |
| 1579 source_(nullptr), | 1582 source_(nullptr), |
| 1580 external_encoder_factory_(external_encoder_factory), | 1583 external_encoder_factory_(external_encoder_factory), |
| 1581 stream_(nullptr), | 1584 stream_(nullptr), |
| 1582 parameters_(config, options, max_bitrate_bps, codec_settings), | 1585 parameters_(config, options, max_bitrate_bps, codec_settings), |
| 1583 rtp_parameters_(CreateRtpParametersWithOneEncoding()), | 1586 rtp_parameters_(CreateRtpParametersWithOneEncoding()), |
| 1584 pending_encoder_reconfiguration_(false), | 1587 pending_encoder_reconfiguration_(false), |
| 1585 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), | 1588 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), |
| 1586 sending_(false), | 1589 sending_(false), |
| 1587 last_frame_timestamp_ms_(0) { | 1590 last_frame_timestamp_ms_(0) { |
| 1588 parameters_.config.rtp.max_packet_size = kVideoMtu; | 1591 parameters_.config.rtp.max_packet_size = kVideoMtu; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 1614 SetCodec(*codec_settings); | 1617 SetCodec(*codec_settings); |
| 1615 } | 1618 } |
| 1616 } | 1619 } |
| 1617 | 1620 |
| 1618 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { | 1621 WebRtcVideoChannel2::WebRtcVideoSendStream::~WebRtcVideoSendStream() { |
| 1619 DisconnectSource(); | 1622 DisconnectSource(); |
| 1620 if (stream_ != NULL) { | 1623 if (stream_ != NULL) { |
| 1621 call_->DestroyVideoSendStream(stream_); | 1624 call_->DestroyVideoSendStream(stream_); |
| 1622 } | 1625 } |
| 1623 DestroyVideoEncoder(&allocated_encoder_); | 1626 DestroyVideoEncoder(&allocated_encoder_); |
| 1627 UpdateHistograms(); |
| 1628 } |
| 1629 |
| 1630 void WebRtcVideoChannel2::WebRtcVideoSendStream::UpdateHistograms() const { |
| 1631 const int kMinRequiredFrames = 200; |
| 1632 if (frame_count_ > kMinRequiredFrames) { |
| 1633 RTC_LOGGED_HISTOGRAM_PERCENTAGE( |
| 1634 "WebRTC.Video.CpuLimitedResolutionInPercent", |
| 1635 cpu_restricted_frame_count_ * 100 / frame_count_); |
| 1636 } |
| 1624 } | 1637 } |
| 1625 | 1638 |
| 1626 void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame( | 1639 void WebRtcVideoChannel2::WebRtcVideoSendStream::OnFrame( |
| 1627 const VideoFrame& frame) { | 1640 const VideoFrame& frame) { |
| 1628 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame"); | 1641 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::OnFrame"); |
| 1629 webrtc::VideoFrame video_frame(frame.video_frame_buffer(), 0, 0, | 1642 webrtc::VideoFrame video_frame(frame.video_frame_buffer(), 0, 0, |
| 1630 frame.rotation()); | 1643 frame.rotation()); |
| 1631 rtc::CritScope cs(&lock_); | 1644 rtc::CritScope cs(&lock_); |
| 1632 | 1645 |
| 1633 if (video_frame.width() != last_frame_info_.width || | 1646 if (video_frame.width() != last_frame_info_.width || |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1668 pending_encoder_reconfiguration_ = false; | 1681 pending_encoder_reconfiguration_ = false; |
| 1669 } | 1682 } |
| 1670 | 1683 |
| 1671 // Not sending, abort after reconfiguration. Reconfiguration should still | 1684 // Not sending, abort after reconfiguration. Reconfiguration should still |
| 1672 // occur to permit sending this input as quickly as possible once we start | 1685 // occur to permit sending this input as quickly as possible once we start |
| 1673 // sending (without having to reconfigure then). | 1686 // sending (without having to reconfigure then). |
| 1674 if (!sending_) { | 1687 if (!sending_) { |
| 1675 return; | 1688 return; |
| 1676 } | 1689 } |
| 1677 | 1690 |
| 1691 ++frame_count_; |
| 1692 if (cpu_restricted_counter_ > 0) |
| 1693 ++cpu_restricted_frame_count_; |
| 1694 |
| 1678 stream_->Input()->IncomingCapturedFrame(video_frame); | 1695 stream_->Input()->IncomingCapturedFrame(video_frame); |
| 1679 } | 1696 } |
| 1680 | 1697 |
| 1681 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoSend( | 1698 bool WebRtcVideoChannel2::WebRtcVideoSendStream::SetVideoSend( |
| 1682 bool enable, | 1699 bool enable, |
| 1683 const VideoOptions* options, | 1700 const VideoOptions* options, |
| 1684 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { | 1701 rtc::VideoSourceInterface<cricket::VideoFrame>* source) { |
| 1685 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetVideoSend"); | 1702 TRACE_EVENT0("webrtc", "WebRtcVideoSendStream::SetVideoSend"); |
| 1686 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 1703 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 1687 | 1704 |
| (...skipping 1008 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2696 rtx_mapping[video_codecs[i].codec.id] != | 2713 rtx_mapping[video_codecs[i].codec.id] != |
| 2697 fec_settings.red_payload_type) { | 2714 fec_settings.red_payload_type) { |
| 2698 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2715 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
| 2699 } | 2716 } |
| 2700 } | 2717 } |
| 2701 | 2718 |
| 2702 return video_codecs; | 2719 return video_codecs; |
| 2703 } | 2720 } |
| 2704 | 2721 |
| 2705 } // namespace cricket | 2722 } // namespace cricket |
| OLD | NEW |