Exemplo n.º 1
0
bool PXL_Texture::create_texture(int w, int h, uint8* pixels, PXL_Channel pixel_channel) {
	if (w <= 0 || h <= 0) {
		PXL_show_exception("Could not create texture, width/height are less than 0", PXL_ERROR_TEXTURE_CREATION_FAILED);
		return false;
	}

	width = w;
	height = h;
	channel = pixel_channel;

	glPixelStorei(GL_UNPACK_ALIGNMENT, channel.num_channels);

	if (!texture_created) { glGenTextures(1, &id); }

	bind();
	glTexImage2D(GL_TEXTURE_2D, 0, channel.gl_pixel_mode, width, height, 0, channel.gl_pixel_mode, GL_UNSIGNED_BYTE, pixels);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
	glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);

	if (!texture_created) { set_filters(); }

	texture_created = true;

	return true;
}
Exemplo n.º 2
0
/*
 * demand_conf - configure the interface for doing dial-on-demand.
 */
void
demand_conf(void)
{
    int i;
    struct protent *protp;

/*    framemax = lcp_allowoptions[0].mru;
    if (framemax < PPP_MRU) */
	framemax = PPP_MRU;
    framemax += PPP_HDRLEN + PPP_FCSLEN;
    frame = malloc(framemax);
    if (frame == NULL)
	novm("demand frame");
    framelen = 0;
    pend_q = NULL;
    escape_flag = 0;
    flush_flag = 0;
    fcs = PPP_INITFCS;

    ppp_send_config(0, PPP_MRU, (u_int32_t) 0, 0, 0);
    ppp_recv_config(0, PPP_MRU, (u_int32_t) 0, 0, 0);

#ifdef PPP_FILTER
    set_filters(&pass_filter, &active_filter);
#endif

    /*
     * Call the demand_conf procedure for each protocol that's got one.
     */
    for (i = 0; (protp = protocols[i]) != NULL; ++i)
	if (protp->enabled_flag && protp->demand_conf != NULL)
	    if (!((*protp->demand_conf)(0)))
		die(1);
}
Exemplo n.º 3
0
/** @brief Finish autoconf
 * This function is called when autoconfiguration is finished
 * It opens what is needed to stream the new channels
 * It creates the file descriptors for the filters, set the filters
 * It also generates a config file with the data obtained during autoconfiguration
 *
 * @param card the card number
 * @param number_of_channels the number of channels
 * @param channels the array of channels
 * @param asked_pid the array containing the pids already asked
 * @param number_chan_asked_pid the number of channels who want this pid
 * @param fds the file descriptors
*/
void autoconf_set_channel_filt(char *card_base_path, int tuner, mumudvb_chan_and_pids_t *chan_and_pids, fds_t *fds)
{
  int curr_channel;
  int curr_pid;


  log_message( log_module, MSG_DETAIL,"Autoconfiguration almost done\n");
  log_message( log_module, MSG_DETAIL,"We open the new file descriptors\n");
  for (curr_channel = 0; curr_channel < chan_and_pids->number_of_channels; curr_channel++)
  {
    for (curr_pid = 0; curr_pid < chan_and_pids->channels[curr_channel].num_pids; curr_pid++)
    {
      if(chan_and_pids->asked_pid[chan_and_pids->channels[curr_channel].pids[curr_pid]]==PID_NOT_ASKED)
        chan_and_pids->asked_pid[chan_and_pids->channels[curr_channel].pids[curr_pid]]=PID_ASKED;
      chan_and_pids->number_chan_asked_pid[chan_and_pids->channels[curr_channel].pids[curr_pid]]++;
    }
  }
  // we open the file descriptors
  if (create_card_fd (card_base_path, tuner, chan_and_pids->asked_pid, fds) < 0)
  {
    log_message( log_module, MSG_ERROR,"ERROR : CANNOT open the new descriptors. Some channels will probably not work\n");
  }

  log_message( log_module, MSG_DETAIL,"Add the new filters\n");
  set_filters(chan_and_pids->asked_pid, fds);
}
Exemplo n.º 4
0
 cnn_layer_model(const cnn_layer_model<T,dims>& model)
  : _version(model._version),
    _kernel_size(model.kernel_size()), _stride_size(model.stride_size()),
    _pooling_size(model.pooling_size()), _visibles_size(model.visibles_size()),
    _activation_function(model.activation_function()),
    _convolution_type(model.convolution_type()),
    _pooling_method(model.pooling_method()),
    _mean(model.mean()), _stddev(model.stddev()),
    _shared_biases(model.shared_bias())
 {
   set_filters(model.filters());
   set_bias(model.bias());
 }
Exemplo n.º 5
0
static void child(int _, char** argv)
{
	/* Request tracing by parent: */
	ptrace(PTRACE_TRACEME, 0, NULL, NULL);

	/* Stop before doing anything, giving parent a chance to catch the exec: */
	kill(getpid(), SIGSTOP);

	set_filters();

	/* Now exec: */
//	execl("/bin/echo", "echo", "lol", NULL);
	execvp(argv[1], argv+1);
}
Exemplo n.º 6
0
/*
 * Proceed to the network phase.
 */
