OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 |
11 #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h" | 11 #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h" |
12 | 12 |
13 #include <stdint.h> | 13 #include <stdint.h> |
14 #include <string.h> | 14 #include <string.h> |
15 | 15 |
16 #include <algorithm> | 16 #include <algorithm> |
17 #include <fstream> | 17 #include <fstream> |
18 #include <istream> | 18 #include <istream> |
| 19 #include <map> |
19 #include <utility> | 20 #include <utility> |
20 | 21 |
21 #include "webrtc/base/checks.h" | 22 #include "webrtc/base/checks.h" |
22 #include "webrtc/base/logging.h" | 23 #include "webrtc/base/logging.h" |
23 #include "webrtc/base/protobuf_utils.h" | 24 #include "webrtc/base/protobuf_utils.h" |
24 #include "webrtc/call/call.h" | 25 #include "webrtc/call/call.h" |
25 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" | 26 #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
26 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ
k_adaptor.h" | 27 #include "webrtc/modules/audio_coding/audio_network_adaptor/include/audio_networ
k_adaptor.h" |
27 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" | 28 #include "webrtc/modules/remote_bitrate_estimator/include/bwe_defines.h" |
28 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" | 29 #include "webrtc/modules/rtp_rtcp/include/rtp_rtcp_defines.h" |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 if (packet != nullptr) { | 310 if (packet != nullptr) { |
310 RTC_CHECK_LE(rtcp_packet.packet_data().size(), | 311 RTC_CHECK_LE(rtcp_packet.packet_data().size(), |
311 static_cast<unsigned>(IP_PACKET_SIZE)); | 312 static_cast<unsigned>(IP_PACKET_SIZE)); |
312 memcpy(packet, rtcp_packet.packet_data().data(), | 313 memcpy(packet, rtcp_packet.packet_data().data(), |
313 rtcp_packet.packet_data().size()); | 314 rtcp_packet.packet_data().size()); |
314 } | 315 } |
315 } | 316 } |
316 | 317 |
317 void ParsedRtcEventLog::GetVideoReceiveConfig( | 318 void ParsedRtcEventLog::GetVideoReceiveConfig( |
318 size_t index, | 319 size_t index, |
319 VideoReceiveStream::Config* config) const { | 320 rtclog::StreamConfig* config) const { |
320 RTC_CHECK_LT(index, GetNumberOfEvents()); | 321 RTC_CHECK_LT(index, GetNumberOfEvents()); |
321 const rtclog::Event& event = events_[index]; | 322 const rtclog::Event& event = events_[index]; |
322 RTC_CHECK(config != nullptr); | 323 RTC_CHECK(config != nullptr); |
323 RTC_CHECK(event.has_type()); | 324 RTC_CHECK(event.has_type()); |
324 RTC_CHECK_EQ(event.type(), rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT); | 325 RTC_CHECK_EQ(event.type(), rtclog::Event::VIDEO_RECEIVER_CONFIG_EVENT); |
325 RTC_CHECK(event.has_video_receiver_config()); | 326 RTC_CHECK(event.has_video_receiver_config()); |
326 const rtclog::VideoReceiveConfig& receiver_config = | 327 const rtclog::VideoReceiveConfig& receiver_config = |
327 event.video_receiver_config(); | 328 event.video_receiver_config(); |
328 // Get SSRCs. | 329 // Get SSRCs. |
329 RTC_CHECK(receiver_config.has_remote_ssrc()); | 330 RTC_CHECK(receiver_config.has_remote_ssrc()); |
330 config->rtp.remote_ssrc = receiver_config.remote_ssrc(); | 331 config->remote_ssrc = receiver_config.remote_ssrc(); |
331 RTC_CHECK(receiver_config.has_local_ssrc()); | 332 RTC_CHECK(receiver_config.has_local_ssrc()); |
332 config->rtp.local_ssrc = receiver_config.local_ssrc(); | 333 config->local_ssrc = receiver_config.local_ssrc(); |
| 334 config->rtx_ssrc = 0; |
333 // Get RTCP settings. | 335 // Get RTCP settings. |
334 RTC_CHECK(receiver_config.has_rtcp_mode()); | 336 RTC_CHECK(receiver_config.has_rtcp_mode()); |
335 config->rtp.rtcp_mode = GetRuntimeRtcpMode(receiver_config.rtcp_mode()); | 337 config->rtcp_mode = GetRuntimeRtcpMode(receiver_config.rtcp_mode()); |
336 RTC_CHECK(receiver_config.has_remb()); | 338 RTC_CHECK(receiver_config.has_remb()); |
337 config->rtp.remb = receiver_config.remb(); | 339 config->remb = receiver_config.remb(); |
| 340 |
338 // Get RTX map. | 341 // Get RTX map. |
339 std::vector<uint32_t> rtx_ssrcs(receiver_config.rtx_map_size()); | 342 std::map<uint32_t, const rtclog::RtxConfig> rtx_map; |
340 config->rtp.rtx_payload_types.clear(); | |
341 for (int i = 0; i < receiver_config.rtx_map_size(); i++) { | 343 for (int i = 0; i < receiver_config.rtx_map_size(); i++) { |
342 const rtclog::RtxMap& map = receiver_config.rtx_map(i); | 344 const rtclog::RtxMap& map = receiver_config.rtx_map(i); |
343 RTC_CHECK(map.has_payload_type()); | 345 RTC_CHECK(map.has_payload_type()); |
344 RTC_CHECK(map.has_config()); | 346 RTC_CHECK(map.has_config()); |
345 RTC_CHECK(map.config().has_rtx_ssrc()); | 347 RTC_CHECK(map.config().has_rtx_ssrc()); |
346 rtx_ssrcs[i] = map.config().rtx_ssrc(); | |
347 RTC_CHECK(map.config().has_rtx_payload_type()); | 348 RTC_CHECK(map.config().has_rtx_payload_type()); |
348 config->rtp.rtx_payload_types.insert( | 349 rtx_map.insert(std::make_pair(map.payload_type(), map.config())); |
349 std::make_pair(map.payload_type(), map.config().rtx_payload_type())); | |
350 } | 350 } |
351 if (!rtx_ssrcs.empty()) { | |
352 config->rtp.rtx_ssrc = rtx_ssrcs[0]; | |
353 | 351 |
354 auto pred = [&config](uint32_t ssrc) { | |
355 return ssrc == config->rtp.rtx_ssrc; | |
356 }; | |
357 if (!std::all_of(rtx_ssrcs.cbegin(), rtx_ssrcs.cend(), pred)) { | |
358 LOG(LS_WARNING) << "RtcEventLog protobuf contained different SSRCs for " | |
359 "different received RTX payload types. Will only use " | |
360 "rtx_ssrc = " | |
361 << config->rtp.rtx_ssrc << "."; | |
362 } | |
363 } | |
364 // Get header extensions. | 352 // Get header extensions. |
365 GetHeaderExtensions(&config->rtp.extensions, | 353 GetHeaderExtensions(&config->rtp_extensions, |
366 receiver_config.header_extensions()); | 354 receiver_config.header_extensions()); |
367 // Get decoders. | 355 // Get decoders. |
368 config->decoders.clear(); | 356 config->codecs.clear(); |
369 for (int i = 0; i < receiver_config.decoders_size(); i++) { | 357 for (int i = 0; i < receiver_config.decoders_size(); i++) { |
370 RTC_CHECK(receiver_config.decoders(i).has_name()); | 358 RTC_CHECK(receiver_config.decoders(i).has_name()); |
371 RTC_CHECK(receiver_config.decoders(i).has_payload_type()); | 359 RTC_CHECK(receiver_config.decoders(i).has_payload_type()); |
372 VideoReceiveStream::Decoder decoder; | 360 int rtx_payload_type = 0; |
373 decoder.payload_name = receiver_config.decoders(i).name(); | 361 auto rtx_it = rtx_map.find(receiver_config.decoders(i).payload_type()); |
374 decoder.payload_type = receiver_config.decoders(i).payload_type(); | 362 if (rtx_it != rtx_map.end()) { |
375 config->decoders.push_back(decoder); | 363 rtx_payload_type = rtx_it->second.rtx_payload_type(); |
| 364 if (config->rtx_ssrc != 0 && |
| 365 config->rtx_ssrc != rtx_it->second.rtx_ssrc()) { |
| 366 LOG(LS_WARNING) |
| 367 << "RtcEventLog protobuf contained different SSRCs for " |
| 368 "different received RTX payload types. Will only use " |
| 369 "rtx_ssrc = " |
| 370 << config->rtx_ssrc << "."; |
| 371 } else { |
| 372 config->rtx_ssrc = rtx_it->second.rtx_ssrc(); |
| 373 } |
| 374 } |
| 375 config->codecs.emplace_back(receiver_config.decoders(i).name(), |
| 376 receiver_config.decoders(i).payload_type(), |
| 377 rtx_payload_type); |
376 } | 378 } |
377 } | 379 } |
378 | 380 |
379 void ParsedRtcEventLog::GetVideoSendConfig( | 381 void ParsedRtcEventLog::GetVideoSendConfig( |
380 size_t index, | 382 size_t index, |
381 VideoSendStream::Config* config) const { | 383 VideoSendStream::Config* config) const { |
382 RTC_CHECK_LT(index, GetNumberOfEvents()); | 384 RTC_CHECK_LT(index, GetNumberOfEvents()); |
383 const rtclog::Event& event = events_[index]; | 385 const rtclog::Event& event = events_[index]; |
384 RTC_CHECK(config != nullptr); | 386 RTC_CHECK(config != nullptr); |
385 RTC_CHECK(event.has_type()); | 387 RTC_CHECK(event.has_type()); |
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
583 rtc::Optional<ProbeFailureReason>(kInvalidSendReceiveRatio); | 585 rtc::Optional<ProbeFailureReason>(kInvalidSendReceiveRatio); |
584 } else if (pr_event.result() == rtclog::BweProbeResult::TIMEOUT) { | 586 } else if (pr_event.result() == rtclog::BweProbeResult::TIMEOUT) { |
585 res.failure_reason = rtc::Optional<ProbeFailureReason>(kTimeout); | 587 res.failure_reason = rtc::Optional<ProbeFailureReason>(kTimeout); |
586 } else { | 588 } else { |
587 RTC_NOTREACHED(); | 589 RTC_NOTREACHED(); |
588 } | 590 } |
589 | 591 |
590 return res; | 592 return res; |
591 } | 593 } |
592 } // namespace webrtc | 594 } // namespace webrtc |
OLD | NEW |