Пример #1
0
 def parse_pusi(self, packet):
     bitbin = BitBin(packet)
     if bitbin.asint(24) != 1: return
     if bitbin.asint(8) in self.NON_PTS_STREAM_IDS: return
     # PES_packet_length =
     bitbin.forward(16)
     if bitbin.asint(2) != 2: return
     bitbin.forward(6)
     '''
     PES_scramble_control = bitbin.asint(2)
     PES_priority = bitbin.asint(1)
     data_align_ind = bitbin.asint(1)
     copyright = bitbin.asint(1)
     orig_or_copy = bitbin.asint(1)
     '''
     if bitbin.asint(2) != 2: return
     bitbin.forward(14)
     if bitbin.asint(4) != 2: return
     a = bitbin.asint(3) << 30
     bitbin.forward(1)
     b = bitbin.asint(15) << 15
     bitbin.forward(1)
     c = bitbin.asint(15)
     d = (a + b + c) / 90000.0
     fpts = f'PTS \033[92m{d:.3f}\033[0m '
     print(f'\r{fpts}', end="\r")
     return
Пример #2
0
 def decode(self):
     """
     decode SCTE35 Dtmf Descriptor
     """
     bitbin = BitBin(self.bites)
     self.parse_id(bitbin)
     self.preroll = bitbin.asint(8)
     self.dtmf_count = d_c = bitbin.asint(3)
     bitbin.forward(5)
     while d_c:
         d_c -= 1
         self.dtmf_chars.append(bitbin.astext(8))
Пример #3
0
 def parse_pusi(self, packetdata):
     '''
     If the pusi data contains these markers,
     we can pull a PTS value..
     '''
     if packetdata[2] == 1:
         if packetdata[3] not in self.NON_PTS_STREAM_IDS:
             if (packetdata[6] >> 6) == 2:
                 if (packetdata[7] >> 6) == 2:
                     if (packetdata[9] >> 4) == 2:
                         bitbin = BitBin(packetdata[9:])
                         bitbin.forward(4)
                         self.parse_pts(bitbin)
Пример #4
0
 def decode(self):
     """
     decode a segmentation descriptor
     """
     bitbin = BitBin(self.bites)
     self.parse_id(bitbin)
     self.segmentation_event_id = bitbin.ashex(32)  # 4 bytes
     self.segmentation_event_cancel_indicator = bitbin.asflag(1)
     bitbin.forward(7)  # 1 byte
     if not self.segmentation_event_cancel_indicator:
         self._decode_flags(bitbin)  # 1 byte
         if not self.program_segmentation_flag:
             self._decode_components(bitbin)
         self._decode_segmentation(bitbin)
Пример #5
0
 def decode(self):
     """
     Decode SCTE35 Audio Descriptor
     """
     bitbin = BitBin(self.bites)
     self.parse_id(bitbin)
     self.audio_count = a_c = bitbin.asint(4)
     bitbin.forward(4)
     while a_c:
         a_c -= 1
         comp = {}
         comp["component_tag"] = bitbin.asint(8)
         comp["ISO_code="] = bitbin.asint(24)
         comp["bit_stream_mode"] = bitbin.asint(3)
         comp["num_channels"] = bitbin.asint(4)
         comp["full_srvc_audio"] = bitbin.asflag(1)
         self.components.append(comp)
Пример #6
0
 def decode(self):
     """
     SpliceInsert.decode
     """
     bitbin = BitBin(self.bites)
     start = bitbin.idx
     self.splice_event_id = bitbin.asint(32)
     self.splice_event_cancel_indicator = bitbin.asflag(1)
     bitbin.forward(7)
     if not self.splice_event_cancel_indicator:
         self._decode_flags(bitbin)
         if self.program_splice_flag:
             if not self.splice_immediate_flag:
                 self._decode_pts(bitbin)
         else:
             self._decode_components(bitbin)
             if not self.splice_immediate_flag:
                 self._decode_pts(bitbin)
         if self.duration_flag:
             self._decode_break(bitbin)
         self.unique_program_id = bitbin.asint(16)
         self.avail_num = bitbin.asint(8)
         self.avail_expected = bitbin.asint(8)
     self._set_len(start, bitbin.idx)
Пример #7
0
 def _program_association_table(self, pkt):
     """
     parse program association table ( pid 0 )
     to program to program table pid mappings.
     """
     sectionlen = (pkt[6] & 15 << 8) | pkt[7]
     pkt = pkt[13:(sectionlen + 5)]
     bitbin = BitBin(pkt)
     slib = sectionlen << 3
     slib -= 40
     while slib > 32:
         program_number = bitbin.asint(16)
         bitbin.forward(3)
         if program_number == 0:
             bitbin.forward(13)
         else:
             self._pmt_pids.add(bitbin.asint(13))
         slib -= 32
     bitbin.forward(32)