-
-
Save cybronics/f3cf060501ffed6975b8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# Include the required packages | |
import os | |
from dvbobjects.PSI.PAT import * | |
from dvbobjects.PSI.NIT import * | |
from dvbobjects.PSI.SDT import * | |
from dvbobjects.PSI.PMT import * | |
from dvbobjects.DVB.Descriptors import * | |
from dvbobjects.MPEG.Descriptors import * | |
from dvbobjects.MHP.AIT import * | |
from dvbobjects.MHP.Descriptors import * | |
# Variables | |
ftv_transport_stream_id = 1 # france television transport stream id | |
fr_network_id = 8442 # French DVB-T id | |
ftv1_service_id = 257 # france 2 service id | |
ftv1_pmt_pid = 256 # france 2 PMT table id | |
ftv1_service_name = "France 2" # france 2 channel name | |
ftv_service_provider_name = "France Televisions" # Service provider name | |
ftv1_ait_pid = 2002 # AIT table id for the france 2 service | |
# NIT Table | |
nit = network_information_section( | |
network_id = fr_network_id, # DVB-T network id | |
network_descriptor_loop = [ | |
network_descriptor(network_name = "reseau television numerique terrestre francais",), # Network name | |
], | |
transport_stream_loop = [ | |
transport_stream_loop_item( | |
transport_stream_id = ftv_transport_stream_id, | |
original_network_id = fr_network_id, # DVB-T network id | |
transport_descriptor_loop = [ | |
# Services description | |
service_list_descriptor( | |
dvb_service_descriptor_loop = [ | |
# we define 1 service | |
service_descriptor_loop_item( | |
service_ID = ftv1_service_id, | |
service_type = 1, | |
), | |
], | |
), | |
# Channel description | |
logical_channel_descriptor( | |
lcn_service_descriptor_loop = [ | |
lcn_service_descriptor_loop_item( | |
service_ID = ftv1_service_id, # Service - channel association | |
visible_service_flag = 1, # visible channel | |
logical_channel_number = 2, # Channel number | |
), | |
], | |
), | |
], | |
), | |
], | |
version_number = 1, | |
section_number = 0, | |
last_section_number = 0, | |
) | |
pat = program_association_section( | |
table_id = 0x00, # PAT table id | |
section_syntax_indicator = 1, | |
transport_stream_id = ftv_transport_stream_id, # on which transport stream the PAT is applied | |
program_loop = [ | |
# Associate service with the PAT | |
program_loop_item( | |
program_number = ftv1_service_id, | |
PID = ftv1_pmt_pid, # association of a PMT table for a service | |
), | |
], | |
version_number = 1, | |
section_number = 0, | |
last_section_number = 0, | |
) | |
sdt = service_description_section( | |
transport_stream_id = ftv_transport_stream_id, # association of the SDT table with the transport stream | |
original_network_id = fr_network_id, # association of the SDT table with the network | |
service_loop = [ | |
# Association of 3 services with the SDR table | |
service_loop_item( | |
service_ID = ftv1_service_id, # id of the service | |
EIT_schedule_flag = 0, | |
EIT_present_following_flag = 0, | |
running_status = 4, | |
free_CA_mode = 0, | |
service_descriptor_loop = [ | |
service_descriptor( | |
service_type = 1, | |
service_provider_name = ftv_service_provider_name, # service provider | |
service_name = ftv1_service_name, # name of the channel associated to the service | |
), | |
], | |
), | |
], | |
version_number = 1, | |
section_number = 0, | |
last_section_number = 0, | |
) | |
pmt1 = program_map_section( | |
table_id = 0x02, # id identifying a PMT table | |
program_number = ftv1_service_id, # id of the service associated to the PMT table | |
PCR_PID = 257, # id of the first item of the feed (video audio or ait) | |
program_info_descriptor_loop = [], | |
# definition of the different feeds in the service | |
stream_loop = [ | |
# Video | |
stream_loop_item( | |
stream_type = 0x1b, # type of the feed (H264) | |
elementary_PID = 257, # id of the video feed (updated) | |
element_info_descriptor_loop = [] | |
), | |
# Audio | |
stream_loop_item( | |
stream_type = 0x0f, # type of the feed | |
elementary_PID = 258, # id of the audio feed (modified) | |
element_info_descriptor_loop = [] | |
), | |
# AIT | |
stream_loop_item( | |
stream_type = 0x5, # AIT stream type | |
elementary_PID = ftv1_ait_pid, # id of the AIT table | |
element_info_descriptor_loop = [ | |
application_signalling_descriptor( | |
application_type = 0x0010, # hbbtv type | |
AIT_version = 1, # ait version used | |
), | |
] | |
) | |
], | |
version_number = 1, | |
section_number = 0, | |
last_section_number = 0, | |
) | |
# | |
# Application Informaton Table (ETSI TS 101 812 10.4.6) | |
# | |
ait1 = application_information_section( | |
table_id = 0x74, # id identifying an AIT table | |
application_type = 0x0010, # hbbtv application type | |
common_descriptor_loop = [], | |
application_loop = [ | |
application_loop_item( | |
organisation_id = 0x00000058, # Organisation_id for France televisions | |
application_id = 1011, # unique application id | |
application_control_code = 0x01, # 1 is AUTOSTART, the application will start immedtiatly to load and to execute | |
# 2 is PRESENT, the decoder will add this application to the user choice of application | |
# 3 is DESTROY, it will signal to the application to stop executing | |
# 4 is KILL, it will stop execute the application | |
# Description of the application | |
application_descriptors_loop = [ | |
transport_ic_protocol_descriptor( | |
protocol_id = 0x0003, | |
URL_base = "http://hbbtv.francetv.fr/", # base of the called url | |
URL_extensions = [], # pas d'extention | |
transport_protocol_label = 0x3, # transport protocol used for launch an URL | |
), | |
application_descriptor( | |
application_profile = 0, | |
version_major = 1, # value of the german HbbTV apps | |
version_minor = 1, # value of the german HbbTV apps | |
version_micro = 0, # value of the german HbbTV apps | |
service_bound_flag = 0, # 1 means the application is expected to die on service change, 0 will wait after the service change to receive all the AITs and check if the same app is signalled or not | |
visibility = 3, # 3 the applications is visible to the user, 1 the application is visible only to other applications , 11 for all | |
application_priority = 1, # 1 is lowset, it is used when more than 1 applications is executing | |
transport_protocol_labels = [3], # same as transport_protocol_label in section "transport_ic_protocol_descriptor" | |
), | |
application_name_descriptor(application_name = "RolandGarros"), # name of the application (updated) | |
# simple application location descriptor | |
simple_application_location_descriptor( | |
descriptor_tag = 0x15, # id identifying a "simple application location descriptor" | |
initial_path = "f5/_gestionnaire_notif/v1.2-rg/index.html", # path of the called url (updated) | |
), | |
] | |
), | |
], | |
version_number = 1, | |
section_number = 0, | |
last_section_number = 0, | |
) | |
# Transform the objects in a .sec file for to transform it into .ts | |
# Table NIT | |
out = open("./nit.sec", "wb") | |
out.write(nit.pack()) | |
out.close | |
out = open("./nit.sec", "wb") # python flush bug | |
out.close | |
os.system('/usr/local/bin/sec2ts 16 < ./nit.sec > ./nit.ts') | |
# Table PAT | |
out = open("./pat.sec", "wb") | |
out.write(pat.pack()) | |
out.close | |
out = open("./pat.sec", "wb") # python flush bug | |
out.close | |
os.system('/usr/local/bin/sec2ts 0 < ./pat.sec > ./pat.ts') | |
# Table SDT | |
out = open("./sdt.sec", "wb") | |
out.write(sdt.pack()) | |
out.close | |
out = open("./sdt.sec", "wb") # python flush bug | |
out.close | |
os.system('/usr/local/bin/sec2ts 17 < ./sdt.sec > ./sdt.ts') | |
# Table PMT | |
out = open("./pmt1.sec", "wb") | |
out.write(pmt1.pack()) | |
out.close | |
out = open("./pmt1.sec", "wb") # python flush bug | |
out.close | |
os.system('/usr/local/bin/sec2ts ' + str(ftv1_pmt_pid) + ' < ./pmt1.sec > ./pmt1.ts') | |
# Table AIT | |
out = open("./ait1.sec", "wb") | |
out.write(ait1.pack()) | |
out.close | |
out = open("./ait1.sec", "wb") # python flush bug | |
out.close | |
os.system('/usr/local/bin/sec2ts ' + str(ftv1_ait_pid) + ' < ./ait1.sec > ./ait1.ts') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment