Avalpa Community
http://www.avalpa.com/forum/

BAT
http://www.avalpa.com/forum/viewtopic.php?f=11&t=251
Page 1 of 1

Author:  orange [ Fri May 08, 2015 3:00 pm ]
Post subject:  BAT

Could you please give an example of BAT table generation?

Author:  orange [ Wed May 13, 2015 7:55 am ]
Post subject:  Re: BAT

I made some progress, here is an example:

PSI/BAT.py

Code:
#! /usr/bin/env python


import string
from dvbobjects.MPEG.Section import Section
from dvbobjects.utils import *
from dvbobjects.DVB.Descriptors import *

######################################################################
class bouquet_association_section(Section):

    table_id = 0x4A
   
    section_max_size = 1024

    def pack_section_body(self):
   
        # pack bouquet_descriptor_loop
        ndl_bytes = string.join(
            map(lambda x: x.pack(),
                self.bouquet_descriptor_loop),
            "")

        # pack transport_stream_loop
        tsl_bytes = string.join(
            map(lambda x: x.pack(),
                self.transport_stream_loop),
            "")

        self.table_id_extension = self.bouquet_id
        self.private_indicator = 1

        fmt = "!H%dsH%ds" % (len(ndl_bytes), len(tsl_bytes))
        return pack(fmt,
            0xF000 | (len(ndl_bytes) & 0x0FFF),
            ndl_bytes,
            0xF000 | (len(tsl_bytes) & 0x0FFF),
            tsl_bytes,
            )

######################################################################
class transport_stream_loop_item(DVBobject):

    def pack(self):
   
        # pack transport_descriptor_loop
        tdl_bytes = string.join(
            map(lambda x: x.pack(),
                self.transport_descriptor_loop),
            "")

        fmt = "!HHH%ds" % len(tdl_bytes)
        return pack(fmt,
                    self.transport_stream_id,
                    self.original_network_id,
                    0xF000 | (len(tdl_bytes) & 0x0FFF),
                    tdl_bytes,
                    )

                   


basically its the same as NIT.py


Descriptors.py:
Code:
######################################################################
class bouquet_name_descriptor(Descriptor):

    descriptor_tag = 0x47

    def bytes(self):
        fmt = "!%ds" % len(self.bouquet_name)
        return pack(fmt,
          self.bouquet_name)


######################################################################
class user_defined_descriptor(Descriptor):

    descriptor_tag = 0x91

    def bytes(self):
        fmt = "!%ds" % len(self.descriptor_data)
        return pack(fmt,
          self.descriptor_data)


######################################################################

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/