示例#1
0
/** @brief Evaluate a string containing sum and mult keeping the priority of the mult over the +
 * Ex : string_sum("2+2*3") returns 8
 * @param string the string to evaluate
 */
int string_comput(char *string)
{
	int number1,len;
	char *pluspos=NULL;
	char *tempchar;
	if(string==NULL)
		return 0;
	pluspos=strchr(string,'+');
	if(pluspos==NULL)
	{
		len=strlen(string);
	}
	else
	{
		len=pluspos-string;
	}
	tempchar=malloc(sizeof(char)*(len+1));
	strncpy(tempchar,string,len);
	tempchar[len]='\0';
	number1=string_mult(tempchar);
	free(tempchar);
	if(pluspos==NULL)
		return number1;
	if(strchr(pluspos+1,'+')!=NULL)
		return number1+string_comput(pluspos+1);
	return number1+string_mult(pluspos+1);
}
示例#2
0
/** @brief Convert the chained list of services into channels
 *
 * This function is called when We've got all the services, we now fill the channels structure
 * After that we go in AUTOCONF_MODE_PIDS to get audio and video pids
 * @param parameters The autoconf parameters
 * @param channels Chained list of channels
 * @param port The mulicast port
 * @param card The card number for the ip address
 * @param unicast_vars The unicast parameters
 * @param fds The file descriptors (for filters and unicast)
 */
