catalinii / minisatip

minisatip is an SATIP server for linux using local DVB-S2, DVB-C, DVB-T or ATSC cards
https://minisatip.org
324 stars 78 forks source link

Minisatip tries wrong PMT #1129

Open surfcu opened 8 months ago

surfcu commented 8 months ago

I can watch all Digital Platform channels on my enigma2 (Zgemma h9 twin se) box 42e. When running Minisatip can provide all but beIN SPORTS 2 (PMT=48). Instead when pmt=48 is requested minisatip tries Ticari beIN Sports 2 (PMT=52) and fails since it's not in the subscription.

minisatip.log

Any ideas?

surfcu commented 8 months ago

I think problem is pmt 48 is misinterpreted as audio. But I don't know much about coding.

iandebris commented 2 weeks ago

i think this happens when the VPID (and PCR) is the same on multiple channels and only APID is different (or reverse, same APID but different VPID on different PMTs like beIN SPORTS ticari/commercial and non-commercial) as it also happens on d***t 42e as well with stingray music channels (12188 V 27500, 8PSK DVB-S2 5/6), all music channels like DEEP BLUES (PMT 1935, APID 235), RIDDIM (PMT 1937, APID 237) etc use the VPID of iTVGAMETEST (PMT 4250, VPID 108) and its a roll of dice whether or not the correct PMT is utilized.

for instance if you load up NATURE ESCAPE (PMT 1908, PCR 308, VPID 108, APID 208), minisatip may use the correct thing; or just go pick up random other PMT that has the same VPID, for instance '80'ler (PID 1922, PCR 308, VPID 108, APID 222)

i've included a sample log from a raspberry pi 4 with TurboSight TBS 5930 DVB-S/S2/S2x

msip.log

Jalle19 commented 2 weeks ago

Thanks for the additional clues!

Jalle19 commented 2 weeks ago

So it seems that the problem is that get_master_pmt_for_pid() returns any PMT that happens to contain some particular PID. This leads to that PMT (PID 1922 in the log above) being set as the master PMT for all the other PMTs in the same PAT, which is obviously incorrect.

Jalle19 commented 2 weeks ago

Same issue in @surfcu 's log (PMT 1 (52) gets incorrectly marked as master for PMT 10 (48)):

$ cat minisatip\(8\).log | grep -e 'new PMT 1 \|new PMT 10 \|master pmt set to'
[13/10 23:19:44.170 AD0]: new PMT 1 AD 0, pid: 0034 (52), len 125, pi_len 0, ver 3, pcr 3301, sid 3718 (14104)  
[13/10 23:19:44.334 AD0]: PMT 5, master pmt set to 3
[13/10 23:19:44.456 AD0]: PMT 8, master pmt set to 3
[13/10 23:19:44.457 AD0]: PMT 9, master pmt set to 0
[13/10 23:19:44.497 AD0]: new PMT 10 AD 0, pid: 0030 (48), len 125, pi_len 0, ver 3, pcr 3301, sid 3715 (14101)  
[13/10 23:19:44.497 AD0]: PMT 10, master pmt set to 1
[13/10 23:19:44.538 AD0]: PMT 11, master pmt set to 0
[13/10 23:19:44.579 AD0]: PMT 12, master pmt set to 1
[13/10 23:19:44.620 AD0]: PMT 13, master pmt set to 4
Jalle19 commented 2 weeks ago

@catalinii what do you think would be the best fix for this? Can you elaborate what the idea behind "master PMT" is? Does it make any sense anymore?

catalinii commented 2 weeks ago

Generally for a vpid/apid, you can have multiple PMTs reporting those vpid/apids (for example the German PMT and the Austrian PMT).

obviously the user owns just one card, however it is imposing to know which one of them is it.

so Master PMT is the first PMT that minisatip receives and the other PMTs are linked to the master, so when the CAPMT is sent it contains all the capids and caids for all PMTs that contains the same vpid/apid to ensure it can be decrypted.

The fix would be to identify why the wrong PMT is linked to the master PMT (see process_pmt)

Jalle19 commented 2 weeks ago

Perhaps the logic should be changed then to look for a PMT that contains both the new PMT's VPID and APID, not just either one of them? Not sure how much better that is but it should at least be a little less prone to false positives.

Jalle19 commented 2 weeks ago

Then again I don't know what would happen to encrypted radio channels (that presumably don't have a VPID at all)

Jalle19 commented 2 weeks ago

https://github.com/Jalle19/minisatip/commit/bdb643b58272284ac3395017f23cba798e1db844 trying a fix here, haven't tested it yet

