/** @brief This function is called when a new PMT packet is there and we asked to check if there is updates*/ void autoconf_pmt_follow(unsigned char *ts_packet, fds_t *fds, mumudvb_channel_t *channel, char *card_base_path, int tuner, mumu_chan_p_t *chan_p) { /*Note : the pmt version is initialized during autoconfiguration*/ /*Check the version stored in the channel*/ if(!channel->pmt_needs_update) { //Checking without crc32, it there is a change we get the full packet for crc32 checking channel->pmt_needs_update=pmt_need_update(channel,get_ts_begin(ts_packet)); } /*We need to update the full packet, we get it*/ if(channel->pmt_needs_update) { while(get_ts_packet(ts_packet,channel->pmt_packet)) { ts_packet=NULL; // next call we only POP packets from the stack if(pmt_need_update(channel,channel->pmt_packet->data_full)) { log_message( log_module, MSG_DETAIL,"PMT packet updated, we have now to check if there is new things\n"); /*We've got the FULL PMT packet*/ if(autoconf_read_pmt(channel->pmt_packet, channel, card_base_path, tuner, chan_p->asked_pid, chan_p->number_chan_asked_pid, fds)==0) { if(channel->need_cam_ask==CAM_ASKED) channel->need_cam_ask=CAM_NEED_UPDATE; //We we resend this packet to the CAM update_pmt_version(channel); channel->pmt_needs_update=0; } } else { log_message( log_module, MSG_DEBUG,"False alert, nothing to do\n"); channel->pmt_needs_update=0; } } } }
/** @brief This function is called when a new packet is there and the autoconf is not finished*/ int autoconf_new_packet(int pid, unsigned char *ts_packet, autoconf_parameters_t *autoconf_vars, fds_t *fds, mumudvb_chan_and_pids_t *chan_and_pids, tuning_parameters_t *tuneparams, multicast_parameters_t *multicast_vars, unicast_parameters_t *unicast_vars, int server_id) { int iRet=0; if(autoconf_vars->autoconfiguration==AUTOCONF_MODE_FULL) //Full autoconfiguration, we search the channels and their names { if(pid==0) //PAT : contains the services identifiers and the PMT PID for each service { if(get_ts_packet(ts_packet,autoconf_vars->autoconf_temp_pat)) { if(autoconf_read_pat(autoconf_vars)) { log_message( log_module, MSG_DEBUG,"It seems that we have finished to get the services list\n"); //we finish full autoconfiguration iRet = autoconf_finish_full(chan_and_pids, autoconf_vars, multicast_vars, tuneparams, fds, unicast_vars, server_id); } } } else if(pid==17) //SDT : contains the names of the services { if(get_ts_packet(ts_packet,autoconf_vars->autoconf_temp_sdt)) { autoconf_read_sdt(autoconf_vars->autoconf_temp_sdt->data_full,autoconf_vars->autoconf_temp_sdt->len_full,autoconf_vars->services); } } else if(pid==PSIP_PID && tuneparams->fe_type==FE_ATSC) //PSIP : contains the names of the services { if(get_ts_packet(ts_packet,autoconf_vars->autoconf_temp_psip)) { autoconf_read_psip(autoconf_vars); } } } else if(autoconf_vars->autoconfiguration==AUTOCONF_MODE_PIDS) //We have the channels and their PMT, we search the other pids { int curr_channel; for(curr_channel=0;curr_channel<MAX_CHANNELS;curr_channel++) { if((!chan_and_pids->channels[curr_channel].autoconfigurated) &&(chan_and_pids->channels[curr_channel].pmt_pid==pid)&& pid) { if(get_ts_packet(ts_packet,chan_and_pids->channels[curr_channel].pmt_packet)) { //Now we have the PMT, we parse it if(autoconf_read_pmt(chan_and_pids->channels[curr_channel].pmt_packet, &chan_and_pids->channels[curr_channel], tuneparams->card_dev_path, tuneparams->tuner, chan_and_pids->asked_pid, chan_and_pids->number_chan_asked_pid, fds)==0) { log_pids(log_module,&chan_and_pids->channels[curr_channel],curr_channel); chan_and_pids->channels[curr_channel].autoconfigurated=1; //We parse the NIT before finishing autoconfiguration autoconf_vars->autoconfiguration=AUTOCONF_MODE_NIT; for (curr_channel = 0; curr_channel < chan_and_pids->number_of_channels; curr_channel++) if(!chan_and_pids->channels[curr_channel].autoconfigurated) autoconf_vars->autoconfiguration=AUTOCONF_MODE_PIDS; //not finished we continue //if it's finished, we open the new descriptors and add the new filters if(autoconf_vars->autoconfiguration!=AUTOCONF_MODE_PIDS) { autoconf_set_channel_filt(tuneparams->card_dev_path, tuneparams->tuner, chan_and_pids, fds); //We free autoconf memory autoconf_freeing(autoconf_vars); if(autoconf_vars->autoconfiguration==AUTOCONF_MODE_NIT) log_message( log_module, MSG_DETAIL,"We search for the NIT\n"); else autoconf_definite_end(tuneparams->card, tuneparams->tuner, chan_and_pids, multicast_vars, unicast_vars); } } } } } } else if(autoconf_vars->autoconfiguration==AUTOCONF_MODE_NIT) //We search the NIT { if(pid==16) //NIT : Network Information Table { if(get_ts_packet(ts_packet,autoconf_vars->autoconf_temp_nit)) { log_message( log_module, MSG_FLOOD,"New NIT\n"); if(autoconf_read_nit(autoconf_vars, chan_and_pids->channels, chan_and_pids->number_of_channels)==0) { autoconf_vars->autoconfiguration=0; int curr_channel; char lcn[4]; int len=MAX_NAME_LEN; for(curr_channel=0;curr_channel<MAX_CHANNELS;curr_channel++) { if(chan_and_pids->channels[curr_channel].logical_channel_number) { sprintf(lcn,"%03d",chan_and_pids->channels[curr_channel].logical_channel_number); mumu_string_replace(chan_and_pids->channels[curr_channel].name,&len,0,"%lcn",lcn); sprintf(lcn,"%02d",chan_and_pids->channels[curr_channel].logical_channel_number); mumu_string_replace(chan_and_pids->channels[curr_channel].name,&len,0,"%2lcn",lcn); } else { mumu_string_replace(chan_and_pids->channels[curr_channel].name,&len,0,"%lcn",""); mumu_string_replace(chan_and_pids->channels[curr_channel].name,&len,0,"%2lcn",""); } } free(autoconf_vars->autoconf_temp_nit); autoconf_vars->autoconf_temp_nit=NULL; autoconf_definite_end(tuneparams->card, tuneparams->tuner, chan_and_pids, multicast_vars, unicast_vars); } } } } return Interrupted; }