Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: webrtc/modules/audio_coding/neteq/tools/rtc_event_log_source.cc

Issue 2855143002: Removed RtcEventLog deps to call:call_interfaces. (Closed)
Patch Set: Formatting. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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_++) {
43 if (parsed_stream_.GetEventType(rtp_packet_index_) == 44 if (parsed_stream_.GetEventType(rtp_packet_index_) ==
44 ParsedRtcEventLog::RTP_EVENT) { 45 ParsedRtcEventLog::RTP_EVENT) {
45 PacketDirection direction; 46 PacketDirection direction;
46 MediaType media_type;
47 size_t header_length; 47 size_t header_length;
48 size_t packet_length; 48 size_t packet_length;
49 uint64_t timestamp_us = parsed_stream_.GetTimestamp(rtp_packet_index_); 49 uint64_t timestamp_us = parsed_stream_.GetTimestamp(rtp_packet_index_);
50 parsed_stream_.GetRtpHeader(rtp_packet_index_, &direction, &media_type, 50 parsed_stream_.GetRtpHeader(rtp_packet_index_, &direction, nullptr,
51 nullptr, &header_length, &packet_length); 51 &header_length, &packet_length);
52 if (direction == kIncomingPacket && media_type == MediaType::AUDIO) { 52
53 uint8_t* packet_header = new uint8_t[header_length]; 53 if (direction != kIncomingPacket) {
54 parsed_stream_.GetRtpHeader(rtp_packet_index_, nullptr, nullptr, 54 continue;
55 packet_header, nullptr, nullptr); 55 }
56 std::unique_ptr<Packet> packet(new Packet( 56
57 packet_header, header_length, packet_length, 57 uint8_t* packet_header = new uint8_t[header_length];
58 static_cast<double>(timestamp_us) / 1000, *parser_.get())); 58 parsed_stream_.GetRtpHeader(rtp_packet_index_, nullptr, packet_header,
59 if (packet->valid_header()) { 59 nullptr, nullptr);
60 // Check if the packet should not be filtered out. 60 std::unique_ptr<Packet> packet(
61 if (!filter_.test(packet->header().payloadType) && 61 new Packet(packet_header, header_length, packet_length,
62 !(use_ssrc_filter_ && packet->header().ssrc != ssrc_)) { 62 static_cast<double>(timestamp_us) / 1000, *parser_.get()));
63 rtp_packet_index_++; 63
64 return packet; 64 if (!packet->valid_header()) {
65 } 65 std::cout << "Warning: Packet with index " << rtp_packet_index_
66 } else { 66 << " has an invalid header and will be ignored." << std::endl;
67 std::cout << "Warning: Packet with index " << rtp_packet_index_ 67 continue;
68 << " has an invalid header and will be ignored." 68 }
69 << std::endl; 69
70 } 70 if (parsed_stream_.GetMediaType(packet->header().ssrc, direction) !=
71 webrtc::ParsedRtcEventLog::MediaType::AUDIO) {
72 continue;
73 }
74
75 // Check if the packet should not be filtered out.
76 if (!filter_.test(packet->header().payloadType) &&
77 !(use_ssrc_filter_ && packet->header().ssrc != ssrc_)) {
78 return packet;
71 } 79 }
72 } 80 }
73 rtp_packet_index_++;
74 } 81 }
75 return nullptr; 82 return nullptr;
76 } 83 }
77 84
78 int64_t RtcEventLogSource::NextAudioOutputEventMs() { 85 int64_t RtcEventLogSource::NextAudioOutputEventMs() {
79 while (audio_output_index_ < parsed_stream_.GetNumberOfEvents()) { 86 while (audio_output_index_ < parsed_stream_.GetNumberOfEvents()) {
80 if (parsed_stream_.GetEventType(audio_output_index_) == 87 if (parsed_stream_.GetEventType(audio_output_index_) ==
81 ParsedRtcEventLog::AUDIO_PLAYOUT_EVENT) { 88 ParsedRtcEventLog::AUDIO_PLAYOUT_EVENT) {
82 uint64_t timestamp_us = parsed_stream_.GetTimestamp(audio_output_index_); 89 uint64_t timestamp_us = parsed_stream_.GetTimestamp(audio_output_index_);
83 // We call GetAudioPlayout only to check that the protobuf event is 90 // We call GetAudioPlayout only to check that the protobuf event is
84 // well-formed. 91 // well-formed.
85 parsed_stream_.GetAudioPlayout(audio_output_index_, nullptr); 92 parsed_stream_.GetAudioPlayout(audio_output_index_, nullptr);
86 audio_output_index_++; 93 audio_output_index_++;
87 return timestamp_us / 1000; 94 return timestamp_us / 1000;
88 } 95 }
89 audio_output_index_++; 96 audio_output_index_++;
90 } 97 }
91 return std::numeric_limits<int64_t>::max(); 98 return std::numeric_limits<int64_t>::max();
92 } 99 }
93 100
94 RtcEventLogSource::RtcEventLogSource() 101 RtcEventLogSource::RtcEventLogSource()
95 : PacketSource(), parser_(RtpHeaderParser::Create()) {} 102 : PacketSource(), parser_(RtpHeaderParser::Create()) {}
96 103
97 bool RtcEventLogSource::OpenFile(const std::string& file_name) { 104 bool RtcEventLogSource::OpenFile(const std::string& file_name) {
98 return parsed_stream_.ParseFile(file_name); 105 return parsed_stream_.ParseFile(file_name);
99 } 106 }
100 107
101 } // namespace test 108 } // namespace test
102 } // namespace webrtc 109 } // namespace webrtc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698