• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 /*
3  *  Copyright (c) 2020 The WebRTC project authors. All Rights Reserved.
4  *
5  *  Use of this source code is governed by a BSD-style license
6  *  that can be found in the LICENSE file in the root of the source
7  *  tree. An additional intellectual property rights grant can be found
8  *  in the file PATENTS.  All contributing project authors may
9  *  be found in the AUTHORS file in the root of the source tree.
10  */
11 
12 #include "rtc_tools/rtc_event_log_visualizer/analyzer_common.h"
13 
14 namespace webrtc {
15 
IsRtxSsrc(const ParsedRtcEventLog & parsed_log,PacketDirection direction,uint32_t ssrc)16 bool IsRtxSsrc(const ParsedRtcEventLog& parsed_log,
17                PacketDirection direction,
18                uint32_t ssrc) {
19   if (direction == kIncomingPacket) {
20     return parsed_log.incoming_rtx_ssrcs().find(ssrc) !=
21            parsed_log.incoming_rtx_ssrcs().end();
22   } else {
23     return parsed_log.outgoing_rtx_ssrcs().find(ssrc) !=
24            parsed_log.outgoing_rtx_ssrcs().end();
25   }
26 }
27 
IsVideoSsrc(const ParsedRtcEventLog & parsed_log,PacketDirection direction,uint32_t ssrc)28 bool IsVideoSsrc(const ParsedRtcEventLog& parsed_log,
29                  PacketDirection direction,
30                  uint32_t ssrc) {
31   if (direction == kIncomingPacket) {
32     return parsed_log.incoming_video_ssrcs().find(ssrc) !=
33            parsed_log.incoming_video_ssrcs().end();
34   } else {
35     return parsed_log.outgoing_video_ssrcs().find(ssrc) !=
36            parsed_log.outgoing_video_ssrcs().end();
37   }
38 }
39 
IsAudioSsrc(const ParsedRtcEventLog & parsed_log,PacketDirection direction,uint32_t ssrc)40 bool IsAudioSsrc(const ParsedRtcEventLog& parsed_log,
41                  PacketDirection direction,
42                  uint32_t ssrc) {
43   if (direction == kIncomingPacket) {
44     return parsed_log.incoming_audio_ssrcs().find(ssrc) !=
45            parsed_log.incoming_audio_ssrcs().end();
46   } else {
47     return parsed_log.outgoing_audio_ssrcs().find(ssrc) !=
48            parsed_log.outgoing_audio_ssrcs().end();
49   }
50 }
51 
GetStreamName(const ParsedRtcEventLog & parsed_log,PacketDirection direction,uint32_t ssrc)52 std::string GetStreamName(const ParsedRtcEventLog& parsed_log,
53                           PacketDirection direction,
54                           uint32_t ssrc) {
55   char buffer[200];
56   rtc::SimpleStringBuilder name(buffer);
57   if (IsAudioSsrc(parsed_log, direction, ssrc)) {
58     name << "Audio ";
59   } else if (IsVideoSsrc(parsed_log, direction, ssrc)) {
60     name << "Video ";
61   } else {
62     name << "Unknown ";
63   }
64   if (IsRtxSsrc(parsed_log, direction, ssrc)) {
65     name << "RTX ";
66   }
67   if (direction == kIncomingPacket)
68     name << "(In) ";
69   else
70     name << "(Out) ";
71   name << "SSRC " << ssrc;
72   return name.str();
73 }
74 
GetLayerName(LayerDescription layer)75 std::string GetLayerName(LayerDescription layer) {
76   char buffer[100];
77   rtc::SimpleStringBuilder name(buffer);
78   name << "SSRC " << layer.ssrc << " sl " << layer.spatial_layer << ", tl "
79        << layer.temporal_layer;
80   return name.str();
81 }
82 
83 }  // namespace webrtc
84