static void
network_phase(int unit)
{
    int i;
    struct protent *protp;
    lcp_options *go = &lcp_gotoptions[unit];

    /*
     * If the peer had to authenticate, run the auth-up script now.
     */
    if ((go->neg_chap || go->neg_upap) && !did_authup) {
	auth_script(_PATH_AUTHUP);
	did_authup = 1;
    }

#ifdef CBCP_SUPPORT
    /*
     * If we negotiated callback, do it now.
     */
    if (go->neg_cbcp) {
	phase = PHASE_CALLBACK;
	(*cbcp_protent.open)(unit);
	return;
    }
#endif

    phase = PHASE_NETWORK;
#if 0
    if (!demand)
	set_filters(&pass_filter, &active_filter);
#endif
    for (i = 0; (protp = protocols[i]) != NULL; ++i)
        if (protp->protocol < 0xC000 && protp->enabled_flag
	    && protp->open != NULL) {
	    (*protp->open)(unit);
	    if (protp->protocol != PPP_CCP)
		++num_np_open;
	}

    if (num_np_open == 0)
	/* nothing to do */
	lcp_close(0, "No network protocols running");
}
Exemplo n.º 7
0
/*
 * demand_conf - configure the interface for doing dial-on-demand.
 */
void
demand_conf()
{
    int i;
    const struct protent *protp;

/*    framemax = lcp_allowoptions[0].mru;
    if (framemax < PPP_MRU) */
	framemax = PPP_MRU;
    framemax += PPP_HDRLEN + PPP_FCSLEN;
    frame = malloc(framemax);
    if (frame == NULL)
	novm("demand frame");
    framelen = 0;
    pend_q = NULL;
    escape_flag = 0;
    flush_flag = 0;
    fcs = PPP_INITFCS;

    netif_set_mtu(pcb, LWIP_MIN(lcp_allowoptions[0].mru, PPP_MRU));
    if (ppp_send_config(pcb, PPP_MRU, (u32_t) 0, 0, 0) < 0
	|| ppp_recv_config(pcb, PPP_MRU, (u32_t) 0, 0, 0) < 0)
	    fatal("Couldn't set up demand-dialled PPP interface: %m");

#ifdef PPP_FILTER
    set_filters(&pass_filter, &active_filter);
#endif

    /*
     * Call the demand_conf procedure for each protocol that's got one.
     */
    for (i = 0; (protp = protocols[i]) != NULL; ++i)
	if (protp->enabled_flag && protp->demand_conf != NULL)
	    ((*protp->demand_conf)(pcb));
/* FIXME: find a way to die() here */
#if 0
	    if (!((*protp->demand_conf)(pcb)))
		die(1);
#endif
}
Exemplo n.º 8
0
/** @brief Reads the program map table
 *
 * It's used to get the differents "useful" pids of the channel
 * @param pmt the pmt packet
 * @param channel the associated channel
 */
