示例#1
0
    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)
示例#2
0
文件: codec.py 项目: jasimmk/rtmpy
    def readHeader(self):
        """
        Reads an RTMP header from the stream.

        @rtype: L{header.Header}
        """
        return header.decode(self.stream)
示例#3
0
    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
示例#4
0
    def _decode(self, s):
        stream = util.BufferedByteStream(s)

        return header.decode(stream)
示例#5
0
    def _decode(self, s):
        stream = util.BufferedByteStream(s)

        return header.decode(stream)