Jalle19 commented 2 weeks ago

Seems to be that going from a random PID to a PMT is not possible to get absolutely right

catalinii commented 2 weeks ago

Try it, let’s see if it works

Jalle19 commented 2 weeks ago

image Now that I think about this some more, it seems like even if we match against both video and audio PIDs it won't fix OPs issue.

Jalle19 commented 2 weeks ago

@surfcu @iandebris can you try this branch? https://github.com/Jalle19/minisatip/tree/master-pmt2

Jalle19 commented 2 weeks ago

Testing it myself at the moment, seems to work just fine

iandebris commented 2 weeks ago

[...] can you try this branch? https://github.com/Jalle19/minisatip/tree/master-pmt2

@Jalle19 Heya, your master-pmt2 branch seems to work, though this time it looks like oscam is choked (running out of demuxers) by many PMTs its receiving (I guess this is what @catalinii meant by finding a master PMT). I'm including the minisatip log and a partial oscam log below:

msip.log

oscam.log

oscam.conf:

[global]
logfile                       = stdout
lb_mode                       = 1
lb_nbest_readers              = 2
lb_force_reopen_always        = 1
lb_stat_cleanup               = 24
disablecrccws                 = 1
disablecrccws_only_for        = 092B:000000;06F8:000000;0656:000000

[cache]

[dvbapi]
enabled                       = 1
au                            = 1
pmt_mode                      = 4
request_mode                  = 1
listen_port                   = 15012
delayer                       = 65
user                          = dvbapi
read_sdt                      = 2
write_sdt_prov                = 1
demuxer_fix                   = 1
boxtype                       = pc

[webif]
httpport                      = 8888
httpallowed                   = 127.0.0.1,192.168.0.0-192.168.255.255,10.0.0.0-10.255.255.255,172.16.0.0-172.31.255.255,::1

oscam.user:

[account]
user                          = dvbapi
uniq                          = 2
au                            = 1
max_connections               = 5
group                         = 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16
Jalle19 commented 2 weeks ago

I figured that could happen. Need to find a better way to "start" only the right PMT.

Jalle19 commented 2 weeks ago

@iandebris are you able to test the Bein Sports 2 vs. Ticari bein sports case?

iandebris commented 2 weeks ago

[...] are you able to test the Bein Sports 2 vs. Ticari bein sports case?

@Jalle19 sorry, although I don't have an access card for the provider of those channels; I can at least confirm the same PMT demux flood happens on oscam:

