Changeset 4771 for trunk/module-dvbapi.c
- Timestamp:
- 03/03/11 23:24:02 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-dvbapi.c
r4736 r4771 5 5 #include "module-dvbapi.h" 6 6 7 #ifdef AZBOX8 #include "openxcas/openxcas_api.h"9 #include "openxcas/openxcas_message.h"10 11 int openxcas_provid, openxcas_seq, openxcas_filter_idx, openxcas_stream_id, openxcas_cipher_idx, openxcas_busy;12 unsigned char openxcas_cw[16];13 unsigned short openxcas_sid, openxcas_caid, openxcas_ecm_pid, openxcas_video_pid, openxcas_audio_pid, openxcas_data_pid;14 15 void azbox_openxcas_ecm_callback(int stream_id, unsigned int sequence, int cipher_index, unsigned int caid, unsigned char *ecm_data, int l, unsigned short pid);16 void azbox_openxcas_ex_callback(int stream_id, unsigned int seq, int idx, unsigned int pid, unsigned char *ecm_data, int l);17 void azbox_send_dcw(struct s_client *client, ECM_REQUEST *er);18 void * azbox_main(void * cli);19 #endif20 21 #ifdef COOL22 int coolapi_set_filter (int fd, int num, int pid, byte * flt, byte * mask);23 int coolapi_remove_filter (int fd, int num);24 int coolapi_open_device (int demux_index, int demux_id);25 int coolapi_close_device(int fd);26 int coolapi_write_cw(int mask, unsigned short *STREAMpids, int count, ca_descr_t * ca_descr);27 int coolapi_set_pid (int demux_id, int num, int index, int pid);28 void coolapi_close_all();29 void dvbapi_write_cw(int demux_id, uchar *cw, int index);30 #endif31 7 const char *boxdesc[] = { "none", "dreambox", "duckbox", "ufs910", "dbox2", "ipbox", "ipbox-pmt", "dm7000", "qboxhd", "coolstream", "neumo" }; 32 8 … … 49 25 struct s_dvbapi_priority *dvbapi_priority=NULL; 50 26 struct s_client *dvbapi_client=NULL; 27 28 int stapi_on = 0; 51 29 52 30 int dvbapi_set_filter(int demux_id, int api, unsigned short pid, uchar *filt, uchar *mask, int timeout, int pidindex, int count, int type) { … … 823 801 if (p->ecmpid && p->ecmpid != ecmpid->ECM_PID) continue; 824 802 if (p->srvid && p->srvid != demux[demux_id].program_number) continue; 825 if (p->chid && ecmpid->irdeto_chid && p->chid != ecmpid->irdeto_chid) continue;826 803 827 804 return p; … … 1461 1438 } 1462 1439 1440 if (buffer[4] != curpid->irdeto_curchid) { 1441 //wait for the correct chid 1442 return; 1443 } 1444 1463 1445 if (demux[demux_id].pidindex==-1) { 1464 1446 int chid = (buffer[6] << 8) | buffer[7]; 1465 curpid->irdeto_chid = 0;1466 struct s_dvbapi_priority *chidentry = dvbapi_check_prio_match(demux_id, demux[demux_id].demux_fd[filter_num].pidindex, 'p');1467 1468 1447 curpid->irdeto_chid = chid; 1448 1449 struct s_dvbapi_priority *chidentry_priority = dvbapi_check_prio_match(demux_id, demux[demux_id].demux_fd[filter_num].pidindex, 'p'); 1469 1450 struct s_dvbapi_priority *chidentry_ignore = dvbapi_check_prio_match(demux_id, demux[demux_id].demux_fd[filter_num].pidindex, 'i'); 1470 if (chidentry_ignore || (chidentry && chidentry->chid && chidentry->chid != chid)) { 1471 cs_debug_mask(D_DVBAPI, "ignoring %04X:%06X:%02X", curpid->CAID, curpid->PROVID, curpid->irdeto_chid); 1472 if (cfg.dvbapi_requestmode!=1) { 1473 dvbapi_try_next_caid(demux_id); 1474 return; 1475 } 1476 1451 1452 if ((chidentry_priority && chidentry_priority->chid && chidentry_priority->chid != chid) || (chidentry_ignore && chidentry_ignore->chid && chidentry_ignore->chid == chid)) { 1477 1453 if (curpid->irdeto_curchid+1 < curpid->irdeto_numchids) { 1478 1454 curpid->irdeto_curchid++; 1479 1455 curpid->table=0; 1480 1456 cs_log("trying irdeto chid index: %d", curpid->irdeto_curchid); 1457 } else { 1458 if (cfg.dvbapi_requestmode == 0) 1459 dvbapi_try_next_caid(demux_id); 1460 else 1461 dvbapi_stop_filternum(demux_id, filter_num); 1481 1462 } 1482 } 1483 } 1484 1485 if (buffer[4] != curpid->irdeto_curchid) { 1486 //wait for the correct chid 1487 return; 1463 return; 1464 } 1488 1465 } 1489 1466 } … … 1590 1567 1591 1568 int listenfd = -1; 1592 if (cfg.dvbapi_boxtype != BOXTYPE_IPBOX_PMT && cfg.dvbapi_pmtmode != 2 ) {1569 if (cfg.dvbapi_boxtype != BOXTYPE_IPBOX_PMT && cfg.dvbapi_pmtmode != 2 && cfg.dvbapi_pmtmode != 5) { 1593 1570 listenfd = dvbapi_init_listenfd(); 1594 1571 if (listenfd < 1) { … … 1598 1575 } 1599 1576 1600 if (cfg.dvbapi_pmtmode != 4 ) {1577 if (cfg.dvbapi_pmtmode != 4 && cfg.dvbapi_pmtmode != 5) { 1601 1578 struct sigaction signal_action; 1602 1579 signal_action.sa_handler = event_handler; … … 1904 1881 return NULL; 1905 1882 } 1883 1884 1885 #ifdef WITH_STAPI 1886 static void stapi_off() { 1887 int i; 1888 1889 pthread_mutex_lock(&filter_lock); 1890 1891 disable_pmt_files=1; 1892 stapi_on=0; 1893 1894 for (i=0;i<MAX_DEMUX;i++) 1895 dvbapi_stop_descrambling(i); 1896 1897 for (i=0;i<PTINUM;i++) { 1898 if (dev_list[i].SessionHandle>0) { 1899 if (dev_list[i].SignalHandle > 0) { 1900 oscam_stapi_SignalAbort(dev_list[i].SignalHandle); 1901 } 1902 pthread_cancel(dev_list[i].thread); 1903 } 1904 } 1905 1906 pthread_mutex_unlock(&filter_lock); 1907 sleep(2); 1908 return; 1909 } 1910 1911 static int stapi_open() { 1912 uint ErrorCode; 1913 1914 DIR *dirp; 1915 struct dirent *dp; 1916 struct stat buf; 1917 int i; 1918 char pfad[80]; 1919 stapi_on=1; 1920 int stapi_priority=0; 1921 1922 dirp = opendir(PROCDIR); 1923 if (!dirp) { 1924 cs_log("opendir errno %d", errno); 1925 return FALSE; 1926 } 1927 1928 memset(dev_list, 0, sizeof(struct STDEVICE)*PTINUM); 1929 1930 if (dvbapi_priority) { 1931 struct s_dvbapi_priority *p; 1932 for (p=dvbapi_priority; p != NULL; p=p->next) { 1933 if (p->type=='s') { 1934 stapi_priority=1; 1935 break; 1936 } 1937 } 1938 } 1939 1940 if (!stapi_priority) { 1941 cs_log("WARNING: no PTI devices defined, stapi disabled"); 1942 return FALSE; 1943 } 1944 1945 oscam_stapi_CheckVersion(); 1946 1947 i=0; 1948 while ((dp = readdir(dirp))) { 1949 sprintf(pfad, "%s%s", PROCDIR, dp->d_name); 1950 if (stat(pfad,&buf) != 0) 1951 continue; 1952 1953 if (!(buf.st_mode & S_IFDIR && strncmp(dp->d_name, ".", 1)!=0)) 1954 continue; 1955 1956 int do_open=0; 1957 struct s_dvbapi_priority *p; 1958 1959 for (p=dvbapi_priority; p != NULL; p=p->next) { 1960 if (p->type!='s') continue; 1961 if(strcmp(dp->d_name, p->devname)==0) { 1962 do_open=1; 1963 break; 1964 } 1965 } 1966 1967 if (!do_open) { 1968 cs_log("PTI: %s skipped", dp->d_name); 1969 continue; 1970 } 1971 1972 ErrorCode= oscam_stapi_Open(dp->d_name, &dev_list[i].SessionHandle); 1973 if (ErrorCode != 0) { 1974 cs_log("STPTI_Open ErrorCode: %d", ErrorCode); 1975 continue; 1976 } 1977 1978 //debug 1979 //oscam_stapi_Capability(dp->d_name); 1980 1981 strcpy(dev_list[i].name,dp->d_name); 1982 cs_log("PTI: %s open %d", dp->d_name, i); 1983 1984 ErrorCode = oscam_stapi_SignalAllocate(dev_list[i].SessionHandle, &dev_list[i].SignalHandle); 1985 if (ErrorCode != 0) 1986 cs_log("SignalAllocate: ErrorCode: %d SignalHandle: %x", ErrorCode, dev_list[i].SignalHandle); 1987 1988 i++; 1989 if (i>=PTINUM) break; 1990 } 1991 closedir(dirp); 1992 1993 if (i==0) return FALSE; 1994 1995 pthread_mutex_init(&filter_lock, NULL); 1996 1997 for (i=0;i<PTINUM;i++) { 1998 if (dev_list[i].SessionHandle==0) 1999 continue; 2000 2001 struct read_thread_param *para=malloc(sizeof(struct read_thread_param)); 2002 para->id=i; 2003 para->cli=cur_client(); 2004 2005 pthread_create(&dev_list[i].thread, NULL, stapi_read_thread, (void *)para); 2006 pthread_detach(dev_list[i].thread); 2007 } 2008 2009 atexit(stapi_off); 2010 2011 cs_log("liboscam_stapi v.%s initialized", oscam_stapi_LibVersion()); 2012 return TRUE; 2013 } 2014 2015 static int stapi_set_filter(int demux_id, ushort pid, uchar *filter, uchar *mask, int num, char *pmtfile) { 2016 int i; 2017 ushort pids[1] = { pid }; 2018 struct s_dvbapi_priority *p; 2019 2020 if (!pmtfile) return FALSE; 2021 2022 cs_debug_mask(D_DVBAPI, "pmt file %s demux_id %d", pmtfile, demux_id); 2023 2024 for (p=dvbapi_priority; p != NULL; p=p->next) { 2025 if (p->type!='s') continue; 2026 if (strcmp(pmtfile, p->pmtfile)!=0) 2027 continue; 2028 2029 for (i=0;i<PTINUM;i++) { 2030 if(strcmp(dev_list[i].name, p->devname)==0 && p->disablefilter==0) { 2031 cs_debug_mask(D_DVBAPI, "set stapi filter on %s for pid %04X", dev_list[i].name, pids[0]); 2032 stapi_do_set_filter(demux_id, &dev_list[i].demux_fd[demux_id][num], pids, 1, filter, mask, i); 2033 } 2034 } 2035 } 2036 2037 cs_debug_mask(D_DVBAPI, "filter #%d set (pid %04X)", num, pid); 2038 return TRUE; 2039 } 2040 2041 static int stapi_remove_filter(int demux_id, int num, char *pmtfile) { 2042 int i; 2043 struct s_dvbapi_priority *p; 2044 2045 if (!pmtfile) return FALSE; 2046 2047 for (p=dvbapi_priority; p != NULL; p=p->next) { 2048 if (p->type!='s') continue; 2049 if (strcmp(pmtfile, p->pmtfile)!=0) 2050 continue; 2051 2052 for (i=0;i<PTINUM;i++) { 2053 if(strcmp(dev_list[i].name, p->devname)==0 && p->disablefilter==0) { 2054 stapi_do_remove_filter(demux_id, &dev_list[i].demux_fd[demux_id][num], i); 2055 } 2056 } 2057 } 2058 2059 cs_debug_mask(D_DVBAPI, "filter #%d removed", num); 2060 return TRUE; 2061 } 2062 2063 static uint check_slot(int dev_id, uint checkslot, FILTERTYPE *skipfilter) { 2064 int d,f,l; 2065 for (d=0; d<MAX_DEMUX; d++) { 2066 for (f=0; f<MAX_FILTER; f++) { 2067 if (skipfilter && &dev_list[dev_id].demux_fd[d][f] == skipfilter) 2068 continue; 2069 for (l=0; l<dev_list[dev_id].demux_fd[d][f].NumSlots; l++) { 2070 if (checkslot == dev_list[dev_id].demux_fd[d][f].SlotHandle[l]) { 2071 return dev_list[dev_id].demux_fd[d][f].BufferHandle[l]; 2072 } 2073 } 2074 } 2075 } 2076 return 0; 2077 } 2078 2079 2080 static int stapi_do_set_filter(int demux_id, FILTERTYPE *filter, ushort *pids, int pidcount, uchar *filt, uchar *mask, int dev_id) { 2081 uint FilterAssociateError=0; 2082 int k, ErrorCode=0, ret=0; 2083 2084 filter->fd = 0; 2085 filter->BufferHandle[0] = 0; 2086 filter->SlotHandle[0] = 0; 2087 2088 if (dev_list[dev_id].SessionHandle==0) return FALSE; 2089 2090 uint FilterAllocateError = oscam_stapi_FilterAllocate(dev_list[dev_id].SessionHandle, &filter->fd); 2091 2092 if (FilterAllocateError != 0) { 2093 cs_log("FilterAllocate problem"); 2094 filter->fd=0; 2095 return FALSE; 2096 } 2097 2098 for (k=0;k<pidcount;k++) { 2099 ushort pid = pids[k]; 2100 2101 uint QuerySlot = oscam_stapi_PidQuery(dev_list[dev_id].name, pid); 2102 int SlotInit=1; 2103 2104 if (QuerySlot != 0) { 2105 uint checkslot = check_slot(dev_id, QuerySlot, NULL); 2106 if (checkslot>0) { 2107 filter->SlotHandle[k] = QuerySlot; 2108 filter->BufferHandle[k] = checkslot; 2109 SlotInit=0; 2110 } else { 2111 cs_log("overtake: clear pid: %d", oscam_stapi_SlotClearPid(QuerySlot)); 2112 SlotInit=1; 2113 } 2114 } 2115 2116 if (SlotInit==1) { 2117 ret = oscam_stapi_SlotInit(dev_list[dev_id].SessionHandle, dev_list[dev_id].SignalHandle, &filter->BufferHandle[k], &filter->SlotHandle[k], pid); 2118 } 2119 2120 FilterAssociateError = oscam_stapi_FilterAssociate(filter->fd, filter->SlotHandle[k]); 2121 filter->NumSlots++; 2122 } 2123 2124 uint FilterSetError = oscam_stapi_FilterSet(filter->fd, filt, mask); 2125 2126 if (ret || FilterAllocateError || FilterAssociateError || FilterSetError) { 2127 cs_log("set_filter: dev: %d FAl: %d FAs: %d FS: %d", 2128 dev_id, FilterAllocateError, FilterAssociateError, FilterSetError); 2129 stapi_do_remove_filter(demux_id, filter, dev_id); 2130 return FALSE; 2131 } else { 2132 return TRUE; 2133 } 2134 } 2135 2136 static int stapi_do_remove_filter(int demux_id, FILTERTYPE *filter, int dev_id) { 2137 if (filter->fd==0) return FALSE; 2138 2139 uint BufferDeallocateError=0, SlotDeallocateError=0; 2140 2141 if (dev_list[dev_id].SessionHandle==0) return FALSE; 2142 2143 int k; 2144 for (k=0;k<filter->NumSlots;k++) { 2145 uint checkslot = check_slot(dev_id, filter->SlotHandle[k], filter); 2146 2147 if (checkslot==0) { 2148 BufferDeallocateError = oscam_stapi_BufferDeallocate(filter->BufferHandle[k]); 2149 SlotDeallocateError = oscam_stapi_SlotDeallocate(filter->SlotHandle[k]); 2150 } 2151 } 2152 uint FilterDeallocateError = oscam_stapi_FilterDeallocate(filter->fd); 2153 2154 memset(filter, 0, sizeof(FILTERTYPE)); 2155 2156 if (BufferDeallocateError||SlotDeallocateError||FilterDeallocateError) { 2157 cs_log("remove_filter: dev: %d BD: %d SD: %d FDe: %d", 2158 dev_id, BufferDeallocateError, SlotDeallocateError, FilterDeallocateError); 2159 return FALSE; 2160 } else { 2161 return TRUE; 2162 } 2163 } 2164 2165 static void stapi_cleanup_thread(void *dev){ 2166 int dev_index=(int)dev; 2167 2168 int ErrorCode; 2169 ErrorCode = oscam_stapi_Close(dev_list[dev_index].SessionHandle); 2170 2171 printf("liboscam_stapi: PTI %s closed - %d\n", dev_list[dev_index].name, ErrorCode); 2172 dev_list[dev_index].SessionHandle=0; 2173 } 2174 2175 static void *stapi_read_thread(void *sparam) { 2176 int dev_index, ErrorCode, i, j, CRCValid; 2177 uint QueryBufferHandle = 0, DataSize = 0; 2178 uchar buf[BUFFLEN]; 2179 2180 struct read_thread_param *para=sparam; 2181 dev_index=para->id; 2182 2183 pthread_setspecific(getclient, para->cli); 2184 pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL); 2185 pthread_cleanup_push(stapi_cleanup_thread, (void*) dev_index); 2186 2187 int error_count=0; 2188 2189 while (1) { 2190 QueryBufferHandle = 0; 2191 ErrorCode = oscam_stapi_SignalWaitBuffer(dev_list[dev_index].SignalHandle, &QueryBufferHandle, 1000); 2192 2193 switch (ErrorCode) { 2194 case 0: // NO_ERROR: 2195 break; 2196 case 852042: // ERROR_SIGNAL_ABORTED 2197 pthread_exit(NULL); 2198 break; 2199 case 11: // ERROR_TIMEOUT: 2200 //cs_log("timeout %d", dev_index); 2201 //TODO: if pidindex == -1 try next 2202 continue; 2203 break; 2204 default: 2205 if (QueryBufferHandle != 0) { 2206 cs_log("SignalWaitBuffer error: %d", ErrorCode); 2207 oscam_stapi_BufferFlush(QueryBufferHandle); 2208 continue; 2209 } 2210 cs_log("SignalWaitBuffer: index %d ErrorCode: %d - QueryBuffer: %x", dev_index, ErrorCode, QueryBufferHandle); 2211 error_count++; 2212 if (error_count>10) { 2213 cs_log("Too many errors in reader thread %d, quitting.", dev_index); 2214 pthread_exit(NULL); 2215 } 2216 continue; 2217 break; 2218 } 2219 2220 unsigned int NumFilterMatches = 0; 2221 int demux_id=0, filter_num=0; 2222 DataSize = 0; 2223 int found=0, k; 2224 2225 unsigned int MatchedFilterList[10]; 2226 ErrorCode = oscam_stapi_BufferReadSection(QueryBufferHandle, MatchedFilterList, 10, &NumFilterMatches, &CRCValid, buf, BUFFLEN, &DataSize); 2227 2228 if (ErrorCode != 0) { 2229 cs_log("BufferRead: index: %d ErrorCode: %d", dev_index, ErrorCode); 2230 cs_sleepms(1000); 2231 continue; 2232 } 2233 2234 if (DataSize<=0) 2235 continue; 2236 2237 pthread_mutex_lock(&filter_lock); 2238 for(k=0;k<NumFilterMatches;k++) { 2239 for (i=0;i<MAX_DEMUX;i++) { 2240 for (j=0;j<MAX_FILTER;j++) { 2241 if (dev_list[dev_index].demux_fd[i][j].fd == MatchedFilterList[k]) { 2242 demux_id=i; 2243 filter_num=j; 2244 2245 dvbapi_process_input(demux_id, filter_num, buf, DataSize); 2246 } 2247 } 2248 } 2249 } 2250 pthread_mutex_unlock(&filter_lock); 2251 } 2252 pthread_cleanup_pop(0); 2253 } 2254 2255 #define ASSOCIATE 1 2256 #define DISASSOCIATE 0 2257 2258 #define DE_START 0 2259 #define DE_STOP 1 2260 2261 static void stapi_DescramblerAssociate(int demux_id, ushort pid, int mode, int n) { 2262 uint Slot=0; 2263 int ErrorCode=0; 2264 2265 if (dev_list[n].SessionHandle==0) return; 2266 2267 Slot = oscam_stapi_PidQuery(dev_list[n].name, pid); 2268 if (!Slot) return; 2269 2270 if (demux[demux_id].DescramblerHandle[n]==0) return; 2271 2272 if (mode == ASSOCIATE) { 2273 int k; 2274 for (k=0;k<SLOTNUM;k++) { 2275 if (demux[demux_id].slot_assc[n][k]==Slot) { 2276 return; 2277 } 2278 } 2279 2280 ErrorCode = oscam_stapi_DescramblerAssociate(demux[demux_id].DescramblerHandle[n], Slot); 2281 cs_debug_mask(D_DVBAPI, "set pid %04x on %s", pid, dev_list[n].name); 2282 2283 if (ErrorCode != 0) 2284 cs_log("DescramblerAssociate %d",ErrorCode); 2285 2286 for (k=0;k<SLOTNUM;k++) { 2287 if (demux[demux_id].slot_assc[n][k]==0) { 2288 demux[demux_id].slot_assc[n][k]=Slot; 2289 break; 2290 } 2291 } 2292 } else { 2293 ErrorCode = oscam_stapi_DescramblerDisassociate(demux[demux_id].DescramblerHandle[n], Slot); 2294 if (ErrorCode != 0) 2295 cs_debug_mask(D_DVBAPI, "DescramblerDisassociate %d", ErrorCode); 2296 2297 cs_debug_mask(D_DVBAPI, "unset pid %04x on %s", pid, dev_list[n].name); 2298 2299 int k; 2300 for (k=0;k<SLOTNUM;k++) { 2301 if (demux[demux_id].slot_assc[n][k]==Slot) { 2302 demux[demux_id].slot_assc[n][k]=0; 2303 return; 2304 } 2305 } 2306 } 2307 2308 return; 2309 } 2310 2311 static void stapi_startdescrambler(int demux_id, int dev_index, int mode) { 2312 int ErrorCode; 2313 2314 if (mode == DE_START && demux[demux_id].DescramblerHandle[dev_index] == 0) { 2315 uint DescramblerHandle=0; 2316 ErrorCode = oscam_stapi_DescramblerAllocate(dev_list[dev_index].SessionHandle, &DescramblerHandle); 2317 if (ErrorCode != 0) { 2318 cs_log("DescramblerAllocate: ErrorCode: %d SignalHandle: %x", ErrorCode, dev_list[dev_index].SignalHandle); 2319 return; 2320 } 2321 2322 demux[demux_id].DescramblerHandle[dev_index]=DescramblerHandle; 2323 } 2324 2325 if (mode == DE_STOP && demux[demux_id].DescramblerHandle[dev_index] > 0) { 2326 ErrorCode = oscam_stapi_DescramblerDeallocate(demux[demux_id].DescramblerHandle[dev_index]); 2327 2328 if (ErrorCode != 0) 2329 cs_log("DescramblerDeallocate: ErrorCode: %d", ErrorCode); 2330 2331 demux[demux_id].DescramblerHandle[dev_index]=0; 2332 } 2333 2334 return; 2335 } 2336 2337 static int stapi_set_pid(int demux_id, int num, int index, ushort pid, char *pmtfile) { 2338 int n; 2339 2340 if (index==-1) { 2341 for (n=0;n<PTINUM;n++) { 2342 if (demux[demux_id].DescramblerHandle[n]==0) continue; 2343 2344 cs_debug_mask(D_DVBAPI, "stop descrambling PTI: %s", dev_list[n].name); 2345 stapi_startdescrambler(demux_id, n, DE_STOP); 2346 } 2347 memset(demux[demux_id].slot_assc[n], 0, SLOTNUM); 2348 } 2349 2350 return TRUE; 2351 } 2352 2353 static int stapi_write_cw(int demux_id, uchar *cw, ushort *STREAMpids, int STREAMpidcount, char *pmtfile) { 2354 int ErrorCode, l, n, k; 2355 unsigned char nullcw[8]; 2356 memset(nullcw, 0, 8); 2357 char *text[] = { "even", "odd" }; 2358 2359 if (!pmtfile) return FALSE; 2360 2361 for (n=0;n<PTINUM;n++) { 2362 if (dev_list[n].SessionHandle==0) continue; 2363 if (demux[demux_id].DescramblerHandle[n]==0) { 2364 struct s_dvbapi_priority *p; 2365 2366 for (p=dvbapi_priority; p != NULL; p=p->next) { 2367 if (p->type!='s') continue; 2368 if (strcmp(pmtfile, p->pmtfile)!=0) 2369 continue; 2370 2371 if(strcmp(dev_list[n].name, p->devname)==0) { 2372 cs_debug_mask(D_DVBAPI, "start descrambling PTI: %s", dev_list[n].name); 2373 stapi_startdescrambler(demux_id, n, DE_START); 2374 } 2375 } 2376 } 2377 2378 if (demux[demux_id].DescramblerHandle[n] == 0) continue; 2379 for (k=0;k<STREAMpidcount;k++) { 2380 stapi_DescramblerAssociate(demux_id, STREAMpids[k], ASSOCIATE, n); 2381 } 2382 } 2383 2384 for (l=0;l<2;l++) { 2385 if (memcmp(cw+(l*8), demux[demux_id].lastcw[l], 8)!=0 && memcmp(cw+(l*8),nullcw,8)!=0) { 2386 for (n=0;n<PTINUM;n++) { 2387 if (demux[demux_id].DescramblerHandle[n]==0) continue; 2388 2389 ErrorCode = oscam_stapi_DescramblerSet(demux[demux_id].DescramblerHandle[n], l, cw+(l*8)); 2390 if (ErrorCode != 0) 2391 cs_log("DescramblerSet: ErrorCode: %d", ErrorCode); 2392 2393 memcpy(demux[demux_id].lastcw[l],cw+(l*8),8); 2394 cs_debug_mask(D_DVBAPI, "write cw %s index: %d %s", text[l], demux_id, dev_list[n].name); 2395 } 2396 } 2397 } 2398 2399 return TRUE; 2400 } 2401 #endif //WITH_STAPI 1906 2402 1907 2403
Note:
See TracChangeset
for help on using the changeset viewer.