Chromium Code Reviews| Index: webrtc/logging/rtc_event_log/rtc_event_log2rtp_dump.cc |
| diff --git a/webrtc/logging/rtc_event_log/rtc_event_log2rtp_dump.cc b/webrtc/logging/rtc_event_log/rtc_event_log2rtp_dump.cc |
| index 2336caa284435afcc91df10bdddd952f8f8b9d9d..c12a1a03d43ed7735a58b1c63861fcb3dc02e213 100644 |
| --- a/webrtc/logging/rtc_event_log/rtc_event_log2rtp_dump.cc |
| +++ b/webrtc/logging/rtc_event_log/rtc_event_log2rtp_dump.cc |
| @@ -15,10 +15,10 @@ |
| #include "gflags/gflags.h" |
| #include "webrtc/base/checks.h" |
| -#include "webrtc/call/call.h" |
| #include "webrtc/logging/rtc_event_log/rtc_event_log.h" |
| #include "webrtc/logging/rtc_event_log/rtc_event_log_parser.h" |
| #include "webrtc/modules/rtp_rtcp/source/byte_io.h" |
| +#include "webrtc/modules/rtp_rtcp/source/rtp_utility.h" |
| #include "webrtc/test/rtp_file_writer.h" |
| namespace { |
| @@ -43,6 +43,31 @@ DEFINE_string(ssrc, |
| "Store only packets with this SSRC (decimal or hex, the latter " |
| "starting with 0x)."); |
| +enum class MediaType { ANY, AUDIO, VIDEO, DATA }; |
| + |
| +// Struct used for storing SSRCs used in a Stream. |
| +struct Stream { |
|
terelius
2017/05/23 11:57:58
If this struct is used by all/most tools, maybe th
perkj_webrtc
2017/05/24 12:32:21
Done.
|
| + Stream(uint32_t ssrc, MediaType media_type, webrtc::PacketDirection direction) |
| + : ssrc(ssrc), media_type(media_type), direction(direction) {} |
| + uint32_t ssrc; |
| + MediaType media_type; |
| + webrtc::PacketDirection direction; |
| +}; |
| + |
| +// All configured streams found in the event log. |
| +std::vector<Stream> global_streams; |
|
terelius
2017/05/23 11:57:58
Another alternative is to make this a part of the
perkj_webrtc
2017/05/24 12:32:21
Done.
|
| + |
| +// Returns the MediaType for registered SSRCs. Search from the end to use last |
| +// registered types first. |
| +MediaType GetMediaType(uint32_t ssrc, webrtc::PacketDirection direction) { |
| + for (auto rit = global_streams.rbegin(); rit != global_streams.rend(); |
| + ++rit) { |
| + if (rit->ssrc == ssrc && rit->direction == direction) |
| + return rit->media_type; |
| + } |
| + return MediaType::ANY; |
| +} |
| + |
| // Parses the input string for a valid SSRC. If a valid SSRC is found, it is |
| // written to the output variable |ssrc|, and true is returned. Otherwise, |
| // false is returned. |
| @@ -110,6 +135,43 @@ int main(int argc, char* argv[]) { |
| int rtp_counter = 0, rtcp_counter = 0; |
| bool header_only = false; |
| for (size_t i = 0; i < parsed_stream.GetNumberOfEvents(); i++) { |
| + if (parsed_stream.GetEventType(i) == |
| + webrtc::ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT) { |
| + webrtc::rtclog::StreamConfig config; |
| + parsed_stream.GetVideoReceiveConfig(i, &config); |
| + |
| + global_streams.emplace_back(config.remote_ssrc, MediaType::VIDEO, |
| + webrtc::kIncomingPacket); |
| + global_streams.emplace_back(config.local_ssrc, MediaType::VIDEO, |
| + webrtc::kOutgoingPacket); |
| + } |
| + if (parsed_stream.GetEventType(i) == |
| + webrtc::ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT) { |
| + webrtc::rtclog::StreamConfig config; |
| + parsed_stream.GetVideoSendConfig(i, &config); |
| + global_streams.emplace_back(config.local_ssrc, MediaType::VIDEO, |
| + webrtc::kOutgoingPacket); |
| + |
| + global_streams.emplace_back(config.rtx_ssrc, MediaType::VIDEO, |
| + webrtc::kOutgoingPacket); |
| + } |
| + if (parsed_stream.GetEventType(i) == |
| + webrtc::ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT) { |
| + webrtc::rtclog::StreamConfig config; |
| + parsed_stream.GetAudioReceiveConfig(i, &config); |
| + global_streams.emplace_back(config.remote_ssrc, MediaType::AUDIO, |
| + webrtc::kIncomingPacket); |
| + global_streams.emplace_back(config.local_ssrc, MediaType::AUDIO, |
| + webrtc::kOutgoingPacket); |
| + } |
| + if (parsed_stream.GetEventType(i) == |
| + webrtc::ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT) { |
| + webrtc::rtclog::StreamConfig config; |
| + parsed_stream.GetAudioSendConfig(i, &config); |
| + global_streams.emplace_back(config.local_ssrc, MediaType::AUDIO, |
| + webrtc::kOutgoingPacket); |
| + } |
| + |
| // The parsed_stream will assert if the protobuf event is missing |
| // some required fields and we attempt to access them. We could consider |
| // a softer failure option, but it does not seem useful to generate |
| @@ -118,21 +180,27 @@ int main(int argc, char* argv[]) { |
| parsed_stream.GetEventType(i) == webrtc::ParsedRtcEventLog::RTP_EVENT) { |
| webrtc::test::RtpPacket packet; |
| webrtc::PacketDirection direction; |
| - webrtc::MediaType media_type; |
| - parsed_stream.GetRtpHeader(i, &direction, &media_type, packet.data, |
| - &packet.length, &packet.original_length); |
| + parsed_stream.GetRtpHeader(i, &direction, packet.data, &packet.length, |
| + &packet.original_length); |
| if (packet.original_length > packet.length) |
| header_only = true; |
| packet.time_ms = parsed_stream.GetTimestamp(i) / 1000; |
| + webrtc::RtpUtility::RtpHeaderParser rtp_parser(packet.data, |
| + packet.length); |
| + |
| // TODO(terelius): Maybe add a flag to dump outgoing traffic instead? |
| if (direction == webrtc::kOutgoingPacket) |
| continue; |
| - if (FLAGS_noaudio && media_type == webrtc::MediaType::AUDIO) |
| + |
| + webrtc::RTPHeader parsed_header; |
| + rtp_parser.Parse(&parsed_header); |
| + MediaType media_type = GetMediaType(parsed_header.ssrc, direction); |
| + if (FLAGS_noaudio && media_type == MediaType::AUDIO) |
| continue; |
| - if (FLAGS_novideo && media_type == webrtc::MediaType::VIDEO) |
| + if (FLAGS_novideo && media_type == MediaType::VIDEO) |
| continue; |
| - if (FLAGS_nodata && media_type == webrtc::MediaType::DATA) |
| + if (FLAGS_nodata && media_type == MediaType::DATA) |
| continue; |
| if (!FLAGS_ssrc.empty()) { |
| const uint32_t packet_ssrc = |
| @@ -150,9 +218,7 @@ int main(int argc, char* argv[]) { |
| webrtc::ParsedRtcEventLog::RTCP_EVENT) { |
| webrtc::test::RtpPacket packet; |
| webrtc::PacketDirection direction; |
| - webrtc::MediaType media_type; |
| - parsed_stream.GetRtcpPacket(i, &direction, &media_type, packet.data, |
| - &packet.length); |
| + parsed_stream.GetRtcpPacket(i, &direction, packet.data, &packet.length); |
| // For RTCP packets the original_length should be set to 0 in the |
| // RTPdump format. |
| packet.original_length = 0; |
| @@ -161,16 +227,17 @@ int main(int argc, char* argv[]) { |
| // TODO(terelius): Maybe add a flag to dump outgoing traffic instead? |
| if (direction == webrtc::kOutgoingPacket) |
| continue; |
| - if (FLAGS_noaudio && media_type == webrtc::MediaType::AUDIO) |
| + |
| + const uint32_t packet_ssrc = webrtc::ByteReader<uint32_t>::ReadBigEndian( |
| + reinterpret_cast<const uint8_t*>(packet.data + 4)); |
| + MediaType media_type = GetMediaType(packet_ssrc, direction); |
|
terelius
2017/05/23 11:57:58
Please add a TODO or comment documenting that medi
|
| + if (FLAGS_noaudio && media_type == MediaType::AUDIO) |
| continue; |
| - if (FLAGS_novideo && media_type == webrtc::MediaType::VIDEO) |
| + if (FLAGS_novideo && media_type == MediaType::VIDEO) |
| continue; |
| - if (FLAGS_nodata && media_type == webrtc::MediaType::DATA) |
| + if (FLAGS_nodata && media_type == MediaType::DATA) |
| continue; |
| if (!FLAGS_ssrc.empty()) { |
| - const uint32_t packet_ssrc = |
| - webrtc::ByteReader<uint32_t>::ReadBigEndian( |
| - reinterpret_cast<const uint8_t*>(packet.data + 4)); |
| if (packet_ssrc != ssrc_filter) |
| continue; |
| } |