Exemplo n.º 1
0
  def PrintSsrcInfo(self, ssrc_id, ssrc):
    """Prints packet and size statistics for a given SSRC.

    Args:
        ssrc_id: textual identifier of SSRC printed beside statistics for it.
        ssrc: SSRC by which to filter data and display statistics
    """
    filtered_ssrc = [point for point in self.data_points if point.ssrc
                     == ssrc]
    payloads = misc.NormalizeCounter(
        collections.Counter([point.payload_type for point in
                             filtered_ssrc]))

    payload_info = "payload type(s): {}".format(
        ", ".join(str(payload) for payload in  payloads))
    print("{} 0x{:x} {}, {:.2f}% packets, {:.2f}% data".format(
        ssrc_id, ssrc, payload_info, self.ssrc_frequencies[ssrc] * 100,
        self.ssrc_size_table[ssrc] * 100))
    print("  packet sizes:")
    (bin_counts, bin_bounds) = numpy.histogram([point.size for point in
                                                filtered_ssrc], bins=5,
                                               density=False)
    bin_proportions = bin_counts / sum(bin_counts)
    print("\n".join([
        " {:.1f} - {:.1f}: {:.2f}%".format(bin_bounds[i], bin_bounds[i + 1],
                                           bin_proportions[i] * 100)
        for i in range(len(bin_proportions))
    ]))
Exemplo n.º 2
0
  def __init__(self, data_points):
    """Initializes object with data_points and computes simple statistics.

    Computes percentages of number of packets and packet sizes by
    SSRC.

    Args:
        data_points: list of pb_parse.DataPoints on which statistics are
            calculated.

    """

    self.data_points = data_points
    self.ssrc_frequencies = misc.NormalizeCounter(
        collections.Counter([pt.ssrc for pt in self.data_points]))
    self.ssrc_size_table = misc.SsrcNormalizedSizeTable(self.data_points)
    self.bandwidth_kbps = None
    self.smooth_bw_kbps = None