int autoconf_read_pmt(mumudvb_ts_packet_t *pmt, mumudvb_channel_t *channel, char *card_base_path, int tuner, uint8_t *asked_pid, uint8_t *number_chan_asked_pid,fds_t *fds)
{
	int section_len, descr_section_len, i,j;
	int pid;
	int pid_type;
	int found=0;
	pmt_t *header;
	pmt_info_t *descr_header;

	int program_info_length;
	int channel_update;

	//For channel update
	int temp_pids[MAX_PIDS];
	int temp_pids_type[MAX_PIDS];
	char temp_pids_language[MAX_PIDS][4];
	//For channel update
	int temp_num_pids=0;

	pid_type=0;

	section_len=pmt->len_full;
	header=(pmt_t *)pmt->data_full;

	if(header->table_id!=0x02)
	{
		log_message( log_module,  MSG_INFO,"Packet PID %d for channel \"%s\" is not a PMT PID. We remove the pmt pid for this channel\n", pmt->pid, channel->name);
		channel->pmt_pid=0; /** @todo : put a threshold, */
		return 1;
	}

	//We check if this PMT belongs to the current channel. (Only works with autoconfiguration full for the moment because it stores the service_id)
	if(channel->service_id && (channel->service_id != HILO(header->program_number)) )
	{
		log_message( log_module,  MSG_DETAIL,"The PMT %d does not belongs to channel \"%s\"\n", pmt->pid, channel->name);
		return 1;
	}

	/*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_DEBUG,"The current_next_indicator is set to 0, this PMT is not valid for the current stream\n");
		return 1;
	}


	log_message( log_module,  MSG_DEBUG,"PMT (PID %d) read for autoconfiguration of channel \"%s\"\n", pmt->pid, channel->name);

	channel_update=channel->num_pids>1?1:0;
	if(channel_update)
	{
		// Update
		log_message( log_module,  MSG_INFO,"Channel %s update\n",channel->name);
		temp_pids[0]=pmt->pid;
		temp_num_pids++;
#ifdef ENABLE_CAM_SUPPORT
		// Reset of the CA SYS saved for the chanel
		for (i=0; i<32; i++)
			channel->ca_sys_id[i]=0;
#endif
	}

	program_info_length=HILO(header->program_info_length); //program_info_length
	char language[4]="";
	int pos=0;

	//we read the different descriptors included in the pmt
	//for more information see ITU-T Rec. H.222.0 | ISO/IEC 13818 table 2-34
	for (i=program_info_length+PMT_LEN; i<=section_len-(PMT_INFO_LEN+4); i+=descr_section_len+PMT_INFO_LEN)
	{
		//we parse the part after the descriptors
		//we map the descriptor header
		descr_header=(pmt_info_t *)(pmt->data_full+i);
		//We get the length of the descriptor
		descr_section_len=HILO(descr_header->ES_info_length);        //ES_info_length

		// Default language value if not found
		snprintf(language,4,"%s","---");
		// Default, no position found
		pos=0;

		pid=HILO(descr_header->elementary_PID);
		//Depending of the stream type we'll take or not this pid
		switch(descr_header->stream_type)
		{
		case 0x01:
			pid_type=PID_VIDEO_MPEG1;
			log_message( log_module,  MSG_DEBUG,"  Video MPEG1 \tpid %d\n",pid);
			break;
		case 0x02:
			pid_type=PID_VIDEO_MPEG2;
			log_message( log_module,  MSG_DEBUG,"  Video MPEG2 \tpid %d\n",pid);
			break;
		case 0x10: /* ISO/IEC 14496-2 Visual - MPEG4 video */
			pid_type=PID_VIDEO_MPEG4_ASP;
			log_message( log_module,  MSG_DEBUG,"  Video MPEG4-ASP \tpid %d\n",pid);
			break;
		case 0x1b: /* AVC video stream as defined in ITU-T Rec. H.264 | ISO/IEC 14496-10 Video */
			pid_type=PID_VIDEO_MPEG4_AVC;
			log_message( log_module,  MSG_DEBUG,"  Video MPEG4-AVC \tpid %d\n",pid);
			break;
		case 0x03:
			pid_type=PID_AUDIO_MPEG1;
			log_message( log_module,  MSG_DEBUG,"  Audio MPEG1 \tpid %d\n",pid);
			break;
		case 0x04:
			pid_type=PID_AUDIO_MPEG2;
			log_message( log_module,  MSG_DEBUG,"  Audio MPEG2 \tpid %d\n",pid);
			break;
		case 0x11: /* ISO/IEC 14496-3 Audio with the LATM transport syntax as defined in ISO/IEC 14496-3 */
			pid_type=PID_AUDIO_AAC_LATM;
			log_message( log_module,  MSG_DEBUG,"  Audio AAC-LATM \tpid %d\n",pid);
			break;
		case 0x0f: /* ISO/IEC 13818-7 Audio with ADTS transport syntax - usually AAC */
			pid_type=PID_AUDIO_AAC_ADTS;
			log_message( log_module,  MSG_DEBUG,"  Audio AAC-ADTS \tpid %d\n",pid);
			break;
		case 0x81: /* Audio per ATSC A/53B [2] Annex B */
			pid_type=PID_AUDIO_ATSC;
			log_message( log_module,  MSG_DEBUG,"  Audio ATSC A/53B \tpid %d\n",pid);
			break;



		case 0x06: /* Descriptor defined in EN 300 468 */
			if(descr_section_len) //If we have an accociated descriptor, we'll search inforation in it
			{
				if(pmt_find_descriptor(0x45,pmt->data_full+i+PMT_INFO_LEN,descr_section_len, NULL)){
					log_message( log_module,  MSG_DEBUG,"  VBI Data \tpid %d\n",pid);
					pid_type=PID_EXTRA_VBIDATA;
				}else if(pmt_find_descriptor(0x46,pmt->data_full+i+PMT_INFO_LEN,descr_section_len, NULL)){
					log_message( log_module,  MSG_DEBUG,"  VBI Teletext \tpid %d\n",pid);
					pid_type=PID_EXTRA_VBITELETEXT;
				}else if(pmt_find_descriptor(0x56,pmt->data_full+i+PMT_INFO_LEN,descr_section_len, NULL)){
					log_message( log_module,  MSG_DEBUG,"  Teletext \tpid %d\n",pid);
					pid_type=PID_EXTRA_TELETEXT;
				}else if(pmt_find_descriptor(0x59,pmt->data_full+i+PMT_INFO_LEN,descr_section_len, &pos)){
					log_message( log_module,  MSG_DEBUG,"  Subtitling \tpid %d\n",pid);
					pid_type=PID_EXTRA_SUBTITLE;
					char * lng=(char *)(pmt->data_full+i+PMT_INFO_LEN+pos+2);
					language[0]=lng[0];
					language[1]=lng[1];
					language[2]=lng[2];
					language[3]=0;
				}else if(pmt_find_descriptor(0x6a,pmt->data_full+i+PMT_INFO_LEN,descr_section_len, NULL)){
					log_message( log_module,  MSG_DEBUG,"  AC3 (audio) \tpid %d\n",pid);
					pid_type=PID_AUDIO_AC3;
				}else if(pmt_find_descriptor(0x7a,pmt->data_full+i+PMT_INFO_LEN,descr_section_len, NULL)){
					log_message( log_module,  MSG_DEBUG,"  Enhanced AC3 (audio) \tpid %d\n",pid);
					pid_type=PID_AUDIO_EAC3;
				}else if(pmt_find_descriptor(0x7b,pmt->data_full+i+PMT_INFO_LEN,descr_section_len, NULL)){
					log_message( log_module,  MSG_DEBUG,"  DTS (audio) \tpid %d\n",pid);
					pid_type=PID_AUDIO_DTS;
				}else if(pmt_find_descriptor(0x7c,pmt->data_full+i+PMT_INFO_LEN,descr_section_len, NULL)){
					log_message( log_module,  MSG_DEBUG,"  AAC (audio) \tpid %d\n",pid);
					pid_type=PID_AUDIO_AAC;
				}else
				{
					log_message( log_module,  MSG_DEBUG,"Unknown descriptor see EN 300 468 v1.9.1 table 12, pid %d descriptor tags : ", pid);
					pmt_print_descriptor_tags(pmt->data_full+i+PMT_INFO_LEN,descr_section_len);
					log_message( log_module,  MSG_DEBUG,"\n");
					continue;
				}
			}
			else
			{
				log_message( log_module,  MSG_DEBUG,"PMT read : stream type 0x06 without descriptor\n");
				continue;
			}
			break;

			//Now, the list of what we drop
		case 0x05:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : 0x05, ITU-T Rec. H.222.0 | ISO/IEC 13818-1 private_sections \n",pid);
			continue;
			//Digital Storage Medium Command and Control (DSM-CC) cf H.222.0 | ISO/IEC 13818-1 annex B
		case 0x0a:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : 0x0A ISO/IEC 13818-6 type A (DSM-CC)\n",pid);
			continue;
		case 0x0b:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : 0x0B ISO/IEC 13818-6 type B (DSM-CC)\n",pid);
			continue;
		case 0x0c:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : 0x0C ISO/IEC 13818-6 type C (DSM-CC)\n",pid);
			continue;
		case 0x0D:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : ISO/IEC 13818-6 type D",pid);
			continue;
		case 0x0E:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : ITU-T Rec. H.222.0 | ISO/IEC 13818-1 auxiliary",pid);
			continue;
		case 0x12:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in PES packets",pid);
			continue;
		case 0x13:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : ISO/IEC 14496-1 SL-packetized stream or FlexMux stream carried in ISO/IEC 14496_sections",pid);
			continue;
		case 0x14:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : ISO/IEC 13818-6 Synchronized Download Protocol",pid);
			continue;
		case 0x15:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : Metadata carried in PES packets",pid);
			continue;
		case 0x16:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : Metadata carried in metadata_sections",pid);
			continue;
		case 0x17:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : Metadata carried in ISO/IEC 13818-6 Data Carousel",pid);
			continue;
		case 0x18:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : Metadata carried in ISO/IEC 13818-6 Object Carousel",pid);
			continue;
		case 0x19:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : Metadata carried in ISO/IEC 13818-6 Synchronized Download Protocol",pid);
			continue;
		case 0x1A:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : IPMP stream (defined in ISO/IEC 13818-11, MPEG-2 IPMP)",pid);
			continue;
		case 0x7F:
			log_message( log_module,  MSG_DEBUG, "Dropped pid %d, type : IPMP stream",pid);
			continue;
		default:
			if(descr_header->stream_type >= 0x1C && descr_header->stream_type <= 0x7E)
				log_message( log_module,  MSG_DEBUG, "Dropped pid %d, stream type : 0x%02x : ITU-T Rec. H.222.0 | ISO/IEC 13818-1 Reserved",pid,descr_header->stream_type);
			else if(descr_header->stream_type >= 0x80)
				log_message( log_module,  MSG_DEBUG, "Dropped pid %d, stream type : 0x%02x : User Private",pid,descr_header->stream_type);
			else
				log_message( log_module,  MSG_INFO, "!!!!Unknown stream type : 0x%02x, PID : %d cf ITU-T Rec. H.222.0 | ISO/IEC 13818\n",descr_header->stream_type,pid);
			continue;
		}

		//We keep this pid

		// We try to find a 0x0a (ISO639) descriptor to have language information about the stream
		pos=0;
		if(pmt_find_descriptor(0x0a,pmt->data_full+i+PMT_INFO_LEN,descr_section_len, &pos)){
			char * lng=(char *)(pmt->data_full+i+PMT_INFO_LEN+pos+2);
			language[0]=lng[0];
			language[1]=lng[1];
			language[2]=lng[2];
			language[3]=0;
		}
		log_message( log_module,  MSG_DEBUG,"  PID Language Code = %s\n",language);

		//For cam debugging purposes, we look if we can find a ca descriptor to display ca system ids
		if(descr_section_len)
		{
			int pos;
			int casysid;
			pos=0;
			while(pmt_find_descriptor(0x09,pmt->data_full+i+PMT_INFO_LEN,descr_section_len,&pos))
			{
				descr_ca_t *ca_descriptor;
				ca_descriptor=(descr_ca_t *)(pmt->data_full+i+PMT_INFO_LEN+pos);
				casysid=0;
				while(casysid<32 && channel->ca_sys_id[casysid] && channel->ca_sys_id[casysid]!=HILO(ca_descriptor->CA_type) )
					casysid++;
				if(casysid<32 && !channel->ca_sys_id[casysid])
				{
					channel->ca_sys_id[casysid]=HILO(ca_descriptor->CA_type);
					log_message( log_module,  MSG_DETAIL,"Ca system id 0x%04x : %s\n", HILO(ca_descriptor->CA_type), ca_sys_id_to_str(HILO(ca_descriptor->CA_type)));//we display it with the description
				}
				if(casysid==32)
					log_message( log_module,  MSG_WARN,"Too much Ca system id line %d file %s\n", __LINE__,__FILE__);
				pos+=ca_descriptor->descriptor_length+2;
			}
		}

		if(channel_update)
		{
			temp_pids[temp_num_pids]=pid;
			temp_pids_type[temp_num_pids]=pid_type;
			snprintf(temp_pids_language[temp_num_pids],4,"%s",language);
			temp_num_pids++;
			if (temp_num_pids >= MAX_PIDS)
			{
				log_message( log_module,  MSG_ERROR,
						"Too many PIDs : %d\n",
						temp_num_pids);
				temp_num_pids--;
			}
		}
		else
		{
			channel->pids[channel->num_pids]=pid;
			channel->pids_type[channel->num_pids]=pid_type;
			snprintf(channel->pids_language[channel->num_pids],4,"%s",language);
			channel->num_pids++;
		}
	}

	/**************************
	 * PCR PID
	 **************************/

	channel->pcr_pid=HILO(header->PCR_PID); //The PCR pid.
	//we check if it's not already included (ie the pcr is carried with the video)
	found=0;
	for(i=0;i<channel->num_pids;i++)
	{
		if((channel_update && temp_pids[i]==channel->pcr_pid) || (!channel_update && channel->pids[i]==channel->pcr_pid))
			found=1;
	}
	if(!found)
	{
		if(channel_update)
		{
			temp_pids[temp_num_pids]=channel->pcr_pid;
			temp_pids_type[temp_num_pids]=PID_PCR;
			snprintf(temp_pids_language[temp_num_pids],4,"%s","---");
			temp_num_pids++;
		}
		else
		{
			channel->pids[channel->num_pids]=channel->pcr_pid;
			channel->pids_type[channel->num_pids]=PID_PCR;
			snprintf(channel->pids_language[channel->num_pids],4,"%s","---");
			channel->num_pids++;
		}
	}
	log_message( log_module,  MSG_DEBUG, "PCR pid %d\n",channel->pcr_pid);

	/**************************
	 * PCR PID - END
	 **************************/
	//We store the PMT version useful to check for updates
	channel->pmt_version=header->version_number;

	/**************************
	 * Channel update
	 **************************/
	//If it's a channel update we will have to update the filters
	if(channel_update)
	{
		log_message( log_module,  MSG_DEBUG,"Channel update new number of pids %d old %d we check for changes\n", temp_num_pids, channel->num_pids);

		//We search for added pids
		for(i=0;i<temp_num_pids;i++)
		{
			found=0;
			for(j=0;j<channel->num_pids;j++)
			{
				if(channel->pids[j]==temp_pids[i])
					found=1;
			}
			if(!found)
			{
				log_message( log_module,  MSG_DETAIL, "Update : pid %d added \n",temp_pids[i]);
				//If the pid is not on the list we add it for the filters
				if(asked_pid[temp_pids[i]]==PID_NOT_ASKED)
					asked_pid[temp_pids[i]]=PID_ASKED;

				number_chan_asked_pid[temp_pids[i]]++;
				channel->pids[channel->num_pids]=temp_pids[i];
				channel->pids_type[channel->num_pids]=temp_pids_type[i];
				snprintf(channel->pids_language[channel->num_pids],4,"%s",temp_pids_language[i]);
				channel->num_pids++;

				log_message( log_module, MSG_DETAIL,"Add the new filters\n");
				// we open the file descriptors
				if (create_card_fd (card_base_path, tuner, asked_pid, fds) < 0)
				{
					log_message( log_module, MSG_ERROR,"CANNOT open the new descriptors. Some channels will probably not work\n");
					//return; //FIXME : what do we do here ?
				}
				//open the new filters
				set_filters(asked_pid, fds);

			}
		}
		//We search for suppressed pids
		for(i=0;i<channel->num_pids;i++)
		{
			found=0;
			for(j=0;j<temp_num_pids;j++)
			{
				if(channel->pids[i]==temp_pids[j])
					found=1;
			}
			if(!found)
			{
				log_message( log_module,  MSG_DETAIL, "Update : pid %d supressed \n",channel->pids[i]);

				//We check the number of channels on wich this pid is registered, if 0 it's strange we warn
				if((channel->pids[i]>MAX_MANDATORY_PID_NUMBER )&& (number_chan_asked_pid[channel->pids[i]]))
				{
					//We decrease the number of channels with this pid
					number_chan_asked_pid[channel->pids[i]]--;
					//If no channel need this pid anymore, we remove the filter (closing the file descriptor remove the filter associated)
					if(number_chan_asked_pid[channel->pids[i]]==0)
					{
						log_message( log_module,  MSG_DEBUG, "Update : pid %d does not belong to any channel anymore, we close the filter \n",channel->pids[i]);
						close(fds->fd_demuxer[channel->pids[i]]);
						fds->fd_demuxer[channel->pids[i]]=0;
						asked_pid[channel->pids[i]]=PID_NOT_ASKED;
					}
				}
				else
					log_message( log_module,  MSG_WARN, "Update : We tried to suppress pid %d in a strange way, please contact if you can reproduce\n",channel->pids[i]);
				//We remove the pid from this channel by swapping with the last one and decreasing the pid number
				channel->pids[i]=channel->pids[channel->num_pids-1];
				channel->num_pids--;
				i--; //we wan to check the pid just moved so we force the loop to reaxamine pid i

			}
		}
		log_message( log_module,  MSG_DETAIL, "        pids : \n");/**@todo Generate a strind and call log_message after, in syslog it generates one line per pid : use the toolbox unicast*/
		int ipid;
		for (ipid = 0; ipid < channel->num_pids; ipid++)
			log_message( log_module,  MSG_DETAIL, "              %d (%s) \n", channel->pids[ipid], pid_type_to_str(channel->pids_type[ipid]));

	}
	/** @todo : update generated conf file*/
	/**************************
	 * Channel update END
	 **************************/
	/*************************
	 * Language template
	 **************************/
	found =0;
	int len=MAX_NAME_LEN;
	for(i=0;i<channel->num_pids && !found;i++)
	{
		if(channel->pids_language[i][0]!='-')
		{
			log_message( log_module,  MSG_FLOOD, "Primary language for channel: %s",channel->pids_language[i]);
			mumu_string_replace(channel->name,&len,0,"%lang",channel->pids_language[i]);
			found=1; //we exit the loop
		}
	}
	//If we don't find a lang we replace by our "usual" ---
	if(!found)
		mumu_string_replace(channel->name,&len,0,"%lang",channel->pids_language[0]);
	/*************************
	 * Language template END
	 **************************/

	log_message( log_module,  MSG_DEBUG,"Number of pids after autoconf %d\n", channel->num_pids);
	return 0;
}
Exemplo n.º 9
0
/** @brief Finish full autoconfiguration (set everything needed to go to partial autoconf)
 * This function is called when FULL autoconfiguration is finished
 * It fill the asked pid array
 * It open the file descriptors for the new filters, and set the filters
 * It open the new sockets
 * It free autoconfiguration memory wich will be not used anymore
 *
 * @param card the card number
 * @param number_of_channels the number of channels
 * @param channels the array of channels
 * @param fds the file descriptors
*/
int autoconf_finish_full(mumudvb_chan_and_pids_t *chan_and_pids, autoconf_parameters_t *autoconf_vars, multicast_parameters_t *multicast_vars, tuning_parameters_t *tuneparams, fds_t *fds, unicast_parameters_t *unicast_vars, int server_id)
{
  int curr_channel,curr_pid;
  //We sort the services
  autoconf_sort_services(autoconf_vars->services);
  chan_and_pids->number_of_channels=autoconf_services_to_channels(*autoconf_vars, chan_and_pids->channels, multicast_vars->common_port, tuneparams->card, tuneparams->tuner, unicast_vars, multicast_vars, server_id); //Convert the list of services into channels
  //we got the pmt pids for the channels, we open the filters
  for (curr_channel = 0; curr_channel < chan_and_pids->number_of_channels; curr_channel++)
  {
    for (curr_pid = 0; curr_pid < chan_and_pids->channels[curr_channel].num_pids; curr_pid++)
    {
      if(chan_and_pids->asked_pid[chan_and_pids->channels[curr_channel].pids[curr_pid]]==PID_NOT_ASKED)
        chan_and_pids->asked_pid[chan_and_pids->channels[curr_channel].pids[curr_pid]]=PID_ASKED;
      chan_and_pids->number_chan_asked_pid[chan_and_pids->channels[curr_channel].pids[curr_pid]]++;
    }
  }

  // we open the file descriptors
  if (create_card_fd (tuneparams->card_dev_path, tuneparams->tuner, chan_and_pids->asked_pid, fds) < 0)
  {
    log_message( log_module, MSG_ERROR,"ERROR : CANNOT open the new descriptors. Some channels will probably not work\n");
  }
  // we set the new filters
  set_filters( chan_and_pids->asked_pid, fds);


  //Networking
  for (curr_channel = 0; curr_channel < chan_and_pids->number_of_channels; curr_channel++)
  {

    /** open the unicast listening connections fo the channels */
    if(chan_and_pids->channels[curr_channel].unicast_port && unicast_vars->unicast)
    {
      log_message( log_module, MSG_INFO,"Unicast : We open the channel %d http socket address %s:%d\n",
                  curr_channel,
                  unicast_vars->ipOut,
                  chan_and_pids->channels[curr_channel].unicast_port);
      unicast_create_listening_socket(UNICAST_LISTEN_CHANNEL,
                                      curr_channel,
                                      unicast_vars->ipOut,
                                      chan_and_pids->channels[curr_channel].unicast_port,
                                      &chan_and_pids->channels[curr_channel].sIn,
                                      &chan_and_pids->channels[curr_channel].socketIn,
                                      fds,
                                      unicast_vars);
    }

    //Open the multicast socket for the new channel
    if(multicast_vars->multicast_ipv4)
      {
	if(multicast_vars->multicast && multicast_vars->auto_join) //See the README for the reason of this option
	  chan_and_pids->channels[curr_channel].socketOut4 = 
	    makeclientsocket (chan_and_pids->channels[curr_channel].ip4Out,
			      chan_and_pids->channels[curr_channel].portOut,
			      multicast_vars->ttl,
			      multicast_vars->iface4,
			      &chan_and_pids->channels[curr_channel].sOut4);
	else if(multicast_vars->multicast)
	  chan_and_pids->channels[curr_channel].socketOut4 = 
	    makesocket (chan_and_pids->channels[curr_channel].ip4Out,
			chan_and_pids->channels[curr_channel].portOut,
			multicast_vars->ttl,
			multicast_vars->iface4,
			&chan_and_pids->channels[curr_channel].sOut4);
      }
    if(multicast_vars->multicast_ipv6)
      {
	if(multicast_vars->multicast && multicast_vars->auto_join) //See the README for the reason of this option
	  chan_and_pids->channels[curr_channel].socketOut6 = 
	    makeclientsocket6 (chan_and_pids->channels[curr_channel].ip6Out,
			      chan_and_pids->channels[curr_channel].portOut,
			      multicast_vars->ttl,
			       multicast_vars->iface6,
			      &chan_and_pids->channels[curr_channel].sOut6);
	else if(multicast_vars->multicast)
	  chan_and_pids->channels[curr_channel].socketOut6 = 
	    makesocket6 (chan_and_pids->channels[curr_channel].ip6Out,
			chan_and_pids->channels[curr_channel].portOut,
			multicast_vars->ttl,
			multicast_vars->iface6,
			&chan_and_pids->channels[curr_channel].sOut6);
      }
  }

  log_message( log_module, MSG_DEBUG,"Step TWO, we get the video and audio PIDs\n");
  //We free autoconf memort
  autoconf_freeing(autoconf_vars);

  autoconf_vars->autoconfiguration=AUTOCONF_MODE_PIDS; //Next step add video and audio pids

  return 0;
}
int ste_adm_hw_handler_vc_u8500(sqlite3* db_p, const char* indev, const char* outdev, int fs)
{
    bool ret, vc_on;
    int ret_func = STE_ADM_RES_ALSA_ERROR;
    const char* dev_top = NULL;
    char* outdev_top = NULL;
    char* indev_top = NULL;

    ALOG_INFO("%s: Enter.", __func__);

    vc_on = (indev != NULL) && (outdev != NULL);
    if (vc_on)
        ALOG_INFO("%s: VC on (indev = '%s', outdev = '%s').", __func__, indev, outdev);
    else
        ALOG_INFO("%s: VC off.", __func__);

    // Become worker thread before opening ALSA controls (to avoid having the
    // "normal-thread" lock at the same time as the ALSA lock)
    srv_become_worker_thread();

    audio_hal_alsa_open_controls(card_name_p);

    ret = audio_hal_alsa_set_control("Master Clock Select", 0, vc_on ? 0 : 1); // VC -> SYSCLK,  Non-VC -> ULPCLK
    if (ret < 0) {
        ALOG_ERR("%s: ERROR: Unable to set audio master-clock!\n", __func__, card_name_p);
        goto cleanup;
    }

    if (vc_on) {
        ret = adm_db_toplevel_mapping_get(indev, &dev_top);
        if (ret < 0) {
            ALOG_ERR("%s: ERROR: Unable to find top-level device for '%s'!\n", __func__, indev);
            ret_func = ret;
            goto cleanup;
        }
        indev_top = strdup(dev_top);
        if (!indev_top) {
            ALOG_ERR("%s: ERROR: strdup() failed\n", __func__);
            goto cleanup;
        }

        ret = adm_db_toplevel_mapping_get(outdev, &dev_top);
        if (ret < 0) {
            ALOG_ERR("%s: ERROR: Unable to find top-level device for '%s'!\n", __func__, outdev);
            ret_func = ret;
            goto cleanup;
        }
        outdev_top = strdup(dev_top);
        if (!outdev_top) {
            ALOG_ERR("%s: ERROR: strdup() failed\n", __func__);
            goto cleanup;
        }

        ALOG_INFO("%s: '%s','%s' maps to '%s','%s' (fs = %d)\n", __func__, indev, outdev, indev_top, outdev_top, fs);

        ret = set_filters(db_p, indev_top, outdev_top, fs);
        if (ret < 0) {
            ALOG_ERR("%s: Failed to configure filters! (ret = %d)\n", __func__, ret);
            goto cleanup;
        }

    } else {
        ret = audio_hal_alsa_set_control("Sidetone Left", 0, 0);
        if (ret < 0) {
            ALOG_ERR("%s: ERROR: Unable to disable sidetone left path! (ret = %d)\n", __func__, ret);
            goto cleanup;
        }
        ret = audio_hal_alsa_set_control("Sidetone Right", 0, 0);
        if (ret < 0) {
            ALOG_ERR("%s: ERROR: Unable to disable sidetone right path! (ret = %d)\n", __func__, ret);
            goto cleanup;
        }
        ret = audio_hal_alsa_set_control("ANC Playback Switch", 0, 0);
        if (ret < 0) {
            ALOG_ERR("%s: ERROR: Unable to disable ANC! (ret = %d)\n", __func__, ret);
            goto cleanup;
        }
    }

    ret_func = STE_ADM_RES_OK;

cleanup:
    if (outdev_top != NULL) free(outdev_top);
    if (indev_top != NULL) free(indev_top);

    audio_hal_alsa_close_controls();
    srv_become_normal_thread();

    return ret_func;
}
Exemplo n.º 11
0
void text::update( platform::context &ctxt )
{
	_mesh.clear();
	if ( !_font || _utf8.empty() )
		return;

	_mesh = gl::mesh();
	// Create the geometry (with texture coordinates) for the text.
	gl::vertex_buffer_data<gl::vec2,gl::vec2> coords;
	gl::element_buffer_data tris;
	{
		using ptype = script::font::coord_type;
		auto add_point = [&]( ptype cx, ptype cy, ptype tx, ptype ty )
		{
			coords.push_back( { cx.count(), cy.count() }, { tx.count(), ty.count() } );
		};

		auto add_tri = [&]( uint32_t a, uint32_t b, uint32_t c )
		{
			tris.push_back( a, b, c );
		};

		_font->render( add_point, add_tri, 0.0, 0.0, _utf8 );
	}

	// don't care about initialization, just need to have the structure
	if ( !_stash )
		ctxt.retrieve_common( this, _stash );

	// Update the font texture if needed.
	auto &fgc = _stash->_font_glyph_cache;
	auto x = fgc.find( _font );

	uint32_t curVer = _font->glyph_version();

	gl::api &ogl = ctxt.api();
	std::shared_ptr<gl::texture> texture;

	bool storeTex = true;
	if ( x != fgc.end() )
	{
		GlyphPack &pk = x->second;
		storeTex = pk.version != curVer;
		texture = pk.texture;
	}
	else
		texture = ogl.new_texture( gl::texture::target::IMAGE_2D );

	auto txt = texture->bind();

	if ( storeTex )
	{
		txt.set_wrapping( gl::wrapping::CLAMP_TO_EDGE );
		txt.set_filters( gl::filter::LINEAR, gl::filter::LINEAR );
		txt.image_2d_red( gl::format::RED,
						  static_cast<size_t>( _font->bitmap_width() ),
						  static_cast<size_t>( _font->bitmap_height() ),
						  gl::image_type::UNSIGNED_BYTE,
						  _font->bitmap().data() );
		fgc[_font] = { _font->glyph_version(), texture };
	}

	auto prog = _stash->_program_cache;
	if ( !prog )
	{
		auto vshader = ogl.new_vertex_shader(
			R"SHADER(
            #version 330

			layout(location = 0) in vec2 vertex_pos;
			layout(location = 1) in vec2 char_pos;

			uniform mat4 matrix;
			out vec2 tex_pos;

			void main()
			{
				tex_pos = char_pos;
				gl_Position = matrix * vec4( vertex_pos, 0.0, 1.0 );
			}
		)SHADER" );

		auto fshader = ogl.new_fragment_shader(
			R"SHADER(
			#version 330

			in vec2 tex_pos;
			out vec4 frag_color;

			uniform vec4 color;
			uniform sampler2D textTex;

			void main()
			{
				vec4 texColor = texture( textTex, tex_pos );
				frag_color = vec4( color.r, color.g, color.b, color.a * texColor.r );
			}