2024/06/20 22:07:06 6C6DDD5E c   (dvbapi) Client connected: 'minisatip/1.3.~ffa4004' (protocol version = 2)
2024/06/20 22:07:38 6C6DDD5E c        (-) -- Skipped 1 duplicated log lines --
2024/06/20 22:07:38 6C6DDD5E c   (dvbapi) Demuxer 0 ecmpid 0 CAID: 0664 ECM_PID: 1E7E PROVID: 000000 
2024/06/20 22:07:38 6C6DDD5E c   (dvbapi) Demuxer 0 ecmpid 1 CAID: 06EE ECM_PID: 13F0 PROVID: 000000 
2024/06/20 22:07:38 6C6DDD5E c   (dvbapi) Demuxer 0 found 2 ECM pids and 5 STREAM pids in CA PMT
2024/06/20 22:07:38 6C6DDD5E c   (dvbapi) Demuxer 0 no suitable readers found that can be used for decoding!
2024/06/20 22:07:38 6C6DDD5E c   (dvbapi) Demuxer 1 ecmpid 0 CAID: 06EE ECM_PID: 13ED PROVID: 000000 
2024/06/20 22:07:38 6C6DDD5E c   (dvbapi) Demuxer 1 ecmpid 1 CAID: 0664 ECM_PID: 1E7C PROVID: 000000 
2024/06/20 22:07:38 6C6DDD5E c   (dvbapi) Demuxer 1 found 2 ECM pids and 5 STREAM pids in CA PMT
2024/06/20 22:07:38 6C6DDD5E c   (dvbapi) Demuxer 1 no suitable readers found that can be used for decoding!
2024/06/20 22:07:38 6C6DDD5E c   (dvbapi) Demuxer 2 ecmpid 0 CAID: 0664 ECM_PID: 1E7D PROVID: 000000 
2024/06/20 22:07:38 6C6DDD5E c   (dvbapi) Demuxer 2 ecmpid 1 CAID: 06EE ECM_PID: 13EF PROVID: 000000 
2024/06/20 22:07:38 6C6DDD5E c   (dvbapi) Demuxer 2 found 2 ECM pids and 3 STREAM pids in CA PMT
2024/06/20 22:07:38 6C6DDD5E c   (dvbapi) Demuxer 2 no suitable readers found that can be used for decoding!
2024/06/20 22:07:41 6C6DDD5E c   (dvbapi) Demuxer 0 no enabled matching ecmpids -> decoding is waiting for matching readers!
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 1 no enabled matching ecmpids -> decoding is waiting for matching readers!
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 0 stopped descrambling for program 3718 (0664@000000:3718 unknown)
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 1 stopped descrambling for program 3715 (06EE@000000:3715 unknown)
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 2 stopped descrambling for program 3717 (0664@000000:3717 unknown)
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 0 ecmpid 0 CAID: 0664 ECM_PID: 1E7E PROVID: 000000 
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 0 ecmpid 1 CAID: 06EE ECM_PID: 13F0 PROVID: 000000 
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 0 found 2 ECM pids and 5 STREAM pids in CA PMT
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 0 no suitable readers found that can be used for decoding!
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 1 ecmpid 0 CAID: 06EE ECM_PID: 13ED PROVID: 000000 
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 1 ecmpid 1 CAID: 0664 ECM_PID: 1E7C PROVID: 000000 
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 1 found 2 ECM pids and 5 STREAM pids in CA PMT
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 1 no suitable readers found that can be used for decoding!
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 2 ecmpid 0 CAID: 0664 ECM_PID: 1E7D PROVID: 000000 
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 2 ecmpid 1 CAID: 06EE ECM_PID: 13EF PROVID: 000000 
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 2 found 2 ECM pids and 3 STREAM pids in CA PMT
2024/06/20 22:07:42 6C6DDD5E c   (dvbapi) Demuxer 2 no suitable readers found that can be used for decoding!
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 0 stopped descrambling for program 3718 (0664@000000:3718 unknown)
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 1 stopped descrambling for program 3715 (06EE@000000:3715 unknown)
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 2 stopped descrambling for program 3717 (0664@000000:3717 unknown)
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 0 ecmpid 0 CAID: 0664 ECM_PID: 1E7E PROVID: 000000 
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 0 ecmpid 1 CAID: 06EE ECM_PID: 13F0 PROVID: 000000 
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 0 found 2 ECM pids and 5 STREAM pids in CA PMT
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 0 no suitable readers found that can be used for decoding!
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 1 ecmpid 0 CAID: 06EE ECM_PID: 13ED PROVID: 000000 
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 1 ecmpid 1 CAID: 0664 ECM_PID: 1E7C PROVID: 000000 
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 1 found 2 ECM pids and 5 STREAM pids in CA PMT
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 1 no suitable readers found that can be used for decoding!
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 2 ecmpid 0 CAID: 0664 ECM_PID: 1E7D PROVID: 000000 
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 2 ecmpid 1 CAID: 06EE ECM_PID: 13EF PROVID: 000000 
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 2 found 2 ECM pids and 3 STREAM pids in CA PMT
2024/06/20 22:07:45 6C6DDD5E c   (dvbapi) Demuxer 2 no suitable readers found that can be used for decoding!
2024/06/20 22:07:47 6C6DDD5E c   (dvbapi) Demuxer 0 stopped descrambling for program 3718 (0664@000000:3718 unknown)
2024/06/20 22:07:47 6C6DDD5E c   (dvbapi) Demuxer 1 stopped descrambling for program 3715 (06EE@000000:3715 unknown)
2024/06/20 22:07:47 6C6DDD5E c   (dvbapi) Demuxer 2 stopped descrambling for program 3717 (0664@000000:3717 unknown)
Jalle19 commented 1 week ago

@catalinii in get_master_pmt_for_pid() it seems we need to be able to look at the PIDs subscribed on the adapter and pick the first PMT which PID is subscribed and which stream PIDs contain the PID given to the function. ad->pids seems to contain all PIDs from the transponder when this function is called though, so that can't be used. Any ideas?

catalinii commented 1 week ago

The idea is that minisatip will cache all PMTs for all seen transponders, so the list of pmts (and pmt-> master pmt) needs to be correct regardless of the subscribed pids.

The other reason is that the clinet can chabge channels (and subscribed pids) without chaging the transponder. Again the subscribed pids should not be relevant.

PAT/PMT scanning is an expensive operation as you need to wait for them to arrive which could take more than 1s