Пример #1
0
/** @brief, tell if the eit have a newer version than the one recorded actually
 * In the EIT pid there is a field to say if the EIT was updated
 * This function check if it has changed (in order to rewrite the eit only once)
 * Note this function can give false positive since it doesn't check the CRC32
 *
 *@param rewrite_vars the parameters for eit rewriting
 *@param buf : the received buffer
 */
int eit_need_update(rewrite_parameters_t *rewrite_vars, unsigned char *buf, int raw)
{

	//Get the SID of the new EIT
	//loop over the stored EIT
	//if found and version > : need update
	//if not found need update


	eit_t       *eit;
	//if it's a raw TS packet we search for the beginning
	if(raw)
		eit=(eit_t*)(get_ts_begin(buf));
	else
		eit=(eit_t*)(buf);

	eit_packet_t *eit_packet;
	if(eit) //It's the beginning of a new packet
	{
		eit_packet=eit_find_by_tsid(rewrite_vars,HILO(eit->service_id));
		if(eit_packet==NULL)
		{
			log_message( log_module, MSG_DETAIL,"EIT sid %d not stored, need update.",
											HILO(eit->service_id));
			return 1;
		}
		//		if((eit->table_id==0x4E)||((eit->table_id&0xF0)==0x50))
		//if((eit->table_id&0xF0)==0x50)
		//	log_message( log_module, MSG_DETAIL,"EIT table id 0x%x schedule not supported yet.",eit->table_id);
		if(eit->table_id==0x4E)
			// 0x4E event_information_section - actual_transport_stream, present/following
			// 0x50 to 0x5F event_information_section - actual_transport_stream, schedule
			//TODO : deal with all these table id_ which could have different version number for the same service
		{
			/*current_next_indicator – A 1-bit indicator, which when set to '1' indicates that the table
        sent is currently applicable.*/
			if(eit->current_next_indicator == 0)
				return 0;

			if(eit->version_number!=eit_packet->version)
			{
				log_message( log_module, MSG_DETAIL,"EIT sid %d need update. stored version : %d, new: %d",
						HILO(eit->service_id),
						eit_packet->version,
						eit->version_number);
				return 1;
			}
			if(!eit_packet->sections_stored[eit->section_number] )
			{
				log_message( log_module, MSG_DETAIL,"EIT sid %d new section %d version : %d",
										HILO(eit->service_id),
										eit->section_number,
										eit_packet->version,
										eit->version_number);
				return 1;
			}
		}
	}
	return 0;
}
Пример #2
0
/** @brief This function tells if we have to send the EIT packet
 */
int eit_sort_new_packet(unsigned char *ts_packet, mumudvb_channel_t *channel)
{
  int send_packet=1;
  ts_header_t *ts_header=(ts_header_t *)ts_packet;
  eit_t       *eit_header=(eit_t*)(get_ts_begin(ts_packet));
  if(ts_header->payload_unit_start_indicator && eit_header) //New packet ?
  {
    if((channel->service_id) &&
        (channel->service_id!= (HILO(eit_header->service_id))))
    {
      send_packet=0;
      channel->eit_dropping=1; //We say that we will drop all the other parts of this packet
    }
    else
    {
      channel->eit_dropping=0;//We say that we will keep all the other parts of this packet
    }
  }
  else if(channel->eit_dropping) //It's not the beginning of a new packet and we drop the beginning, we continue dropping
    send_packet=0;

  if(send_packet)
  {
    /*We set the continuity counter*/
    set_continuity_counter(ts_packet,channel->eit_continuity_counter);
    /*To avoid discontinuities, we have to update the continuity counter*/
    channel->eit_continuity_counter++;
    channel->eit_continuity_counter= channel->eit_continuity_counter % 16;
    return 1;
  }
  return 0;
}
Пример #3
0
/** @brief, tell if the sdt have a newer version than the one recorded actually
 * In the SDT pid there is a field to say if the SDT was updated
 * This function check if it has changed (in order to rewrite the sdt only once)
 * General Note : in case it change during streaming it can be a problem ane we would have to deal with re-autoconfiguration
 * Note this function can give flase positive since it doesn't check the CRC32
 *
 *@param rewrite_vars the parameters for sdt rewriting 
 *@param buf : the received buffer
 */
int sdt_need_update(rewrite_parameters_t *rewrite_vars, unsigned char *buf)
{
  sdt_t       *sdt=(sdt_t*)(get_ts_begin(buf));
  if(sdt) //It's the beginning of a new packet
    if((sdt->version_number!=rewrite_vars->sdt_version) && (sdt->table_id==0x42))
      {
        /*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(sdt->current_next_indicator == 0)
        {
          return 0;
        }
	log_message( log_module, MSG_DEBUG,"Need update. stored version : %d, new: %d\n",rewrite_vars->sdt_version,sdt->version_number);
	if(rewrite_vars->sdt_version!=-1)
	  log_message( log_module, MSG_INFO,"The SDT version changed, so the channels names changed probably.\n");
	return 1;
      }
  return 0;

}
Пример #4
0
/** @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;
			}
		}
	}
}