Chromium Code Reviews| 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 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 335 // duration hasn't been implemented. | 335 // duration hasn't been implemented. |
| 336 static const int kNackHistoryMs = 1000; | 336 static const int kNackHistoryMs = 1000; |
| 337 | 337 |
| 338 static const int kDefaultQpMax = 56; | 338 static const int kDefaultQpMax = 56; |
| 339 | 339 |
| 340 static const int kDefaultRtcpReceiverReportSsrc = 1; | 340 static const int kDefaultRtcpReceiverReportSsrc = 1; |
| 341 | 341 |
| 342 // Down grade resolution at most 2 times for CPU reasons. | 342 // Down grade resolution at most 2 times for CPU reasons. |
| 343 static const int kMaxCpuDowngrades = 2; | 343 static const int kMaxCpuDowngrades = 2; |
| 344 | 344 |
| 345 // Minimum time interval for logging stats. | |
| 346 static const int64_t kStatsLogIntervalMs = 8000; | |
| 347 | |
| 345 // Adds |codec| to |list|, and also adds an RTX codec if |codec|'s name is | 348 // Adds |codec| to |list|, and also adds an RTX codec if |codec|'s name is |
| 346 // recognized. | 349 // recognized. |
| 347 // TODO(deadbeef): Should we add RTX codecs for external codecs whose names we | 350 // TODO(deadbeef): Should we add RTX codecs for external codecs whose names we |
| 348 // don't recognize? | 351 // don't recognize? |
| 349 void AddCodecAndMaybeRtxCodec(const VideoCodec& codec, | 352 void AddCodecAndMaybeRtxCodec(const VideoCodec& codec, |
| 350 std::vector<VideoCodec>* codecs) { | 353 std::vector<VideoCodec>* codecs) { |
| 351 codecs->push_back(codec); | 354 codecs->push_back(codec); |
| 352 int rtx_payload_type = 0; | 355 int rtx_payload_type = 0; |
| 353 if (CodecNamesEq(codec.name, kVp8CodecName)) { | 356 if (CodecNamesEq(codec.name, kVp8CodecName)) { |
| 354 rtx_payload_type = kDefaultRtxVp8PlType; | 357 rtx_payload_type = kDefaultRtxVp8PlType; |
| (...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 669 const std::vector<VideoCodec>& recv_codecs, | 672 const std::vector<VideoCodec>& recv_codecs, |
| 670 WebRtcVideoEncoderFactory* external_encoder_factory, | 673 WebRtcVideoEncoderFactory* external_encoder_factory, |
| 671 WebRtcVideoDecoderFactory* external_decoder_factory) | 674 WebRtcVideoDecoderFactory* external_decoder_factory) |
| 672 : VideoMediaChannel(config), | 675 : VideoMediaChannel(config), |
| 673 call_(call), | 676 call_(call), |
| 674 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), | 677 unsignalled_ssrc_handler_(&default_unsignalled_ssrc_handler_), |
| 675 video_config_(config.video), | 678 video_config_(config.video), |
| 676 external_encoder_factory_(external_encoder_factory), | 679 external_encoder_factory_(external_encoder_factory), |
| 677 external_decoder_factory_(external_decoder_factory), | 680 external_decoder_factory_(external_decoder_factory), |
| 678 default_send_options_(options), | 681 default_send_options_(options), |
| 679 red_disabled_by_remote_side_(false) { | 682 red_disabled_by_remote_side_(false), |
| 683 last_stats_log_ms_(-1) { | |
| 680 RTC_DCHECK(thread_checker_.CalledOnValidThread()); | 684 RTC_DCHECK(thread_checker_.CalledOnValidThread()); |
| 681 | 685 |
| 682 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; | 686 rtcp_receiver_report_ssrc_ = kDefaultRtcpReceiverReportSsrc; |
| 683 sending_ = false; | 687 sending_ = false; |
| 684 RTC_DCHECK(ValidateCodecFormats(recv_codecs)); | 688 RTC_DCHECK(ValidateCodecFormats(recv_codecs)); |
| 685 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs)); | 689 recv_codecs_ = FilterSupportedCodecs(MapCodecs(recv_codecs)); |
| 686 } | 690 } |
| 687 | 691 |
| 688 WebRtcVideoChannel2::~WebRtcVideoChannel2() { | 692 WebRtcVideoChannel2::~WebRtcVideoChannel2() { |
| 689 for (auto& kv : send_streams_) | 693 for (auto& kv : send_streams_) |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1338 return false; | 1342 return false; |
| 1339 } | 1343 } |
| 1340 | 1344 |
| 1341 it->second->SetSink(sink); | 1345 it->second->SetSink(sink); |
| 1342 return true; | 1346 return true; |
| 1343 } | 1347 } |
| 1344 | 1348 |
| 1345 bool WebRtcVideoChannel2::GetStats(VideoMediaInfo* info) { | 1349 bool WebRtcVideoChannel2::GetStats(VideoMediaInfo* info) { |
| 1346 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::GetStats"); | 1350 TRACE_EVENT0("webrtc", "WebRtcVideoChannel2::GetStats"); |
| 1347 info->Clear(); | 1351 info->Clear(); |
| 1348 FillSenderStats(info); | 1352 FillSenderStats(info); |
|
mflodman
2016/08/04 13:37:09
We could keep track of time just here and add a "b
mflodman
2016/08/04 13:37:09
And related, should we just enable this as is or g
åsapersson
2016/08/04 14:54:18
Done.
| |
| 1349 FillReceiverStats(info); | 1353 FillReceiverStats(info); |
| 1350 webrtc::Call::Stats stats = call_->GetStats(); | 1354 webrtc::Call::Stats stats = call_->GetStats(); |
| 1351 FillBandwidthEstimationStats(stats, info); | 1355 FillBandwidthEstimationStats(stats, info); |
| 1352 if (stats.rtt_ms != -1) { | 1356 if (stats.rtt_ms != -1) { |
| 1353 for (size_t i = 0; i < info->senders.size(); ++i) { | 1357 for (size_t i = 0; i < info->senders.size(); ++i) { |
| 1354 info->senders[i].rtt_ms = stats.rtt_ms; | 1358 info->senders[i].rtt_ms = stats.rtt_ms; |
| 1355 } | 1359 } |
| 1356 } | 1360 } |
| 1361 // Log stats periodically. | |
| 1362 int64_t now_ms = rtc::TimeMillis(); | |
| 1363 if (last_stats_log_ms_ == -1 || | |
| 1364 now_ms - last_stats_log_ms_ > kStatsLogIntervalMs) { | |
| 1365 last_stats_log_ms_ = now_ms; | |
| 1366 LOG(LS_INFO) << stats.ToString(now_ms); | |
| 1367 } | |
| 1357 return true; | 1368 return true; |
| 1358 } | 1369 } |
| 1359 | 1370 |
| 1360 void WebRtcVideoChannel2::FillSenderStats(VideoMediaInfo* video_media_info) { | 1371 void WebRtcVideoChannel2::FillSenderStats(VideoMediaInfo* video_media_info) { |
| 1361 rtc::CritScope stream_lock(&stream_crit_); | 1372 rtc::CritScope stream_lock(&stream_crit_); |
| 1362 for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator it = | 1373 for (std::map<uint32_t, WebRtcVideoSendStream*>::iterator it = |
| 1363 send_streams_.begin(); | 1374 send_streams_.begin(); |
| 1364 it != send_streams_.end(); ++it) { | 1375 it != send_streams_.end(); ++it) { |
| 1365 video_media_info->senders.push_back(it->second->GetVideoSenderInfo()); | 1376 video_media_info->senders.push_back(it->second->GetVideoSenderInfo()); |
| 1366 } | 1377 } |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1547 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions, | 1558 const rtc::Optional<std::vector<webrtc::RtpExtension>>& rtp_extensions, |
| 1548 // TODO(deadbeef): Don't duplicate information between send_params, | 1559 // TODO(deadbeef): Don't duplicate information between send_params, |
| 1549 // rtp_extensions, options, etc. | 1560 // rtp_extensions, options, etc. |
| 1550 const VideoSendParameters& send_params) | 1561 const VideoSendParameters& send_params) |
| 1551 : worker_thread_(rtc::Thread::Current()), | 1562 : worker_thread_(rtc::Thread::Current()), |
| 1552 ssrcs_(sp.ssrcs), | 1563 ssrcs_(sp.ssrcs), |
| 1553 ssrc_groups_(sp.ssrc_groups), | 1564 ssrc_groups_(sp.ssrc_groups), |
| 1554 call_(call), | 1565 call_(call), |
| 1555 cpu_restricted_counter_(0), | 1566 cpu_restricted_counter_(0), |
| 1556 number_of_cpu_adapt_changes_(0), | 1567 number_of_cpu_adapt_changes_(0), |
| 1568 last_stats_log_ms_(-1), | |
| 1557 source_(nullptr), | 1569 source_(nullptr), |
| 1558 external_encoder_factory_(external_encoder_factory), | 1570 external_encoder_factory_(external_encoder_factory), |
| 1559 stream_(nullptr), | 1571 stream_(nullptr), |
| 1560 parameters_(config, options, max_bitrate_bps, codec_settings), | 1572 parameters_(config, options, max_bitrate_bps, codec_settings), |
| 1561 rtp_parameters_(CreateRtpParametersWithOneEncoding()), | 1573 rtp_parameters_(CreateRtpParametersWithOneEncoding()), |
| 1562 pending_encoder_reconfiguration_(false), | 1574 pending_encoder_reconfiguration_(false), |
| 1563 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), | 1575 allocated_encoder_(nullptr, webrtc::kVideoCodecUnknown, false), |
| 1564 sending_(false), | 1576 sending_(false), |
| 1565 last_frame_timestamp_ms_(0) { | 1577 last_frame_timestamp_ms_(0) { |
| 1566 parameters_.config.rtp.max_packet_size = kVideoMtu; | 1578 parameters_.config.rtp.max_packet_size = kVideoMtu; |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2116 info.preferred_bitrate += | 2128 info.preferred_bitrate += |
| 2117 parameters_.encoder_config.streams[i].target_bitrate_bps; | 2129 parameters_.encoder_config.streams[i].target_bitrate_bps; |
| 2118 } | 2130 } |
| 2119 } | 2131 } |
| 2120 | 2132 |
| 2121 if (stream_ == NULL) | 2133 if (stream_ == NULL) |
| 2122 return info; | 2134 return info; |
| 2123 | 2135 |
| 2124 stats = stream_->GetStats(); | 2136 stats = stream_->GetStats(); |
| 2125 } | 2137 } |
| 2138 | |
| 2139 // Log stats periodically. | |
| 2140 int64_t now_ms = rtc::TimeMillis(); | |
| 2141 if (last_stats_log_ms_ == -1 || | |
| 2142 now_ms - last_stats_log_ms_ > kStatsLogIntervalMs) { | |
| 2143 last_stats_log_ms_ = now_ms; | |
| 2144 LOG(LS_INFO) << stats.ToString(now_ms); | |
| 2145 } | |
| 2146 | |
| 2126 info.adapt_changes = number_of_cpu_adapt_changes_; | 2147 info.adapt_changes = number_of_cpu_adapt_changes_; |
| 2127 info.adapt_reason = | 2148 info.adapt_reason = |
| 2128 cpu_restricted_counter_ <= 0 ? ADAPTREASON_NONE : ADAPTREASON_CPU; | 2149 cpu_restricted_counter_ <= 0 ? ADAPTREASON_NONE : ADAPTREASON_CPU; |
| 2129 | 2150 |
| 2130 // Get bandwidth limitation info from stream_->GetStats(). | 2151 // Get bandwidth limitation info from stream_->GetStats(). |
| 2131 // Input resolution (output from video_adapter) can be further scaled down or | 2152 // Input resolution (output from video_adapter) can be further scaled down or |
| 2132 // higher video layer(s) can be dropped due to bitrate constraints. | 2153 // higher video layer(s) can be dropped due to bitrate constraints. |
| 2133 // Note, adapt_changes only include changes from the video_adapter. | 2154 // Note, adapt_changes only include changes from the video_adapter. |
| 2134 if (stats.bw_limited_resolution) | 2155 if (stats.bw_limited_resolution) |
| 2135 info.adapt_reason |= ADAPTREASON_BANDWIDTH; | 2156 info.adapt_reason |= ADAPTREASON_BANDWIDTH; |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2230 bool default_stream, | 2251 bool default_stream, |
| 2231 const std::vector<VideoCodecSettings>& recv_codecs, | 2252 const std::vector<VideoCodecSettings>& recv_codecs, |
| 2232 bool red_disabled_by_remote_side) | 2253 bool red_disabled_by_remote_side) |
| 2233 : call_(call), | 2254 : call_(call), |
| 2234 stream_params_(sp), | 2255 stream_params_(sp), |
| 2235 stream_(NULL), | 2256 stream_(NULL), |
| 2236 default_stream_(default_stream), | 2257 default_stream_(default_stream), |
| 2237 config_(std::move(config)), | 2258 config_(std::move(config)), |
| 2238 red_disabled_by_remote_side_(red_disabled_by_remote_side), | 2259 red_disabled_by_remote_side_(red_disabled_by_remote_side), |
| 2239 external_decoder_factory_(external_decoder_factory), | 2260 external_decoder_factory_(external_decoder_factory), |
| 2261 last_stats_log_ms_(-1), | |
| 2240 sink_(NULL), | 2262 sink_(NULL), |
| 2241 last_width_(-1), | 2263 last_width_(-1), |
| 2242 last_height_(-1), | 2264 last_height_(-1), |
| 2243 first_frame_timestamp_(-1), | 2265 first_frame_timestamp_(-1), |
| 2244 estimated_remote_start_ntp_time_ms_(0) { | 2266 estimated_remote_start_ntp_time_ms_(0) { |
| 2245 config_.renderer = this; | 2267 config_.renderer = this; |
| 2246 std::vector<AllocatedDecoder> old_decoders; | 2268 std::vector<AllocatedDecoder> old_decoders; |
| 2247 ConfigureCodecs(recv_codecs, &old_decoders); | 2269 ConfigureCodecs(recv_codecs, &old_decoders); |
| 2248 RecreateWebRtcStream(); | 2270 RecreateWebRtcStream(); |
| 2249 RTC_DCHECK(old_decoders.empty()); | 2271 RTC_DCHECK(old_decoders.empty()); |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2529 info.jitter_buffer_ms = stats.jitter_buffer_ms; | 2551 info.jitter_buffer_ms = stats.jitter_buffer_ms; |
| 2530 info.min_playout_delay_ms = stats.min_playout_delay_ms; | 2552 info.min_playout_delay_ms = stats.min_playout_delay_ms; |
| 2531 info.render_delay_ms = stats.render_delay_ms; | 2553 info.render_delay_ms = stats.render_delay_ms; |
| 2532 | 2554 |
| 2533 info.codec_name = GetCodecNameFromPayloadType(stats.current_payload_type); | 2555 info.codec_name = GetCodecNameFromPayloadType(stats.current_payload_type); |
| 2534 | 2556 |
| 2535 info.firs_sent = stats.rtcp_packet_type_counts.fir_packets; | 2557 info.firs_sent = stats.rtcp_packet_type_counts.fir_packets; |
| 2536 info.plis_sent = stats.rtcp_packet_type_counts.pli_packets; | 2558 info.plis_sent = stats.rtcp_packet_type_counts.pli_packets; |
| 2537 info.nacks_sent = stats.rtcp_packet_type_counts.nack_packets; | 2559 info.nacks_sent = stats.rtcp_packet_type_counts.nack_packets; |
| 2538 | 2560 |
| 2561 // Log stats periodically. | |
| 2562 int64_t now_ms = rtc::TimeMillis(); | |
| 2563 if (last_stats_log_ms_ == -1 || | |
| 2564 now_ms - last_stats_log_ms_ > kStatsLogIntervalMs) { | |
| 2565 last_stats_log_ms_ = now_ms; | |
| 2566 LOG(LS_INFO) << stats.ToString(now_ms); | |
| 2567 } | |
| 2568 | |
| 2539 return info; | 2569 return info; |
| 2540 } | 2570 } |
| 2541 | 2571 |
| 2542 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetFecDisabledRemotely( | 2572 void WebRtcVideoChannel2::WebRtcVideoReceiveStream::SetFecDisabledRemotely( |
| 2543 bool disable) { | 2573 bool disable) { |
| 2544 red_disabled_by_remote_side_ = disable; | 2574 red_disabled_by_remote_side_ = disable; |
| 2545 RecreateWebRtcStream(); | 2575 RecreateWebRtcStream(); |
| 2546 } | 2576 } |
| 2547 | 2577 |
| 2548 WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings() | 2578 WebRtcVideoChannel2::VideoCodecSettings::VideoCodecSettings() |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2651 rtx_mapping[video_codecs[i].codec.id] != | 2681 rtx_mapping[video_codecs[i].codec.id] != |
| 2652 fec_settings.red_payload_type) { | 2682 fec_settings.red_payload_type) { |
| 2653 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; | 2683 video_codecs[i].rtx_payload_type = rtx_mapping[video_codecs[i].codec.id]; |
| 2654 } | 2684 } |
| 2655 } | 2685 } |
| 2656 | 2686 |
| 2657 return video_codecs; | 2687 return video_codecs; |
| 2658 } | 2688 } |
| 2659 | 2689 |
| 2660 } // namespace cricket | 2690 } // namespace cricket |
| OLD | NEW |