diff options
author | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2004-01-04 18:00:00 +0100 |
---|---|---|
committer | Klaus Schmidinger <kls (at) cadsoft (dot) de> | 2004-01-04 18:00:00 +0100 |
commit | 93a94b18b540fbcb9bcdaaea9abd26cdf23d6ee6 (patch) | |
tree | bede17e6cd329d36ec02bc53dfe567b95ec835a5 /dvbdevice.c | |
parent | c432905dd60630f906ac89f58592ad835a9063ef (diff) | |
download | vdr-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 'dvbdevice.c')
-rw-r--r-- | dvbdevice.c | 140 |
1 files changed, 75 insertions, 65 deletions
diff --git a/dvbdevice.c b/dvbdevice.c index 5ae8c6f..e42ff4b 100644 --- a/dvbdevice.c +++ b/dvbdevice.c @@ -4,7 +4,7 @@ * See the main source file 'vdr.c' for copyright information and * how to reach the author. * - * $Id: dvbdevice.c 1.67.1.4 2003/11/09 11:08:22 kls Exp $ + * $Id: dvbdevice.c 1.76 2004/01/04 14:48:37 kls Exp $ */ #include "dvbdevice.h" @@ -86,7 +86,7 @@ public: virtual ~cDvbTuner(); bool IsTunedTo(const cChannel *Channel) const; void Set(const cChannel *Channel, bool Tune, bool UseCa); - bool Locked(void) { return tunerStatus == tsLocked; } + bool Locked(void) { return tunerStatus >= tsLocked; } }; cDvbTuner::cDvbTuner(int Fd_Frontend, int CardIndex, fe_type_t FrontendType, cCiHandler *CiHandler) @@ -100,6 +100,7 @@ cDvbTuner::cDvbTuner(int Fd_Frontend, int CardIndex, fe_type_t FrontendType, cCi useCa = false; tunerStatus = tsIdle; startTime = time(NULL); + SetDescription("tuner on device %d", cardIndex + 1); Start(); } @@ -113,19 +114,18 @@ cDvbTuner::~cDvbTuner() bool cDvbTuner::IsTunedTo(const cChannel *Channel) const { - return tunerStatus != tsIdle && channel.Source() == Channel->Source() && channel.Frequency() == Channel->Frequency(); + return tunerStatus != tsIdle && channel.Source() == Channel->Source() && channel.Transponder() == Channel->Transponder(); } void cDvbTuner::Set(const cChannel *Channel, bool Tune, bool UseCa) { cMutexLock MutexLock(&mutex); - bool CaChange = !(Channel->GetChannelID() == channel.GetChannelID()); if (Tune) tunerStatus = tsSet; - else if (tunerStatus == tsCam && CaChange) + else if (tunerStatus == tsCam) tunerStatus = tsTuned; useCa = UseCa; - if (Channel->Ca() && CaChange) + if (Channel->Ca() && tunerStatus != tsCam) startTime = time(NULL); channel = *Channel; newSet.Broadcast(); @@ -247,7 +247,6 @@ bool cDvbTuner::SetFrontend(void) void cDvbTuner::Action(void) { - dsyslog("tuner thread started on device %d (pid=%d)", cardIndex + 1, getpid()); active = true; while (active) { cMutexLock MutexLock(&mutex); @@ -268,41 +267,31 @@ void cDvbTuner::Action(void) continue; } } - if (tunerStatus >= tsLocked) { - if (ciHandler) { - if (ciHandler->Process() && useCa) { - if (tunerStatus != tsCam) {//XXX TODO update in case the CA descriptors have changed - for (int Slot = 0; Slot < ciHandler->NumSlots(); Slot++) { - uchar buffer[2048]; - int length = cSIProcessor::GetCaDescriptors(channel.Source(), channel.Frequency(), channel.Sid(), ciHandler->GetCaSystemIds(Slot), sizeof(buffer), buffer); - if (length > 0) { - cCiCaPmt CaPmt(channel.Sid()); - CaPmt.AddCaDescriptor(length, buffer); - if (channel.Vpid()) - CaPmt.AddPid(channel.Vpid()); - if (channel.Apid1()) - CaPmt.AddPid(channel.Apid1()); - if (channel.Apid2()) - CaPmt.AddPid(channel.Apid2()); - if (channel.Dpid1()) - CaPmt.AddPid(channel.Dpid1()); - if (ciHandler->SetCaPmt(CaPmt, Slot)) { - tunerStatus = tsCam; - startTime = 0; - } - } + } + if (ciHandler) { + if (ciHandler->Process() && useCa) { + if (tunerStatus == tsLocked) { + for (int Slot = 0; Slot < ciHandler->NumSlots(); Slot++) { + cCiCaPmt CaPmt(channel.Source(), channel.Frequency(), channel.Sid(), ciHandler->GetCaSystemIds(Slot)); + if (CaPmt.Valid()) { + CaPmt.AddPid(channel.Vpid(), 2); + CaPmt.AddPid(channel.Apid1(), 4); + CaPmt.AddPid(channel.Apid2(), 4); + CaPmt.AddPid(channel.Dpid1(), 0); + if (ciHandler->SetCaPmt(CaPmt, Slot)) { + tunerStatus = tsCam; + startTime = 0; } - } - } - else - tunerStatus = tsLocked; + } + } } } + else if (tunerStatus > tsLocked) + tunerStatus = tsLocked; } // in the beginning we loop more often to let the CAM connection start up fast newSet.TimedWait(mutex, (ciHandler && (time(NULL) - startTime < 20)) ? 100 : 1000); } - dsyslog("tuner thread ended on device %d (pid=%d)", cardIndex + 1, getpid()); } // --- cDvbDevice ------------------------------------------------------------ @@ -313,13 +302,12 @@ cDvbDevice::cDvbDevice(int n) { dvbTuner = NULL; frontendType = fe_type_t(-1); // don't know how else to initialize this - there is no FE_UNKNOWN - siProcessor = NULL; spuDecoder = NULL; playMode = pmNone; // Devices that are present on all card types: - int fd_frontend = DvbOpen(DEV_DVB_FRONTEND, n, O_RDWR | O_NONBLOCK); + int fd_frontend = DvbOpen(DEV_DVB_FRONTEND, n, O_RDWR | O_NONBLOCK); // Devices that are only present on cards with decoders: @@ -369,7 +357,6 @@ cDvbDevice::cDvbDevice(int n) if (fd_frontend >= 0) { dvb_frontend_info feinfo; - siProcessor = new cSIProcessor(DvbName(DEV_DVB_DEMUX, n)); if (ioctl(fd_frontend, FE_GET_INFO, &feinfo) >= 0) { frontendType = feinfo.type; ciHandler = cCiHandler::CreateCiHandler(DvbName(DEV_DVB_CA, n)); @@ -382,12 +369,13 @@ cDvbDevice::cDvbDevice(int n) esyslog("ERROR: can't open DVB device %d", n); aPid1 = aPid2 = 0; + + StartSectionHandler(); } cDvbDevice::~cDvbDevice() { delete spuDecoder; - delete siProcessor; delete dvbTuner; // We're not explicitly closing any device files here, since this sometimes // caused segfaults. Besides, the program is about to terminate anyway... @@ -445,6 +433,17 @@ bool cDvbDevice::HasDecoder(void) const return fd_video >= 0 && fd_audio >= 0; } +int cDvbDevice::ProvidesCa(const cChannel *Channel) const +{ + if (Channel->Ca() >= 0x0100 && ciHandler) { + unsigned short ids[MAXCAIDS + 1]; + for (int i = 0; i <= MAXCAIDS; i++) // '<=' copies the terminating 0! + ids[i] = Channel->Ca(i); + return ciHandler->ProvidesCa(ids); + } + return cDevice::ProvidesCa(Channel); +} + cOsdBase *cDvbDevice::NewOsd(int x, int y) { return new cDvbOsd(x, y); @@ -618,6 +617,30 @@ bool cDvbDevice::SetPid(cPidHandle *Handle, int Type, bool On) return true; } +int cDvbDevice::OpenFilter(u_short Pid, u_char Tid, u_char Mask) +{ + const char *FileName = DvbName(DEV_DVB_DEMUX, CardIndex()); + int f = open(FileName, O_RDWR | O_NONBLOCK); + if (f >= 0) { + dmx_sct_filter_params sctFilterParams; + memset(&sctFilterParams, 0, sizeof(sctFilterParams)); + sctFilterParams.pid = Pid; + sctFilterParams.timeout = 0; + sctFilterParams.flags = DMX_IMMEDIATE_START; + sctFilterParams.filter.filter[0] = Tid; + sctFilterParams.filter.mask[0] = Mask; + if (ioctl(f, DMX_SET_FILTER, &sctFilterParams) >= 0) + return f; + else { + esyslog("ERROR: can't set filter (pid=%d, tid=%02X, mask=%02X)", Pid, Tid, Mask); + close(f); + } + } + else + esyslog("ERROR: can't open filter handle on '%s'", FileName); + return -1; +} + void cDvbDevice::TurnOffLiveMode(void) { // Avoid noise while switching: @@ -646,13 +669,18 @@ bool cDvbDevice::ProvidesSource(int Source) const return true; } +bool cDvbDevice::ProvidesTransponder(const cChannel *Channel) const +{ + return ProvidesSource(Channel->Source()) && ((Channel->Source() & cSource::st_Mask) != cSource::stSat || Diseqcs.Get(Channel->Source(), Channel->Frequency(), Channel->Polarization())); +} + bool cDvbDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool *NeedsDetachReceivers) const { bool result = false; bool hasPriority = Priority < 0 || Priority > this->Priority(); bool needsDetachReceivers = false; - if (ProvidesSource(Channel->Source()) && ProvidesCa(Channel->Ca())) { + if ((Channel->Vpid() || Channel->Apid1()) && ProvidesSource(Channel->Source()) && ProvidesCa(Channel)) { result = hasPriority; if (Priority >= 0 && Receiving()) { if (dvbTuner->IsTunedTo(Channel)) { @@ -716,27 +744,19 @@ bool cDvbDevice::SetChannelDevice(const cChannel *Channel, bool LiveView) TurnOnLivePIDs = false; } - // Stop SI filtering: - - if (siProcessor) { - siProcessor->SetCurrentTransponder(0, 0); - siProcessor->SetStatus(false); - } - // Turn off live PIDs if necessary: if (TurnOffLivePIDs) TurnOffLiveMode(); - dvbTuner->Set(Channel, DoTune, !EITScanner.UsesDevice(this)); //XXX 1.3: this is an ugly hack - find a cleaner solution + dvbTuner->Set(Channel, DoTune, !EITScanner.UsesDevice(this)); //XXX 1.3: this is an ugly hack - find a cleaner solution//XXX // PID settings: if (TurnOnLivePIDs) { aPid1 = Channel->Apid1(); aPid2 = Channel->Apid2(); - int pPid = Channel->Ppid() ? Channel->Ppid() : Channel->Vpid(); - if (!(AddPid(pPid, ptPcr) && AddPid(Channel->Apid1(), ptAudio) && AddPid(Channel->Vpid(), ptVideo))) {//XXX+ dolby dpid1!!! (if audio plugins are attached) + if (!(AddPid(Channel->Ppid(), ptPcr) && AddPid(Channel->Apid1(), ptAudio) && AddPid(Channel->Vpid(), ptVideo))) {//XXX+ dolby dpid1!!! (if audio plugins are attached) esyslog("ERROR: failed to set PIDs for channel %d on device %d", Channel->Number(), CardIndex() + 1); return false; } @@ -747,16 +767,14 @@ bool cDvbDevice::SetChannelDevice(const cChannel *Channel, bool LiveView) else if (StartTransferMode) cControl::Launch(new cTransferControl(this, Channel->Vpid(), Channel->Apid1(), Channel->Apid2(), Channel->Dpid1(), Channel->Dpid2())); - // Start SI filtering: - - if (siProcessor) { - siProcessor->SetCurrentTransponder(Channel->Source(), Channel->Frequency()); - siProcessor->SetStatus(true); - } - return true; } +bool cDvbDevice::HasLock(void) +{ + return dvbTuner->Locked(); +} + void cDvbDevice::SetVolumeDevice(int Volume) { if (HasDecoder()) { @@ -830,16 +848,12 @@ bool cDvbDevice::SetPlayMode(ePlayMode PlayMode) CHECK(ioctl(fd_audio, AUDIO_SELECT_SOURCE, AUDIO_SOURCE_DEMUX)); CHECK(ioctl(fd_audio, AUDIO_SET_AV_SYNC, true)); CHECK(ioctl(fd_audio, AUDIO_SET_MUTE, false)); - if (siProcessor) - siProcessor->SetStatus(true); break; case pmAudioVideo: if (playMode == pmNone) TurnOffLiveMode(); // continue with next... case pmAudioOnlyBlack: - if (siProcessor) - siProcessor->SetStatus(false); CHECK(ioctl(fd_video, VIDEO_SET_BLANK, true)); CHECK(ioctl(fd_audio, AUDIO_SELECT_SOURCE, AUDIO_SOURCE_MEMORY)); CHECK(ioctl(fd_audio, AUDIO_SET_AV_SYNC, PlayMode == pmAudioVideo)); @@ -848,8 +862,6 @@ bool cDvbDevice::SetPlayMode(ePlayMode PlayMode) CHECK(ioctl(fd_video, VIDEO_PLAY)); break; case pmAudioOnly: - if (siProcessor) - siProcessor->SetStatus(false); CHECK(ioctl(fd_video, VIDEO_SET_BLANK, true)); CHECK(ioctl(fd_audio, AUDIO_STOP, true)); CHECK(ioctl(fd_audio, AUDIO_CLEAR_BUFFER)); @@ -859,8 +871,6 @@ bool cDvbDevice::SetPlayMode(ePlayMode PlayMode) CHECK(ioctl(fd_video, VIDEO_SET_BLANK, false)); break; case pmExtern_THIS_SHOULD_BE_AVOIDED: - if (siProcessor) - siProcessor->SetStatus(false); close(fd_video); close(fd_audio); fd_video = fd_audio = -1; |