Example #1
0
int softdvb_init()
{
	int ret = 0;
	Filter_param param;
	
	// xml 根pid
	unsigned short root_pid = root_channel_get();
	int filter1 = alloc_filter(root_pid, 0);
	DEBUG("set dvb filter, pid=%d, fid=%d\n", root_pid, filter1);
	
	// 升级pid
	memset(&param,0,sizeof(param));
	param.filter[0] = 0xf0;
	param.mask[0] = 0xff;
	loader_dsc_fid=TC_alloc_filter(0x1ff0, &param, loader_des_section_handle, NULL, 0);
	DEBUG("set upgrade filter, pid=0x1ff0, fid=%d\n", loader_dsc_fid);
	
	// ca pid
	memset(&param,0,sizeof(param));
	param.filter[0] = 0x1;
	param.mask[0] = 0xff;
	int ca_dsc_fid=TC_alloc_filter(0x1, &param, ca_section_handle, NULL, 0);
	DEBUG("set ca filter, pid=0x1, fid=%d\n", ca_dsc_fid);
	
#ifdef PUSH_LOCAL_TEST
	// prog/video
	unsigned short video_pid = 123;
	int filter5 = alloc_filter(video_pid, 1);
	DEBUG("set dvb filter3, pid=%d, fid=%d\n", video_pid, filter5);
	
	// prog/file
	unsigned short file_pid = 654;
	int filter4 = alloc_filter(file_pid, 1);
	DEBUG("set dvb filter3, pid=%d, fid=%d\n", file_pid, filter4);
	
	// prog/audio
	unsigned short audio_pid = 8123;
	int filter3 = alloc_filter(audio_pid, 1);
	DEBUG("set dvb filter3, pid=%d, fid=%d\n", audio_pid, filter3);
#else
	if(-1==pid_init(1)){
		DEBUG("allpid init faild\n");
		return -1;
	}
#endif
	
	tdt_time_sync_awake();
	
	if(0==pthread_create(&pth_softdvb_id, NULL, softdvb_thread, NULL)){
		//pthread_detach(pth_softdvb_id);
		DEBUG("create soft dvb thread success\n");
		ret = 0;
	}
	else{
		ERROROUT("create multicast receive thread failed\n");
		ret = -1;
	}
	
	return ret;
}
Example #2
0
/* Test the example of a train moving along a 1-d track */
void test_train() {
  KalmanFilter f = alloc_filter(2, 1);

  /* The train state is a 2d vector containing position and velocity.
     Velocity is measured in position units per timestep units. */
  set_matrix(f.state_transition,
	     1.0, 1.0,
	     0.0, 1.0);

  /* We only observe position */
  set_matrix(f.observation_model, 1.0, 0.0);

  /* The covariance matrices are blind guesses */
  set_identity_matrix(f.process_noise_covariance);
  set_identity_matrix(f.observation_noise_covariance);

  /* Our knowledge of the start position is incorrect and unconfident */
  double deviation = 1000.0;
  set_matrix(f.state_estimate, 10 * deviation);
  set_identity_matrix(f.estimate_covariance);
  scale_matrix(f.estimate_covariance, deviation * deviation);

  /* Test with time steps of the position gradually increasing */
  for (int i = 0; i < 10; ++i) {
    set_matrix(f.observation, (double) i);
    update(f);
  }

  /* Our prediction should be close to (10, 1) */
  printf("estimated position: %f\n", f.state_estimate.data[0][0]);
  printf("estimated velocity: %f\n", f.state_estimate.data[1][0]);

  free_filter(f);
}
Example #3
0
static void alloc_section(class_handle_t handle, dvb_section_t *p_src_sec)
{
  u16 id = 0;
  service_t *p_svc = p_src_sec->p_svc;
  dvb_section_t *p_sec = NULL;
  dvb_svc_data_t *p_svc_data = (dvb_svc_data_t *)p_svc->get_data_buffer(p_svc);
  dvb_priv_t *p_priv = p_svc_data->p_this->p_data;
  alloc_ret_t ret = ALLOC_SUC;
  BOOL ret_boo = FALSE;
  class_handle_t q_handle = p_priv->q_handle;

  MT_ASSERT(p_src_sec != NULL);

  ret_boo = pop_simple_queue(p_priv->q_handle, p_priv->free_queue, &id);

  //fix me
  if(!ret_boo)
  {
    return; //drap it
  }

  if(id >= DVB_MAX_SECTION_NUM)
  {
    return; //drap it
  }
  
  MT_ASSERT(ret_boo == TRUE);
  p_sec = p_priv->p_sec + id;
  //MT_ASSERT(id == p_sec->id);
  if(id != p_sec->id)
  {
    show_sec(p_priv);
    id = p_sec->id;

   // MT_ASSERT(0);
  }

  memcpy(p_sec, p_src_sec, sizeof(dvb_section_t));
  p_sec->pti_handle = NULL;
  p_sec->p_buffer = NULL;
  p_sec->id = id;
  
//    push_simple_queue(p_priv->q_handle, p_svc_data->wait_queue, id);
  
  ret = alloc_filter(p_priv, p_sec);
  if(ALLOC_SUC == ret)
  {
    MT_ASSERT(p_sec->pti_handle != NULL);
    // alloc filter suc, push it to using q
    push_simple_queue(q_handle, p_svc_data->using_queue, id);
  }
  else
  {
    OS_PRINTF("xxx dvb_alloc_section failed continue... \n");
    push_simple_queue(p_priv->q_handle, p_svc_data->wait_queue, id);
  }
  
}
Example #4
0
static int allpid_sqlite_cb(char **result, int row, int column, void *filter_act, unsigned int receiver_size)
{
	DEBUG("sqlite callback, row=%d, column=%d, filter_act addr: %p, receiver_size=%u\n", row, column, filter_act,receiver_size);
	if(row<1 || NULL==filter_act){
		DEBUG("no record in table, return\n");
		return 0;
	}
	
	int i = 0;
	
	for(i=1;i<row+1;i++)
	{
		unsigned short pid = (unsigned short)(strtol(result[i*column],NULL,0));
		if(0==*((int *)filter_act) || 0==atoi(result[i*column+2])){
			int ret = free_filter(pid);
			DEBUG("free pid %d[%s] return with %d\n", pid, result[i*column], ret);
		}
	}
	
	for(i=1;i<row+1;i++)
	{
		DEBUG("PID --- %s:%s:%s --- \n", result[i*column],result[i*column+1],result[i*column+2]);
		unsigned short pid = (unsigned short)(strtol(result[i*column],NULL,0));
		if(1==*((int *)filter_act) && 1==atoi(result[i*column+2])){
			int filter = -1;
			if(0==strcmp(result[i*column+1],"file"))
				filter = alloc_filter(pid, 1);
			else
				filter = alloc_filter(pid, 0);
			DEBUG("set filter, pid=%d[%s], fid=%d\n", pid, result[i*column], filter);
		}
//		else{
//			int ret = free_filter(pid);
//			DEBUG("free pid %d return with %d\n", pid, ret);
//		}
	}
	
	return 0;
}
Example #5
0
GPSFilter::GPSFilter(double noise){
  //KalmanFilter alloc_filter_velocity2d(double noise) {
  /* The state model has four dimensions:
     x, y, x', y'
     Each time step we can only observe position, not velocity, so the
     observation vector has only two dimensions.
  */
  f = alloc_filter(4, 2);

  /* Assuming the axes are rectilinear does not work well at the
     poles, but it has the bonus that we don't need to convert between
     lat/long and more rectangular coordinates. The slight inaccuracy
     of our physics model is not too important.
   */
  double v2p = 0.001;
  set_identity_matrix(f.state_transition);
  set_seconds_per_timestep(1.0);
	     
  /* We observe (x, y) in each time step */
  set_matrix(f.observation_model,
	     1.0, 0.0, 0.0, 0.0,
	     0.0, 1.0, 0.0, 0.0);

  /* Noise in the world. */
  double pos = 0.000001;
  set_matrix(f.process_noise_covariance,
	     pos, 0.0, 0.0, 0.0,
	     0.0, pos, 0.0, 0.0,
	     0.0, 0.0, 1.0, 0.0,
	     0.0, 0.0, 0.0, 1.0);

  /* Noise in our observation */
  set_matrix(f.observation_noise_covariance,
	     pos * noise, 0.0,
	     0.0, pos * noise);

  /* The start position is totally unknown, so give a high variance */
  set_matrix(f.state_estimate, 0.0, 0.0, 0.0, 0.0);
  set_identity_matrix(f.estimate_covariance);
  double trillion = 1000.0 * 1000.0 * 1000.0 * 1000.0;
  scale_matrix(f.estimate_covariance, trillion);

  //return f;
}
static void dvb_alloc_filter(service_t *p_svc)
{
  dvb_svc_data_t *p_svc_data = (dvb_svc_data_t *)p_svc->get_data_buffer(p_svc);
  dvb_priv_t *p_priv = p_svc_data->p_this->p_data;
  class_handle_t q_handle = p_priv->q_handle;
  dvb_section_t *p_sec = NULL;
  u16 sec_id = 0;
  alloc_ret_t ret = ALLOC_SUC;
  u16 i = 0;
  u16 sec_num = get_simple_queue_len(q_handle, p_svc_data->wait_queue);
  
  for(i = 0; i < sec_num; i ++)
  {
    pop_simple_queue(q_handle, p_svc_data->wait_queue, &sec_id);
    p_sec = p_priv->p_sec + sec_id;
    MT_ASSERT(sec_id == p_sec->id);
    // has jobs to do, try to allocate PTI filter
    ret = alloc_filter(p_priv, p_sec);
    if(ALLOC_SUC == ret)
    {
      MT_ASSERT(p_sec->dmx_handle != 0xffff);
      // alloc filter suc, push it to using q
      push_simple_queue(q_handle, p_svc_data->using_queue, sec_id);
      break;
    }
    else if(ALLOC_FILTER_FULL == ret)
    {
      // no pti filter, push it back
      push_simple_queue_on_head(q_handle, p_svc_data->wait_queue, sec_id);
      break;
    }
    else if(ALLOC_FAIL == ret)
    {
      //in this case, have a same PID between ts and section request
      //push it back, search continue
      OS_PRINTF("xxx dvb alloc filter failed continue... \n");
      push_simple_queue(q_handle, p_svc_data->wait_queue, sec_id);
    }
  }
}
void kvdb_catch_table(u16 pid, u16 table_id)
{
     adv_demux_filter_t *sn_filter = NULL;
     dmx_filter_setting_t param;
     KVDB_DRV_DEBUG("%s, %d \n", __FUNCTION__, __LINE__);
     KVDB_DRV_DEBUG("pid = %d , table_id = %d \n", pid, table_id);
     memset(&param,0x0, sizeof(dmx_filter_setting_t) );
      sn_filter = alloc_filter(pid);
      if(!sn_filter)
      {
            KVDB_DRV_DEBUG("sn_filter is NULL \n");
            return;
      }
      param.continuous = FALSE;
      param.en_crc = TRUE;
      param.req_mode =  DMX_REQ_MODE_SINGLE_SECTION;

      param.value[0] = table_id;
      param.mask[0] = 0xff,      
      set_filter( sn_filter, &param, call_back_data_procee);
      KVDB_DRV_DEBUG("start_filter ----\n");
      start_filter(sn_filter);
      return;
}
static void alloc_section(class_handle_t handle, dvb_section_t *p_src_sec)
{
  u16 id = 0;
  service_t *p_svc = p_src_sec->p_svc;
  dvb_section_t *p_sec = NULL;
  dvb_svc_data_t *p_svc_data = (dvb_svc_data_t *)p_svc->get_data_buffer(p_svc);
  dvb_priv_t *p_priv = p_svc_data->p_this->p_data;
  alloc_ret_t ret = ALLOC_SUC;
  BOOL ret_boo = FALSE;
  class_handle_t q_handle = p_priv->q_handle;

  MT_ASSERT(p_src_sec != NULL);

  ret_boo = pop_simple_queue(p_priv->q_handle, p_priv->free_queue, &id);

  //for warriors bug 22712,37060, prj shoudl select soft filter.
  p_src_sec->use_soft_filter = g_use_soft_filter;

  //fix me
  if(!ret_boo)
  {
    return; //drap it
  }

  if(id >= DVB_MAX_SECTION_NUM)
  {
    return; //drap it
  }
  
  MT_ASSERT(ret_boo == TRUE);
  p_sec = p_priv->p_sec + id;
  //MT_ASSERT(id == p_sec->id);
  if(id != p_sec->id)
  {
    OS_PRINTF("DVB WARNING!!!id %d, p_sec->id %d\n", id, p_sec->id);
    show_sec(p_priv);
    id = p_sec->id;

   // MT_ASSERT(0);
  }

  memcpy(p_sec, p_src_sec, sizeof(dvb_section_t));
  p_sec->dmx_handle = 0xffff;
  p_sec->p_buffer = NULL;
  p_sec->id = id;
  p_sec->buf_id = 0xffff;
  p_sec->ts_in = p_priv->current_ts_in;
  
//    push_simple_queue(p_priv->q_handle, p_svc_data->wait_queue, id);
  
  ret = alloc_filter(p_priv, p_sec);
  if(ALLOC_SUC == ret)
  {
    MT_ASSERT(p_sec->dmx_handle != 0xffff);
    // alloc filter suc, push it to using q
    push_simple_queue(q_handle, p_svc_data->using_queue, id);
  }
  else
  {
    OS_PRINTF("xxx dvb_alloc_section failed continue... \n");
    push_simple_queue(p_priv->q_handle, p_svc_data->wait_queue, id);
  }
  
}