def test_extended_timestamp_compressed(self): """ A compressed header with an extended timestamp must read the timestamp (again). @see: #107 """ bytes = ( # full header '\x04\xff\xff\xff\x00\x02\x2d\x12\x01\x00\x00\x00\x0e\xc1\x5f\xe6' # compressed header '\xc4\x0e\xc1\x5f\xe6' ) stream = util.BufferedByteStream(bytes) channel = ConsumingChannel(2, stream, 1) h = header.decode(stream) channel.setHeader(h) self.assertEqual(h.timestamp, 247554022) h = header.decode(stream) self.assertEqual(h.timestamp, -1) channel.setHeader(h) self.assertEqual(h.timestamp, 247554022)
def readHeader(self): """ Reads an RTMP header from the stream. @rtype: L{header.Header} """ return header.decode(self.stream)
def readHeader(self): """ Reads an RTMP header from the stream. @rtype: L{header.Header} """ orig_pos = self.stream.tell() try: return header.decode(self.stream) except IOError: raise except Exception: # something went wrong, lets dump out the state of the decoder so # we might have a chance to debug what's going on boom_pos = self.stream.tell() self.stream.seek(orig_pos) # yes, print, bog off :P print 'Attempted to decode header for %r' % (self._currentChannel,) print 'Stream bytes was: %r' % ( self.stream.read(boom_pos - orig_pos + 1),) print 'Channel state: %r' % (self.channels,) raise
def _decode(self, s): stream = util.BufferedByteStream(s) return header.decode(stream)