int autoconf_services_to_channels(autoconf_parameters_t parameters, mumudvb_channel_t *channels, int port, int card, int tuner, unicast_parameters_t *unicast_vars, multicast_parameters_t *multicast_vars, int server_id)
{

  mumudvb_service_t *actual_service;
  int channel_number=0;
  int found_in_service_id_list;
  int unicast_port_per_channel;
  char tempstring[256];
  actual_service=parameters.services;
  unicast_port_per_channel=strlen(parameters.autoconf_unicast_port)?1:0;

  do
  {
    if(parameters.autoconf_scrambled && actual_service->free_ca_mode)
        log_message( log_module, MSG_DETAIL,"Service scrambled. Name \"%s\"\n", actual_service->name);

    //If there is a service_id list we look if we find it (option autoconf_sid_list)
    if(parameters.num_service_id)
    {
      int actual_service_id;
      found_in_service_id_list=0;
      for(actual_service_id=0;actual_service_id<parameters.num_service_id && !found_in_service_id_list;actual_service_id++)
      {
        if(parameters.service_id_list[actual_service_id]==actual_service->id)
        {
          found_in_service_id_list=1;
          log_message( log_module, MSG_DEBUG,"Service found in the service_id list. Name \"%s\"\n", actual_service->name);
        }
      }
    }
    else //No ts id list so it is found
      found_in_service_id_list=1;

    if(!parameters.autoconf_scrambled && actual_service->free_ca_mode)
      log_message( log_module, MSG_DETAIL,"Service scrambled, no CAM support and no autoconf_scrambled, we skip. Name \"%s\"\n", actual_service->name);
    else if(!actual_service->pmt_pid)
      log_message( log_module, MSG_DETAIL,"Service without a PMT pid, we skip. Name \"%s\"\n", actual_service->name);
    else if(!found_in_service_id_list)
      log_message( log_module, MSG_DETAIL,"Service NOT in the service_id list, we skip. Name \"%s\", id %d\n", actual_service->name, actual_service->id);
    else //service is ok, we make it a channel
    {
      //Cf EN 300 468 v1.9.1 Table 81
      if((actual_service->type==0x01||
          actual_service->type==0x11||
          actual_service->type==0x16||
          actual_service->type==0x19)||
          ((actual_service->type==0x02||
          actual_service->type==0x0a)&&parameters.autoconf_radios))
      {
        log_message( log_module, MSG_DETAIL,"We convert a new service into a channel, sid %d pmt_pid %d name \"%s\" \n",
			  actual_service->id, actual_service->pmt_pid, actual_service->name);
        display_service_type(actual_service->type, MSG_DETAIL, log_module);

        channels[channel_number].channel_type=actual_service->type;
        channels[channel_number].num_packet = 0;
        channels[channel_number].num_scrambled_packets = 0;
        channels[channel_number].scrambled_channel = 0;
        channels[channel_number].streamed_channel = 1;
        channels[channel_number].nb_bytes=0;
        channels[channel_number].pids[0]=actual_service->pmt_pid;
        channels[channel_number].pids_type[0]=PID_PMT;
        channels[channel_number].num_pids=1;
        snprintf(channels[channel_number].pids_language[0],4,"%s","---");
        if(strlen(parameters.name_template))
        {
          strcpy(channels[channel_number].name,parameters.name_template);
          int len=MAX_NAME_LEN;
          char number[10];
          mumu_string_replace(channels[channel_number].name,&len,0,"%name",actual_service->name);
          sprintf(number,"%d",channel_number+1);
          mumu_string_replace(channels[channel_number].name,&len,0,"%number",number);
          //put LCN here
        }
        else
          strcpy(channels[channel_number].name,actual_service->name);
        if(multicast_vars->multicast)
        {
          char number[10];
          char ip[80];
          int len=80;
          if(strlen(parameters.autoconf_multicast_port))
          {
            strcpy(tempstring,parameters.autoconf_multicast_port);
            sprintf(number,"%d",channel_number);
            mumu_string_replace(tempstring,&len,0,"%number",number);
            sprintf(number,"%d",card);
            mumu_string_replace(tempstring,&len,0,"%card",number);
            sprintf(number,"%d",tuner);
            mumu_string_replace(tempstring,&len,0,"%tuner",number);
            sprintf(number,"%d",server_id);
            mumu_string_replace(tempstring,&len,0,"%server",number);
            channels[channel_number].portOut=string_comput(tempstring);
          }
          else
          {
            channels[channel_number].portOut=port;//do here the job for evaluating the string
          }
	  if(multicast_vars->multicast_ipv4)
	    {
	      strcpy(ip,parameters.autoconf_ip4);
	      sprintf(number,"%d",channel_number);
	      mumu_string_replace(ip,&len,0,"%number",number);
	      sprintf(number,"%d",card);
	      mumu_string_replace(ip,&len,0,"%card",number);
	      sprintf(number,"%d",tuner);
	      mumu_string_replace(ip,&len,0,"%tuner",number);
	      sprintf(number,"%d",server_id);
	      mumu_string_replace(ip,&len,0,"%server",number);
	      strcpy(channels[channel_number].ip4Out,ip);
	      log_message( log_module, MSG_DEBUG,"Channel IPv4 : \"%s\" port : %d\n",channels[channel_number].ip4Out,channels[channel_number].portOut);
	    }
	  if(multicast_vars->multicast_ipv6)
	    {
	      strcpy(ip,parameters.autoconf_ip6);
	      sprintf(number,"%d",channel_number);
	      mumu_string_replace(ip,&len,0,"%number",number);
	      sprintf(number,"%d",card);
	      mumu_string_replace(ip,&len,0,"%card",number);
	      sprintf(number,"%d",tuner);
	      mumu_string_replace(ip,&len,0,"%tuner",number);
	      sprintf(number,"%d",server_id);
	      mumu_string_replace(ip,&len,0,"%server",number);
	      strcpy(channels[channel_number].ip6Out,ip);
	      log_message( log_module, MSG_DEBUG,"Channel IPv6 : \"%s\" port : %d\n",channels[channel_number].ip6Out,channels[channel_number].portOut);
	    }	  
        }

        //This is a scrambled channel, we will have to ask the cam for descrambling it
        if(parameters.autoconf_scrambled && actual_service->free_ca_mode)
          channels[channel_number].need_cam_ask=CAM_NEED_ASK;

        //We store the PMT and the service id in the channel
        channels[channel_number].pmt_pid=actual_service->pmt_pid;
        channels[channel_number].service_id=actual_service->id;
        init_rtp_header(&channels[channel_number]); //We init the rtp header in all cases

        if(channels[channel_number].pmt_packet==NULL)
        {
          channels[channel_number].pmt_packet=malloc(sizeof(mumudvb_ts_packet_t));
          if(channels[channel_number].pmt_packet==NULL)
          {
            log_message( log_module, MSG_ERROR,"Problem with malloc : %s file : %s line %d\n",strerror(errno),__FILE__,__LINE__);
            Interrupted=ERROR_MEMORY<<8;
            return -1;
          }
          memset (channels[channel_number].pmt_packet, 0, sizeof( mumudvb_ts_packet_t));//we clear it
          pthread_mutex_init(&channels[channel_number].pmt_packet->packetmutex,NULL);
        }
#ifdef ENABLE_CAM_SUPPORT
        //We allocate the packet for storing the PMT for CAM purposes
        if(channels[channel_number].cam_pmt_packet==NULL)
        {
          channels[channel_number].cam_pmt_packet=malloc(sizeof(mumudvb_ts_packet_t));
          if(channels[channel_number].cam_pmt_packet==NULL)
          {
            log_message( log_module, MSG_ERROR,"Problem with malloc : %s file : %s line %d\n",strerror(errno),__FILE__,__LINE__);
            Interrupted=ERROR_MEMORY<<8;
            return -1;
          }
          memset (channels[channel_number].cam_pmt_packet, 0, sizeof( mumudvb_ts_packet_t));//we clear it
          pthread_mutex_init(&channels[channel_number].cam_pmt_packet->packetmutex,NULL);
        }
#endif
        //We update the unicast port, the connection will be created in autoconf_finish_full
        if(unicast_port_per_channel && unicast_vars->unicast)
        {
          strcpy(tempstring,parameters.autoconf_unicast_port);
          int len;len=256;
          char number[10];
          sprintf(number,"%d",channel_number);
          mumu_string_replace(tempstring,&len,0,"%number",number);
          sprintf(number,"%d",card);
          mumu_string_replace(tempstring,&len,0,"%card",number);
          sprintf(number,"%d",tuner);
          mumu_string_replace(tempstring,&len,0,"%tuner",number);
          sprintf(number,"%d",server_id);
          mumu_string_replace(tempstring,&len,0,"%server",number);
          channels[channel_number].unicast_port=string_comput(tempstring);
          log_message( log_module, MSG_DEBUG,"Channel (direct) unicast port  %d\n",channels[channel_number].unicast_port);
        }
#ifdef ENABLE_TRANSCODING
        //We copy the common transcode options to the new channel
        transcode_copy_options(&global_transcode_opt,&channels[channel_number].transcode_options);
        transcode_options_apply_templates(&channels[channel_number].transcode_options,card,tuner,server_id,channel_number);
#endif
        channel_number++;
      }
      else if(actual_service->type==0x02||actual_service->type==0x0a) //service_type digital radio sound service
        log_message( log_module, MSG_DETAIL,"Service type digital radio sound service, no autoconfigure. (if you want add autoconf_radios=1 to your configuration file) Name \"%s\"\n",actual_service->name);
      else if(actual_service->type!=0) //0 is an empty service
      {
        //We show the service type
        log_message( log_module, MSG_DETAIL,"No autoconfigure due to service type : %s. Name \"%s\"\n",service_type_to_str(actual_service->type),actual_service->name);
      }
    }
    actual_service=actual_service->next;
  }
  while(actual_service && channel_number<MAX_CHANNELS);

  if(channel_number==MAX_CHANNELS)
    log_message( log_module, MSG_WARN,"Warning : We reached the maximum channel number, we drop other possible channels !\n");

  return channel_number;
}
示例#3
0
int main(void)
{
  int press_enter = PRESS_ENTER;

  //We initalise the logging parameters
  log_params.verbosity = 999;
  log_params.log_type=LOGGING_CONSOLE;


  log_message( log_module, MSG_INFO,"===================================================================\n");
  log_message( log_module, MSG_INFO,"Testing program for MuMuDVB\n");
  log_message( log_module, MSG_INFO,"===================================================================\n");

  /****************************  Very basic test ****************************************************/
  log_message( log_module, MSG_INFO,"===================================================================\n");
  log_message( log_module, MSG_INFO,"Display Ca system id 1\n" );
  log_message( log_module, MSG_INFO,"===================================================================\n");

  log_message( log_module, MSG_INFO,"%s\n\n" ,ca_sys_id_to_str(1));

  /****************************  Testing string compute *********************************************/
  log_message( log_module, MSG_INFO,"===================================================================\n");
  log_message( log_module, MSG_INFO,"Testing string compute %s\n",TEST_STRING_COMPUT );
  log_message( log_module, MSG_INFO,"===================================================================\n");

  int resultat;
  resultat=string_comput(TEST_STRING_COMPUT);
  if(resultat==TEST_STRING_COMPUT_RES)
    log_message( log_module, MSG_INFO,"%d  --  PASS\n\n" ,resultat);
  else
    log_message( log_module, MSG_INFO,"%d  --  FAIL\n\n" ,resultat);

  /************************************* Testing the SDT parser *************************************/
  char *files_sdt[NUM_FILES_TEST_READ_SDT]={FILES_TEST_READ_SDT_TS};
  for(int i_file=0;i_file<NUM_FILES_TEST_READ_SDT;i_file++)
  {
    log_message( log_module, MSG_INFO,"===================================================================\n");
    log_message( log_module, MSG_INFO,"Testing TS read for SDT - test %d on %d file %s\n", i_file+1, NUM_FILES_TEST_READ_SDT , files_sdt[i_file] );
    press_enter_func(press_enter);
    FILE *testfile;
    testfile=fopen (files_sdt[i_file], "r");
    if(testfile!=NULL)
      {
        //We read all the packets contained in the file
        unsigned char ts_packet_raw[TS_PACKET_SIZE];
        int num_sdt_read=0;
        mumudvb_ts_packet_t ts_packet_mumu;
        memset(&ts_packet_mumu, 0, sizeof(mumudvb_ts_packet_t));

        mumudvb_service_t services;
        memset(&services, 0, sizeof(mumudvb_service_t));
        //Just to make pthread happy
        pthread_mutex_init(&ts_packet_mumu.packetmutex,NULL);
        int iRet,pid;
        log_message( log_module, MSG_INFO,"File opened, reading packets\n" );
        while(fread(ts_packet_raw,TS_PACKET_SIZE,1, testfile) && num_sdt_read<NUM_READ_SDT)
          {
            /************ SYNC *************/
            if(ts_packet_raw[0] != 0x47)
              {
                log_message( log_module, MSG_INFO," !!!!!!!!!!!!! Sync error, we search for a new sync byte !!!!!!!!!!!!!!\n");
                unsigned char sync;
                //We search the next sync byte
                while(fread(&sync,1,1, testfile) && sync!=0x47);
                ts_packet_raw[0]=sync;
                //We found a "sync byte" we get the rest of the packet
                if(!fread(ts_packet_raw-1,TS_PACKET_SIZE-1,1, testfile))
                  continue;
                else
                  log_message( log_module, MSG_INFO," sync byte found :) \n");
              }
            // Get the PID of the received TS packet
            pid = HILO(((ts_header_t *)ts_packet_raw)->pid);
            if(pid != 17) continue;
            log_message( log_module, MSG_INFO,"New elementary (188bytes TS packet) pid %d continuity_counter %d",
                         pid,
                         ((ts_header_t *)ts_packet_raw)->continuity_counter );
            iRet=get_ts_packet(ts_packet_raw, &ts_packet_mumu);
            //If it's the beginning of a new packet we display some information
            if(((ts_header_t *)ts_packet_raw)->payload_unit_start_indicator)
              log_message(log_module, MSG_INFO, "First two bytes of the packet 0x%02x %02x",
                          ts_packet_mumu.data_partial[0],
                          ts_packet_mumu.data_partial[1]);

            if(iRet==1)//packet is parsed
              {
                log_message( log_module, MSG_INFO,"New packet -- parsing\n" );
                num_sdt_read++;
                autoconf_read_sdt(ts_packet_mumu.data_full,ts_packet_mumu.len_full,&services);
              }
          }
        log_message( log_module, MSG_INFO,"Final services list .... \n");
        autoconf_print_services(&services);
        log_message( log_module, MSG_INFO,"===================================================================\n");
        log_message( log_module, MSG_INFO,"Testing service sorting on this list\n" );
        press_enter_func(press_enter);
        autoconf_sort_services(&services);
        autoconf_print_services(&services);
        //We free starting at the next since the first is not malloc'ed
        autoconf_free_services(services.next);
        fclose(testfile);

      }
    else
      log_message( log_module, MSG_INFO,"Test file %s cannot be open : %s\n", files_sdt[i_file],strerror(errno) );

  }


  /************************************* Testing the NIT parser *************************************/
  char *files_nit[NUM_FILES_TEST_READ_NIT]={FILES_TEST_READ_NIT_TS};
  for(int i_file=0;i_file<NUM_FILES_TEST_READ_NIT;i_file++)
  {
    log_message( log_module, MSG_INFO,"===================================================================\n");
    log_message( log_module, MSG_INFO,"Testing TS read for NIT - test %d on %d file %s\n", i_file+1, NUM_FILES_TEST_READ_NIT , files_sdt[i_file] );
    press_enter_func(press_enter);
    FILE *testfile;
    testfile=fopen (files_nit[i_file], "r");
    if(testfile!=NULL)
      {
        //We read all the packets contained in the file
        unsigned char ts_packet_raw[TS_PACKET_SIZE];
        int num_nit_read=0;
        mumudvb_ts_packet_t ts_packet_mumu;
        memset(&ts_packet_mumu, 0, sizeof(mumudvb_ts_packet_t));

        mumudvb_service_t services;
        memset(&services, 0, sizeof(mumudvb_service_t));
        //Just to make pthread happy
        pthread_mutex_init(&ts_packet_mumu.packetmutex,NULL);
        int iRet,pid;
        log_message( log_module, MSG_INFO,"File opened, reading packets\n" );
        while(fread(ts_packet_raw,TS_PACKET_SIZE,1, testfile) && num_nit_read<NUM_READ_NIT)
          {
            /************ SYNC *************/
            if(ts_packet_raw[0] != 0x47)
              {
                log_message( log_module, MSG_INFO," !!!!!!!!!!!!! Sync error, we search for a new sync byte !!!!!!!!!!!!!!\n");
                unsigned char sync;
                //We search the next sync byte
                while(fread(&sync,1,1, testfile) && sync!=0x47);
                ts_packet_raw[0]=sync;
                //We found a "sync byte" we get the rest of the packet
                if(!fread(ts_packet_raw-1,TS_PACKET_SIZE-1,1, testfile))
                  continue;
                else
                  log_message( log_module, MSG_INFO," sync byte found :) \n");
              }
            // Get the PID of the received TS packet
            pid = HILO(((ts_header_t *)ts_packet_raw)->pid);
            if(pid != 16) continue;
            log_message( log_module, MSG_INFO,"New elementary (188bytes TS packet) pid %d continuity_counter %d",
                         pid,
                         ((ts_header_t *)ts_packet_raw)->continuity_counter );
            iRet=get_ts_packet(ts_packet_raw, &ts_packet_mumu);
            //If it's the beginning of a new packet we display some information
            if(((ts_header_t *)ts_packet_raw)->payload_unit_start_indicator)
              log_message(log_module, MSG_INFO, "First two bytes of the packet 0x%02x %02x",
                          ts_packet_mumu.data_partial[0],
                          ts_packet_mumu.data_partial[1]);

            if(iRet==1)//packet is parsed
              {
                log_message( log_module, MSG_INFO,"New packet -- parsing\n" );
                num_nit_read++;
                //autoconf_read_sdt(ts_packet_mumu.data_full,ts_packet_mumu.len_full,&services);
				parse_nit_descriptors(ts_packet_mumu.data_full,ts_packet_mumu.len_full);
              }
          }
        log_message( log_module, MSG_INFO,"===================================================================\n");
        fclose(testfile);
      }
    else
      log_message( log_module, MSG_INFO,"Test file %s cannot be open : %s\n", files_sdt[i_file],strerror(errno) );

  }


  /************************************* Testing the resistance to strange data *********************/
  log_message( log_module, MSG_INFO,"===================================================================\n");
  char *files_rand[NUM_FILES_TEST_READ_RAND]={FILES_TEST_READ_RAND};
  for(int i_file=0;i_file<NUM_FILES_TEST_READ_RAND;i_file++)
    {
      log_message( log_module, MSG_INFO,"Testing Resistance to bad packets file %d on %d : %s\n", i_file+1, NUM_FILES_TEST_READ_RAND, files_rand[i_file] );
      press_enter_func(press_enter);
      FILE *testfile;
      testfile=fopen (files_rand[i_file] , "r");
      if(testfile!=NULL)
	{
	  //We read all the packets contained in the file
	  unsigned char ts_packet_raw[TS_PACKET_SIZE];
	  int num_rand_read=0;
	  mumudvb_ts_packet_t ts_packet_mumu;
	  //Just to make pthread happy
	  pthread_mutex_init(&ts_packet_mumu.packetmutex,NULL);
	  int iRet;
	  log_message( log_module, MSG_INFO,"File opened, reading packets\n" );
	  while(fread(ts_packet_raw,TS_PACKET_SIZE,1, testfile))
	    {
	      num_rand_read++;
	      log_message( log_module, MSG_INFO,"Position %d packets\n", num_rand_read);
	      iRet=get_ts_packet(ts_packet_raw, &ts_packet_mumu);
	      if(iRet==1)//packet is parsed
		{
		  log_message( log_module, MSG_INFO,"New VALID packet\n" );
		}
	    }
	  fclose(testfile);
	}
      else
	log_message( log_module, MSG_INFO,"Test file %s cannot be open : %s\n", files_rand[i_file], strerror(errno) );
    }
  /************************ Testing autoconfiguration with a dump **********************************/
  char *files_autoconf[NUM_FILES_TEST_AUTOCONF]={FILES_TEST_AUTOCONF};
  for(int i_file=0;i_file<NUM_FILES_TEST_AUTOCONF;i_file++)
  {

    log_message( log_module, MSG_INFO,"===================================================================\n");
    log_message( log_module, MSG_INFO,"Testing autoconfiguration file %d on %d %s\n",i_file+1, NUM_FILES_TEST_AUTOCONF, files_autoconf[i_file]);
    press_enter_func(press_enter);

    FILE *testfile;
    testfile=fopen (files_autoconf[i_file] , "r");
    if(testfile!=NULL)
    {
      int iret;
      mumudvb_chan_and_pids_t chan_and_pids;
      memset(&chan_and_pids,0,sizeof(mumudvb_chan_and_pids_t));
      chan_and_pids.number_of_channels=0;

      //autoconfiguration
      autoconf_parameters_t autoconf_vars;
      memset(&autoconf_vars,0,sizeof(autoconf_parameters_t));
      autoconf_vars.autoconfiguration=AUTOCONF_MODE_FULL;
      autoconf_vars.autoconf_radios=1;
      autoconf_vars.autoconf_scrambled=1;
      strcpy (autoconf_vars.autoconf_ip4,"239.100.%card.%number");
      autoconf_vars.transport_stream_id=-1;


      unicast_parameters_t unicast_vars;
      memset(&unicast_vars,0,sizeof(unicast_parameters_t));
      unicast_vars.unicast=0;

      //multicast parameters
      multicast_parameters_t multicast_vars;
      memset(&multicast_vars,0,sizeof(multicast_parameters_t));
      multicast_vars.multicast=0;

      fds_t fds;
      memset(&fds,0,sizeof(fds_t));
      tuning_parameters_t tuneparams;
      memset(&tuneparams,0,sizeof(tuning_parameters_t));

      iret=autoconf_init(&autoconf_vars, chan_and_pids.channels,chan_and_pids.number_of_channels);
      if(iret)
      {
        log_message( log_module, MSG_INFO,"error with autoconfiguration init\n");
      }

      unsigned char actual_ts_packet[TS_PACKET_SIZE];
      int pid;
      int packet_count=0;
      while(fread(actual_ts_packet,TS_PACKET_SIZE,1, testfile))
      {
        // get the pid of the received ts packet
        pid = ((actual_ts_packet[1] & 0x1f) << 8) | (actual_ts_packet[2]);
        packet_count++;
        if(!(packet_count %100))
          log_message( log_module, MSG_INFO,"Packet count %d", packet_count);

        iret = autoconf_new_packet(pid, actual_ts_packet, &autoconf_vars,  &fds, &chan_and_pids, &tuneparams, &multicast_vars, &unicast_vars, 0);

      }
      log_message( log_module, MSG_INFO,"===================================================================\n");
      log_message( log_module, MSG_INFO,"Forcing to finish and re read");
      press_enter_func(press_enter);
      //if there is a partial service list, we force autoconf to go to the next step
      autoconf_vars.time_start_autoconfiguration=1;
      autoconf_poll(100000, &autoconf_vars, &chan_and_pids, &tuneparams, &multicast_vars, &fds, &unicast_vars, 0);
      press_enter_func(press_enter);
      rewind(testfile);
      while(fread(actual_ts_packet,TS_PACKET_SIZE,1, testfile))
      {
        // get the pid of the received ts packet
        pid = ((actual_ts_packet[1] & 0x1f) << 8) | (actual_ts_packet[2]);
        log_message( log_module, MSG_INFO,"PID  %d", pid);
        packet_count++;
        if(!(packet_count %100))
          log_message( log_module, MSG_INFO,"Packet count %d", packet_count);

        iret = autoconf_new_packet(pid, actual_ts_packet, &autoconf_vars,  &fds, &chan_and_pids, &tuneparams, &multicast_vars, &unicast_vars, 0);

      }
      fclose(testfile);

      log_message( log_module, MSG_INFO,"============ DONE we display the services ========\n");
      if(autoconf_vars.services)
      {
        autoconf_sort_services(autoconf_vars.services);
        autoconf_print_services(autoconf_vars.services);
      }
      else
        log_message( log_module, MSG_INFO,"No services or services freed\n");

      log_message( log_module, MSG_INFO,"============ DONE we display the channels ========\n");
      if(chan_and_pids.number_of_channels)
      {
        log_streamed_channels(log_module,chan_and_pids.number_of_channels, chan_and_pids.channels, 1, 0, 0, 0,"");
        //We can tests other things here like REWRITE etc ....
        log_message( log_module, MSG_INFO,"===================================================================\n");
        log_message( log_module, MSG_INFO,"Testing SDT rewrite on this file (%s)\n", files_autoconf[i_file]);
        press_enter_func(press_enter);
        FILE *testfile;
        testfile=fopen (files_autoconf[i_file] , "r");
        if(testfile!=NULL)
        {
          //Parameters for rewriting
          rewrite_parameters_t rewrite_vars={
            .rewrite_pat = OPTION_OFF,
            .pat_version=-1,
            .full_pat=NULL,
            .pat_needs_update=1,
            .full_pat_ok=0,
            .pat_continuity_counter=0,
            .rewrite_sdt = OPTION_ON,
            .sdt_version=-1,
            .full_sdt=NULL,
            .sdt_needs_update=1,
            .full_sdt_ok=0,
            .sdt_continuity_counter=0,
            .eit_sort=OPTION_OFF,
          };
          for (int curr_channel = 0; curr_channel < MAX_CHANNELS; curr_channel++)
            chan_and_pids.channels[curr_channel].generated_sdt_version=-1;
          rewrite_vars.full_sdt=malloc(sizeof(mumudvb_ts_packet_t));
          if(rewrite_vars.full_sdt==NULL)
          {
            log_message( log_module, MSG_ERROR,"Problem with malloc : %s file : %s line %d\n",strerror(errno),__FILE__,__LINE__);
          }
          memset (rewrite_vars.full_sdt, 0, sizeof( mumudvb_ts_packet_t));//we clear it
          pthread_mutex_init(&rewrite_vars.full_sdt->packetmutex,NULL);

          while(fread(actual_ts_packet,TS_PACKET_SIZE,1, testfile))
          {
            // get the pid of the received ts packet
            pid = ((actual_ts_packet[1] & 0x1f) << 8) | (actual_ts_packet[2]);
            if( (pid == 17) ) //This is a SDT PID
              {
                //we check the new packet and if it's fully updated we set the skip to 0
                if(sdt_rewrite_new_global_packet(actual_ts_packet, &rewrite_vars)==1)
                {
                  log_message( log_module, MSG_DETAIL,"The SDT version changed, we force the update of all the channels.\n");
                  for (int curr_channel = 0; curr_channel < chan_and_pids.number_of_channels; curr_channel++)
                    chan_and_pids.channels[curr_channel].sdt_rewrite_skip=0;
                }
                for (int curr_channel = 0; curr_channel < chan_and_pids.number_of_channels; curr_channel++)
                {
                  if(!chan_and_pids.channels[curr_channel].sdt_rewrite_skip ) //AND the generation was successful
                    sdt_rewrite_new_channel_packet(actual_ts_packet, &rewrite_vars, &chan_and_pids.channels[curr_channel], curr_channel);
                }
              }

          }
          fclose(testfile);
          log_message( log_module, MSG_INFO,"===================================================================\n");
          log_message( log_module, MSG_INFO,"End of testing SDT rewritef\n");
          log_message( log_module, MSG_INFO,"===================================================================\n");
        }

      }
      else