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 |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
301 | 301 |
302 // Maps a stream identifier consisting of ssrc and direction | 302 // Maps a stream identifier consisting of ssrc and direction |
303 // to the header extensions used by that stream, | 303 // to the header extensions used by that stream, |
304 std::map<StreamId, RtpHeaderExtensionMap> extension_maps; | 304 std::map<StreamId, RtpHeaderExtensionMap> extension_maps; |
305 | 305 |
306 PacketDirection direction; | 306 PacketDirection direction; |
307 uint8_t header[IP_PACKET_SIZE]; | 307 uint8_t header[IP_PACKET_SIZE]; |
308 size_t header_length; | 308 size_t header_length; |
309 size_t total_length; | 309 size_t total_length; |
310 | 310 |
| 311 uint8_t last_incoming_rtcp_packet[IP_PACKET_SIZE]; |
| 312 uint8_t last_incoming_rtcp_packet_length = 0; |
| 313 |
311 // Make a default extension map for streams without configuration information. | 314 // Make a default extension map for streams without configuration information. |
312 // TODO(ivoc): Once configuration of audio streams is stored in the event log, | 315 // TODO(ivoc): Once configuration of audio streams is stored in the event log, |
313 // this can be removed. Tracking bug: webrtc:6399 | 316 // this can be removed. Tracking bug: webrtc:6399 |
314 RtpHeaderExtensionMap default_extension_map = GetDefaultHeaderExtensionMap(); | 317 RtpHeaderExtensionMap default_extension_map = GetDefaultHeaderExtensionMap(); |
315 | 318 |
316 for (size_t i = 0; i < parsed_log_.GetNumberOfEvents(); i++) { | 319 for (size_t i = 0; i < parsed_log_.GetNumberOfEvents(); i++) { |
317 ParsedRtcEventLog::EventType event_type = parsed_log_.GetEventType(i); | 320 ParsedRtcEventLog::EventType event_type = parsed_log_.GetEventType(i); |
318 if (event_type != ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT && | 321 if (event_type != ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT && |
319 event_type != ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT && | 322 event_type != ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT && |
320 event_type != ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT && | 323 event_type != ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT && |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 uint64_t timestamp = parsed_log_.GetTimestamp(i); | 399 uint64_t timestamp = parsed_log_.GetTimestamp(i); |
397 rtp_packets_[stream].push_back( | 400 rtp_packets_[stream].push_back( |
398 LoggedRtpPacket(timestamp, parsed_header, total_length)); | 401 LoggedRtpPacket(timestamp, parsed_header, total_length)); |
399 break; | 402 break; |
400 } | 403 } |
401 case ParsedRtcEventLog::RTCP_EVENT: { | 404 case ParsedRtcEventLog::RTCP_EVENT: { |
402 uint8_t packet[IP_PACKET_SIZE]; | 405 uint8_t packet[IP_PACKET_SIZE]; |
403 MediaType media_type; | 406 MediaType media_type; |
404 parsed_log_.GetRtcpPacket(i, &direction, &media_type, packet, | 407 parsed_log_.GetRtcpPacket(i, &direction, &media_type, packet, |
405 &total_length); | 408 &total_length); |
406 | 409 // Currently incoming RTCP packets are logged twice, both for audio and |
407 // Currently feedback is logged twice, both for audio and video. | 410 // video. Only act on one of them. Compare against the previous parsed |
408 // Only act on one of them. | 411 // incoming RTCP packet. |
409 if (media_type == MediaType::AUDIO || media_type == MediaType::ANY) { | 412 if (direction == webrtc::kIncomingPacket) { |
410 rtcp::CommonHeader header; | 413 RTC_CHECK_LE(total_length, IP_PACKET_SIZE); |
411 const uint8_t* packet_end = packet + total_length; | 414 if (total_length == last_incoming_rtcp_packet_length && |
412 for (const uint8_t* block = packet; block < packet_end; | 415 memcmp(last_incoming_rtcp_packet, packet, total_length) == 0) { |
413 block = header.NextPacket()) { | 416 continue; |
414 RTC_CHECK(header.Parse(block, packet_end - block)); | 417 } else { |
415 if (header.type() == rtcp::TransportFeedback::kPacketType && | 418 memcpy(last_incoming_rtcp_packet, packet, total_length); |
416 header.fmt() == rtcp::TransportFeedback::kFeedbackMessageType) { | 419 last_incoming_rtcp_packet_length = total_length; |
417 std::unique_ptr<rtcp::TransportFeedback> rtcp_packet( | 420 } |
418 new rtcp::TransportFeedback()); | 421 } |
419 if (rtcp_packet->Parse(header)) { | 422 rtcp::CommonHeader header; |
420 uint32_t ssrc = rtcp_packet->sender_ssrc(); | 423 const uint8_t* packet_end = packet + total_length; |
421 StreamId stream(ssrc, direction); | 424 for (const uint8_t* block = packet; block < packet_end; |
422 uint64_t timestamp = parsed_log_.GetTimestamp(i); | 425 block = header.NextPacket()) { |
423 rtcp_packets_[stream].push_back(LoggedRtcpPacket( | 426 RTC_CHECK(header.Parse(block, packet_end - block)); |
424 timestamp, kRtcpTransportFeedback, std::move(rtcp_packet))); | 427 if (header.type() == rtcp::TransportFeedback::kPacketType && |
425 } | 428 header.fmt() == rtcp::TransportFeedback::kFeedbackMessageType) { |
426 } else if (header.type() == rtcp::SenderReport::kPacketType) { | 429 std::unique_ptr<rtcp::TransportFeedback> rtcp_packet( |
427 std::unique_ptr<rtcp::SenderReport> rtcp_packet( | 430 new rtcp::TransportFeedback()); |
428 new rtcp::SenderReport()); | 431 if (rtcp_packet->Parse(header)) { |
429 if (rtcp_packet->Parse(header)) { | 432 uint32_t ssrc = rtcp_packet->sender_ssrc(); |
430 uint32_t ssrc = rtcp_packet->sender_ssrc(); | 433 StreamId stream(ssrc, direction); |
431 StreamId stream(ssrc, direction); | 434 uint64_t timestamp = parsed_log_.GetTimestamp(i); |
432 uint64_t timestamp = parsed_log_.GetTimestamp(i); | 435 rtcp_packets_[stream].push_back(LoggedRtcpPacket( |
433 rtcp_packets_[stream].push_back(LoggedRtcpPacket( | 436 timestamp, kRtcpTransportFeedback, std::move(rtcp_packet))); |
434 timestamp, kRtcpSr, std::move(rtcp_packet))); | 437 } |
435 } | 438 } else if (header.type() == rtcp::SenderReport::kPacketType) { |
436 } else if (header.type() == rtcp::ReceiverReport::kPacketType) { | 439 std::unique_ptr<rtcp::SenderReport> rtcp_packet( |
437 std::unique_ptr<rtcp::ReceiverReport> rtcp_packet( | 440 new rtcp::SenderReport()); |
438 new rtcp::ReceiverReport()); | 441 if (rtcp_packet->Parse(header)) { |
439 if (rtcp_packet->Parse(header)) { | 442 uint32_t ssrc = rtcp_packet->sender_ssrc(); |
440 uint32_t ssrc = rtcp_packet->sender_ssrc(); | 443 StreamId stream(ssrc, direction); |
441 StreamId stream(ssrc, direction); | 444 uint64_t timestamp = parsed_log_.GetTimestamp(i); |
442 uint64_t timestamp = parsed_log_.GetTimestamp(i); | 445 rtcp_packets_[stream].push_back( |
443 rtcp_packets_[stream].push_back(LoggedRtcpPacket( | 446 LoggedRtcpPacket(timestamp, kRtcpSr, std::move(rtcp_packet))); |
444 timestamp, kRtcpRr, std::move(rtcp_packet))); | 447 } |
445 } | 448 } else if (header.type() == rtcp::ReceiverReport::kPacketType) { |
| 449 std::unique_ptr<rtcp::ReceiverReport> rtcp_packet( |
| 450 new rtcp::ReceiverReport()); |
| 451 if (rtcp_packet->Parse(header)) { |
| 452 uint32_t ssrc = rtcp_packet->sender_ssrc(); |
| 453 StreamId stream(ssrc, direction); |
| 454 uint64_t timestamp = parsed_log_.GetTimestamp(i); |
| 455 rtcp_packets_[stream].push_back( |
| 456 LoggedRtcpPacket(timestamp, kRtcpRr, std::move(rtcp_packet))); |
446 } | 457 } |
447 } | 458 } |
448 } | 459 } |
449 break; | 460 break; |
450 } | 461 } |
451 case ParsedRtcEventLog::LOG_START: { | 462 case ParsedRtcEventLog::LOG_START: { |
452 break; | 463 break; |
453 } | 464 } |
454 case ParsedRtcEventLog::LOG_END: { | 465 case ParsedRtcEventLog::LOG_END: { |
455 break; | 466 break; |
(...skipping 932 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1388 }, | 1399 }, |
1389 audio_network_adaptation_events_, begin_time_, &time_series); | 1400 audio_network_adaptation_events_, begin_time_, &time_series); |
1390 plot->AppendTimeSeries(std::move(time_series)); | 1401 plot->AppendTimeSeries(std::move(time_series)); |
1391 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | 1402 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
1392 plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))", | 1403 plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))", |
1393 kBottomMargin, kTopMargin); | 1404 kBottomMargin, kTopMargin); |
1394 plot->SetTitle("Reported audio encoder number of channels"); | 1405 plot->SetTitle("Reported audio encoder number of channels"); |
1395 } | 1406 } |
1396 } // namespace plotting | 1407 } // namespace plotting |
1397 } // namespace webrtc | 1408 } // namespace webrtc |
OLD | NEW |