Beispiel #1
0
 def _write_page(self):
     self.page_out[-1] = len(self.s_table)
     crc = utils.crc32(self.page_out, self.s_table, self.segments)
     self.page_out[22:26] = array('B', crc)
     self.output_file.write(self.page_out)
     self.output_file.write(self.s_table)
     self.output_file.write(self.segments)
Beispiel #2
0
    def as_bytes(self, update_crc=False):
        """Get the complete page as bytes.

        :paramer update_crc: Flag to know if recalculate the CRC.
        :type update_crc: ``boolean``
        :returns: Ogg page
        :rtype: :py:class:`array.array` of bytes, typecode = 'B'
        """

        if update_crc:
            self.crc = 0

        page = array('B')
        page.extend(self._pack())
        page.extend(self.segment_table)
        page.extend(self.fileobj.read(sum(self.segment_table)))
        self.segment_table_index = len(self.segment_table)

        if update_crc:
            crc = utils.crc32(page)
            page[22:26] = array('B', crc)

        return page