[vdr] Instant Timer with a given Channel

Patrick Fischer patrick_fischer at gmx.de
Fri Dec 2 13:31:45 CET 2005


Hello Christian.
Thanks for this workaround.
Now it works. This is my function:

bool cTuner::startTimeShift(int originalNetworkId,int 
transportStreamId,int serviceId){
       
  cChannel *channel = 
GetChannelBy_ONID_TID_SID(originalNetworkId,transportStreamId,serviceId);    

       
  dsyslog("start Instant Timer on Channel  %s",channel->Name());   
  char *buffer;
  char *buffer2;
  int starthh,startmm,stophh,stopmm;
  time_t now = time(NULL);
  struct tm *tm_t=localtime(&now);
 
  sscanf(*TimeString(now),"%2d:%2d",&starthh,&startmm);
  
sscanf(*TimeString(now+Setup.InstantRecordTime*60),"%2d:%2d",&stophh,&stopmm);  

  asprintf(&buffer2,"@ Instant Recording for Channel %s",channel->Name()); 
  
asprintf(&buffer,"1:%d:%d:%d%d:%d%d:%d:%d:%s",channel->Number(),tm_t->tm_mday,starthh,startmm,stophh,stopmm,Setup.DefaultPriority,Setup.DefaultLifetime,buffer2);
 
  cTimer *timer=new cTimer(false,false);
  if (!timer->Parse(buffer)){
      dsyslog("error at parse timer");
  }
 
  free(buffer);       
  free(buffer2);
   
  if(timer){
    cTimer *t=Timers.GetTimer(timer);
    if(t)
    {
      delete timer;
      timer=t;
    } 
  }       
  return cRecordControls::Start(timer,false);
}




> Hi Patrick,
>
> I use the following code, that nordlicht at vdrportal send me:
>
>       time_t now = time(NULL); // thanks to nordlich at vdrportal for the 
> following code, that
>       char *buffer=NULL;       // allows setting the channel for a 
> timer without event
>       int starthh,startmm,stophh,stopmm;
>       //for getting the day of month
>       struct tm *tm_t=localtime(&now);
>       //we have to get away the ':' from the time string
>       sscanf(TIMESTRING(now),"%2d:%2d",&starthh,&startmm);
>      
> sscanf(TIMESTRING(now+Setup.InstantRecordTime*60),"%2d:%2d",&stophh,&stopmm); 
>
>      
> //active:channel:day_of_month:starttime:endtime:priority:durability:title: 
>
>      
> asprintf(&buffer,"1:%d:%d:%d%d:%d%d:%d:%d:%s:",item->channel->Number(),tm_t->tm_mday,starthh,startmm,stophh,stopmm,Setup.DefaultPriority,Setup.DefaultLifetime,item->channel->Name()); 
>
>       timer=new cTimer(false,false);
>       if(timer->Parse(buffer))
>           free(buffer);   
>
> it abuses the parse function for that purpose. Of course, an extended 
> constructur would be much better.
>
> BR,
>
> Christian.





More information about the vdr mailing list