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 | 33 |
34 RtcEventLogSource::~RtcEventLogSource() {} | 34 RtcEventLogSource::~RtcEventLogSource() {} |
35 | 35 |
36 bool RtcEventLogSource::RegisterRtpHeaderExtension(RTPExtensionType type, | 36 bool RtcEventLogSource::RegisterRtpHeaderExtension(RTPExtensionType type, |
37 uint8_t id) { | 37 uint8_t id) { |
38 RTC_CHECK(parser_.get()); | 38 RTC_CHECK(parser_.get()); |
39 return parser_->RegisterRtpHeaderExtension(type, id); | 39 return parser_->RegisterRtpHeaderExtension(type, id); |
40 } | 40 } |
41 | 41 |
42 Packet* RtcEventLogSource::NextPacket() { | 42 std::unique_ptr<Packet> RtcEventLogSource::NextPacket() { |
43 while (rtp_packet_index_ < parsed_stream_.GetNumberOfEvents()) { | 43 while (rtp_packet_index_ < parsed_stream_.GetNumberOfEvents()) { |
44 if (parsed_stream_.GetEventType(rtp_packet_index_) == | 44 if (parsed_stream_.GetEventType(rtp_packet_index_) == |
45 ParsedRtcEventLog::RTP_EVENT) { | 45 ParsedRtcEventLog::RTP_EVENT) { |
46 PacketDirection direction; | 46 PacketDirection direction; |
47 MediaType media_type; | 47 MediaType media_type; |
48 size_t header_length; | 48 size_t header_length; |
49 size_t packet_length; | 49 size_t packet_length; |
50 uint64_t timestamp_us = parsed_stream_.GetTimestamp(rtp_packet_index_); | 50 uint64_t timestamp_us = parsed_stream_.GetTimestamp(rtp_packet_index_); |
51 parsed_stream_.GetRtpHeader(rtp_packet_index_, &direction, &media_type, | 51 parsed_stream_.GetRtpHeader(rtp_packet_index_, &direction, &media_type, |
52 nullptr, &header_length, &packet_length); | 52 nullptr, &header_length, &packet_length); |
53 if (direction == kIncomingPacket && media_type == MediaType::AUDIO) { | 53 if (direction == kIncomingPacket && media_type == MediaType::AUDIO) { |
54 uint8_t* packet_header = new uint8_t[header_length]; | 54 uint8_t* packet_header = new uint8_t[header_length]; |
55 parsed_stream_.GetRtpHeader(rtp_packet_index_, nullptr, nullptr, | 55 parsed_stream_.GetRtpHeader(rtp_packet_index_, nullptr, nullptr, |
56 packet_header, nullptr, nullptr); | 56 packet_header, nullptr, nullptr); |
57 Packet* packet = new Packet(packet_header, header_length, packet_length, | 57 std::unique_ptr<Packet> packet(new Packet( |
58 static_cast<double>(timestamp_us) / 1000, | 58 packet_header, header_length, packet_length, |
59 *parser_.get()); | 59 static_cast<double>(timestamp_us) / 1000, *parser_.get())); |
60 if (packet->valid_header()) { | 60 if (packet->valid_header()) { |
61 // Check if the packet should not be filtered out. | 61 // Check if the packet should not be filtered out. |
62 if (!filter_.test(packet->header().payloadType) && | 62 if (!filter_.test(packet->header().payloadType) && |
63 !(use_ssrc_filter_ && packet->header().ssrc != ssrc_)) { | 63 !(use_ssrc_filter_ && packet->header().ssrc != ssrc_)) { |
64 rtp_packet_index_++; | 64 rtp_packet_index_++; |
65 return packet; | 65 return packet; |
66 } | 66 } |
67 } else { | 67 } else { |
68 std::cout << "Warning: Packet with index " << rtp_packet_index_ | 68 std::cout << "Warning: Packet with index " << rtp_packet_index_ |
69 << " has an invalid header and will be ignored." | 69 << " has an invalid header and will be ignored." |
70 << std::endl; | 70 << std::endl; |
71 } | 71 } |
72 // The packet has either an invalid header or needs to be filtered out, | |
73 // so it can be deleted. | |
74 delete packet; | |
75 } | 72 } |
76 } | 73 } |
77 rtp_packet_index_++; | 74 rtp_packet_index_++; |
78 } | 75 } |
79 return nullptr; | 76 return nullptr; |
80 } | 77 } |
81 | 78 |
82 int64_t RtcEventLogSource::NextAudioOutputEventMs() { | 79 int64_t RtcEventLogSource::NextAudioOutputEventMs() { |
83 while (audio_output_index_ < parsed_stream_.GetNumberOfEvents()) { | 80 while (audio_output_index_ < parsed_stream_.GetNumberOfEvents()) { |
84 if (parsed_stream_.GetEventType(audio_output_index_) == | 81 if (parsed_stream_.GetEventType(audio_output_index_) == |
(...skipping 12 matching lines...) Expand all Loading... |
97 | 94 |
98 RtcEventLogSource::RtcEventLogSource() | 95 RtcEventLogSource::RtcEventLogSource() |
99 : PacketSource(), parser_(RtpHeaderParser::Create()) {} | 96 : PacketSource(), parser_(RtpHeaderParser::Create()) {} |
100 | 97 |
101 bool RtcEventLogSource::OpenFile(const std::string& file_name) { | 98 bool RtcEventLogSource::OpenFile(const std::string& file_name) { |
102 return parsed_stream_.ParseFile(file_name); | 99 return parsed_stream_.ParseFile(file_name); |
103 } | 100 } |
104 | 101 |
105 } // namespace test | 102 } // namespace test |
106 } // namespace webrtc | 103 } // namespace webrtc |
OLD | NEW |