summaryrefslogtreecommitdiff
path: root/device.c
diff options
context:
space:
mode:
authorKlaus Schmidinger <kls (at) cadsoft (dot) de>2004-01-04 18:00:00 +0100
committerKlaus Schmidinger <kls (at) cadsoft (dot) de>2004-01-04 18:00:00 +0100
commit93a94b18b540fbcb9bcdaaea9abd26cdf23d6ee6 (patch)
treebede17e6cd329d36ec02bc53dfe567b95ec835a5 /device.c
parentc432905dd60630f906ac89f58592ad835a9063ef (diff)
downloadvdr-patch-lnbsharing-93a94b18b540fbcb9bcdaaea9abd26cdf23d6ee6.tar.gz
vdr-patch-lnbsharing-93a94b18b540fbcb9bcdaaea9abd26cdf23d6ee6.tar.bz2
Version 1.3.0vdr-1.3.0
- Changed thread handling to make it work with NPTL ("Native Posix Thread Library"). Thanks to Jon Burgess, Andreas Schultz, Werner Fink and Stefan Huelswitt. - The cThread class now accepts a 'Description' parameter, which is used to log the beginning and end of the thread, together with its process and thread id. For descriptions that need additional parameters you can use the function cThread::SetDescription(), which accepts 'printf()' like arguments. Existing plugins that use threads should be changed to use this functionality instead of explicit 'dsyslog()' calls inside their Action() function in order to support logging the thread ids. - Added "Slovak Link" and "Czech Link" to 'ca.conf' (thanks to Emil Petersky). However, 'ca.conf' is now pretty much obsolete due to the automatic CA handling. - Mutexes are now created with PTHREAD_MUTEX_ERRORCHECK_NP, which makes the 'lockingTid' stuff obsolete (thanks to Stefan Huelswitt). - Changed font handling to allow language specific character sets. - Adopted the small font character set from the "Elchi" patch (originally provided by Alessio Sangalli). - Greek language texts now use iso8859-7 character set (thanks to Dimitrios Dimitrakos). - Rearranged section data handling, so that the actual data handling can be done separately, even from within plugins. - The EPG data structures have been moved from eit.[hc] to epg.[hc] and have been adapted to the general VDR coding style. Plugins that use these data structures may need to change some function names (which should be obvious). The name 'subtitle' has been changed to 'shortText' to avoid clashes with actual subtitles that are part of a movie. The name 'extendedDescription' has been shortened to 'description'. - Replaced 'libdtv' with 'libsi' (thanks to Marcel Wiesweg), which is thread safe and can be used by multiple section filters simultaneously. - Added 'cRwLock' to 'thread.[hc]'. Note that all plugin Makefiles need to define _GNU_SOURCE for this to work (see the example plugin Makefiles and 'newplugin'). - Fixed a problem with crc32 in SI handling on 64bit systems (thanks to Pedro Miguel Sequeira de Justo Teixeira for reporting this one). - Fixed an alignment problem in CAM access on 64bit systems (thanks to Pedro Miguel Sequeira de Justo Teixeira for reporting this one). - Added 'StreamType' setting to CAM communication, which is important for Aston/SECA CAMs (thanks to Antonino Sergi). - Now the CA descriptors are sent to the CAM in the 'program' or 'ES level' sections, depending on where they are found in the PMT (thanks to Hans-Peter Raschke for reporting this one). This should make SkyCrypt CAMs work. - Now using the 'version number' of EPG events to avoid unnecessary work. - Channel data is now automatically derived from the DVB data stream (inspired by the 'autopid' patch from Andreas Schultz). - The current channel is now automatically re-tuned if the PIDs or other settings change. If a recording is going on on a channel that has a change in its settings, the recording will be stopped and immediately restarted to use the new channel settings. - EPG events now use the complete channel ID with NID, TID and SID. - Channel names in 'channels.conf' can now have a short form, as provided by some tv stations (see man vdr(5)). Currently channels that provide short names in addition to long ones are listed in the OSD as "short,long name", as in "RTL,RTL Television". The short names will be used explicitly later. - The Ca parameter in 'channels.conf' has been extended and now contains all the CA system ids for the given channel. When switching to a channel VDR now tests for a device that provides one of these CA system ids. The devices automatically get their supported ids from the CI handler. - The values in 'ca.conf' are currently without any real meaning. Whether or not a channel with conditional access can be received is now determined automatically by evaluating its CA descriptors and comparing them to the CA system ids provided by the installed CAM. Only the special values 1-16 are used to assign a channel to a particular device. - Increased the maximum number of possible OSD colors to 256. - Limited the line length in the EPG bugfix report, which appears to fix a buffer overflow that caused a crash when cleaning up the EPG data (at 05:00 in the morning).
Diffstat (limited to 'device.c')
-rw-r--r--device.c95
1 files changed, 71 insertions, 24 deletions
diff --git a/device.c b/device.c
index 9a698ea..8f73a14 100644
--- a/device.c
+++ b/device.c
@@ -4,7 +4,7 @@
* See the main source file 'vdr.c' for copyright information and
* how to reach the author.
*
- * $Id: device.c 1.47.1.1 2003/11/07 13:16:12 kls Exp $
+ * $Id: device.c 1.51 2004/01/04 11:30:05 kls Exp $
*/
#include "device.h"
@@ -13,7 +13,6 @@
#include <sys/mman.h>
#include "audio.h"
#include "channels.h"
-#include "eit.h"
#include "i18n.h"
#include "player.h"
#include "receiver.h"
@@ -36,6 +35,8 @@ cDevice::cDevice(void)
{
cardIndex = nextCardIndex++;
+ SetDescription("receiver on device %d", CardIndex() + 1);
+
SetVideoFormat(Setup.VideoFormat);
active = false;
@@ -43,6 +44,11 @@ cDevice::cDevice(void)
mute = false;
volume = Setup.CurrentVolume;
+ sectionHandler = NULL;
+ eitFilter = NULL;
+ patFilter = NULL;
+ sdtFilter = NULL;
+
ciHandler = NULL;
player = NULL;
@@ -63,6 +69,10 @@ cDevice::~cDevice()
for (int i = 0; i < MAXRECEIVERS; i++)
Detach(receiver[i]);
delete ciHandler;
+ delete sdtFilter;
+ delete patFilter;
+ delete eitFilter;
+ delete sectionHandler;
}
void cDevice::SetUseDevice(int n)
@@ -149,7 +159,7 @@ cDevice *cDevice::GetDevice(const cChannel *Channel, int Priority, bool *NeedsDe
if (device[i]->ProvidesChannel(Channel, Priority, &ndr)) { // this device is basicly able to do the job
if (device[i]->Receiving() && !ndr)
pri = 0; // receiving and allows additional receivers
- else if (d && !device[i]->Receiving() && device[i]->ProvidesCa(Channel->Ca()) < d->ProvidesCa(Channel->Ca()))
+ else if (d && !device[i]->Receiving() && device[i]->ProvidesCa(Channel) < d->ProvidesCa(Channel))
pri = 1; // free and fewer Ca's
else if (!device[i]->Receiving() && !device[i]->IsPrimaryDevice())
pri = 2; // free and not the primary device
@@ -157,7 +167,7 @@ cDevice *cDevice::GetDevice(const cChannel *Channel, int Priority, bool *NeedsDe
pri = 3; // free
else if (d && device[i]->Priority() < d->Priority())
pri = 4; // receiving but priority is lower
- else if (d && device[i]->Priority() == d->Priority() && device[i]->ProvidesCa(Channel->Ca()) < d->ProvidesCa(Channel->Ca()))
+ else if (d && device[i]->Priority() == d->Priority() && device[i]->ProvidesCa(Channel) < d->ProvidesCa(Channel))
pri = 5; // receiving with same priority but fewer Ca's
else
pri = 6; // all others
@@ -311,11 +321,42 @@ bool cDevice::SetPid(cPidHandle *Handle, int Type, bool On)
return false;
}
+void cDevice::StartSectionHandler(void)
+{
+ if (!sectionHandler) {
+ sectionHandler = new cSectionHandler(this);
+ AttachFilter(eitFilter = new cEitFilter);
+ AttachFilter(patFilter = new cPatFilter);
+ AttachFilter(sdtFilter = new cSdtFilter(patFilter));
+ sectionHandler->SetStatus(true);
+ }
+}
+
+int cDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask)
+{
+ return -1;
+}
+
+void cDevice::AttachFilter(cFilter *Filter)
+{
+ sectionHandler->Attach(Filter);
+}
+
+void cDevice::Detach(cFilter *Filter)
+{
+ sectionHandler->Detach(Filter);
+}
+
bool cDevice::ProvidesSource(int Source) const
{
return false;
}
+bool cDevice::ProvidesTransponder(const cChannel *Channel) const
+{
+ return false;
+}
+
bool cDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers) const
{
return false;
@@ -398,16 +439,28 @@ eSetChannelResult cDevice::SetChannel(const cChannel *Channel, bool LiveView)
Result = scrNotAvailable;
}
else {
+ Channels.Lock(false);
cStatus::MsgChannelSwitch(this, 0); // only report status if we are actually going to switch the channel
- if (!SetChannelDevice(Channel, LiveView))
+ // Stop section handling:
+ if (sectionHandler) {
+ sectionHandler->SetStatus(false);
+ sectionHandler->SetSource(0, 0);
+ }
+ if (SetChannelDevice(Channel, LiveView)) {
+ // Start section handling:
+ if (sectionHandler) {
+ sectionHandler->SetSource(Channel->Source(), Channel->Transponder());
+ sectionHandler->SetStatus(true);
+ }
+ }
+ else
Result = scrFailed;
+ Channels.Unlock();
}
if (Result == scrOk) {
- if (LiveView && IsPrimaryDevice()) {
- cSIProcessor::SetCurrentChannelID(Channel->GetChannelID());
+ if (LiveView && IsPrimaryDevice())
currentChannel = Channel->Number();
- }
cStatus::MsgChannelSwitch(this, Channel->Number()); // only report status if channel switch successfull
}
@@ -419,6 +472,11 @@ bool cDevice::SetChannelDevice(const cChannel *Channel, bool LiveView)
return false;
}
+bool cDevice::HasLock(void)
+{
+ return true;
+}
+
bool cDevice::HasProgramme(void)
{
return Replaying() || pidHandles[ptAudio].pid || pidHandles[ptVideo].pid;
@@ -608,6 +666,7 @@ int cDevice::Priority(void) const
int cDevice::CanShift(int Ca, int Priority, int UsedCards) const
{
return -1;//XXX+ too complex with multiple recordings per device
+ /*XXX
// Test whether a receiver on this device can be shifted to another one
// in order to perform a new receiving with the given Ca and Priority on this device:
int ShiftLevel = -1; // default means this device can't be shifted
@@ -638,25 +697,17 @@ int cDevice::CanShift(int Ca, int Priority, int UsedCards) const
else if (Priority > this->Priority())
ShiftLevel = 0; // no shifting necessary, this device can do the job
return ShiftLevel;
+ XXX*/
}
-int cDevice::ProvidesCa(int Ca) const
+int cDevice::ProvidesCa(const cChannel *Channel) const
{
+ int Ca = Channel->Ca();
if (Ca == CardIndex() + 1)
return 1; // exactly _this_ card was requested
if (Ca && Ca <= MAXDEVICES)
return 0; // a specific card was requested, but not _this_ one
- int result = Ca ? 0 : 1; // by default every card can provide FTA
- int others = Ca ? 1 : 0;
- for (int i = 0; i < MAXCACAPS; i++) {
- if (caCaps[i]) {
- if (caCaps[i] == Ca)
- result = 1;
- else
- others++;
- }
- }
- return result ? result + others : 0;
+ return !Ca; // by default every card can provide FTA
}
bool cDevice::Receiving(bool CheckAny) const
@@ -670,8 +721,6 @@ bool cDevice::Receiving(bool CheckAny) const
void cDevice::Action(void)
{
- dsyslog("receiver thread started on device %d (pid=%d)", CardIndex() + 1, getpid());
-
if (OpenDvr()) {
active = true;
for (; active;) {
@@ -694,8 +743,6 @@ void cDevice::Action(void)
}
CloseDvr();
}
-
- dsyslog("receiver thread ended on device %d (pid=%d)", CardIndex() + 1, getpid());
}
bool cDevice::OpenDvr(void)