예제 #1
0
	def test_loopback_rand_rs_int(self):
		"""
		Loopback of data, (de)randomiser, rs (en/de)coder, (de)interleaver
		"""
		src_data = make_transport_stream()
		# Disregard end bytes of source data, accounting for interleaver delay
		expected_delay = dvb_interleaver_bb.DELAY * \
				dvb_swig.MPEG_TS_PKT_LENGTH / dvb_swig.DVB_RS_ENCODED_LENGTH
		expected_result = tuple(src_data[:-expected_delay])

		src = gr.vector_source_b(src_data)
		txpad = dvb_swig.pad_mpeg_ts_packet_bp()
		randomizer = dvb_swig.randomizer_pp()
		rs_encoder = dvb_swig.rs_encoder_pp()
		txdepad = dvb_swig.depad_dvb_packet_rs_encoded_pb()
		interleaver = dvb_interleaver_bb.interleaver_bb()
		deinterleaver = dvb_interleaver_bb.deinterleaver_bb()
		rxpad = dvb_swig.pad_dvb_packet_rs_encoded_bp()
		rs_decoder = dvb_swig.rs_decoder_pp()
		derandomizer = dvb_swig.derandomizer_pp()
		rxdepad = dvb_swig.depad_mpeg_ts_packet_pb()
		dst = gr.vector_sink_b()

		# Connect and run
		self.tb.connect(src, txpad, randomizer, rs_encoder, txdepad, interleaver, deinterleaver)
		self.tb.connect(deinterleaver, rxpad, rs_decoder, derandomizer, rxdepad, dst)
		self.tb.run()
		# Check that the decoded bytes are the same as original
		self.assertEqual(expected_result, dst.data())
예제 #2
0
	def derandomizer_pp_desync(self, offset):
		"""
		Tests the ability of the derandomiser to synchronise when the inverted SYNC is <offset> packets away
		Note: This method itself is not a unit test method.
		"""
		assert offset < 8

		useful_data = make_transport_stream()
		src = gr.vector_source_b(useful_data)
		pad = dvb_swig.pad_mpeg_ts_packet_bp()
		randomizer = dvb_swig.randomizer_pp()
		depad = dvb_swig.depad_mpeg_ts_packet_pb()
		dst = gr.vector_sink_b()
		self.tb.connect(src, pad, randomizer, depad, dst)
		self.tb.run()
		randomized_data = dst.data()

		src_data = make_fake_transport_stream_packet(offset)
		src_data.extend(randomized_data)

		self.tb = gr.top_block()
		src = gr.vector_source_b(src_data)
		pad = dvb_swig.pad_mpeg_ts_packet_bp()
		derandomizer = dvb_swig.derandomizer_pp()
		depad = dvb_swig.depad_mpeg_ts_packet_pb()
		dst = gr.vector_sink_b()

		self.tb.connect(src, pad, derandomizer, depad, dst)
		self.tb.run()
		result_data = dst.data()
		self.assertEqual(tuple(useful_data), result_data[-len(useful_data):])
예제 #3
0
	def test_loopback_rand_rs(self):
		"""
		Loopback src > randomiser > rs encoder > rs decoder > derandomiser > dst
		"""
		src_data = make_transport_stream()

		src = gr.vector_source_b(src_data)
		pad = dvb_swig.pad_mpeg_ts_packet_bp()
		randomizer = dvb_swig.randomizer_pp()
		rs_encoder = dvb_swig.rs_encoder_pp()
		rs_decoder = dvb_swig.rs_decoder_pp()
		derandomizer = dvb_swig.derandomizer_pp()
		depad = dvb_swig.depad_mpeg_ts_packet_pb()
		dst = gr.vector_sink_b()

		# Connect and run
		self.tb.connect(src, pad, randomizer, rs_encoder, rs_decoder, derandomizer, depad, dst)
		self.tb.run()
		# Check that the decoded bytes are the same as original
		self.assertEqual(src_data, dst.data())
예제 #4
0
	def test_randomizer_pp_sync_bytes(self):
		"""
		Tests correctness of sync bytes
		"""
		src_data = make_transport_stream()
		check_sync_bytes(self, src_data)

		src = gr.vector_source_b(src_data)
		pad = dvb_swig.pad_mpeg_ts_packet_bp()
		randomizer = dvb_swig.randomizer_pp()
		depad = dvb_swig.depad_mpeg_ts_packet_pb()
		dst = gr.vector_sink_b()

		# Connect and run
		self.tb.connect(src, pad, randomizer, depad, dst)
		self.tb.run()
		# Check sync bytes
		result_data = dst.data()
		self.assertEqual(len(src_data), len(result_data))
		check_sync_bytes(self, result_data, randomized=True)
예제 #5
0
	def randomizer_derandomizer_with_length(self, npackets):
		"""
		Loopback randomiser to derandomiser
		Note: This method itself is not a unit test method.
		"""
		src_data = make_fake_transport_stream_packet(npackets)
		check_sync_bytes(self, src_data)
		expected_result = tuple(src_data)

		src = gr.vector_source_b(src_data)
		pad = dvb_swig.pad_mpeg_ts_packet_bp()
		randomizer = dvb_swig.randomizer_pp()
		derandomizer = dvb_swig.derandomizer_pp()
		depad = dvb_swig.depad_mpeg_ts_packet_pb()
		dst = gr.vector_sink_b()

		# Connect and run
		self.tb.connect(src, pad, randomizer, derandomizer, depad, dst)
		self.tb.run()
		# Check that the decoded bytes are the same as original
		self.assertEqual(expected_result, dst.data())