[vdr] create a channel by SetId(int Nid, int Tid, int Sid, int
Rid = 0)
Patrick Fischer
patrick_fischer at gmx.de
Tue Nov 15 16:44:11 CET 2005
Now I can switch only be define Nid, Tid and Sid.
This is my provisional Version which only works if I make a channelsscan
which takes the Nid, Tid and Sid.
Im not very happy with this solution but it works for me.
Maybe somebody make a better version.
This is my provisional Version:
bool ctuner::changeService(int originalNetworkId, int transportStreamId,
int serviceId){
char buffer[MAXPARSEBUFFER];
if (getLineByIDs(originalNetworkId,transportStreamId,serviceId,buffer)){
dsyslog("Can't find originalNetworkId=%d, transportStreamId=%d
and serviceId=%d in
Channels.conf",originalNetworkId,transportStreamId,serviceId);
return false;
}
cChannel* channel = new cChannel();
if (!channel->Parse(buffer)){
dsyslog("can't parse channel from buffer");
return false;
}
cChannel *mChannel =
Channels.GetByServiceID(channel->Source(),channel->Transponder(),channel->Sid());
delete channel;
if (!mChannel){
//should never be reached
esyslog("can't find channel from channels.conf in
channelslist");
return false;
}
if (!cDevice::PrimaryDevice()->SwitchChannel(mChannel,true)){
dsyslog("can't switch to channel");
return false;
}
return true;
}
bool getLineByIDs(int originalNetworkId, int transportStreamId, int
serviceId, char* resultbuffer){
char *FileName = "/video/channels.conf";//TODO
"AddDirectory(ConfigDirectory, "channels.conf");
bool allowComments = false;
if (FileName && access(FileName, F_OK) == 0) {
isyslog("loading %s", FileName);
FILE *f = fopen(FileName, "r");
if (f) {
char buffer[MAXPARSEBUFFER];
while (fgets(buffer, sizeof(buffer), f) > 0) {
if (allowComments) {
char *p = strchr(buffer, '#');
if (p)
*p = 0;
}
stripspace(buffer);
if (!isempty(buffer)) {
int tmp, sid, nid, tid;
int fields = sscanf(buffer, "%*[^:]:%d
:%*[^:]:%*[^:] :%d :%*[^:]:%*[^:]:%d :%*[^:]:%d :%d :%d :%d ", &tmp,
&tmp, &tmp, &sid, &nid, &tid, &tmp);
if (fields == 7 && originalNetworkId==nid &&
transportStreamId==tid && serviceId == sid){
memcpy(resultbuffer, buffer, MAXPARSEBUFFER);
fclose(f);
return true;
}
}
}
fclose(f);
}
else {
LOG_ERROR_STR(FileName);
return false;
}
}
return false;
}
Patrick Fischer schrieb:
> //damn copy&past.... new version
>
>
> Hello
> Today I'm wondering about the SetId from cChannels.h
> As I know, I can specify a channel only by NID, TID and SID
>
> I know vdr don't use the way, but is there an way to switch to a
> channel only by this values?
>
> I have tried this code:
> cChannel* channel = new cChannel();
> channel->SetId(8468,12801,16406);
> cDevice::ActualDevice()->SwitchChannel(channel,true);
>
> If I execute this code, vdr will show me only the last still Pic of
> the old channel.
>
> The values are from my channels.conf created with w_scan
>
> Name Frequenz Parameter Quelle SRate VPID APID TPID CA SID NID TID RID
> RTL2:578000:I0C23D12M16B8T8G4Y0:T:27500:353:354:359:0:16406:8468:12801:0
>
> If I don't find a better way, I will parse my channels.conf for the
> SID,NID and TID
> If I found the right line, then I can create a cChannel with
> cChannel-Parse(the found line);
>
> I don't like the alternative way.
> Can anybody tell me a better way?
>
> greetings
> Patrick
>
> _______________________________________________
> vdr mailing list
> vdr at linuxtv.org
> http://www.linuxtv.org/cgi-bin/mailman/listinfo/vdr
>
>
More information about the vdr
mailing list