| 59 | |
| 60 | |
| 61 | class SegmentHeader(object): |
| 62 | |
| 63 | payload_length = None |
| 64 | uncompressed_payload_length = None |
| 65 | is_self_contained = None |
| 66 | |
| 67 | def __init__(self, payload_length, uncompressed_payload_length, is_self_contained): |
| 68 | self.payload_length = payload_length |
| 69 | self.uncompressed_payload_length = uncompressed_payload_length |
| 70 | self.is_self_contained = is_self_contained |
| 71 | |
| 72 | @property |
| 73 | def segment_length(self): |
| 74 | """ |
| 75 | Return the total length of the segment, including the CRC. |
| 76 | """ |
| 77 | hl = SegmentCodec.UNCOMPRESSED_HEADER_LENGTH if self.uncompressed_payload_length < 1 \ |
| 78 | else SegmentCodec.COMPRESSED_HEADER_LENGTH |
| 79 | return hl + CRC24_LENGTH + self.payload_length + CRC32_LENGTH |
| 80 | |
| 81 | |
| 82 | class Segment(object): |