@@ -1160,15 +1160,33 @@ def make_pmt_with_outer(program_num: int, pcr_pid: int, outer_desc: bytes,
11601160 ett_b = make_atsc_ett ((0x00FF << 16 ) | 0xC002 , long_b )
11611161
11621162 video_pes = make_ts_pes (0xE0 , MPGV_PAYLOAD , pts_90khz = 900 )
1163+ # Section dispatch is driven by dvbpsi sub-decoders attached lazily as
1164+ # tables arrive. In particular:
1165+ # - The STT sub-decoder is attached at PSIP base setup time.
1166+ # - ATSC_STT_Callback's first call attaches the MGT decoder.
1167+ # - ATSC_MGT_Callback attaches the VCT and per-PID EIT/ETT decoders.
1168+ # - ATSC_EIT_Callback won't process anything until both p_stt and
1169+ # p_vct are already set on the base PSIP context.
1170+ # We therefore inject STT first to bootstrap MGT, then MGT (which
1171+ # attaches VCT + EIT/ETT decoders), then TVCT, then a second STT/MGT
1172+ # round so the EIT/ETT sections that follow have a fully-populated
1173+ # base context to satisfy ATSC_EIT_Callback's pre-conditions.
11631174 return (psi_packet (pat , 0x0000 ) +
11641175 psi_packet (pmt , PMT_PID ) +
11651176 pes_ts_packets (video_pes , VIDEO_PID , pcr_90khz = 450 ) +
1177+ psi_packet (stt , ATSC_BASE_PID ) +
11661178 psi_packet (mgt , ATSC_BASE_PID ) +
1179+ psi_packet (tvct , ATSC_BASE_PID ) +
11671180 psi_packet (stt , ATSC_BASE_PID ) +
1181+ psi_packet (mgt , ATSC_BASE_PID ) +
11681182 psi_packet (tvct , ATSC_BASE_PID ) +
11691183 psi_packet (eit0 , eit_pid_0 ) +
11701184 psi_packet (eit1 , eit_pid_1 ) +
11711185 psi_packet (ett_a , ett_pid_0 ) +
1186+ psi_packet (ett_b , ett_pid_1 ) +
1187+ psi_packet (eit0 , eit_pid_0 ) +
1188+ psi_packet (eit1 , eit_pid_1 ) +
1189+ psi_packet (ett_a , ett_pid_0 ) +
11721190 psi_packet (ett_b , ett_pid_1 ))
11731191
11741192
0 commit comments