def __init__(self, f): ''' :param bytes: array of bytes payload ''' self._TMD = read.ucb(f)>>6 if self._TMD == 0x1 or self._TMD == 0x2: # 36 bit STM time, followed by 4 bit reserved data # followed by 24 bit data_unit_loop_length. # We'll read all that as a single 64 bit value and break it up d = read.ulb(f) self.STM = d >> 28 self._data_unit_loop_length = d & 0xffffffff if DEBUG: print 'CaptionStatementData: STM (time) ' + str(self.STM) print 'CaptionStatementData: data unit loop length: ' + str(self._data_unit_loop_length) else: self.STM = 0 self._data_unit_loop_length = read.ui3b(f) if DEBUG: print 'Caption statement: data unit loop length: ' + str(self._data_unit_loop_length) bytes_read = 0 self._data_units = [] while bytes_read < self._data_unit_loop_length: self._data_units.append(DataUnit(f)) bytes_read += self._data_units[-1].size()
def __init__(self, f): """ """ self.TMD = read.ucb(f) >> 6 if self.TMD == 0b10: _t = read.uib(f) _ub = read.uic(f) >> 4 self._OTM = _t | (_ub << 32) if DEBUG: print("Caption management OTM: " + str(self._OTM)) self._num_languages = read.ucb(f) self._languages = [] for lang in range(self._num_languages): self._languages.append(Language(f)) self._data_unit_loop_length = read.ui3b(f) if DEBUG: print('Caption managmentdata : data unit loop length: ' + str(self._data_unit_loop_length)) bytes_read = 0 self._data_units = [] while bytes_read < self._data_unit_loop_length[0]: self._data_units.append(DataUnit(f)) bytes_read += self._data_units[-1].size()
def __init__(self, f): self._unit_separator = read.ucb(f) if(self._unit_separator is not 0x1f): if DEBUG: print 'Unit separator not found at start of data unit.' raise ValueError self._data_unit_type = read.ucb(f) if DEBUG: print 'data unit type: ' + str(self._data_unit_type) self._data_unit_size = read.ui3b(f) if DEBUG: print 'DataUnit size found to be: ' + str(self._data_unit_size) #self._payload = f.read(self._data_unit_size) self._payload = self.load_unit(f)
def __init__(self, f): ''' :param bytes: array of bytes payload ''' self._TMD = read.ucb(f)>>6 if self._TMD == 0x01 or self._TMD == 0X10: self.STM = 0#TODO: read four bytes else: self.STM = 0 self._data_unit_loop_length = read.ui3b(f) if DEBUG: print 'Caption statement: data unit loop length: ' + str(self._data_unit_loop_length) #self._payload = f.read(self._data_unit_loop_length) bytes_read = 0 self._data_units = [] while bytes_read < self._data_unit_loop_length: self._data_units.append(DataUnit(f)) bytes_read += self._data_units[-1].size()
def __init__(self, f): ''' :param bytes: array of bytes payload ''' self._TMD = read.ucb(f) >> 6 if self._TMD == 0x01 or self._TMD == 0X10: self.STM = 0 #TODO: read four bytes else: self.STM = 0 self._data_unit_loop_length = read.ui3b(f) if DEBUG: print 'Caption statement: data unit loop length: ' + str( self._data_unit_loop_length) #self._payload = f.read(self._data_unit_loop_length) bytes_read = 0 self._data_units = [] while bytes_read < self._data_unit_loop_length: self._data_units.append(DataUnit(f)) bytes_read += self._data_units[-1].size()
def __init__(self, f): """ """ self.TMD = read.ucb(f) >> 6 if self.TMD == 0b10: _t = read.uib(f) _ub = read.uic(f) >> 4 self._OTM = _t | (_ub << 32) if DEBUG: print "Caption management OTM: " + str(self._OTM) self._num_languages = read.ucb(f) self._languages = [] for lang in range(self._num_languages): self._languages.append(Language(f)) self._data_unit_loop_length = read.ui3b(f) if DEBUG: print 'Caption managmentdata : data unit loop length: ' + str(self._data_unit_loop_length) bytes_read = 0 self._data_units = [] while bytes_read < self._data_unit_loop_length: self._data_units.append(DataUnit(f)) bytes_read += self._data_units[-1].size()