def listenRtp(self):
    'Listen for RTP packets.'
    while 1:
        try:
            cachename = ((CACHE_FILE_NAME + str(self.sessionId)) + CACHE_FILE_EXT)
            file = open(cachename, 'wb+')
            while 1:
                data = self.rtpSocket.recv(RECV_SIZE)
                if data:
                    rtpPacket = RtpPacket()
                    rtpPacket.decode(data)
                    currFrameNbr = rtpPacket.seqNum()
                    file.write(rtpPacket.getPayload())
                    print(('Current Seq Num: ' + str(currFrameNbr)))
                    if ((currFrameNbr > self.frameNbr) and rtpPacket.getIfEnd()):
                        self.frameNbr = currFrameNbr
                        self.updateMovie(cachename)
                        file.close()
                        break
        except:
            if self.playEvent.isSet():
                break
            print('Frame receiving failed!')
            if (self.teardownAcked == 1):
                self.rtpSocket.shutdown(socket.SHUT_RDWR)
                self.rtpSocket.close()
                break
Listen for RTP packets.
def listenRtp(self):
    
    while 1:
        try:
            cachename = ((CACHE_FILE_NAME + str(self.sessionId)) + CACHE_FILE_EXT)
            file = open(cachename, 'wb+')
            while 1:
                data = self.rtpSocket.recv(RECV_SIZE)
                if data:
                    rtpPacket = RtpPacket()
                    rtpPacket.decode(data)
                    currFrameNbr = rtpPacket.seqNum()
                    file.write(rtpPacket.getPayload())
                    print(('Current Seq Num: ' + str(currFrameNbr)))
                    if ((currFrameNbr > self.frameNbr) and rtpPacket.getIfEnd()):
                        self.frameNbr = currFrameNbr
                        self.updateMovie(cachename)
                        file.close()
                        break
        except:
            if self.playEvent.isSet():
                break
            print('Frame receiving failed!')
            if (self.teardownAcked == 1):
                self.rtpSocket.shutdown(socket.SHUT_RDWR)
                self.rtpSocket.close()
                break