| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2015 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2015 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 21 matching lines...) Expand all Loading... |
| 32 | 32 |
| 33 RtcEventLogSource::~RtcEventLogSource() {} | 33 RtcEventLogSource::~RtcEventLogSource() {} |
| 34 | 34 |
| 35 bool RtcEventLogSource::RegisterRtpHeaderExtension(RTPExtensionType type, | 35 bool RtcEventLogSource::RegisterRtpHeaderExtension(RTPExtensionType type, |
| 36 uint8_t id) { | 36 uint8_t id) { |
| 37 RTC_CHECK(parser_.get()); | 37 RTC_CHECK(parser_.get()); |
| 38 return parser_->RegisterRtpHeaderExtension(type, id); | 38 return parser_->RegisterRtpHeaderExtension(type, id); |
| 39 } | 39 } |
| 40 | 40 |
| 41 std::unique_ptr<Packet> RtcEventLogSource::NextPacket() { | 41 std::unique_ptr<Packet> RtcEventLogSource::NextPacket() { |
| 42 while (rtp_packet_index_ < parsed_stream_.GetNumberOfEvents()) { | 42 for (; rtp_packet_index_ < parsed_stream_.GetNumberOfEvents(); |
| 43 rtp_packet_index_++) { |
| 44 if (parsed_stream_.GetEventType(rtp_packet_index_) == |
| 45 webrtc::ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT) { |
| 46 webrtc::rtclog::StreamConfig config; |
| 47 parsed_stream_.GetAudioReceiveConfig(rtp_packet_index_, &config); |
| 48 streams_.push_back(config.remote_ssrc); |
| 49 } |
| 50 |
| 43 if (parsed_stream_.GetEventType(rtp_packet_index_) == | 51 if (parsed_stream_.GetEventType(rtp_packet_index_) == |
| 44 ParsedRtcEventLog::RTP_EVENT) { | 52 ParsedRtcEventLog::RTP_EVENT) { |
| 45 PacketDirection direction; | 53 PacketDirection direction; |
| 46 MediaType media_type; | |
| 47 size_t header_length; | 54 size_t header_length; |
| 48 size_t packet_length; | 55 size_t packet_length; |
| 49 uint64_t timestamp_us = parsed_stream_.GetTimestamp(rtp_packet_index_); | 56 uint64_t timestamp_us = parsed_stream_.GetTimestamp(rtp_packet_index_); |
| 50 parsed_stream_.GetRtpHeader(rtp_packet_index_, &direction, &media_type, | 57 parsed_stream_.GetRtpHeader(rtp_packet_index_, &direction, nullptr, |
| 51 nullptr, &header_length, &packet_length); | 58 &header_length, &packet_length); |
| 52 if (direction == kIncomingPacket && media_type == MediaType::AUDIO) { | 59 |
| 53 uint8_t* packet_header = new uint8_t[header_length]; | 60 if (direction != kIncomingPacket) { |
| 54 parsed_stream_.GetRtpHeader(rtp_packet_index_, nullptr, nullptr, | 61 continue; |
| 55 packet_header, nullptr, nullptr); | 62 } |
| 56 std::unique_ptr<Packet> packet(new Packet( | 63 |
| 57 packet_header, header_length, packet_length, | 64 uint8_t* packet_header = new uint8_t[header_length]; |
| 58 static_cast<double>(timestamp_us) / 1000, *parser_.get())); | 65 parsed_stream_.GetRtpHeader(rtp_packet_index_, nullptr, packet_header, |
| 59 if (packet->valid_header()) { | 66 nullptr, nullptr); |
| 60 // Check if the packet should not be filtered out. | 67 std::unique_ptr<Packet> packet( |
| 61 if (!filter_.test(packet->header().payloadType) && | 68 new Packet(packet_header, header_length, packet_length, |
| 62 !(use_ssrc_filter_ && packet->header().ssrc != ssrc_)) { | 69 static_cast<double>(timestamp_us) / 1000, *parser_.get())); |
| 63 rtp_packet_index_++; | 70 |
| 64 return packet; | 71 if (!packet->valid_header()) { |
| 65 } | 72 std::cout << "Warning: Packet with index " << rtp_packet_index_ |
| 66 } else { | 73 << " has an invalid header and will be ignored." << std::endl; |
| 67 std::cout << "Warning: Packet with index " << rtp_packet_index_ | 74 continue; |
| 68 << " has an invalid header and will be ignored." | 75 } |
| 69 << std::endl; | 76 |
| 70 } | 77 if (!IsAudioSsrc(packet->header().ssrc)) { |
| 78 continue; |
| 79 } |
| 80 |
| 81 // Check if the packet should not be filtered out. |
| 82 if (!filter_.test(packet->header().payloadType) && |
| 83 !(use_ssrc_filter_ && packet->header().ssrc != ssrc_)) { |
| 84 return packet; |
| 71 } | 85 } |
| 72 } | 86 } |
| 73 rtp_packet_index_++; | |
| 74 } | 87 } |
| 75 return nullptr; | 88 return nullptr; |
| 76 } | 89 } |
| 77 | 90 |
| 78 int64_t RtcEventLogSource::NextAudioOutputEventMs() { | 91 int64_t RtcEventLogSource::NextAudioOutputEventMs() { |
| 79 while (audio_output_index_ < parsed_stream_.GetNumberOfEvents()) { | 92 while (audio_output_index_ < parsed_stream_.GetNumberOfEvents()) { |
| 80 if (parsed_stream_.GetEventType(audio_output_index_) == | 93 if (parsed_stream_.GetEventType(audio_output_index_) == |
| 81 ParsedRtcEventLog::AUDIO_PLAYOUT_EVENT) { | 94 ParsedRtcEventLog::AUDIO_PLAYOUT_EVENT) { |
| 82 uint64_t timestamp_us = parsed_stream_.GetTimestamp(audio_output_index_); | 95 uint64_t timestamp_us = parsed_stream_.GetTimestamp(audio_output_index_); |
| 83 // We call GetAudioPlayout only to check that the protobuf event is | 96 // We call GetAudioPlayout only to check that the protobuf event is |
| 84 // well-formed. | 97 // well-formed. |
| 85 parsed_stream_.GetAudioPlayout(audio_output_index_, nullptr); | 98 parsed_stream_.GetAudioPlayout(audio_output_index_, nullptr); |
| 86 audio_output_index_++; | 99 audio_output_index_++; |
| 87 return timestamp_us / 1000; | 100 return timestamp_us / 1000; |
| 88 } | 101 } |
| 89 audio_output_index_++; | 102 audio_output_index_++; |
| 90 } | 103 } |
| 91 return std::numeric_limits<int64_t>::max(); | 104 return std::numeric_limits<int64_t>::max(); |
| 92 } | 105 } |
| 93 | 106 |
| 94 RtcEventLogSource::RtcEventLogSource() | 107 RtcEventLogSource::RtcEventLogSource() |
| 95 : PacketSource(), parser_(RtpHeaderParser::Create()) {} | 108 : PacketSource(), parser_(RtpHeaderParser::Create()) {} |
| 96 | 109 |
| 97 bool RtcEventLogSource::OpenFile(const std::string& file_name) { | 110 bool RtcEventLogSource::OpenFile(const std::string& file_name) { |
| 98 return parsed_stream_.ParseFile(file_name); | 111 return parsed_stream_.ParseFile(file_name); |
| 99 } | 112 } |
| 100 | 113 |
| 114 bool RtcEventLogSource::IsAudioSsrc(uint32_t ssrc) const { |
| 115 return std::find(streams_.begin(), streams_.end(), ssrc) != streams_.end(); |
| 116 } |
| 117 |
| 101 } // namespace test | 118 } // namespace test |
| 102 } // namespace webrtc | 119 } // namespace webrtc |
| OLD | NEW |