- Timestamp:
- 06/26/17 19:26:42 (7 years ago)
- Location:
- trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-dvbapi.c
r11385 r11386 483 483 } 484 484 485 int32_t dvbapi_net_send(uint32_t request, int32_t socket_fd, int32_t demux_index, uint32_t filter_number, unsigned char *data, struct s_client *client, ECM_REQUEST *er, uint16_t client_proto_version)485 int32_t dvbapi_net_send(uint32_t request, int32_t socket_fd, uint32_t msgid, int32_t demux_index, uint32_t filter_number, unsigned char *data, struct s_client *client, ECM_REQUEST *er, uint16_t client_proto_version) 486 486 { 487 487 unsigned char packet[DVBAPI_MAX_PACKET_SIZE]; //maximum possible packet size 488 488 int32_t size = 0; 489 uint32_t u32; 489 490 490 491 // not connected? … … 497 498 if (client_proto_version <= 0) 498 499 packet[size++] = demux[demux_index].adapter_index; //adapter index - 1 byte 500 else if (client_proto_version >= 3) { 501 packet[size++] = 0xa5; //message start 502 u32 = htonl(msgid); 503 memcpy(&packet[size], &u32, 4); 504 size += 4; 505 } 499 506 500 507 // type of request 501 u int32_t req= request;508 u32 = request; 502 509 if (client_proto_version >= 1) 503 req = htonl(req);504 memcpy(&packet[size], & req, 4); //request - 4 bytes510 u32 = htonl(u32); 511 memcpy(&packet[size], &u32, 4); 505 512 size += 4; 506 513 … … 784 791 memcpy(sFP2.filter.mask, mask, 16); 785 792 if (cfg.dvbapi_listenport || cfg.dvbapi_boxtype == BOXTYPE_PC_NODMX) 786 ret = dvbapi_net_send(DVBAPI_DMX_SET_FILTER, demux[demux_id].socket_fd, demux_id, n, (unsigned char *) &sFP2, NULL, NULL, demux[demux_id].client_proto_version);793 ret = dvbapi_net_send(DVBAPI_DMX_SET_FILTER, demux[demux_id].socket_fd, 0, demux_id, n, (unsigned char *) &sFP2, NULL, NULL, demux[demux_id].client_proto_version); 787 794 else 788 795 ret = dvbapi_ioctl(filterfd, DMX_SET_FILTER, &sFP2); … … 1123 1130 } 1124 1131 1125 int32_t dvbapi_stop_filter(int32_t demux_index, int32_t type )1132 int32_t dvbapi_stop_filter(int32_t demux_index, int32_t type, uint32_t msgid) 1126 1133 { 1127 1134 #if defined(WITH_COOLAPI) || defined(WITH_COOLAPI2) … … 1138 1145 if(demux[demux_index].demux_fd[g].type == type) 1139 1146 { 1140 if(dvbapi_stop_filternum(demux_index, g ) == -1)1147 if(dvbapi_stop_filternum(demux_index, g, msgid) == -1) 1141 1148 { 1142 1149 error = 1; … … 1147 1154 } 1148 1155 1149 int32_t dvbapi_stop_filternum(int32_t demux_index, int32_t num )1156 int32_t dvbapi_stop_filternum(int32_t demux_index, int32_t num, uint32_t msgid) 1150 1157 { 1151 1158 int32_t retfilter = -1, retfd = -1, fd = demux[demux_index].demux_fd[num].fd, try = 0; … … 1175 1182 case DVBAPI_3: 1176 1183 if (cfg.dvbapi_listenport || cfg.dvbapi_boxtype == BOXTYPE_PC_NODMX) 1177 retfilter = dvbapi_net_send(DVBAPI_DMX_STOP, demux[demux_index].socket_fd, demux_index, num, NULL, NULL, NULL, demux[demux_index].client_proto_version);1184 retfilter = dvbapi_net_send(DVBAPI_DMX_STOP, demux[demux_index].socket_fd, msgid, demux_index, num, NULL, NULL, NULL, demux[demux_index].client_proto_version); 1178 1185 else 1179 1186 retfilter = dvbapi_ioctl(fd, DMX_STOP, NULL); … … 1825 1832 } 1826 1833 1827 void dvbapi_set_pid(int32_t demux_id, int32_t num, ca_index_t idx, bool enable, bool use_des )1834 void dvbapi_set_pid(int32_t demux_id, int32_t num, ca_index_t idx, bool enable, bool use_des, uint32_t msgid) 1828 1835 { 1829 1836 int32_t i, currentfd; … … 1900 1907 1901 1908 if(cfg.dvbapi_boxtype == BOXTYPE_PC || cfg.dvbapi_boxtype == BOXTYPE_PC_NODMX) 1902 dvbapi_net_send(DVBAPI_CA_SET_PID, demux[demux_id].socket_fd, demux_id, -1 /*unused*/, (unsigned char *) &ca_pid2, NULL, NULL, demux[demux_id].client_proto_version);1909 dvbapi_net_send(DVBAPI_CA_SET_PID, demux[demux_id].socket_fd, msgid, demux_id, -1 /*unused*/, (unsigned char *) &ca_pid2, NULL, NULL, demux[demux_id].client_proto_version); 1903 1910 else 1904 1911 { … … 1935 1942 } 1936 1943 1937 void dvbapi_stop_all_descrambling( void)1944 void dvbapi_stop_all_descrambling(uint32_t msgid) 1938 1945 { 1939 1946 int32_t j; … … 1941 1948 { 1942 1949 if(demux[j].program_number == 0) { continue; } 1943 dvbapi_stop_descrambling(j );1944 } 1945 } 1946 1947 void dvbapi_stop_all_emm_sdt_filtering( void)1950 dvbapi_stop_descrambling(j, msgid); 1951 } 1952 } 1953 1954 void dvbapi_stop_all_emm_sdt_filtering(uint32_t msgid) 1948 1955 { 1949 1956 int32_t j; … … 1951 1958 { 1952 1959 if(demux[j].program_number == 0) { continue; } 1953 dvbapi_stop_filter(j, TYPE_EMM );1954 dvbapi_stop_filter(j, TYPE_SDT );1960 dvbapi_stop_filter(j, TYPE_EMM, msgid); 1961 dvbapi_stop_filter(j, TYPE_SDT, msgid); 1955 1962 demux[j].emm_filter = -1; 1956 1963 } … … 1958 1965 1959 1966 1960 void dvbapi_stop_descrambling(int32_t demux_id )1967 void dvbapi_stop_descrambling(int32_t demux_id, uint32_t msgid) 1961 1968 { 1962 1969 int32_t i, j, z; … … 1969 1976 cs_log("Demuxer %d stop descrambling program number %04X (%s)", demux_id, demux[demux_id].program_number, channame); 1970 1977 1971 dvbapi_stop_filter(demux_id, TYPE_EMM );1972 dvbapi_stop_filter(demux_id, TYPE_SDT );1973 dvbapi_stop_filter(demux_id, TYPE_PAT );1974 dvbapi_stop_filter(demux_id, TYPE_PMT );1978 dvbapi_stop_filter(demux_id, TYPE_EMM, msgid); 1979 dvbapi_stop_filter(demux_id, TYPE_SDT, msgid); 1980 dvbapi_stop_filter(demux_id, TYPE_PAT, msgid); 1981 dvbapi_stop_filter(demux_id, TYPE_PMT, msgid); 1975 1982 1976 1983 for(i = 0; i < demux[demux_id].ECMpidcount && demux[demux_id].ECMpidcount > 0; i++) … … 1983 1990 for(z = 0; z < demux[demux_id].STREAMpidcount; z++) 1984 1991 { 1985 dvbapi_set_pid(demux_id, z, demux[demux_id].ECMpids[i].index[j], false, false ); // disable streampid1992 dvbapi_set_pid(demux_id, z, demux[demux_id].ECMpids[i].index[j], false, false, msgid); // disable streampid 1986 1993 } 1987 1994 demux[demux_id].ECMpids[i].index[j] = INDEX_INVALID; 1988 1995 } 1989 1996 } 1990 dvbapi_stop_filter(demux_id, TYPE_ECM );1997 dvbapi_stop_filter(demux_id, TYPE_ECM, msgid); 1991 1998 1992 1999 pthread_mutex_destroy(&demux[demux_id].answerlock); … … 2009 2016 } 2010 2017 2011 int32_t dvbapi_start_descrambling(int32_t demux_id, int32_t pid, int8_t checked )2018 int32_t dvbapi_start_descrambling(int32_t demux_id, int32_t pid, int8_t checked, uint32_t msgid) 2012 2019 { 2013 2020 int32_t started = 0; // in case ecmfilter started = 1 … … 2064 2071 er->pmtpid = demux[demux_id].pmtpid; 2065 2072 er->onid = demux[demux_id].onid; 2073 er->msgid = msgid; 2066 2074 2067 2075 #ifdef WITH_STAPI5 … … 3080 3088 } 3081 3089 3082 void dvbapi_try_next_caid(int32_t demux_id, int8_t checked )3090 void dvbapi_try_next_caid(int32_t demux_id, int8_t checked, uint32_t msgid) 3083 3091 { 3084 3092 … … 3106 3114 || (caid_is_dre(demux[demux_id].ECMpids[found].CAID) && ((demux[demux_id].ECMpids[found].PROVID == 0x11 || demux[demux_id].ECMpids[found].PROVID == 0xFE)))) 3107 3115 { demux[demux_id].emmstart.time = 0; } 3108 3109 started = dvbapi_start_descrambling(demux_id, found, checked); 3116 started = dvbapi_start_descrambling(demux_id, found, checked, msgid); 3110 3117 if(cfg.dvbapi_requestmode == 0 && started == 1) { return; } // in requestmode 0 we only start 1 ecm request at the time 3111 3118 } … … 3175 3182 } 3176 3183 3177 int32_t dvbapi_parse_capmt(unsigned char *buffer, uint32_t length, int32_t connfd, char *pmtfile, int8_t is_real_pmt, uint16_t existing_demux_id, uint16_t client_proto_version )3184 int32_t dvbapi_parse_capmt(unsigned char *buffer, uint32_t length, int32_t connfd, char *pmtfile, int8_t is_real_pmt, uint16_t existing_demux_id, uint16_t client_proto_version, uint32_t msgid) 3178 3185 { 3179 3186 uint32_t i = 0, start_descrambling = 0; … … 3265 3272 { 3266 3273 if(demux[j].program_number == 0) { continue; } 3267 if(demux[j].stopdescramble == 1) { dvbapi_stop_descrambling(j ); }// Stop descrambling and remove all demuxer entries not in new PMT.3274 if(demux[j].stopdescramble == 1) { dvbapi_stop_descrambling(j, msgid); }// Stop descrambling and remove all demuxer entries not in new PMT. 3268 3275 } 3269 3276 start_descrambling = 1; // flag that demuxer descrambling is to be executed! … … 3318 3325 demux_id = existing_demux_id; 3319 3326 3320 dvbapi_stop_filter(demux_id, TYPE_PMT );3327 dvbapi_stop_filter(demux_id, TYPE_PMT, msgid); 3321 3328 3322 3329 program_number = b2i(2, buffer + 3); … … 3559 3566 if(demux[j].running == 0 && demux[j].ECMpidcount != 0 ) // only start demuxer if it wasnt running 3560 3567 { 3561 dvbapi_stop_all_emm_sdt_filtering( ); // remove all unimportant filtering (there are images with limited amount of filters available!)3568 dvbapi_stop_all_emm_sdt_filtering(msgid); // remove all unimportant filtering (there are images with limited amount of filters available!) 3562 3569 cs_log_dbg(D_DVBAPI, "Demuxer %d/%d lets start descrambling (srvid = %04X fd = %d ecmpids = %d)", j, MAX_DEMUX, 3563 3570 demux[j].program_number, connfd, demux[j].ECMpidcount); … … 3566 3573 demux[j].decodingtries = -1; 3567 3574 dvbapi_resort_ecmpids(j); 3568 dvbapi_try_next_caid(j, 0 );3575 dvbapi_try_next_caid(j, 0, msgid); 3569 3576 cs_sleepms(1); 3570 3577 } … … 3575 3582 demux[j].running = 0; // reset running flag 3576 3583 demux[demux_id].pidindex = -1; // reset ecmpid used for descrambling 3577 dvbapi_stop_filter(j, TYPE_ECM );3584 dvbapi_stop_filter(j, TYPE_ECM, msgid); 3578 3585 if(cfg.usrfileflag) { cs_statistics(dvbapi_client);} // add to user log previous channel + time on channel 3579 3586 dvbapi_client->last_srvid = demux[demux_id].program_number; // set new channel srvid … … 3820 3827 } 3821 3828 3822 static void dvbapi_parse_sdt(int32_t demux_id, unsigned char *buffer, uint32_t length )3829 static void dvbapi_parse_sdt(int32_t demux_id, unsigned char *buffer, uint32_t length, uint32_t msgid) 3823 3830 { 3824 3831 uint8_t tag, data_length = 0, provider_name_length, service_name_length, service_type; … … 3911 3918 cs_log_dbg(D_DVBAPI,"sdt-info (provider: %s - channel: %s)", provider_name, service_name); 3912 3919 3913 dvbapi_stop_filter(demux_id, TYPE_SDT );3920 dvbapi_stop_filter(demux_id, TYPE_SDT, msgid); 3914 3921 3915 3922 if(strlen(provider_name) && caid != NO_CAID_VALUE) … … 3989 3996 } 3990 3997 3991 static void dvbapi_parse_pat(int32_t demux_id, unsigned char *buffer, uint32_t length )3998 static void dvbapi_parse_pat(int32_t demux_id, unsigned char *buffer, uint32_t length, uint32_t msgid) 3992 3999 { 3993 4000 uint16_t srvid; 3994 4001 uint32_t i; 3995 4002 3996 dvbapi_stop_filter(demux_id, TYPE_PAT );4003 dvbapi_stop_filter(demux_id, TYPE_PAT, msgid); 3997 4004 3998 4005 for(i=8; i+7<length; i+=4) … … 4125 4132 if((time_t)pmt_info.st_mtime != demux[i].pmt_time) 4126 4133 { 4127 dvbapi_stop_descrambling(i );4134 dvbapi_stop_descrambling(i, 0); 4128 4135 } 4129 4136 … … 4135 4142 { 4136 4143 cs_log("Demuxer %d Unable to open PMT file %s -> stop descrambling!", i, dest); 4137 dvbapi_stop_descrambling(i );4144 dvbapi_stop_descrambling(i, 0); 4138 4145 } 4139 4146 } … … 4271 4278 memcpy(dest + 7, mbuf + 12, len - 12 - 4); 4272 4279 4273 pmt_id = dvbapi_parse_capmt((uchar *)dest, 7 + len - 12 - 4, -1, dp->d_name, 0, 0, 0 );4280 pmt_id = dvbapi_parse_capmt((uchar *)dest, 7 + len - 12 - 4, -1, dp->d_name, 0, 0, 0, 0); 4274 4281 #endif 4275 4282 … … 4304 4311 } 4305 4312 4306 void dvbapi_process_input(int32_t demux_id, int32_t filter_num, uchar *buffer, int32_t len )4313 void dvbapi_process_input(int32_t demux_id, int32_t filter_num, uchar *buffer, int32_t len, uint32_t msgid) 4307 4314 { 4308 4315 struct s_ecmpids *curpid = NULL; … … 4355 4362 dvbapi_edit_channel_cache(demux_id, pid, 0); // remove this pid from channelcache since we had no founds on any ecmpid! 4356 4363 } 4357 dvbapi_stop_filternum(demux_id, filter_num ); // stop this ecm filter!4364 dvbapi_stop_filternum(demux_id, filter_num, msgid); // stop this ecm filter! 4358 4365 return; 4359 4366 } … … 4415 4422 chid = get_subid(er); // fetch chid or fake chid 4416 4423 er->chid = chid; 4424 er->msgid = msgid; 4417 4425 dvbapi_set_section_filter(demux_id, er, filter_num); 4418 4426 NULLFREE(er); … … 4455 4463 er->ecmlen = sctlen; 4456 4464 memcpy(er->ecm, buffer, er->ecmlen); 4465 er->msgid = msgid; 4457 4466 4458 4467 chid = get_subid(er); // fetch chid or fake chid … … 4529 4538 curpid->CHID = 0x10000; 4530 4539 } 4531 dvbapi_stop_filternum(demux_id, filter_num ); // stop this ecm filter!4540 dvbapi_stop_filternum(demux_id, filter_num, msgid); // stop this ecm filter! 4532 4541 NULLFREE(er); 4533 4542 return; … … 4560 4569 curpid->CHID = 0x10000; 4561 4570 } 4562 dvbapi_stop_filternum(demux_id, filter_num ); // stop this ecm filter!4571 dvbapi_stop_filternum(demux_id, filter_num, msgid); // stop this ecm filter! 4563 4572 NULLFREE(er); 4564 4573 return; … … 4632 4641 curpid->CHID = 0x10000; 4633 4642 } 4634 dvbapi_stop_filternum(demux_id, filter_num ); // stop this ecm filter!4643 dvbapi_stop_filternum(demux_id, filter_num, msgid); // stop this ecm filter! 4635 4644 } 4636 4645 NULLFREE(er); … … 4667 4676 dvbapi_parse_cat(demux_id, buffer, sctlen); 4668 4677 4669 dvbapi_stop_filternum(demux_id, filter_num );4678 dvbapi_stop_filternum(demux_id, filter_num, msgid); 4670 4679 return; 4671 4680 } … … 4676 4685 { 4677 4686 cs_log_dump_dbg(D_DVBAPI, buffer, sctlen, "Demuxer %d Filter %d fetched SDT data (length = 0x%03X):", demux_id, filter_num + 1, sctlen); 4678 dvbapi_parse_sdt(demux_id, buffer, sctlen );4687 dvbapi_parse_sdt(demux_id, buffer, sctlen, msgid); 4679 4688 } 4680 4689 … … 4682 4691 { 4683 4692 cs_log_dump_dbg(D_DVBAPI, buffer, sctlen, "Demuxer %d Filter %d fetched PAT data (length = 0x%03X):", demux_id, filter_num + 1, sctlen); 4684 dvbapi_parse_pat(demux_id, buffer, sctlen );4693 dvbapi_parse_pat(demux_id, buffer, sctlen, msgid); 4685 4694 } 4686 4695 … … 4688 4697 { 4689 4698 cs_log_dump_dbg(D_DVBAPI, buffer, sctlen, "Demuxer %d Filter %d fetched CAPMT data (length = 0x%03X):", demux_id, filter_num + 1, sctlen); 4690 dvbapi_parse_capmt(buffer, sctlen, demux[demux_id].socket_fd, demux[demux_id].pmt_file, 1, demux_id, demux[demux_id].client_proto_version );4699 dvbapi_parse_capmt(buffer, sctlen, demux[demux_id].socket_fd, demux[demux_id].pmt_file, 1, demux_id, demux[demux_id].client_proto_version, msgid); 4691 4700 } 4692 4701 } … … 4757 4766 } 4758 4767 4759 static void dvbapi_get_packet_size(uchar* mbuf, uint16_t mbuf_len, uint16_t* chunksize, uint16_t *data_len )4768 static void dvbapi_get_packet_size(uchar* mbuf, uint16_t mbuf_len, uint16_t* chunksize, uint16_t *data_len, uint16_t client_proto_version) 4760 4769 { 4761 4770 //chunksize: size of complete chunk in the buffer (an opcode with the data) 4762 4771 //data_len: variable for internal data length (eg. for the filter data size, PMT len) 4772 uint32_t msgid_size = 0; 4763 4773 4764 4774 (*chunksize) = 0; 4765 4775 (*data_len) = 0; 4766 4776 4767 if(mbuf_len < 4) 4777 if (client_proto_version >= 3) 4778 msgid_size = 5; 4779 4780 if(mbuf_len < 4 + msgid_size) 4768 4781 { 4769 4782 cs_log("dvbapi_get_packet_size(): error - buffer length (%" PRIu16 ") too short", mbuf_len); … … 4773 4786 } 4774 4787 4788 mbuf += msgid_size; 4775 4789 uint32_t opcode = b2i(4, mbuf); //get the client opcode (4 bytes) 4776 4790 … … 4870 4884 (*data_len) = 1; 4871 4885 } 4886 if((*chunksize) > 1) 4887 (*chunksize) += msgid_size; 4872 4888 } 4873 4889 4874 4890 static void dvbapi_handlesockmsg(uchar* mbuf, uint16_t chunksize, uint16_t data_len, uint8_t* add_to_poll, int32_t connfd, uint16_t* client_proto_version) 4875 4891 { 4892 uint32_t msgid = 0; 4893 if (*client_proto_version >= 3) { 4894 if (mbuf[0] != 0xa5) { 4895 cs_log("Error: network packet malformed! (no start)"); 4896 return; 4897 } 4898 msgid = b2i(4, mbuf + 1); 4899 mbuf += 5; 4900 } 4901 4876 4902 uint32_t opcode = b2i(4, mbuf); //get the client opcode (4 bytes) 4877 4903 … … 4891 4917 cs_log_dump_dbg(D_DVBAPI, mbuf, chunksize, "Parsing PMT object:"); 4892 4918 4893 dvbapi_parse_capmt(mbuf + (chunksize - data_len), data_len, connfd, NULL, 0, 0, *client_proto_version );4919 dvbapi_parse_capmt(mbuf + (chunksize - data_len), data_len, connfd, NULL, 0, 0, *client_proto_version, msgid); 4894 4920 break; 4895 4921 } … … 4921 4947 if(demux[i].socket_fd == connfd) 4922 4948 { 4923 dvbapi_stop_descrambling(i );4949 dvbapi_stop_descrambling(i, msgid); 4924 4950 } 4925 4951 } 4926 4952 else if (demux[i].demux_index == demux_index) 4927 4953 { 4928 dvbapi_stop_descrambling(i );4954 dvbapi_stop_descrambling(i, msgid); 4929 4955 break; 4930 4956 } … … 5000 5026 } 5001 5027 5002 dvbapi_process_input(demux_id, filter_num, mbuf + 6, data_len + 3 );5028 dvbapi_process_input(demux_id, filter_num, mbuf + 6, data_len + 3, msgid); 5003 5029 break; 5004 5030 } … … 5020 5046 5021 5047 // as a response we are sending our info to the client: 5022 dvbapi_net_send(DVBAPI_SERVER_INFO, connfd, -1, -1, NULL, NULL, NULL, client_proto);5048 dvbapi_net_send(DVBAPI_SERVER_INFO, connfd, msgid, -1, -1, NULL, NULL, NULL, client_proto); 5023 5049 break; 5024 5050 } … … 5067 5093 { 5068 5094 // we got at least the first few bytes, detect packet type and length, then read the missing bytes 5069 dvbapi_get_packet_size(mbuf, unhandled_len, &chunksize, &data_len );5095 dvbapi_get_packet_size(mbuf, unhandled_len, &chunksize, &data_len, *client_proto_version); 5070 5096 5071 5097 if(chunksize > mbuf_size) … … 5391 5417 if(demux[i].ECMpids[g].checked == 0 && demux[i].ECMpids[g].status >= 0) // check if prio run is done 5392 5418 { 5393 dvbapi_try_next_caid(i, 0 ); // not done, so start next prio pid5419 dvbapi_try_next_caid(i, 0, 0); // not done, so start next prio pid 5394 5420 started = 1; 5395 5421 break; … … 5410 5436 demux[i].ECMpids[g].table = 0; 5411 5437 demux[i].ECMpids[g].CHID = 0x10000; // remove chid prio 5412 dvbapi_try_next_caid(i, 2 ); // not done, so start next no prio pid5438 dvbapi_try_next_caid(i, 2, 0); // not done, so start next no prio pid 5413 5439 started = 1; 5414 5440 break; … … 5457 5483 cs_log("Demuxer %d restarting decodingrequests after %"PRId64" ms with %d enabled and %d disabled ecmpids!", i, gone, number_of_enabled_pids, 5458 5484 (demux[i].ECMpidcount-number_of_enabled_pids)); 5459 dvbapi_try_next_caid(i, 0 );5485 dvbapi_try_next_caid(i, 0, 0); 5460 5486 } 5461 5487 } … … 5526 5552 if(demux[j].socket_fd == pfd2[i].fd) // if listenfd closes stop all assigned decoding! 5527 5553 { 5528 dvbapi_stop_descrambling(j );5554 dvbapi_stop_descrambling(j, 0); 5529 5555 } 5530 5556 … … 5551 5577 if(cfg.dvbapi_boxtype != BOXTYPE_SAMYGO) 5552 5578 { 5553 dvbapi_stop_filternum(demux_index, n ); // stop filter since its giving errors and wont return anything good.5579 dvbapi_stop_filternum(demux_index, n, 0); // stop filter since its giving errors and wont return anything good. 5554 5580 } 5555 5581 else … … 5585 5611 5586 5612 if(ret == -1) 5587 dvbapi_stop_filternum(demux_index, n ); // stop filter since its giving errors and wont return anything good.5613 dvbapi_stop_filternum(demux_index, n, 0); // stop filter since its giving errors and wont return anything good. 5588 5614 } 5589 5615 } … … 5647 5673 if (demux[j].socket_fd == connfd) 5648 5674 { 5649 dvbapi_stop_descrambling(j );5675 dvbapi_stop_descrambling(j, 0); 5650 5676 } 5651 5677 else if (demux[j].socket_fd) … … 5719 5745 if(len < 0) // serious filterdata read error 5720 5746 { 5721 dvbapi_stop_filternum(demux_index, n ); // stop filter since its giving errors and wont return anything good.5747 dvbapi_stop_filternum(demux_index, n, 0); // stop filter since its giving errors and wont return anything good. 5722 5748 maxfilter--; // lower maxfilters to avoid this with new filter setups! 5723 5749 continue; … … 5728 5754 } 5729 5755 5730 dvbapi_process_input(demux_index, n, mbuf, len );5756 dvbapi_process_input(demux_index, n, mbuf, len, 0); 5731 5757 } 5732 5758 continue; // continue with other events! … … 5743 5769 } 5744 5770 5745 void dvbapi_write_cw(int32_t demux_id, uchar *cw, int32_t pid, int32_t stream_id, enum ca_descr_algo algo, enum ca_descr_cipher_mode cipher_mode )5771 void dvbapi_write_cw(int32_t demux_id, uchar *cw, int32_t pid, int32_t stream_id, enum ca_descr_algo algo, enum ca_descr_cipher_mode cipher_mode, uint32_t msgid) 5746 5772 { 5747 5773 int32_t n; … … 5771 5797 && (memcmp(cw + (n * 8), nullcw, 8) != 0 || demux[demux_id].ECMpids[pid].CAID == 0x2600)) 5772 5798 { 5773 ca_index_t idx = dvbapi_ca_setpid(demux_id, pid, stream_id, (algo == CA_ALGO_DES) ); // prepare ca5799 ca_index_t idx = dvbapi_ca_setpid(demux_id, pid, stream_id, (algo == CA_ALGO_DES), msgid); // prepare ca 5774 5800 if (idx == INDEX_INVALID) return; // return on no index! 5775 5801 … … 5836 5862 5837 5863 if(cfg.dvbapi_boxtype == BOXTYPE_PC || cfg.dvbapi_boxtype == BOXTYPE_PC_NODMX) 5838 dvbapi_net_send(DVBAPI_CA_SET_DESCR_MODE, demux[demux_id].socket_fd, demux_id, -1 /*unused*/, (unsigned char *) &ca_descr_mode, NULL, NULL, demux[demux_id].client_proto_version);5864 dvbapi_net_send(DVBAPI_CA_SET_DESCR_MODE, demux[demux_id].socket_fd, msgid, demux_id, -1 /*unused*/, (unsigned char *) &ca_descr_mode, NULL, NULL, demux[demux_id].client_proto_version); 5839 5865 else 5840 5866 { … … 5852 5878 5853 5879 if(cfg.dvbapi_boxtype == BOXTYPE_PC || cfg.dvbapi_boxtype == BOXTYPE_PC_NODMX) 5854 dvbapi_net_send(DVBAPI_CA_SET_DESCR, demux[demux_id].socket_fd, demux_id, -1 /*unused*/, (unsigned char *) &ca_descr, NULL, NULL, demux[demux_id].client_proto_version);5880 dvbapi_net_send(DVBAPI_CA_SET_DESCR, demux[demux_id].socket_fd, msgid, demux_id, -1 /*unused*/, (unsigned char *) &ca_descr, NULL, NULL, demux[demux_id].client_proto_version); 5855 5881 else 5856 5882 { … … 6006 6032 if(demux[i].demux_fd[o].fd > 0 && demux[i].demux_fd[o].type == TYPE_ECM && (demux[i].demux_fd[o].pidindex == t)) 6007 6033 { 6008 dvbapi_stop_filternum(i, o ); // ecmfilter belongs to lower status pid -> kill!6034 dvbapi_stop_filternum(i, o, er->msgid); // ecmfilter belongs to lower status pid -> kill! 6009 6035 } 6010 6036 } … … 6036 6062 if(er->rc == E_SLEEPING) 6037 6063 { 6038 dvbapi_stop_descrambling(i );6064 dvbapi_stop_descrambling(i, er->msgid); 6039 6065 return; 6040 6066 } … … 6117 6143 if(fd > 0) // in case valid fd 6118 6144 { 6119 dvbapi_stop_filternum(i, filternum ); // stop ecmfilter6145 dvbapi_stop_filternum(i, filternum, er->msgid); // stop ecmfilter 6120 6146 found = 1; 6121 6147 } … … 6129 6155 if(fd > 0) // in case valid fd 6130 6156 { 6131 dvbapi_stop_filternum(i, filternum ); // stop emmfilter6157 dvbapi_stop_filternum(i, filternum, er->msgid); // stop emmfilter 6132 6158 found = 1; 6133 6159 } … … 6188 6214 { 6189 6215 idx = demux[i].ECMpids[j].useMultipleIndices ? demux[i].ECMpids[j].index[k] : demux[i].ECMpids[j].index[0]; 6190 dvbapi_set_pid(i, k, idx, false, false ); // disable streampid6216 dvbapi_set_pid(i, k, idx, false, false, er->msgid); // disable streampid 6191 6217 } 6192 6218 … … 6233 6259 } 6234 6260 6235 dvbapi_write_cw(i, cw, j, k, er->cw_ex.algo, er->cw_ex.algo_mode );6261 dvbapi_write_cw(i, cw, j, k, er->cw_ex.algo, er->cw_ex.algo_mode, er->msgid); 6236 6262 } 6237 6263 } … … 6239 6265 { 6240 6266 demux[i].ECMpids[j].useMultipleIndices = 0; 6241 dvbapi_write_cw(i, er->cw, j, 0, er->cw_ex.algo, er->cw_ex.algo_mode );6267 dvbapi_write_cw(i, er->cw, j, 0, er->cw_ex.algo, er->cw_ex.algo_mode, er->msgid); 6242 6268 } 6243 6269 #else 6244 6270 cfg.dvbapi_extended_cw_api = 0; // in CSA mode extended_cw_api should be always 0 regardless what user selected! 6245 dvbapi_write_cw(i, er->cw, j, 0, CA_ALGO_DVBCSA, CA_MODE_ECB );6271 dvbapi_write_cw(i, er->cw, j, 0, CA_ALGO_DVBCSA, CA_MODE_ECB, er->msgid); 6246 6272 #endif 6247 6273 break; … … 6253 6279 6254 6280 if ((cfg.dvbapi_listenport || cfg.dvbapi_boxtype == BOXTYPE_PC_NODMX) && demux[i].client_proto_version >= 2) 6255 { dvbapi_net_send(DVBAPI_ECM_INFO, demux[i].socket_fd, i, 0, NULL, client, er, demux[i].client_proto_version); }6281 { dvbapi_net_send(DVBAPI_ECM_INFO, demux[i].socket_fd, 0, i, 0, NULL, client, er, demux[i].client_proto_version); } 6256 6282 #ifndef __CYGWIN__ 6257 6283 else if (!cfg.dvbapi_listenport && cfg.dvbapi_boxtype != BOXTYPE_PC_NODMX) … … 6608 6634 } 6609 6635 6610 int32_t ret = dvbapi_activate_section_filter(demux_index, n, fd, curpid->ECM_PID, filter, mask );6636 int32_t ret = dvbapi_activate_section_filter(demux_index, n, fd, curpid->ECM_PID, filter, mask, er->msgid); 6611 6637 if(ret < 0) // something went wrong setting filter! 6612 6638 { 6613 6639 cs_log("Demuxer %d Filter %d (fd %d) error setting section filtering -> stop filter!", demux_index, n + 1, fd); 6614 ret = dvbapi_stop_filternum(demux_index, n );6640 ret = dvbapi_stop_filternum(demux_index, n, er->msgid); 6615 6641 if(ret == -1) 6616 6642 { 6617 6643 cs_log("Demuxer %d Filter %d (fd %d) stopping filter failed -> kill all filters of this demuxer!", demux_index, n + 1, fd); 6618 dvbapi_stop_filter(demux_index, TYPE_EMM );6619 dvbapi_stop_filter(demux_index, TYPE_ECM );6644 dvbapi_stop_filter(demux_index, TYPE_EMM, er->msgid); 6645 dvbapi_stop_filter(demux_index, TYPE_ECM, er->msgid); 6620 6646 } 6621 6647 return -1; … … 6624 6650 } 6625 6651 6626 int32_t dvbapi_activate_section_filter(int32_t demux_index, int32_t num, int32_t fd, int32_t pid, uchar *filter, uchar *mask )6652 int32_t dvbapi_activate_section_filter(int32_t demux_index, int32_t num, int32_t fd, int32_t pid, uchar *filter, uchar *mask, uint32_t msgid) 6627 6653 { 6628 6654 … … 6665 6691 memcpy(sFP2.filter.mask, mask, 16); 6666 6692 if (cfg.dvbapi_listenport || cfg.dvbapi_boxtype == BOXTYPE_PC_NODMX) 6667 ret = dvbapi_net_send(DVBAPI_DMX_SET_FILTER, demux[demux_index].socket_fd, demux_index, num, (unsigned char *) &sFP2, NULL, NULL, demux[demux_index].client_proto_version);6693 ret = dvbapi_net_send(DVBAPI_DMX_SET_FILTER, demux[demux_index].socket_fd, msgid, demux_index, num, (unsigned char *) &sFP2, NULL, NULL, demux[demux_index].client_proto_version); 6668 6694 else 6669 6695 ret = dvbapi_ioctl(fd, DMX_SET_FILTER, &sFP2); … … 6782 6808 } 6783 6809 6784 ca_index_t dvbapi_ca_setpid(int32_t demux_index, int32_t pid, int32_t stream_id, bool use_des )6810 ca_index_t dvbapi_ca_setpid(int32_t demux_index, int32_t pid, int32_t stream_id, bool use_des, uint32_t msgid) 6785 6811 { 6786 6812 ca_index_t idx; … … 6810 6836 if(!demux[demux_index].ECMpids[pid].streams || ((demux[demux_index].ECMpids[pid].streams & (1 << n)) == (uint) (1 << n))) 6811 6837 { 6812 dvbapi_set_pid(demux_index, n, idx, true, use_des ); // enable streampid6838 dvbapi_set_pid(demux_index, n, idx, true, use_des, msgid); // enable streampid 6813 6839 } 6814 6840 else 6815 6841 { 6816 dvbapi_set_pid(demux_index, n, idx, false, false ); // disable streampid6842 dvbapi_set_pid(demux_index, n, idx, false, false, msgid); // disable streampid 6817 6843 } 6818 6844 } … … 6839 6865 if(!demux[demux_index].ECMpids[pid].streams || ((demux[demux_index].ECMpids[pid].streams & (1 << n)) == (uint) (1 << n))) 6840 6866 { 6841 dvbapi_set_pid(demux_index, n, idx, true, use_des ); // enable streampid6867 dvbapi_set_pid(demux_index, n, idx, true, use_des, 0); // enable streampid 6842 6868 } 6843 6869 else 6844 6870 { 6845 dvbapi_set_pid(demux_index, n, idx, false, false ); // disable streampid6871 dvbapi_set_pid(demux_index, n, idx, false, false, 0); // disable streampid 6846 6872 } 6847 6873 } … … 7003 7029 if (n == demux[demux_id].STREAMpidcount){ 7004 7030 demux[demux_id].STREAMpids[n] = listitem->streampid; // put it temp here! 7005 dvbapi_set_pid(demux_id, n, idx, false, false ); // no match found so disable this now unused streampid7031 dvbapi_set_pid(demux_id, n, idx, false, false, 0); // no match found so disable this now unused streampid 7006 7032 demux[demux_id].STREAMpids[n] = 0; // remove temp! 7007 7033 } … … 7024 7050 if(!listitem) // if streampid not listed -> enable it! 7025 7051 { 7026 dvbapi_set_pid(demux_id, n, idx, true, false ); // enable streampid7052 dvbapi_set_pid(demux_id, n, idx, true, false, 0); // enable streampid 7027 7053 } 7028 7054 } … … 7073 7099 if (n == demux[demux_id].STREAMpidcount){ 7074 7100 demux[demux_id].STREAMpids[n] = listitem->streampid; // put it temp here! 7075 dvbapi_set_pid(demux_id, n, idx, false, false ); // no match found so disable this now unused streampid7101 dvbapi_set_pid(demux_id, n, idx, false, false, 0); // no match found so disable this now unused streampid 7076 7102 demux[demux_id].STREAMpids[n] = 0; // remove temp! 7077 7103 } … … 7108 7134 if(!listitem) // if streampid not listed -> enable it! 7109 7135 { 7110 dvbapi_set_pid(demux_id, n, idx, true, false ); // enable streampid7136 dvbapi_set_pid(demux_id, n, idx, true, false, 0); // enable streampid 7111 7137 } 7112 7138 } … … 7257 7283 { 7258 7284 // stop active filter and add to pending list 7259 dvbapi_stop_filternum(filter_item->demux_id, filter_item->num - 1 );7285 dvbapi_stop_filternum(filter_item->demux_id, filter_item->num - 1, 0); 7260 7286 ll_iter_remove_data(&itr); 7261 7287 add_emmfilter_to_list(filter_item->demux_id, filter_item->filter, filter_item->caid, -
trunk/module-dvbapi.h
r11331 r11386 78 78 79 79 //constants used int socket communication: 80 #define DVBAPI_PROTOCOL_VERSION 280 #define DVBAPI_PROTOCOL_VERSION 3 81 81 82 82 #define DVBAPI_CA_SET_PID 0x40086f87 … … 344 344 // -------------------------------------------------------------------- 345 345 346 void dvbapi_stop_descrambling(int );347 void dvbapi_stop_all_descrambling( void);348 void dvbapi_process_input(int32_t demux_id, int32_t filter_num, uchar *buffer, int32_t len );346 void dvbapi_stop_descrambling(int32_t demux_id, uint32_t msgid); 347 void dvbapi_stop_all_descrambling(uint32_t msgid); 348 void dvbapi_process_input(int32_t demux_id, int32_t filter_num, uchar *buffer, int32_t len, uint32_t msgid); 349 349 int32_t dvbapi_open_device(int32_t, int32_t, int); 350 int32_t dvbapi_stop_filternum(int32_t demux_index, int32_t num );351 int32_t dvbapi_stop_filter(int32_t demux_index, int32_t type );350 int32_t dvbapi_stop_filternum(int32_t demux_index, int32_t num, uint32_t msgid); 351 int32_t dvbapi_stop_filter(int32_t demux_index, int32_t type, uint32_t msgid); 352 352 struct s_dvbapi_priority *dvbapi_check_prio_match(int32_t demux_id, int32_t pidindex, char type); 353 353 void dvbapi_send_dcw(struct s_client *client, ECM_REQUEST *er); 354 void dvbapi_write_cw(int32_t demux_id, uchar *cw, int32_t pid, int32_t stream_id, enum ca_descr_algo algo, enum ca_descr_cipher_mode cipher_mode );355 int32_t dvbapi_parse_capmt(unsigned char *buffer, uint32_t length, int32_t connfd, char *pmtfile, int8_t is_real_pmt, uint16_t existing_demux_id, uint16_t client_proto_version );354 void dvbapi_write_cw(int32_t demux_id, uchar *cw, int32_t pid, int32_t stream_id, enum ca_descr_algo algo, enum ca_descr_cipher_mode cipher_mode, uint32_t msgid); 355 int32_t dvbapi_parse_capmt(unsigned char *buffer, uint32_t length, int32_t connfd, char *pmtfile, int8_t is_real_pmt, uint16_t existing_demux_id, uint16_t client_proto_version, uint32_t msgid); 356 356 void request_cw(struct s_client *client, ECM_REQUEST *er, int32_t demux_id, uint8_t delayed_ecm_check); 357 void dvbapi_try_next_caid(int32_t demux_id, int8_t checked );357 void dvbapi_try_next_caid(int32_t demux_id, int8_t checked, uint32_t msgid); 358 358 void dvbapi_read_priority(void); 359 359 int32_t dvbapi_set_section_filter(int32_t demux_index, ECM_REQUEST *er, int32_t n); 360 int32_t dvbapi_activate_section_filter(int32_t demux_index, int32_t num, int32_t fd, int32_t pid, uchar *filter, uchar *mask );360 int32_t dvbapi_activate_section_filter(int32_t demux_index, int32_t num, int32_t fd, int32_t pid, uchar *filter, uchar *mask, uint32_t msgid); 361 361 int32_t dvbapi_check_ecm_delayed_delivery(int32_t demux_index, ECM_REQUEST *er); 362 362 int32_t dvbapi_get_filternum(int32_t demux_index, ECM_REQUEST *er, int32_t type); 363 ca_index_t dvbapi_ca_setpid(int32_t demux_index, int32_t pid, int32_t stream_id, bool use_des );364 void dvbapi_set_pid(int32_t demux_id, int32_t num, ca_index_t idx, bool enable, bool use_des );363 ca_index_t dvbapi_ca_setpid(int32_t demux_index, int32_t pid, int32_t stream_id, bool use_des, uint32_t msgid); 364 void dvbapi_set_pid(int32_t demux_id, int32_t num, ca_index_t idx, bool enable, bool use_des, uint32_t msgid); 365 365 int8_t update_streampid_list(uint8_t cadevice, uint16_t pid, ca_index_t idx, bool use_des); 366 366 int8_t remove_streampid_from_list(uint8_t cadevice, uint16_t pid, ca_index_t idx); -
trunk/oscam.c
r11373 r11386 1909 1909 1910 1910 stat_finish(); 1911 dvbapi_stop_all_descrambling( );1911 dvbapi_stop_all_descrambling(0); 1912 1912 dvbapi_save_channel_cache(); 1913 1913 emm_save_cache();
Note:
See TracChangeset
for help on using the changeset viewer.