Esempio n. 1
0
    def filter_ssrc(self, chosen_ssrc):
        """Filters and wraps data points.

    Removes data points with `ssrc != chosen_ssrc`. Unwraps sequence
    numbers and timestamps for the chosen selection.
    """
        self.data_points = [point for point in self.data_points if point.ssrc == chosen_ssrc]
        unwrapped_sequence_numbers = misc.unwrap([point.sequence_number for point in self.data_points], 2 ** 16 - 1)
        for (data_point, sequence_number) in zip(self.data_points, unwrapped_sequence_numbers):
            data_point.sequence_number = sequence_number

        unwrapped_timestamps = misc.unwrap([point.timestamp for point in self.data_points], 2 ** 32 - 1)

        for (data_point, timestamp) in zip(self.data_points, unwrapped_timestamps):
            data_point.timestamp = timestamp
Esempio n. 2
0
  def testRandomlyDataShouldNotChangeAfterUnwrap(self):
    random_data = [random.randint(0, 9) for _ in range(100)]
    random_data_copy = random_data[:]
    for mod in range(1, 100):
      _ = misc.unwrap(random_data, mod)

      self.assertEqual(random_data, random_data_copy)
Esempio n. 3
0
    def testRandomlyDataShouldNotChangeAfterUnwrap(self):
        random_data = [random.randint(0, 9) for _ in range(100)]
        random_data_copy = random_data[:]
        for mod in range(1, 100):
            _ = misc.unwrap(random_data, mod)

            self.assertEqual(random_data, random_data_copy)
Esempio n. 4
0
  def testRandomlyMultiplesOfModAdded(self):
    # `unwrap` definition says only multiples of mod are added.
    random_data = [random.randint(0, 9) for _ in range(100)]

    for mod in range(1, 100):
      random_data_unwrapped_mod = misc.unwrap(random_data, mod)

      for (old_a, a) in zip(random_data, random_data_unwrapped_mod):
        self.assertEqual((old_a - a) % mod, 0)
Esempio n. 5
0
    def testRandomlyMultiplesOfModAdded(self):
        # `unwrap` definition says only multiples of mod are added.
        random_data = [random.randint(0, 9) for _ in range(100)]

        for mod in range(1, 100):
            random_data_unwrapped_mod = misc.unwrap(random_data, mod)

            for (old_a, a) in zip(random_data, random_data_unwrapped_mod):
                self.assertEqual((old_a - a) % mod, 0)
Esempio n. 6
0
  def testRandomlyAgainstInequalityDefinition(self):
    # Data has to satisfy -mod/2 <= difference < mod/2 for every
    # difference between consecutive values after unwrap.
    random_data = [random.randint(0, 9) for _ in range(100)]

    for mod in range(1, 100):
      random_data_unwrapped_mod = misc.unwrap(random_data, mod)

      for (a, b) in zip(random_data_unwrapped_mod,
                        random_data_unwrapped_mod[1:]):
        self.assertTrue(-mod / 2 <= b - a < mod / 2)
Esempio n. 7
0
  def filter_ssrc(self, chosen_ssrc):
    """Filters and wraps data points.

    Removes data points with `ssrc != chosen_ssrc`. Unwraps sequence
    numbers and timestamps for the chosen selection.
    """
    self.data_points = [point for point in self.data_points if
                        point.ssrc == chosen_ssrc]
    unwrapped_sequence_numbers = misc.unwrap(
        [point.sequence_number for point in self.data_points], 2**16 - 1)
    for (data_point, sequence_number) in zip(self.data_points,
                                             unwrapped_sequence_numbers):
      data_point.sequence_number = sequence_number

    unwrapped_timestamps = misc.unwrap([point.timestamp for point in
                                        self.data_points], 2**32 - 1)

    for (data_point, timestamp) in zip(self.data_points,
                                       unwrapped_timestamps):
      data_point.timestamp = timestamp
Esempio n. 8
0
    def testRandomlyAgainstInequalityDefinition(self):
        # Data has to satisfy -mod/2 <= difference < mod/2 for every
        # difference between consecutive values after unwrap.
        random_data = [random.randint(0, 9) for _ in range(100)]

        for mod in range(1, 100):
            random_data_unwrapped_mod = misc.unwrap(random_data, mod)

            for (a, b) in zip(random_data_unwrapped_mod,
                              random_data_unwrapped_mod[1:]):
                self.assertTrue(-mod / 2 <= b - a < mod / 2)
Esempio n. 9
0
  def testDataShouldNotChangeAfterUnwrap(self):
    data = [0, 1, 2, 0, -1, -2, -3, -4]
    _ = misc.unwrap(data, 4)

    self.assertEqual([0, 1, 2, 0, -1, -2, -3, -4], data)
Esempio n. 10
0
 def testUnwrapMod4(self):
   data = [0, 1, 2, 0, -1, -2, -3, -4]
   unwrapped_4 = misc.unwrap(data, 4)
   self.assertEqual([0, 1, 2, 0, -1, -2, -3, -4], unwrapped_4)
Esempio n. 11
0
 def testUnwrapMod3(self):
   data = [0, 1, 2, 0, -1, -2, -3, -4]
   unwrapped_3 = misc.unwrap(data, 3)
   self.assertEqual([0, 1, 2, 3, 2, 1, 0, -1], unwrapped_3)
Esempio n. 12
0
    def testDataShouldNotChangeAfterUnwrap(self):
        data = [0, 1, 2, 0, -1, -2, -3, -4]
        _ = misc.unwrap(data, 4)

        self.assertEqual([0, 1, 2, 0, -1, -2, -3, -4], data)
Esempio n. 13
0
 def testUnwrapMod4(self):
     data = [0, 1, 2, 0, -1, -2, -3, -4]
     unwrapped_4 = misc.unwrap(data, 4)
     self.assertEqual([0, 1, 2, 0, -1, -2, -3, -4], unwrapped_4)
Esempio n. 14
0
 def testUnwrapMod3(self):
     data = [0, 1, 2, 0, -1, -2, -3, -4]
     unwrapped_3 = misc.unwrap(data, 3)
     self.assertEqual([0, 1, 2, 3, 2, 1, 0, -1], unwrapped_3)