C
campag5242
I've patched oscam-emu to perform better (for me at least) on feeds.
Background:
New to oscam & feeds, I soon became frustrated with not being able to zap between certain live feeds without having to edit the key files.
For feeds, oscam generates a fake ecm whose payload is the service_id followed by all elementary stream pids. Quite often this ecm is *identical* across many feeds. There lies the problem - the ecm is not sufficiently unique per channel/feed.
So I extended the fake ecm, adding a uint32_t "fingerprint" of the channel after the list of pids. The fingerprint is a crc32 over an extended list of pids, and more importantly, the enigma2 namespace for the channel. The namespace is a 32-bit value formed from the orbital position, frequency & polarisation. The namespace is also appended to the fake ecm. Those mods are in module-dvbapi.c
The BISS emu in module-emulator-osemu.c is updated to handle this extended fake ecm, whilst maintaining compatiblity with the previous scheme. SoftCam.Key is used, replacing the svid|pid key index with the crc32 channel hash.
Usage:
Remove old entries in SoftCam.Key.
On zapping to a new feed, in the live log you will see the emu searching for a key as before svid|pid. If no match is found, you'll see a suggested SoftCam.Key line in the log:
F DE1F1603 00 0000000000000000 7.0°E 12564H 20170923@1928
You'll notice it's annotated with the sat, frequency & time. Copy/paste that into your SoftCam.Key & insert the correct key. I store them in sorted sat/freq order, adding the feed name & event details by hand. It grows to become a nice log of your feedhunting activity:
Note:
I occasionally see incorrect frequency/polarity 0H. On those channels I see the namespace reported in enigma2's webif with lower 16 bits all 0's too, so suspect a bug in openatv/enigma2.
Patch placed here as I couldn't see how to insert an attachment (maybe I don't have rights, or am blind this morning lol). First patch oscam svn with oscam-emu.patch, then this one.:
I'll attach an arm build as used on my SF4008 as soon as I can find the attach button :thum:
Background:
New to oscam & feeds, I soon became frustrated with not being able to zap between certain live feeds without having to edit the key files.
For feeds, oscam generates a fake ecm whose payload is the service_id followed by all elementary stream pids. Quite often this ecm is *identical* across many feeds. There lies the problem - the ecm is not sufficiently unique per channel/feed.
So I extended the fake ecm, adding a uint32_t "fingerprint" of the channel after the list of pids. The fingerprint is a crc32 over an extended list of pids, and more importantly, the enigma2 namespace for the channel. The namespace is a 32-bit value formed from the orbital position, frequency & polarisation. The namespace is also appended to the fake ecm. Those mods are in module-dvbapi.c
The BISS emu in module-emulator-osemu.c is updated to handle this extended fake ecm, whilst maintaining compatiblity with the previous scheme. SoftCam.Key is used, replacing the svid|pid key index with the crc32 channel hash.
Usage:
Remove old entries in SoftCam.Key.
On zapping to a new feed, in the live log you will see the emu searching for a key as before svid|pid. If no match is found, you'll see a suggested SoftCam.Key line in the log:
F DE1F1603 00 0000000000000000 7.0°E 12564H 20170923@1928
You'll notice it's annotated with the sat, frequency & time. Copy/paste that into your SoftCam.Key & insert the correct key. I store them in sorted sat/freq order, adding the feed name & event details by hand. It grows to become a nice log of your feedhunting activity:
Code:
#############################################
# BISS KEYS #
#############################################
;On every channel change, the emu makes a BISS key search, in this order, until a match is found:
;1st: F SvIdEcmP 00 0102030405060708 ;(ServiceID<<16 | ECMPID) whenever ecmpid!=0x1FFF
;2nd+: F SvIdXPid 00 0102030405060708 ;(ServiceID<<16 | XPID) where X = any valid A/V pid for the service, searched in turn, in the order they appear in the PMT.
;then: F ChnlHash 00 0102030405060708 ;(channel hash) a (hopefully!) unique value which can be seen in OSCAM's live log whilst the emu searches for a match.
;last: F SvId1FFF 00 0102030405060708 ;(ServiceID<<16 | 0x1FFF) last chance saloon, effectively just search on the serviceID.
;If the key changes, either replace the key or place another line *below* the original entry
;Keys are re-read on stop-starting the emulator reader, or re-starting oscam.
F 00011FFF 00 0000000000000000 Default key (RAI) will be used for serviceID 0001 when no matching hash is found
F AE43A6F6 00 0000000000000000 12.5°W 11485H 20170923@1525 Derby-Birm City (EFL)
F 896A3EFA 00 0000000000000000 12.5°W 12678H 20170923@1532 F503 Cod2 (Montpellier - PSG)
F 9F5296B0 00 0000000000000000 0.8°W 11486V 20170923@1724 Connacht v Cardiff Vis 1 (Rugby)
F CAAE4226 00 0000000000000000 0.8°W 11500V 20170923@1726 Connacht v Cardiff World Feed (Rugby)
F E9ECF7B6 00 0000000000000000 0.8°W 11513V 20170923@1716 Tower OB TX4
F B1406A6A 00 0000000000000000 3.0°E 0H 20170923@1859 F32 Cod5 L1 (French Football)
F D06B4F53 00 0000000000000000 3.0°E 0H 20170923@1906
F 9E62C8B1 00 0000000000000000 3.0°E 10962H 20170923@2142 ITA 692 (Serie A Football)
F B242A483 00 0000000000000000 3.0°E 10985H 20170923@1918 BeIN - LCFC Vs LFC (Premiership Football)
F E8533582 00 0000000000000000 3.0°E 11524V 20170923@1903 E381 Via1 (French Football)
F 9679484D 00 0000000000000000 7.0°E 11104V 20170924@0859 D 408 # 2 Berlin (Marathon)
F E1EE1438 00 0000000000000000 7.0°E 11500V 20170923@0806 MOTO GP ARAGON
F DE1F1603 00 0000000000000000 7.0°E 12564H 20170923@1928 AUT10/ITTF-Austria-1
F B2A42DDC 00 0000000000000000 7.0°E 12569H 20170923@1129 Arqiva HD3
F F471D2EB 00 0000000000000000 10.0°E 10887V 20170923@1251 Zambia OB6 Encoder 1
F 8C0768BC 00 0000000000000000 10.0°E 11059V 20170923@1224 Rai ITA 475A
F A26143E5 00 0000000000000000 10.0°E 11043V 20170923@1241 Rai ITA77A
F 980634F3 00 0000000000000000 10.0°E 11055V 20170923@1354 RAI ITA 94 A
F FC6D9C33 00 0000000000000000 10.0°E 11062V 20170923@1225 Rai ITA 475B
F F1C53A0C 00 0000000000000000 10.0°E 11067V 20170923@1227 Rai ITA76B
F 84919CDE 00 0000000000000000 10.0°E 11107V 20170923@1356 RAI ITA88A
F 95D7FA42 00 0000000000000000 10.0°E 11163H 20170923@1154 GCUK Enc 1 (Scottish Football)
F AF95A273 00 0000000000000000 10.0°E 11500H 20170923@1247 GCUK Enc 5
F 96E924AE 00 0000000000000000 10.0°E 11500V 20170923@1407 MOTO GP ARAGON
F 96E924AE 00 0000000000000000 10.0°E 11500V 20170924@0750 MOTO GP ARAGON
F EABD1656 00 0000000000000000 10.0°E 12739V 20170923@1301 E-399 Via1
F B61C7EB2 00 0000000000000000 16.0°E 10997H 20170924@0735 EUTELSAT 16A S3-02
F FA02EC8D 00 0000000000000000 16.0°E 11000H 20170924@0736 ITA466 RM-1
F F47D3E5F 00 0000000000000000 21.6°E 0H 20170923@1802 MBC Feed
F E099AD52 00 0000000000000000 28.2°E 12683H 20170923@1427 SiS80 Coder 2 (Premiership Football)
I occasionally see incorrect frequency/polarity 0H. On those channels I see the namespace reported in enigma2's webif with lower 16 bits all 0's too, so suspect a bug in openatv/enigma2.
Patch placed here as I couldn't see how to insert an attachment (maybe I don't have rights, or am blind this morning lol). First patch oscam svn with oscam-emu.patch, then this one.:
Code:
Common subdirectories: oscam-svn-emu/cscrypt and oscam-svn-dev/cscrypt
Common subdirectories: oscam-svn-emu/csctapi and oscam-svn-dev/csctapi
Common subdirectories: oscam-svn-emu/devtools and oscam-svn-dev/devtools
Common subdirectories: oscam-svn-emu/Distribution and oscam-svn-dev/Distribution
Common subdirectories: oscam-svn-emu/extapi and oscam-svn-dev/extapi
Common subdirectories: oscam-svn-emu/ffdecsa and oscam-svn-dev/ffdecsa
Common subdirectories: oscam-svn-emu/minilzo and oscam-svn-dev/minilzo
diff -u oscam-svn-emu/module-dvbapi.c oscam-svn-dev/module-dvbapi.c
--- oscam-svn-emu/module-dvbapi.c 2017-09-24 09:30:50.415061296 +0100
+++ oscam-svn-dev/module-dvbapi.c 2017-09-24 09:25:00.000000000 +0100
@@ -2141,6 +2141,25 @@
er->ecmlen += 2;
}
+ //add more pids/IDs to better "fingerprint" the feed
+ i2b_buf(2, er->caid, er->ecm + 3 + er->ecm[2]);
+ i2b_buf(2, er->pid, er->ecm + 5 + er->ecm[2]);
+ i2b_buf(2, er->prid, er->ecm + 7 + er->ecm[2]);
+ i2b_buf(2, er->pmtpid, er->ecm + 9 + er->ecm[2]);
+ i2b_buf(2, er->onid, er->ecm + 11 + er->ecm[2]);
+ i2b_buf(2, er->tsid, er->ecm + 13 + er->ecm[2]);
+ uint32_t ensp=demux[demux_id].enigma_namespace;
+ i2b_buf(4, ensp, er->ecm + 15 + er->ecm[2]);
+
+ //generate a hash from the pid list
+ int32_t pidsCRC32=crc32(0x2600, er->ecm + 3, er->ecm[2] + 16);
+
+ pidsCRC32|=0x80000000; //set bit31: flag to BISS emu this is our CRC32, not a pid ie use full 32bit hash instead of (tsid<<16 | pid) as key index
+ i2b_buf(4, pidsCRC32, er->ecm + 3 + er->ecm[2]); //place crc32 after last stream pid
+ i2b_buf(4, ensp, er->ecm + 3 + er->ecm[2] + 4); //place namespace after crc32 hash (we'll use this to annotate the softcam entry with pos & freq)
+ er->ecm[2] += 8;
+ er->ecmlen += 8;
+
cs_log("Demuxer %d trying to descramble PID %d CAID %04X PROVID %06X ECMPID %04X ANY CHID PMTPID %04X VPID %04X", demux_id, pid,
demux[demux_id].ECMpids[pid].CAID, demux[demux_id].ECMpids[pid].PROVID, demux[demux_id].ECMpids[pid].ECM_PID,
demux[demux_id].pmtpid, demux[demux_id].ECMpids[pid].VPID);
diff -u oscam-svn-emu/module-emulator-osemu.c oscam-svn-dev/module-emulator-osemu.c
--- oscam-svn-emu/module-emulator-osemu.c 2017-09-24 09:30:50.485058327 +0100
+++ oscam-svn-dev/module-emulator-osemu.c 2017-09-24 09:15:27.000000000 +0100
@@ -2420,15 +2420,48 @@
}
// BISS Emu
+void time2str(char * buf, uint8_t len)
+{
+ time_t rawtime;
+ struct tm timeinfo;
+ time(&rawtime);
+ localtime_r(&rawtime, &timeinfo);
+ strftime(buf, len, "%Y%m%d@%H%M", &timeinfo);
+}
+
+void namespace2str(char *buf, uint8_t len, uint32_t hash)
+{
+ //extract pos & freq from namespace hash. See
+ //https://github.com/openatv/enigma2/blob/master/lib/dvb/frontend.cpp#L496
+ //hash = (sat.orbital_position << 16);
+ //hash |= ((sat.frequency/1000)&0xFFFF)|((sat.polarisation&1) << 15);
+
+ uint16_t frequency, degrees;
+ char compass, polarisation;
+
+ degrees = hash **** 16;
+ if (degrees > 1800)
+ {
+ degrees = 3600 - degrees;
+ compass = 'W';
+ }
+ else compass = 'E';
+
+ frequency = hash & 0x7FFF;
+ polarisation = hash&0x8000 ? 'V':'H';
+
+ snprintf(buf, len, "%5.1f\xB0%c %5d%c", degrees/10.0, compass, frequency, polarisation);
+}
+
static int8_t BissECM(uint16_t UNUSED(caid), const uint8_t *ecm, int16_t ecmDataLen,
uint8_t *dw, uint16_t srvid, uint16_t ecmpid)
{
uint8_t haveKey1 = 0, haveKey2 = 0;
uint16_t ecmLen = 0, pid = 0;
- uint32_t i;
+ uint32_t i, pidsCRC32;
//try using ecmpid if it seems to be valid
- if(ecmpid != 0) {
+ if(ecmpid != 0x1FFF) {
haveKey1 = FindKey('F', (srvid<<16)|ecmpid, 0, "00", dw, 8, 1, 0, 0, NULL);
haveKey2 = FindKey('F', (srvid<<16)|ecmpid, 0, "01", &dw[8], 8, 1, 0, 0, NULL);
@@ -2437,13 +2470,29 @@
else if(!haveKey1 && haveKey2) {memcpy(dw, &dw[8], 8); return 0;}
}
- //try to get the pid from oscam's fake ecm ([sid] ([pid1] [pid2] ... [pidx])
+ //try to get the pid from oscam's fake ecm ([sid] ([pid1] [pid2] ... [pidx] [CRC32] [nameSpace])
if(ecmDataLen >= 3) {
ecmLen = GetEcmLen(ecm);
if(ecmLen > 7 && ecmLen <= ecmDataLen) {
for(i=5; i+1<ecmLen; i+=2) {
pid = b2i(2, ecm+i);
+ if(pid&0x8000 && ecmLen==i+8) {
+ char tbuf[32], tbuf2[32];
+ pidsCRC32=b2i(4, ecm + i);
+ haveKey1 = FindKey('F', pidsCRC32, 0, "00", dw, 8, 1, 0, 0, NULL);
+ namespace2str(tbuf2, sizeof(tbuf2), b2i(4, ecm + i+4));
+ if(haveKey1)
+ {
+ memcpy(&dw[8], dw, 8);
+ cs_log("Key found F %08X ........ %s", pidsCRC32, tbuf2);
+ return 0;
+ }
+ //no key found matching our hash: put example SoftCam.Key BISS line for this feed in the live log
+ time2str(tbuf, sizeof(tbuf));
+ cs_log("F %08X 00 0000000000000000 %s %s", pidsCRC32, tbuf2, tbuf);
+ break;
+ }
haveKey1 = FindKey('F', (srvid<<16)|pid, 0, "00", dw, 8, 1, 0, 0, NULL);
haveKey2 = FindKey('F', (srvid<<16)|pid, 0, "01", &dw[8], 8, 1, 0, 0, NULL);
Common subdirectories: oscam-svn-emu/.svn and oscam-svn-dev/.svn
Common subdirectories: oscam-svn-emu/tommyDS_hashlin and oscam-svn-dev/tommyDS_hashlin
Common subdirectories: oscam-svn-emu/toolchains and oscam-svn-dev/toolchains
Common subdirectories: oscam-svn-emu/utils and oscam-svn-dev/utils
Common subdirectories: oscam-svn-emu/webif and oscam-svn-dev/webif
I'll attach an arm build as used on my SF4008 as soon as I can find the attach button :thum: