Changeset 11692
- Timestamp:
- 05/05/21 22:12:47 (3 years ago)
- Location:
- trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-dvbapi.c
r11691 r11692 384 384 static int32_t ca_fd[CA_MAX]; // holds fd handle of all ca devices (0 not in use) 385 385 static LLIST *ll_activestreampids; // list of all enabled streampids on ca devices 386 static int32_t unassoc_fd[MAX_DEMUX];386 static int32_t assoc_fd[MAX_ASSOC_FD]; // list of all client sockets 387 387 388 388 bool is_dvbapi_usr(char *usr) … … 4723 4723 case CA_PMT_CMD_OK_DESCRAMBLING: 4724 4724 { 4725 // remove from unassoc_fd when necessary4726 for(i = 0; i < MAX_DEMUX; i++)4727 {4728 if(unassoc_fd[i] == connfd)4729 {4730 unassoc_fd[i] = 0;4731 }4732 }4733 4734 4725 dvbapi_capmt_notify(&demux[demux_id]); 4735 4726 dvbapi_prepare_descrambling(demux_id, msgid); … … 6319 6310 } 6320 6311 6321 static void dvbapi_handlesockmsg(uint8_t *mbuf, uint16_t chunksize, uint16_t data_len, uint8_t *add_to_poll,int32_t connfd, uint16_t *client_proto_version)6312 static void dvbapi_handlesockmsg(uint8_t *mbuf, uint16_t chunksize, uint16_t data_len, int32_t connfd, uint16_t *client_proto_version) 6322 6313 { 6323 6314 uint32_t msgid = 0; … … 6382 6373 cs_log_dbg(D_DVBAPI,"Received DVBAPI_AOT_CA_PMT object on socket %d:", connfd); 6383 6374 dvbapi_parse_capmt(mbuf + (chunksize - data_len), data_len, connfd, NULL, *client_proto_version, msgid); 6384 (*add_to_poll) = 0;6385 6375 break; 6386 6376 } … … 6432 6422 } 6433 6423 } 6434 6435 if(cfg.dvbapi_listenport)6436 {6437 (*add_to_poll) = 1;6438 break;6439 }6440 6424 } 6441 6425 else if(cfg.dvbapi_pmtmode != 6) … … 6447 6431 } 6448 6432 } 6449 (*add_to_poll) = 0;6450 6433 break; 6451 6434 } … … 6466 6449 } 6467 6450 6468 static bool dvbapi_handlesockdata(int32_t connfd, uint8_t *mbuf, uint16_t mbuf_size, uint16_t unhandled_len, 6469 uint8_t *add_to_poll, uint16_t *new_unhandled_len, uint16_t *client_proto_version) 6451 static bool dvbapi_handlesockdata(int32_t connfd, uint8_t *mbuf, uint16_t mbuf_size, uint16_t unhandled_len, uint16_t *new_unhandled_len, uint16_t *client_proto_version) 6470 6452 { 6471 6453 int32_t recv_result; … … 6536 6518 } 6537 6519 6538 dvbapi_handlesockmsg(mbuf, chunksize-msgid_size, data_len, add_to_poll,connfd, client_proto_version);6520 dvbapi_handlesockmsg(mbuf, chunksize-msgid_size, data_len, connfd, client_proto_version); 6539 6521 6540 6522 unhandled_len -= chunksize; … … 6549 6531 (*new_unhandled_len) = unhandled_len; 6550 6532 return true; 6533 } 6534 6535 static void add_to_assoc_fd(int sock) 6536 { 6537 uint i; 6538 6539 for(i = 0; i < MAX_ASSOC_FD; i++) 6540 { 6541 if(assoc_fd[i] == sock) 6542 { 6543 return; // do not add twice 6544 } 6545 } 6546 6547 for(i = 0; i < MAX_ASSOC_FD; i++) 6548 { 6549 if(!assoc_fd[i]) 6550 { 6551 assoc_fd[i] = sock; 6552 return; 6553 } 6554 } 6555 } 6556 6557 static void del_from_assoc_fd(int sock) 6558 { 6559 uint i; 6560 6561 for(i = 0; i < MAX_ASSOC_FD; i++) 6562 { 6563 if(assoc_fd[i] == sock) 6564 { 6565 assoc_fd[i] = 0; 6566 } 6567 } 6551 6568 } 6552 6569 … … 6616 6633 6617 6634 memset(ca_fd, 0, sizeof(ca_fd)); 6618 memset( unassoc_fd, 0, sizeof(unassoc_fd));6635 memset(assoc_fd, 0, sizeof(assoc_fd)); 6619 6636 dvbapi_read_priority(); 6620 6637 dvbapi_load_channel_cache(); … … 6743 6760 6744 6761 pfdcount = (listenfd > -1) ? 1 : 0; 6745 for(i = 0; i < MAX_DEMUX; i++) 6746 { 6747 // add client fd's which are not yet associated 6748 // with the demux but needs to be polled for data 6749 if(unassoc_fd[i]) 6750 { 6751 pfd2[pfdcount].fd = unassoc_fd[i]; 6762 6763 for(i = 0; i < MAX_ASSOC_FD; i++) // add all associated fds (this should include also demux[X].socket_fd) 6764 { 6765 if(assoc_fd[i]) 6766 { 6767 pfd2[pfdcount].fd = assoc_fd[i]; 6752 6768 pfd2[pfdcount].events = (POLLIN | POLLPRI); 6753 6769 client_proto_version[pfdcount] = last_client_proto_version; 6754 6770 type[pfdcount++] = 1; 6755 6771 } 6756 6772 } 6773 6774 for(i = 0; i < MAX_DEMUX; i++) 6775 { 6757 6776 if(demux[i].program_number == 0) 6758 6777 { … … 6956 6975 } 6957 6976 } 6958 6959 if(demux[i].socket_fd > 0 && cfg.dvbapi_pmtmode != 6)6960 {6961 rc = 0;6962 for(j = 0; j < pfdcount; j++)6963 {6964 if(pfd2[j].fd == demux[i].socket_fd)6965 {6966 rc = 1;6967 break;6968 }6969 }6970 6971 if(rc == 1)6972 {6973 continue;6974 }6975 6976 pfd2[pfdcount].fd = demux[i].socket_fd;6977 pfd2[pfdcount].events = (POLLIN | POLLPRI);6978 ids[pfdcount] = i;6979 type[pfdcount++] = 1;6980 }6981 6977 } 6982 6978 … … 7022 7018 if(type[i] == 1) 7023 7019 { 7020 del_from_assoc_fd(pfd2[i].fd); 7021 7024 7022 for(j = 0; j < MAX_DEMUX; j++) 7025 7023 { … … 7028 7026 { 7029 7027 dvbapi_stop_descrambling(j, 0); 7030 }7031 7032 // remove from unassoc_fd when necessary7033 if(unassoc_fd[j] == pfd2[i].fd)7034 {7035 unassoc_fd[j] = 0;7036 7028 } 7037 7029 } … … 7099 7091 if(type[i] == 1) 7100 7092 { 7101 uint8_t add_to_poll = 0; // we may need to additionally poll this socket when no PMT data comes in7102 7103 7093 if(pfd2[i].fd == listenfd) 7104 7094 { … … 7120 7110 client->port = ntohs(SIN_GET_PORT(servaddr)); 7121 7111 } 7122 add_to_poll = 1; 7112 7113 add_to_assoc_fd(connfd); 7123 7114 7124 7115 if(cfg.dvbapi_pmtmode == 3 || cfg.dvbapi_pmtmode == 0) … … 7147 7138 } 7148 7139 7149 if(!dvbapi_handlesockdata(connfd, mbuf, mbuf_size, unhandled_buf_used[i], & add_to_poll, &unhandled_buf_used[i], &client_proto_version[i]))7140 if(!dvbapi_handlesockdata(connfd, mbuf, mbuf_size, unhandled_buf_used[i], &unhandled_buf_used[i], &client_proto_version[i])) 7150 7141 { 7151 7142 unhandled_buf_used[i] = 0; … … 7155 7146 cs_log_dbg(D_DVBAPI, "Socket %d reported connection close", connfd); 7156 7147 int active_conn = 0; // other active connections counter 7157 add_to_poll = 0;7158 7148 7159 7149 for(j = 0; j < MAX_DEMUX; j++) … … 7167 7157 active_conn++; 7168 7158 } 7169 7170 // remove from unassoc_fd when necessary7171 if(unassoc_fd[j] == connfd)7172 {7173 unassoc_fd[j] = 0;7174 }7175 7159 } 7160 7161 // stop polling on this socket 7162 del_from_assoc_fd(connfd); 7176 7163 close(connfd); 7177 7164 … … 7203 7190 } 7204 7191 memcpy(unhandled_buf[i], mbuf, unhandled_buf_used[i]); 7205 }7206 7207 // if the connection is new and we read no PMT data, then add it to the poll,7208 // otherwise this socket will not be checked with poll when data arives7209 // because fd it is not yet assigned with the demux7210 if(add_to_poll)7211 {7212 for(j = 0; j < MAX_DEMUX; j++)7213 {7214 if(!unassoc_fd[j])7215 {7216 unassoc_fd[j] = connfd;7217 break;7218 }7219 }7220 7192 } 7221 7193 } -
trunk/module-dvbapi.h
r11569 r11692 399 399 #define MAX_STREAM_PIDS 32 // Max number of pids other than ECM and EMM (e.g. audio, video, subtitle, etc) per demux (hardware descramblers might have a capacity of 30 pids) 400 400 #define MAX_FILTER 64 401 #define MAX_ASSOC_FD MAX_DEMUX 401 402 402 403 #define PTINUM 10
Note:
See TracChangeset
for help on using the changeset viewer.