OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2016 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
292 } | 292 } |
293 } | 293 } |
294 | 294 |
295 } // namespace | 295 } // namespace |
296 | 296 |
297 EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log) | 297 EventLogAnalyzer::EventLogAnalyzer(const ParsedRtcEventLog& log) |
298 : parsed_log_(log), window_duration_(250000), step_(10000) { | 298 : parsed_log_(log), window_duration_(250000), step_(10000) { |
299 uint64_t first_timestamp = std::numeric_limits<uint64_t>::max(); | 299 uint64_t first_timestamp = std::numeric_limits<uint64_t>::max(); |
300 uint64_t last_timestamp = std::numeric_limits<uint64_t>::min(); | 300 uint64_t last_timestamp = std::numeric_limits<uint64_t>::min(); |
301 | 301 |
302 // Maps a stream identifier consisting of ssrc and direction | |
303 // to the header extensions used by that stream, | |
304 std::map<StreamId, RtpHeaderExtensionMap> extension_maps; | |
305 | |
306 PacketDirection direction; | 302 PacketDirection direction; |
307 uint8_t header[IP_PACKET_SIZE]; | 303 uint8_t header[IP_PACKET_SIZE]; |
308 size_t header_length; | 304 size_t header_length; |
309 size_t total_length; | 305 size_t total_length; |
310 | 306 |
311 uint8_t last_incoming_rtcp_packet[IP_PACKET_SIZE]; | 307 uint8_t last_incoming_rtcp_packet[IP_PACKET_SIZE]; |
312 uint8_t last_incoming_rtcp_packet_length = 0; | 308 uint8_t last_incoming_rtcp_packet_length = 0; |
313 | 309 |
314 // Make a default extension map for streams without configuration information. | 310 // Make a default extension map for streams without configuration information. |
315 // TODO(ivoc): Once configuration of audio streams is stored in the event log, | 311 // TODO(ivoc): Once configuration of audio streams is stored in the event log, |
(...skipping 10 matching lines...) Expand all Loading... |
326 event_type != ParsedRtcEventLog::LOG_END) { | 322 event_type != ParsedRtcEventLog::LOG_END) { |
327 uint64_t timestamp = parsed_log_.GetTimestamp(i); | 323 uint64_t timestamp = parsed_log_.GetTimestamp(i); |
328 first_timestamp = std::min(first_timestamp, timestamp); | 324 first_timestamp = std::min(first_timestamp, timestamp); |
329 last_timestamp = std::max(last_timestamp, timestamp); | 325 last_timestamp = std::max(last_timestamp, timestamp); |
330 } | 326 } |
331 | 327 |
332 switch (parsed_log_.GetEventType(i)) { | 328 switch (parsed_log_.GetEventType(i)) { |
333 case ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT: { | 329 case ParsedRtcEventLog::VIDEO_RECEIVER_CONFIG_EVENT: { |
334 rtclog::StreamConfig config = parsed_log_.GetVideoReceiveConfig(i); | 330 rtclog::StreamConfig config = parsed_log_.GetVideoReceiveConfig(i); |
335 StreamId stream(config.remote_ssrc, kIncomingPacket); | 331 StreamId stream(config.remote_ssrc, kIncomingPacket); |
336 extension_maps[stream] = RtpHeaderExtensionMap(config.rtp_extensions); | |
337 video_ssrcs_.insert(stream); | 332 video_ssrcs_.insert(stream); |
338 StreamId rtx_stream(config.rtx_ssrc, kIncomingPacket); | 333 StreamId rtx_stream(config.rtx_ssrc, kIncomingPacket); |
339 extension_maps[rtx_stream] = | |
340 RtpHeaderExtensionMap(config.rtp_extensions); | |
341 video_ssrcs_.insert(rtx_stream); | 334 video_ssrcs_.insert(rtx_stream); |
342 rtx_ssrcs_.insert(rtx_stream); | 335 rtx_ssrcs_.insert(rtx_stream); |
343 break; | 336 break; |
344 } | 337 } |
345 case ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT: { | 338 case ParsedRtcEventLog::VIDEO_SENDER_CONFIG_EVENT: { |
346 std::vector<rtclog::StreamConfig> configs = | 339 std::vector<rtclog::StreamConfig> configs = |
347 parsed_log_.GetVideoSendConfig(i); | 340 parsed_log_.GetVideoSendConfig(i); |
348 for (const auto& config : configs) { | 341 for (const auto& config : configs) { |
349 StreamId stream(config.local_ssrc, kOutgoingPacket); | 342 StreamId stream(config.local_ssrc, kOutgoingPacket); |
350 extension_maps[stream] = | |
351 RtpHeaderExtensionMap(config.rtp_extensions); | |
352 video_ssrcs_.insert(stream); | 343 video_ssrcs_.insert(stream); |
353 StreamId rtx_stream(config.rtx_ssrc, kOutgoingPacket); | 344 StreamId rtx_stream(config.rtx_ssrc, kOutgoingPacket); |
354 extension_maps[rtx_stream] = | |
355 RtpHeaderExtensionMap(config.rtp_extensions); | |
356 video_ssrcs_.insert(rtx_stream); | 345 video_ssrcs_.insert(rtx_stream); |
357 rtx_ssrcs_.insert(rtx_stream); | 346 rtx_ssrcs_.insert(rtx_stream); |
358 } | 347 } |
359 break; | 348 break; |
360 } | 349 } |
361 case ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT: { | 350 case ParsedRtcEventLog::AUDIO_RECEIVER_CONFIG_EVENT: { |
362 rtclog::StreamConfig config = parsed_log_.GetAudioReceiveConfig(i); | 351 rtclog::StreamConfig config = parsed_log_.GetAudioReceiveConfig(i); |
363 StreamId stream(config.remote_ssrc, kIncomingPacket); | 352 StreamId stream(config.remote_ssrc, kIncomingPacket); |
364 extension_maps[stream] = RtpHeaderExtensionMap(config.rtp_extensions); | |
365 audio_ssrcs_.insert(stream); | 353 audio_ssrcs_.insert(stream); |
366 break; | 354 break; |
367 } | 355 } |
368 case ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT: { | 356 case ParsedRtcEventLog::AUDIO_SENDER_CONFIG_EVENT: { |
369 rtclog::StreamConfig config = parsed_log_.GetAudioSendConfig(i); | 357 rtclog::StreamConfig config = parsed_log_.GetAudioSendConfig(i); |
370 StreamId stream(config.local_ssrc, kOutgoingPacket); | 358 StreamId stream(config.local_ssrc, kOutgoingPacket); |
371 extension_maps[stream] = RtpHeaderExtensionMap(config.rtp_extensions); | |
372 audio_ssrcs_.insert(stream); | 359 audio_ssrcs_.insert(stream); |
373 break; | 360 break; |
374 } | 361 } |
375 case ParsedRtcEventLog::RTP_EVENT: { | 362 case ParsedRtcEventLog::RTP_EVENT: { |
376 parsed_log_.GetRtpHeader(i, &direction, header, &header_length, | 363 RtpHeaderExtensionMap* extension_map = parsed_log_.GetRtpHeader( |
377 &total_length); | 364 i, &direction, header, &header_length, &total_length); |
378 // Parse header to get SSRC. | |
379 RtpUtility::RtpHeaderParser rtp_parser(header, header_length); | 365 RtpUtility::RtpHeaderParser rtp_parser(header, header_length); |
380 RTPHeader parsed_header; | 366 RTPHeader parsed_header; |
381 rtp_parser.Parse(&parsed_header); | 367 if (extension_map != nullptr) { |
382 StreamId stream(parsed_header.ssrc, direction); | |
383 // Look up the extension_map and parse it again to get the extensions. | |
384 if (extension_maps.count(stream) == 1) { | |
385 RtpHeaderExtensionMap* extension_map = &extension_maps[stream]; | |
386 rtp_parser.Parse(&parsed_header, extension_map); | 368 rtp_parser.Parse(&parsed_header, extension_map); |
387 } else { | 369 } else { |
388 // Use the default extension map. | 370 // Use the default extension map. |
389 // TODO(ivoc): Once configuration of audio streams is stored in the | 371 // TODO(ivoc): Once configuration of audio streams is stored in the |
390 // event log, this can be removed. | 372 // event log, this can be removed. |
391 // Tracking bug: webrtc:6399 | 373 // Tracking bug: webrtc:6399 |
392 rtp_parser.Parse(&parsed_header, &default_extension_map); | 374 rtp_parser.Parse(&parsed_header, &default_extension_map); |
393 } | 375 } |
394 uint64_t timestamp = parsed_log_.GetTimestamp(i); | 376 uint64_t timestamp = parsed_log_.GetTimestamp(i); |
| 377 StreamId stream(parsed_header.ssrc, direction); |
395 rtp_packets_[stream].push_back( | 378 rtp_packets_[stream].push_back( |
396 LoggedRtpPacket(timestamp, parsed_header, total_length)); | 379 LoggedRtpPacket(timestamp, parsed_header, total_length)); |
397 break; | 380 break; |
398 } | 381 } |
399 case ParsedRtcEventLog::RTCP_EVENT: { | 382 case ParsedRtcEventLog::RTCP_EVENT: { |
400 uint8_t packet[IP_PACKET_SIZE]; | 383 uint8_t packet[IP_PACKET_SIZE]; |
401 parsed_log_.GetRtcpPacket(i, &direction, packet, &total_length); | 384 parsed_log_.GetRtcpPacket(i, &direction, packet, &total_length); |
402 // Currently incoming RTCP packets are logged twice, both for audio and | 385 // Currently incoming RTCP packets are logged twice, both for audio and |
403 // video. Only act on one of them. Compare against the previous parsed | 386 // video. Only act on one of them. Compare against the previous parsed |
404 // incoming RTCP packet. | 387 // incoming RTCP packet. |
(...skipping 986 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1391 }, | 1374 }, |
1392 audio_network_adaptation_events_, begin_time_, &time_series); | 1375 audio_network_adaptation_events_, begin_time_, &time_series); |
1393 plot->AppendTimeSeries(std::move(time_series)); | 1376 plot->AppendTimeSeries(std::move(time_series)); |
1394 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); | 1377 plot->SetXAxis(0, call_duration_s_, "Time (s)", kLeftMargin, kRightMargin); |
1395 plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))", | 1378 plot->SetSuggestedYAxis(0, 1, "Number of channels (1 (mono)/2 (stereo))", |
1396 kBottomMargin, kTopMargin); | 1379 kBottomMargin, kTopMargin); |
1397 plot->SetTitle("Reported audio encoder number of channels"); | 1380 plot->SetTitle("Reported audio encoder number of channels"); |
1398 } | 1381 } |
1399 } // namespace plotting | 1382 } // namespace plotting |
1400 } // namespace webrtc | 1383 } // namespace webrtc |
OLD | NEW |