コード例 #1
0
ファイル: section.c プロジェクト: nvertigo/vdr
void PremiereCIT::Parse() {
   int offset=0;
   data.setPointerAndOffset<const pcit>(s, offset);
   eventDescriptors.setData(data+offset, HILO(s->descriptors_loop_length));
}
コード例 #2
0
ファイル: servicedvbrecord.cpp プロジェクト: HasBahCa/enigma2
RESULT eDVBServiceRecord::prepare(const char *filename, time_t begTime, time_t endTime, int eit_event_id, const char *name, const char *descr, const char *tags, bool descramble, bool recordecm)
{
	m_filename = filename;
	m_streaming = 0;
	m_descramble = descramble;
	m_record_ecm = recordecm;

	if (m_state == stateIdle)
	{
		int ret = doPrepare();
		if (!ret)
		{
			eServiceReferenceDVB ref = m_ref.getParentServiceReference();
			ePtr<eDVBResourceManager> res_mgr;
			eDVBMetaParser meta;
			std::string service_data;
			if (!ref.valid())
				ref = m_ref;
			if (!eDVBResourceManager::getInstance(res_mgr))
			{
				ePtr<iDVBChannelList> db;
				if (!res_mgr->getChannelList(db))
				{
					ePtr<eDVBService> service;
					if (!db->getService(ref, service))
					{
						char tmp[255];
						sprintf(tmp, "f:%x", service->m_flags);
						service_data += tmp;
						// cached pids
						for (int x=0; x < eDVBService::cacheMax; ++x)
						{
							int entry = service->getCacheEntry((eDVBService::cacheID)x);
							if (entry != -1)
							{
								sprintf(tmp, ",c:%02d%04x", x, entry);
								service_data += tmp;
							}
						}
					}
				}
			}
			meta.m_time_create = begTime;
			meta.m_ref = m_ref;
			meta.m_data_ok = 1;
			meta.m_service_data = service_data;
			if (name)
				meta.m_name = name;
			if (descr)
				meta.m_description = descr;
			if (tags)
				meta.m_tags = tags;
			meta.m_scrambled = m_record_ecm; /* assume we will record scrambled data, when ecm will be included in the recording */
			ret = meta.updateMeta(filename) ? -255 : 0;
			if (!ret)
			{
				const eit_event_struct *event = 0;
				eEPGCache::getInstance()->Lock();
				if ( eit_event_id != -1 )
				{
					eDebug("query epg event id %d", eit_event_id);
					eEPGCache::getInstance()->lookupEventId(ref, eit_event_id, event);
				}
				if ( !event && (begTime != -1 && endTime != -1) )
				{
					time_t queryTime = begTime + ((endTime-begTime)/2);
					tm beg, end, query;
					localtime_r(&begTime, &beg);
					localtime_r(&endTime, &end);
					localtime_r(&queryTime, &query);
					eDebug("query stime %d:%d:%d, etime %d:%d:%d, qtime %d:%d:%d",
						beg.tm_hour, beg.tm_min, beg.tm_sec,
						end.tm_hour, end.tm_min, end.tm_sec,
						query.tm_hour, query.tm_min, query.tm_sec);
					eEPGCache::getInstance()->lookupEventTime(ref, queryTime, event);
				}
				if ( event )
				{
					eDebug("found event.. store to disc");
					std::string fname = filename;
					fname.erase(fname.length()-2, 2);
					fname+="eit";
					int fd = open(fname.c_str(), O_CREAT|O_WRONLY, 0666);
					if (fd>-1)
					{
						int evLen=HILO(event->descriptors_loop_length)+12/*EIT_LOOP_SIZE*/;
						int wr = ::write( fd, (unsigned char*)event, evLen );
						if ( wr != evLen )
							eDebug("eit write error (%m)");
						::close(fd);
					}
				}
				eEPGCache::getInstance()->Unlock();
			}
		}
		return ret;
	}
	return -1;
}
コード例 #3
0
ファイル: section.c プロジェクト: nvertigo/vdr
int AIT::getApplicationType() const {
   return HILO(first->application_type);
}
コード例 #4
0
ファイル: section.c プロジェクト: nvertigo/vdr
int PAT::Association::getPid() const {
   return HILO(s->network_pid);
}
コード例 #5
0
ファイル: section.c プロジェクト: nvertigo/vdr
int RST::RunningInfo::getOriginalNetworkId() const {
   return HILO(s->original_network_id);
}
コード例 #6
0
ファイル: section.c プロジェクト: nvertigo/vdr
int RST::RunningInfo::getServiceId() const {
   return HILO(s->service_id);
}
コード例 #7
0
ファイル: autoconf_atsc.c プロジェクト: Maescool/MuMuDVB
int autoconf_parse_vct_channel(unsigned char *buf, autoconf_parameters_t *parameters)
{
  psip_vct_channel_t *vct_channel;
  char unconverted_short_name[15];//2*7 + 1 (for '\0')
#ifdef HAVE_ICONV
  char *inbuf, *dest; //Pointers for iconv conversion
#endif
  char utf8_short_name[15];
  char *channel_name=NULL;
  char long_name[MAX_NAME_LEN];

  int mpeg2_service_type=0;
  vct_channel=(psip_vct_channel_t *)buf;
  long_name[0]='\0';

  mumudvb_service_t *new_service=NULL;

  // *********** We get the channel short name *******************
  memcpy (unconverted_short_name, vct_channel->short_name, 14*sizeof(uint8_t));
  unconverted_short_name[14] = '\0';

#ifdef HAVE_ICONV
  //Conversion to utf8 of the short name
  iconv_t cd;
  //we open the conversion table
  cd = iconv_open( "UTF8", "UTF-16BE" );
  log_message( log_module, MSG_DEBUG,"We use big Endian UTF16 as source for channel name, if it give weird characters please contact\n");
  size_t inSize, outSize=14;
  inSize=14;
  //pointers initialisation
  dest=utf8_short_name;
  inbuf=unconverted_short_name;
  //conversion
  iconv(cd, &inbuf, &inSize, &dest, &outSize );
  *dest = '\0';
  iconv_close( cd );
#else
  log_message( log_module, MSG_DETAIL, "Iconv not present, no name encoding conversion the reseult will be probably bad\n");
  memcpy (utf8_short_name, vct_channel->short_name, 14*sizeof(uint8_t));
  utf8_short_name[14] = '\0';
#endif
  log_message( log_module, MSG_DEBUG, "\tchannel short_name : \"%s\"\n", utf8_short_name);


  //************ We skip "ininteresting" channels  ****************
  if(vct_channel->modulation_mode==0x01)
    {
      log_message( log_module, MSG_DEBUG, "\tAnalog channel, we skip\n");
      return PSIP_VCT_LEN + HILO(vct_channel->descriptor_length); //We return the length
    }
  if(HILO(vct_channel->channel_tsid)!=parameters->transport_stream_id)
    {
      log_message( log_module, MSG_DEBUG,"Channel for another transponder, we skip :  Channel TSID 0x%x , PAT TSID 0x%x\n",
		  HILO(vct_channel->channel_tsid),
		  parameters->transport_stream_id);
      return PSIP_VCT_LEN + HILO(vct_channel->descriptor_length); //We return the length
    }
  if(vct_channel->hidden)
    {
      log_message( log_module, MSG_DEBUG,"This channel is supposed to be hidden, we skip. Please contact if you want to bypass\n");
      return PSIP_VCT_LEN + HILO(vct_channel->descriptor_length); //We return the length
    }


  //We "convert" ATSC service type to the "equivalent" MPEG2 service type
  switch(vct_channel->service_type)
    {
    case 0x02://ATSC_digital_television — The virtual channel carries television programming (audio, video and
      //optional associated data) conforming to ATSC standards
      mpeg2_service_type=0x01; //service_type "digital television service" (0x01)
      log_message( log_module, MSG_DEBUG,"vct_channel->service_type ATSC_digital_television\n");
      break;
    case 0x03://ATSC_audio — The virtual channel carries audio programming (audio service and optional
      //associated data) conforming to ATSC standards.
      mpeg2_service_type=0x02;//service_type digital radio sound service  (0x02)
      log_message( log_module, MSG_DEBUG,"vct_channel->service_type ATSC_audio\n",vct_channel->service_type);
      break;
    case 0x04://ATSC_data_only_service — The virtual channel carries a data service conforming to ATSC
      //standards, but no video of stream_type 0x02 or audio of stream_type 0x81.
      mpeg2_service_type=0x0c;//service_type data broadcast service
      log_message( log_module, MSG_DEBUG,"vct_channel->service_type ATSC_data_only_service\n",vct_channel->service_type);
      break;
    default:
      log_message( log_module, MSG_DEBUG,"Unknown vct_channel->service_type 0x%02x\n",vct_channel->service_type);
      break;
    }

#ifdef HAVE_LIBUCSI //used to decompress the atsc_text_descriptor
  int descriptor_delta;
  uint8_t *dest8=NULL; //Pointer for libusci conversion
  size_t destbufsize=MAX_NAME_LEN;
  size_t destbufpos=0;
  int descriptor_len;
  int atsc_decode_out;
  int delta_multiple_string_structure; //the beginning of tmultiple string structure
  //We loop on the different descriptors to find the long channel name
  for(descriptor_delta=0;descriptor_delta<HILO(vct_channel->descriptor_length);)
    {
      descriptor_len=buf[PSIP_VCT_LEN+descriptor_delta+1];
      if(buf[PSIP_VCT_LEN+descriptor_delta]==0xA0) //Extended channel name descriptor
	{
	  log_message( log_module, MSG_DEBUG, "Extended channel name descriptor, we try to decode long channel name\n");
	  dest8=(uint8_t *)long_name; //same type size, just the sign change but we don't care
	  //check 
	  delta_multiple_string_structure=PSIP_VCT_LEN+descriptor_delta+2;//+2 to skip descriptor tag and descriptor len
	  if (atsc_text_validate(((uint8_t*)(buf + delta_multiple_string_structure) ),
				 buf[PSIP_VCT_LEN+descriptor_delta+1]))
	    {
	      log_message( log_module, MSG_DEBUG, "Error when VALIDATING long channel name, we take the short one\n");
	    }
	  else
	    {
	      //If we have multiple strings for the channel name we ask people to report
	      if(buf[delta_multiple_string_structure]!=1 || buf[delta_multiple_string_structure+1+3] !=1)
		{
		  log_message( log_module, MSG_WARN, "!!!!! Please report : parsing of long name :  number strings : %d number segments : %d\n",
			      buf[delta_multiple_string_structure],
			      buf[delta_multiple_string_structure+1+3]);
		}

	      //Since it's only the channel name, we don't loop over strings and segments
	      //We decode the text using LIBUCSI
	      atsc_decode_out=atsc_text_segment_decode((struct atsc_text_string_segment *) (buf +delta_multiple_string_structure + MULTIPLE_STRING_STRUCTURE_HEADER),
						       &dest8,
						       &destbufsize,
						       &destbufpos);
	      if(atsc_decode_out!=-1) //No errors
		{
		  dest8[atsc_decode_out]='\0';
		  //We take the long one
		  log_message( log_module, MSG_DEBUG, "Decoded long channel name : \"%s\"\n",dest8);
		  channel_name=long_name;	  
		}
	      else
		log_message( log_module, MSG_DEBUG, "Error when decoding long channel name, we take the short one\n");
	    }
	}
      //Take the short name if error
      if(!channel_name)
	channel_name=utf8_short_name;

      //Next descriptor
      descriptor_delta+=descriptor_len+2;//We add the descriptor_len +2 for descriptor tag and descriptor len
    }
#else
  //We don't use libusci, we don't try to get long channel name
  channel_name=utf8_short_name;
#endif

  //************** We add this channel to the list of services *****************
  //we search if we already have service id
  new_service=autoconf_find_service_for_add(parameters->services,HILO(vct_channel->program_number)); //The service id IS the program number
  
  if(new_service)
    {
      log_message( log_module, MSG_DETAIL, "Adding new channel %s to the list of services , program number : 0x%x \n",
		  channel_name,
		  HILO(vct_channel->program_number));
      //we store the data
      new_service->id=HILO(vct_channel->program_number);
      new_service->running_status=0;
      new_service->type=mpeg2_service_type;
      new_service->free_ca_mode=vct_channel->access_controlled;
      log_message( log_module, MSG_DEBUG, "access_controlled : 0x%x\n", new_service->free_ca_mode);
      memcpy (new_service->name, channel_name, strlen(channel_name));
      new_service->name[strlen(channel_name)] = '\0';

    }

  //**************** Work done for this channel -- goodbye *********************
  return PSIP_VCT_LEN + HILO(vct_channel->descriptor_length); //We return the length

}
コード例 #8
0
ファイル: section.c プロジェクト: nvertigo/vdr
int PAT::getTransportStreamId() const {
   return HILO(s->transport_stream_id);
}
コード例 #9
0
ファイル: mumudvb_test.c プロジェクト: Maescool/MuMuDVB
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_DEBUG,"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_FLOOD, "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 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_DEBUG,"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_DEBUG,"PID  %d", pid);
        packet_count++;
        if(!(packet_count %100))
          log_message( log_module, MSG_DEBUG,"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
コード例 #10
0
ファイル: autoconf_sdt.c プロジェクト: uow-dmurrell/MuMuDVB
/** @brief Read the service description table (cf EN 300 468)
 *
 * This table is used to find the name of the services versus the service number
 * This function will fill the services chained list.
 *
 * @param buf the buffer containing the SDT
 * @param len the len of the buffer
 * @param services the chained list of services
 * @todo : give the parameters as read_pat
 */
int autoconf_read_sdt(unsigned char *buf,int len, mumudvb_service_t *services)
{
  int delta;
  sdt_t *header;
  sdt_descr_t *descr_header;
  mumudvb_service_t *new_service=NULL;

  header=(sdt_t *)buf; //we map the packet over the header structure

  /*current_next_indicator – A 1-bit indicator, which when set to '1' indicates that the Program Association Table
  sent is currently applicable. When the bit is set to '0', it indicates that the table sent is not yet applicable
  and shall be the next table to become valid.*/
  if(header->current_next_indicator == 0)
  {
    log_message( log_module, MSG_FLOOD,"SDT not yet valid, we get a new one (current_next_indicator == 0)\n");
    return 0;
  }

  //We look only for the following table
  //0x42 service_description_section - actual_transport_stream
  if(header->table_id==0x42)
  {
    log_message( log_module, MSG_DEBUG, "-- SDT : Service Description Table (id 0x%02x)--\n",header->table_id);

    log_message( log_module, MSG_FLOOD, "-- SDT: TSID %d Original network id %d version %d section number %d last section number %d  --\n",
                  HILO(header->transport_stream_id),
                  HILO(header->original_network_id),
                  header->version_number,
                  header->section_number,
                  header->last_section_number);
    //Loop over different services in the SDT
    delta=SDT_LEN;
    while((len-delta)>=(4+SDT_DESCR_LEN))
    {
      descr_header=(sdt_descr_t *)(buf +delta );
      //we search if we already have service id
      new_service=autoconf_find_service_for_add(services,HILO(descr_header->service_id));
      if(new_service)
      {
        log_message( log_module, MSG_DEBUG, "We discovered a new service, service_id : 0x%x\n", HILO(descr_header->service_id));
        //For information only
        switch(descr_header->running_status)
        {
          case 0:
            log_message( log_module, MSG_DEBUG, "\trunning_status : undefined\n");  break;
          case 1:
            log_message( log_module, MSG_DEBUG, "\trunning_status : not running\n");  break;
          case 2:
            log_message( log_module, MSG_DEBUG, "\trunning_status : starts in a few seconds\n");  break;
          case 3:
            log_message( log_module, MSG_DEBUG, "\trunning_status : pausing\n");  break;
          case 4:  log_message( log_module, MSG_FLOOD, "\trunning_status : running\n");  break; //too usual to be printed as debug
          case 5:
            log_message( log_module, MSG_DEBUG, "\trunning_status : service off-air\n");  break;
        }
        //we store the data
        new_service->id=HILO(descr_header->service_id);
        new_service->running_status=descr_header->running_status;
        new_service->free_ca_mode=descr_header->free_ca_mode;
        log_message( log_module, MSG_DEBUG, "\tfree_ca_mode : 0x%x\n", descr_header->free_ca_mode);
        //We read the descriptor
        parse_sdt_descriptor(buf+delta+SDT_DESCR_LEN,HILO(descr_header->descriptors_loop_length),new_service);
      }
    delta+=HILO(descr_header->descriptors_loop_length)+SDT_DESCR_LEN;
    }
  }
  else
    log_message( log_module, MSG_FLOOD, "-- SDT : bad table id 0x%02x--\n",header->table_id);
  return 0;
}
コード例 #11
0
ファイル: si.c プロジェクト: FFTEAM/evolux-spark-sh4
int NumberedSection::getTableIdExtension(const unsigned char *d) {
   return HILO(((const ExtendedSectionHeader *)d)->table_id_extension);
}
コード例 #12
0
ファイル: si.c プロジェクト: FFTEAM/evolux-spark-sh4
int Section::getLength(const unsigned char *d) {
   return HILO(((const SectionHeader *)d)->section_length)+sizeof(SectionHeader);
}
コード例 #13
0
ファイル: xns.c プロジェクト: mingpen/OpenNT
BOOL RplSend( VOID)
{
    WORD                Temp;

    (VOID)memset( (PVOID)&Ccb, '\0', sizeof(Ccb));
    Ccb.uchDlcCommand = LLC_TRANSMIT_DIR_FRAME;

    Ccb.u.pParameterTable = (PLLC_PARMS)&TransmitParms;
    memset( (PVOID)&TransmitParms, '\0', sizeof(TransmitParms));
    TransmitParms.uchXmitReadOption = DLC_DO_NOT_CHAIN_XMIT;

    //
    //  Initialize XmitQueue which contains the first send buffer.
    //
    TransmitParms.pXmitQueue1 = (LLC_XMIT_BUFFER *)&XmitQueue;
    memset( (PVOID)&XmitQueue, '\0', sizeof( XmitQueue.XmitBuffer));
    XmitQueue.XmitBuffer.cbBuffer = sizeof( XmitQueue.LanHeader);
    //
    //  In case of a direct open auchLanHeader[] returned by DLC contains
    //  LAN_HEADER structure without physical control fields.  For now
    //  we work around this DLC bug by using offset 6 instead of 8 as a
    //  source address offset in auchLanHeader[].
    //
#define RPLDLC_SOURCE_OFFSET    6   //  BUGBUG  not 8 due to dlc bug
    RplCopy( XmitQueue.LanHeader.dest_addr,
        (PBYTE)&pRcvbuf->b.auchLanHeader[ RPLDLC_SOURCE_OFFSET],
        NODE_ADDRESS_LENGTH);
    RplCopy( XmitQueue.LanHeader.source_addr,
        DirStatusParms.auchNodeAddress,
        NODE_ADDRESS_LENGTH);
    //
    //  These two are important for token ring already.
    //  I was hoping they will set XNS identifier field itself.
    //
    XmitQueue.LanHeader.routing_info_header[0] = 0x06;
    XmitQueue.LanHeader.routing_info_header[1] = 0x00;

    //
    //  Initialize EtherstartResp which contains the second & the last
    //  send buffer.
    //
    TransmitParms.pBuffer1 = (PVOID)&EtherstartResp;
    Temp = min( EtherstartReq->count,
        (WORD)(sizeof_ripl_rom - EtherstartReq->start));
    TransmitParms.cbBuffer1 = (WORD)( sizeof(EtherstartResp) -
        sizeof( EtherstartResp.data) + Temp);
    EtherstartResp.idp.chksum = XNS_NO_CHKSUM;
    EtherstartResp.idp.len = HILO( TransmitParms.cbBuffer1);
    EtherstartResp.idp.packet_type = PEX_TYPE;
    RplCopy( EtherstartResp.idp.dest.host,
        (PBYTE)&pRcvbuf->b.auchLanHeader[ RPLDLC_SOURCE_OFFSET],
        NODE_ADDRESS_LENGTH);
    EtherstartResp.idp.dest.socket = ETHERSTART_SOCKET;
    RplCopy( EtherstartResp.idp.src.host, DirStatusParms.auchNodeAddress,
        NODE_ADDRESS_LENGTH);
    EtherstartResp.idp.src.socket = ETHERSTART_SOCKET;
    EtherstartResp.pex.pex_id = EtherstartReq->pex.pex_id;
    EtherstartResp.pex.pex_client = ETHERSERIES_CLIENT;
    EtherstartResp.es.func = FUNC_READFILERESP;
    EtherstartResp.es.bytes = Temp; // stays intel ordered
    RplCopy( EtherstartResp.data, &ripl_rom[ EtherstartReq->start], Temp);
    return( EtherAcsLan());
}
コード例 #14
0
ファイル: section.c プロジェクト: nvertigo/vdr
int EIT::Event::getMJD() const {
   return HILO(s->mjd);
}
コード例 #15
0
ファイル: section.c プロジェクト: nvertigo/vdr
int NIT::TransportStream::getOriginalNetworkId() const {
   return HILO(s->original_network_id);
}
コード例 #16
0
ファイル: section.c プロジェクト: nvertigo/vdr
void EIT::Event::Parse() {
   int offset=0;
   data.setPointerAndOffset<const eit_event>(s, offset);
   //printf("%d %d %d\n", getStartTime(), getDuration(), getRunningStatus());
   eventDescriptors.setData(data+offset, HILO(s->descriptors_loop_length));
}
コード例 #17
0
ファイル: section.c プロジェクト: nvertigo/vdr
void NIT::TransportStream::Parse() {
   int offset=0;
   data.setPointerAndOffset<const ni_ts>(s, offset);
   transportStreamDescriptors.setData(data+offset, HILO(s->transport_descriptors_length));
}
コード例 #18
0
ファイル: section.c プロジェクト: nvertigo/vdr
int RST::RunningInfo::getTransportStreamId() const {
   return HILO(s->transport_stream_id);
}
コード例 #19
0
ファイル: section.c プロジェクト: nvertigo/vdr
int SDT::Service::getServiceId() const {
   return HILO(s->service_id);
}
コード例 #20
0
ファイル: section.c プロジェクト: nvertigo/vdr
int PAT::Association::getServiceId() const {
   return HILO(s->program_number);
}
コード例 #21
0
ファイル: section.c プロジェクト: nvertigo/vdr
void SDT::Service::Parse() {
   int offset=0;
   data.setPointerAndOffset<const sdt_descr>(s, offset);
   serviceDescriptors.setData(data+offset, HILO(s->descriptors_loop_length));
}
コード例 #22
0
ファイル: section.c プロジェクト: nvertigo/vdr
int RST::RunningInfo::getEventId() const {
   return HILO(s->event_id);
}
コード例 #23
0
ファイル: section.c プロジェクト: nvertigo/vdr
int EIT::getServiceId() const {
   return HILO(s->service_id);
}
コード例 #24
0
ファイル: section.c プロジェクト: nvertigo/vdr
int AIT::Application::getApplicationId() const {
   return HILO(s->application_id);
}
コード例 #25
0
ファイル: section.c プロジェクト: nvertigo/vdr
int EIT::getOriginalNetworkId() const {
   return HILO(s->original_network_id);
}
コード例 #26
0
ファイル: section.c プロジェクト: nvertigo/vdr
void AIT::Application::Parse() {
   int offset=0;
   data.setPointerAndOffset<const ait_app>(s, offset);
   applicationDescriptors.setData(data+offset, HILO(s->application_descriptors_length));
}
コード例 #27
0
ファイル: section.c プロジェクト: nvertigo/vdr
int EIT::Event::getEventId() const {
   return HILO(s->event_id);
}
コード例 #28
0
ファイル: section.c プロジェクト: nvertigo/vdr
int PremiereCIT::getContentId() const {
   return (HILO(s->contentId_hi) << 16) | HILO(s->contentId_lo);
}
コード例 #29
0
ファイル: ptexenc.c プロジェクト: starseeker/ModTeX
/* input line with encoding conversion */
long input_line2(FILE *fp, unsigned char *buff, long pos,
                 const long buffsize, int *lastchar)
{
    long i;
    static boolean injis = false;
    const int fd = fileno(fp);

    if (infile_enc[fd] == ENC_UNKNOWN) { /* just after opened */
        ungetbuff[fd].size = 0;
        if (isUTF8Nstream(fp)) infile_enc[fd] = ENC_UTF8;
        else                   infile_enc[fd] = get_file_enc();
    }
    buffer = buff;
    first = last = pos;

    while (last < buffsize-30 && (i=getc4(fp)) != EOF && i!='\n' && i!='\r') {
        /* 30 is enough large size for one char */
        /* attention: 4 times of write_hex() eats 16byte */
        if (i == ESC) {
            if ((i=getc4(fp)) == '$') { /* ESC '$' (Kanji-in) */
                i = getc4(fp);
                if (i == '@' || i == 'B') {
                    injis = true;
                } else {               /* broken Kanji-in */
                    buffer[last++] = ESC;
                    buffer[last++] = '$';
                    if (is_tail(&i, fp)) break;
                    buffer[last++] = i;
                }
            } else if (i == '(') {     /* ESC '(' (Kanji-out) */
                i = getc4(fp);
                if (i == 'J' || i == 'B' || i == 'H') {
                    injis = false;
                } else {               /* broken Kanji-out */
                    buffer[last++] = ESC;
                    buffer[last++] = '(';
                    if (is_tail(&i, fp)) break;
                    buffer[last++] = i;
                }
            } else { /* broken ESC */
                buffer[last++] = ESC;
                if (is_tail(&i, fp)) break;
                buffer[last++] = i;
            }
        } else { /* rather than ESC */
            if (injis) { /* in JIS */
                long j = getc4(fp);
                if (is_tail(&j, fp)) {
                    buffer[last++] = i;
                    i = j;
                    break;
                } else { /* JIS encoding */
                    i = fromJIS(HILO(i,j));
                    if (i == 0) i = fromUCS(U_REPLACEMENT_CHARACTER);
                    write_multibyte(toBUFF(i));
                }
            } else {  /* normal */
                if        (infile_enc[fd] == ENC_SJIS && isSJISkanji1(i)) {
                    get_sjis(i, fp);
                } else if (infile_enc[fd] == ENC_EUC  && isEUCkanji1(i)) {
                    get_euc(i, fp);
                } else if (infile_enc[fd] == ENC_UTF8 && UTF8length(i) > 1) {
                    get_utf8(i, fp);
                } else {
                    buffer[last++] = i;
                }
            }
        }
    }

    buffer[last] = '\0';
    if (i == EOF || i == '\n' || i == '\r') injis = false;
    if (lastchar != NULL) *lastchar = i;

    return last;
}