OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2017 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 <iostream> | 11 #include <iostream> |
12 #include <map> | |
12 #include <sstream> | 13 #include <sstream> |
13 #include <string> | 14 #include <string> |
15 #include <utility> // pair | |
14 | 16 |
15 #include "gflags/gflags.h" | 17 #include "gflags/gflags.h" |
16 #include "webrtc/base/checks.h" | 18 #include "webrtc/base/checks.h" |
17 #include "webrtc/common_types.h" | 19 #include "webrtc/common_types.h" |
18 #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h" | 20 #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h" |
19 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" | 21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/bye.h" |
20 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" | 22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/common_header.h" |
21 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" | 23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/extended_reports.h" |
22 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" | 24 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/fir.h" |
23 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" | 25 #include "webrtc/modules/rtp_rtcp/source/rtcp_packet/nack.h" |
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
341 | 343 |
342 if (!FLAGS_ssrc.empty()) | 344 if (!FLAGS_ssrc.empty()) |
343 RTC_CHECK(ParseSsrc(FLAGS_ssrc)) << "Flag verification has failed."; | 345 RTC_CHECK(ParseSsrc(FLAGS_ssrc)) << "Flag verification has failed."; |
344 | 346 |
345 webrtc::ParsedRtcEventLog parsed_stream; | 347 webrtc::ParsedRtcEventLog parsed_stream; |
346 if (!parsed_stream.ParseFile(input_file)) { | 348 if (!parsed_stream.ParseFile(input_file)) { |
347 std::cerr << "Error while parsing input file: " << input_file << std::endl; | 349 std::cerr << "Error while parsing input file: " << input_file << std::endl; |
348 return -1; | 350 return -1; |
349 } | 351 } |
350 | 352 |
353 typedef std::pair<uint32_t, webrtc::PacketDirection> StreamId; | |
354 // For each separate stream identified by StreamId we need a | |
355 // separate extension_map, because negotiated extensions may differ. | |
356 std::map<StreamId, webrtc::RtpHeaderExtensionMap> extension_maps; | |
357 | |
351 for (size_t i = 0; i < parsed_stream.GetNumberOfEvents(); i++) { | 358 for (size_t i = 0; i < parsed_stream.GetNumberOfEvents(); i++) { |
352 if (!FLAGS_noconfig && !FLAGS_novideo && !FLAGS_noincoming && | 359 if (!FLAGS_noconfig && !FLAGS_novideo && !FLAGS_noincoming && |
353 parsed_stream.GetEventType(i) == | 360 parsed_stream.GetEventType(i) == |
354 webrtc::ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT) { | 361 webrtc::ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT) { |
355 webrtc::rtclog::StreamConfig config = | 362 webrtc::rtclog::StreamConfig config = |
356 parsed_stream.GetVideoReceiveConfig(i); | 363 parsed_stream.GetVideoReceiveConfig(i); |
364 extension_maps[StreamId(config.remote_ssrc, webrtc::kIncomingPacket)] = | |
365 webrtc::RtpHeaderExtensionMap(config.rtp_extensions); | |
366 extension_maps[StreamId(config.rtx_ssrc, webrtc::kIncomingPacket)] = | |
367 webrtc::RtpHeaderExtensionMap(config.rtp_extensions); | |
357 std::cout << parsed_stream.GetTimestamp(i) << "\tVIDEO_RECV_CONFIG" | 368 std::cout << parsed_stream.GetTimestamp(i) << "\tVIDEO_RECV_CONFIG" |
358 << "\tssrc=" << config.remote_ssrc | 369 << "\tssrc=" << config.remote_ssrc |
359 << "\tfeedback_ssrc=" << config.local_ssrc; | 370 << "\tfeedback_ssrc=" << config.local_ssrc; |
360 std::cout << "\textensions={"; | 371 std::cout << "\textensions={"; |
361 for (const auto& extension : config.rtp_extensions) { | 372 for (const auto& extension : config.rtp_extensions) { |
362 std::cout << extension.ToString() << ","; | 373 std::cout << extension.ToString() << ","; |
363 } | 374 } |
364 std::cout << "}"; | 375 std::cout << "}"; |
365 std::cout << "\tcodecs={"; | 376 std::cout << "\tcodecs={"; |
366 for (const auto& codec : config.codecs) { | 377 for (const auto& codec : config.codecs) { |
367 std::cout << "{name: " << codec.payload_name | 378 std::cout << "{name: " << codec.payload_name |
368 << ", payload_type: " << codec.payload_type | 379 << ", payload_type: " << codec.payload_type |
369 << ", rtx_payload_type: " << codec.rtx_payload_type << "}"; | 380 << ", rtx_payload_type: " << codec.rtx_payload_type << "}"; |
370 } | 381 } |
371 std::cout << "}" << std::endl; | 382 std::cout << "}" << std::endl; |
372 } | 383 } |
373 if (!FLAGS_noconfig && !FLAGS_novideo && !FLAGS_nooutgoing && | 384 if (!FLAGS_noconfig && !FLAGS_novideo && !FLAGS_nooutgoing && |
374 parsed_stream.GetEventType(i) == | 385 parsed_stream.GetEventType(i) == |
375 webrtc::ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT) { | 386 webrtc::ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT) { |
376 std::vector<webrtc::rtclog::StreamConfig> configs = | 387 std::vector<webrtc::rtclog::StreamConfig> configs = |
377 parsed_stream.GetVideoSendConfig(i); | 388 parsed_stream.GetVideoSendConfig(i); |
378 for (const auto& config : configs) { | 389 for (const auto& config : configs) { |
390 extension_maps[StreamId(config.local_ssrc, webrtc::kOutgoingPacket)] = | |
391 webrtc::RtpHeaderExtensionMap(config.rtp_extensions); | |
392 extension_maps[StreamId(config.rtx_ssrc, webrtc::kOutgoingPacket)] = | |
393 webrtc::RtpHeaderExtensionMap(config.rtp_extensions); | |
terelius
2017/06/02 10:55:03
Maybe this should be parsed from audio configs too
ilnik
2017/06/02 11:25:59
Done.
| |
379 std::cout << parsed_stream.GetTimestamp(i) << "\tVIDEO_SEND_CONFIG"; | 394 std::cout << parsed_stream.GetTimestamp(i) << "\tVIDEO_SEND_CONFIG"; |
380 std::cout << "\tssrcs=" << config.local_ssrc; | 395 std::cout << "\tssrcs=" << config.local_ssrc; |
381 std::cout << "\trtx_ssrcs=" << config.rtx_ssrc; | 396 std::cout << "\trtx_ssrcs=" << config.rtx_ssrc; |
382 std::cout << "\textensions={"; | 397 std::cout << "\textensions={"; |
383 for (const auto& extension : config.rtp_extensions) { | 398 for (const auto& extension : config.rtp_extensions) { |
384 std::cout << extension.ToString() << ","; | 399 std::cout << extension.ToString() << ","; |
385 } | 400 } |
386 std::cout << "}"; | 401 std::cout << "}"; |
387 std::cout << "\tcodecs={"; | 402 std::cout << "\tcodecs={"; |
388 for (const auto& codec : config.codecs) { | 403 for (const auto& codec : config.codecs) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
432 << ", rtx_payload_type: " << codec.rtx_payload_type << "}"; | 447 << ", rtx_payload_type: " << codec.rtx_payload_type << "}"; |
433 } | 448 } |
434 std::cout << "}" << std::endl; | 449 std::cout << "}" << std::endl; |
435 } | 450 } |
436 if (!FLAGS_nortp && | 451 if (!FLAGS_nortp && |
437 parsed_stream.GetEventType(i) == webrtc::ParsedRtcEventLog::RTP_EVENT) { | 452 parsed_stream.GetEventType(i) == webrtc::ParsedRtcEventLog::RTP_EVENT) { |
438 size_t header_length; | 453 size_t header_length; |
439 size_t total_length; | 454 size_t total_length; |
440 uint8_t header[IP_PACKET_SIZE]; | 455 uint8_t header[IP_PACKET_SIZE]; |
441 webrtc::PacketDirection direction; | 456 webrtc::PacketDirection direction; |
442 | |
443 parsed_stream.GetRtpHeader(i, &direction, header, &header_length, | 457 parsed_stream.GetRtpHeader(i, &direction, header, &header_length, |
444 &total_length); | 458 &total_length); |
445 | 459 |
446 // Parse header to get SSRC and RTP time. | 460 // Parse header to get SSRC and RTP time. |
447 webrtc::RtpUtility::RtpHeaderParser rtp_parser(header, header_length); | 461 webrtc::RtpUtility::RtpHeaderParser rtp_parser(header, header_length); |
448 webrtc::RTPHeader parsed_header; | 462 webrtc::RTPHeader parsed_header; |
449 rtp_parser.Parse(&parsed_header); | 463 rtp_parser.Parse(&parsed_header); |
464 StreamId stream_id(parsed_header.ssrc, direction); | |
465 if (extension_maps.count(stream_id) == 1) { | |
466 webrtc::RtpHeaderExtensionMap* extension_map = | |
467 &extension_maps[stream_id]; | |
468 rtp_parser.Parse(&parsed_header, extension_map); | |
469 } | |
450 MediaType media_type = | 470 MediaType media_type = |
451 parsed_stream.GetMediaType(parsed_header.ssrc, direction); | 471 parsed_stream.GetMediaType(parsed_header.ssrc, direction); |
452 | 472 |
453 if (ExcludePacket(direction, media_type, parsed_header.ssrc)) | 473 if (ExcludePacket(direction, media_type, parsed_header.ssrc)) |
454 continue; | 474 continue; |
455 | 475 |
456 std::cout << parsed_stream.GetTimestamp(i) << "\tRTP" | 476 std::cout << parsed_stream.GetTimestamp(i) << "\tRTP" |
457 << StreamInfo(direction, media_type) | 477 << StreamInfo(direction, media_type) |
458 << "\tssrc=" << parsed_header.ssrc | 478 << "\tssrc=" << parsed_header.ssrc |
459 << "\ttimestamp=" << parsed_header.timestamp << std::endl; | 479 << "\ttimestamp=" << parsed_header.timestamp; |
480 if (parsed_header.extension.hasAbsoluteSendTime) { | |
481 std::cout << "\tAbsSendTime=" | |
terelius
2017/06/02 10:55:03
Is this the format that perkj suggested?
ilnik
2017/06/02 11:25:59
No. It was something quick I used for myself. Do w
ilnik
2017/06/02 11:43:35
We had an offline discussion with perkj@. He doesn
| |
482 << parsed_header.extension.absoluteSendTime; | |
483 } | |
484 if (parsed_header.extension.hasVideoContentType) { | |
485 std::cout << "\tContentType=" | |
486 << static_cast<int>(parsed_header.extension.videoContentType); | |
487 } | |
488 if (parsed_header.extension.hasVideoRotation) { | |
489 std::cout << "\tRotation=" | |
490 << static_cast<int>(parsed_header.extension.videoRotation); | |
491 } | |
492 if (parsed_header.extension.hasTransportSequenceNumber) { | |
493 std::cout << "\tTransportSeq=" | |
494 << parsed_header.extension.transportSequenceNumber; | |
495 } | |
496 if (parsed_header.extension.hasTransmissionTimeOffset) { | |
497 std::cout << "\tTransmTimeOffset=" | |
498 << parsed_header.extension.transmissionTimeOffset; | |
499 } | |
500 if (parsed_header.extension.hasAudioLevel) { | |
501 std::cout << "\tAudioLevel=" << parsed_header.extension.audioLevel; | |
502 } | |
503 std::cout << std::endl; | |
460 } | 504 } |
461 if (!FLAGS_nortcp && | 505 if (!FLAGS_nortcp && |
462 parsed_stream.GetEventType(i) == | 506 parsed_stream.GetEventType(i) == |
463 webrtc::ParsedRtcEventLog::RTCP_EVENT) { | 507 webrtc::ParsedRtcEventLog::RTCP_EVENT) { |
464 size_t length; | 508 size_t length; |
465 uint8_t packet[IP_PACKET_SIZE]; | 509 uint8_t packet[IP_PACKET_SIZE]; |
466 webrtc::PacketDirection direction; | 510 webrtc::PacketDirection direction; |
467 parsed_stream.GetRtcpPacket(i, &direction, packet, &length); | 511 parsed_stream.GetRtcpPacket(i, &direction, packet, &length); |
468 | 512 |
469 webrtc::rtcp::CommonHeader rtcp_block; | 513 webrtc::rtcp::CommonHeader rtcp_block; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
504 direction); | 548 direction); |
505 break; | 549 break; |
506 default: | 550 default: |
507 break; | 551 break; |
508 } | 552 } |
509 } | 553 } |
510 } | 554 } |
511 } | 555 } |
512 return 0; | 556 return 0; |
513 } | 557 } |
OLD | NEW |