예제 #1
0
    def test_packet_with_recovery(self):
        midi_list = [[[128, 10, 0], 1000], [[144, 32, 110], 1000]]

        recovery_journal_system = RecoveryJournal()
        seq = 12

        #midi session part (sending)
        packet = OldPacket(seq, midi_list, 0)

        midi_list_formated, length = MidiCommand().encode_midi_commands(
            midi_list)
        header = MidiCommand().header(0, 1, 0, 0, length)

        #Building Chunk

        recovery_journal_system.update(packet)
        recovery_journal = recovery_journal_system.content

        chunk = header + midi_list_formated + recovery_journal
        #protocol part
        packet = RTPPacket(424242, seq, 10, chunk, 96, marker=1)

        bytes = packet.netbytes()
        packet = parse_rtppacket(bytes)

        #midisession part (receiving)
        marker_b, marker_j, marker_z, marker_p, length = MidiCommand(
        ).parse_header(packet.data[0])
        if marker_p:
            #silent packet with recovery
            midi_list = []

        else:
            #normal packet
            #Extract Midi Note (length en nb notes)
            print "test 1:", len(packet.data[1:length * 7 + 1])
            midi_list = packet.data[1:length * 7 + 1]

            #Decoding midi commands
            midi_list = MidiCommand().decode_midi_commands(midi_list, length)

            #Saving feed history
            packet_to_save = OldPacket(seq, midi_list, 0)

        #Extract Midi Recovery Journal if is present in the packet and
        #the previous packet has been lost
        if marker_j:
            print "recovery journal"
            print len(packet.data[length * 7 + 1:])
            journal = packet.data[length * 7 + 1:]

            #Parse Recovery journal
            r_journal = recovery_journal_system.parse(journal)
예제 #2
0
 def setUp(self):
     self.midi_command = MidiCommand()