Hello I want to create a new instant Recording from a Plugin at a specific Channel.
The normal way to create a instant Recording is to call
cRecordControls::Start ();
This will create a Recording of the current Channel.
So if I want to create a recording on an different Channel, I can create a new Timer and give this new Timer to cRecordControls::Start ().
cTimer *timer = new cTimer(true,false); cRecordControls::Start (timer);
But new cTimer(true, false) also use the current Channel.
Is it possible that Klaus change the Constructor from cTimer::cTimer(bool Instant, bool Pause) to cTimer::cTimer(bool Instant, bool Pause, int channel = 0)
And the line 30 in timers.c from channel = Channels.GetByNumber(cDevice::CurrentChannel()); to channel = Channels.GetByNumber(channel?channel:cDevice::CurrentChannel());
In this case i can create a new recording by cTimer *timer = new cTimer(true,false,MYCHANNEL); cRecordControls::Start (timer);
please!!! :-)
Yours sincerely, Patrick
Patrick Fischer schrieb:
Hello I want to create a new instant Recording from a Plugin at a specific Channel.
The normal way to create a instant Recording is to call
cRecordControls::Start ();
This will create a Recording of the current Channel.
So if I want to create a recording on an different Channel, I can create a new Timer and give this new Timer to cRecordControls::Start ().
cTimer *timer = new cTimer(true,false); cRecordControls::Start (timer);
But new cTimer(true, false) also use the current Channel.
Is it possible that Klaus change the Constructor from cTimer::cTimer(bool Instant, bool Pause) to cTimer::cTimer(bool Instant, bool Pause, int channel = 0)
And the line 30 in timers.c from channel = Channels.GetByNumber(cDevice::CurrentChannel()); to channel = Channels.GetByNumber(channel?channel:cDevice::CurrentChannel());
In this case i can create a new recording by cTimer *timer = new cTimer(true,false,MYCHANNEL); cRecordControls::Start (timer);
please!!! :-)
Yours sincerely, Patrick
A improved Version would be this:
cTimer::cTimer(bool Instant, bool Pause,cChannel *Channel=NULL) { startTime = stopTime = 0; recording = pending = inVpsMargin = false; flags = tfNone; if (Instant) SetFlags(tfActive | tfInstant); channel = Channel?Channel:Channels.GetByNumber(cDevice::CurrentChannel()); time_t t = time(NULL); struct tm tm_r; struct tm *now = localtime_r(&t, &tm_r); day = SetTime(t, 0); weekdays = 0; start = now->tm_hour * 100 + now->tm_min; stop = now->tm_hour * 60 + now->tm_min + Setup.InstantRecordTime; stop = (stop / 60) * 100 + (stop % 60); if (stop >= 2400) stop -= 2400; priority = Pause ? Setup.PausePriority : Setup.DefaultPriority; lifetime = Pause ? Setup.PauseLifetime : Setup.DefaultLifetime; *file = 0; summary = NULL; event = NULL; if (Instant && channel) snprintf(file, sizeof(file), "%s%s", Setup.MarkInstantRecord ? "@" : "", *Setup.NameInstantRecord ? Setup.NameInstantRecord : channel->Name()); }
Patrick Fischer wrote:
Patrick Fischer schrieb:
Hello I want to create a new instant Recording from a Plugin at a specific Channel.
The normal way to create a instant Recording is to call
cRecordControls::Start ();
This will create a Recording of the current Channel.
So if I want to create a recording on an different Channel, I can create a new Timer and give this new Timer to cRecordControls::Start ().
cTimer *timer = new cTimer(true,false); cRecordControls::Start (timer);
But new cTimer(true, false) also use the current Channel.
Is it possible that Klaus change the Constructor from cTimer::cTimer(bool Instant, bool Pause) to cTimer::cTimer(bool Instant, bool Pause, int channel = 0)
And the line 30 in timers.c from channel = Channels.GetByNumber(cDevice::CurrentChannel()); to channel = Channels.GetByNumber(channel?channel:cDevice::CurrentChannel());
In this case i can create a new recording by cTimer *timer = new cTimer(true,false,MYCHANNEL); cRecordControls::Start (timer);
please!!! :-)
Yours sincerely, Patrick
A improved Version would be this:
cTimer::cTimer(bool Instant, bool Pause,cChannel *Channel=NULL) { ... channel = Channel?Channel:Channels.GetByNumber(cDevice::CurrentChannel());
I'll make it that way in VDR 1.3.38.
Klaus
Hi Patrick,
I use the following code, that nordlicht@vdrportal send me:
time_t now = time(NULL); // thanks to nordlich@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.
Patrick Fischer schrieb:
Hello I want to create a new instant Recording from a Plugin at a specific Channel.
The normal way to create a instant Recording is to call
cRecordControls::Start ();
This will create a Recording of the current Channel.
So if I want to create a recording on an different Channel, I can create a new Timer and give this new Timer to cRecordControls::Start ().
cTimer *timer = new cTimer(true,false); cRecordControls::Start (timer);
But new cTimer(true, false) also use the current Channel.
Is it possible that Klaus change the Constructor from cTimer::cTimer(bool Instant, bool Pause) to cTimer::cTimer(bool Instant, bool Pause, int channel = 0)
And the line 30 in timers.c from channel = Channels.GetByNumber(cDevice::CurrentChannel()); to channel = Channels.GetByNumber(channel?channel:cDevice::CurrentChannel());
In this case i can create a new recording by cTimer *timer = new cTimer(true,false,MYCHANNEL); cRecordControls::Start (timer);
please!!! :-)
Yours sincerely, Patrick
vdr mailing list vdr@linuxtv.org http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr
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@vdrportal send me:
time_t now = time(NULL); // thanks to nordlich@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.