Пример #1
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;
}
Пример #2
0
int main(int argc, char *argv[]) {

// filedescriptors for video, audio and dvr-device
  int fda,fdv;
  int fd_dvr;

// pids for video and audio stream  
  uint16_t vpid = 0;
  uint16_t apid = 0;

  struct sockaddr_in si;
  int socketIn;

  char *ip = "224.0.1.2";
  int port = 5004;

// process command-line arguments
  static struct option long_options[]={
    {"group", required_argument, NULL, 'g'},
    {"port", required_argument, NULL, 'p'},
    {"vpid", required_argument, NULL, 'v'},
    {"apid", required_argument, NULL, 'a'},
    {"help", no_argument, NULL, 'h'},
    {0}
  };

  int c;
  int option_index = 0;

  fprintf(stderr,"*** rtpfeed 0.1 ***\n");

  while((c = getopt_long(argc, argv, "g:p:v:a:h",long_options, &option_index))!=-1)
  {
    switch(c)
    {
    case 'g':
      ip = optarg;
      break;
    case 'p':
      port = atoi(optarg);
      break;
    case 'v':
      vpid = atoi(optarg);
      break;
    case 'a':
      apid = atoi(optarg);
      break;
    case 'h':
      fprintf(stderr,"Usage: %s [-g group] [-p port] [-v video PID] [-a audio PID] \n",argv[0]);
      exit(1);
    }// end switch
  }// end while


// open dvr device for output			
  if((fd_dvr = open("/dev/ost/dvr",O_WRONLY)) < 0){
	perror("DVR DEVICE: ");
	return -1;
  }

// open video device, set filters
  if(vpid!=0){
    if((fdv = open("/dev/ost/demux",O_RDWR|O_NONBLOCK)) < 0){
      perror("DEMUX DEVICE: ");
      return -1;
    }// end if

    set_ts_filt(fdv, vpid, 1);
  }// end if

// open audio device, set filters
  if(apid!=0){
    if((fda = open("/dev/ost/demux",O_RDWR|O_NONBLOCK)) < 0){
      perror("DEMUX DEVICE: ");
      return -1;
    }// end if
    set_ts_filt(fda, apid, 2);
  }// end if

  socketIn  = makeclientsocket(ip,port,2,&si);
  dumprtp(socketIn, fd_dvr);

  close(socketIn);
  return(0);
}