diff options
Diffstat (limited to 'client')
-rw-r--r-- | client/device.c | 24 | ||||
-rw-r--r-- | client/device.h | 6 | ||||
-rw-r--r-- | client/socket.c | 36 | ||||
-rw-r--r-- | client/socket.h | 5 |
4 files changed, 59 insertions, 12 deletions
diff --git a/client/device.c b/client/device.c index 581176f..bbdaf6a 100644 --- a/client/device.c +++ b/client/device.c @@ -1,5 +1,5 @@ /* - * $Id: device.c,v 1.18.2.3 2010/06/08 05:56:15 schmirl Exp $ + * $Id: device.c,v 1.18.2.4 2010/08/18 10:26:18 schmirl Exp $ */ #include "client/device.h" @@ -8,6 +8,7 @@ #include "tools/select.h" +#include <vdr/config.h> #include <vdr/channels.h> #include <vdr/ringbuffer.h> #include <vdr/eit.h> @@ -32,6 +33,7 @@ cStreamdevDevice::cStreamdevDevice(void) { m_Device = this; m_Pids = 0; + m_Priority = -1; m_DvrClosed = true; } @@ -108,7 +110,7 @@ bool cStreamdevDevice::ProvidesChannel(const cChannel *Channel, int Priority, res = prio && ClientSocket.ProvidesChannel(Channel, Priority); ndr = true; } - + if (NeedsDetachReceivers) *NeedsDetachReceivers = ndr; Dprintf("prov res = %d, ndr = %d\n", res, ndr); @@ -119,6 +121,9 @@ bool cStreamdevDevice::SetChannelDevice(const cChannel *Channel, bool LiveView) { Dprintf("SetChannelDevice Channel: %s, LiveView: %s\n", Channel->Name(), LiveView ? "true" : "false"); + LOCK_THREAD; + + m_UpdatePriority = ClientSocket.SupportsPrio(); if (LiveView) return false; @@ -139,6 +144,8 @@ bool cStreamdevDevice::SetPid(cPidHandle *Handle, int Type, bool On) { Handle->used); LOCK_THREAD; + m_UpdatePriority = ClientSocket.SupportsPrio(); + if (On && !m_TSBuffer) { Dprintf("SetPid: no data connection -> OpenDvr()"); OpenDvrInt(); @@ -305,3 +312,16 @@ bool cStreamdevDevice::ReInit(void) { return StreamdevClientSetup.StartClient ? Init() : true; } +void cStreamdevDevice::UpdatePriority(void) { + if (m_Device) { + m_Device->Lock(); + if (m_Device->m_UpdatePriority && ClientSocket.DataSocket(siLive)) { + int Priority = m_Device->Priority(); + if (m_Device == cDevice::ActualDevice() && Priority < Setup.PrimaryLimit) + Priority = Setup.PrimaryLimit; + if (m_Device->m_Priority != Priority && ClientSocket.SetPriority(Priority)) + m_Device->m_Priority = Priority; + } + m_Device->Unlock(); + } +} diff --git a/client/device.h b/client/device.h index ada66de..909e015 100644 --- a/client/device.h +++ b/client/device.h @@ -1,5 +1,5 @@ /* - * $Id: device.h,v 1.7.2.1 2008/04/07 15:07:39 schmirl Exp $ + * $Id: device.h,v 1.7.2.2 2010/08/18 10:26:18 schmirl Exp $ */ #ifndef VDR_STREAMDEV_DEVICE_H @@ -15,13 +15,14 @@ class cTBString; #define CMD_LOCK_OBJ(x) cMutexLock CmdLock((cMutex*)&(x)->m_Mutex) class cStreamdevDevice: public cDevice { - friend class cRemoteRecordings; private: const cChannel *m_Channel; cTSBuffer *m_TSBuffer; cStreamdevFilters *m_Filters; int m_Pids; + int m_Priority; + bool m_UpdatePriority; bool m_DvrClosed; static cStreamdevDevice *m_Device; @@ -56,6 +57,7 @@ public: bool *NeedsDetachReceivers = NULL) const; virtual bool IsTunedToTransponder(const cChannel *Channel); + static void UpdatePriority(void); static bool Init(void); static bool ReInit(void); diff --git a/client/socket.c b/client/socket.c index e766f7c..f2b5eea 100644 --- a/client/socket.c +++ b/client/socket.c @@ -1,5 +1,5 @@ /* - * $Id: socket.c,v 1.11.2.1 2010/06/08 05:56:15 schmirl Exp $ + * $Id: socket.c,v 1.11.2.3 2010/08/18 10:26:18 schmirl Exp $ */ #include <tools/select.h> @@ -21,6 +21,7 @@ cClientSocket ClientSocket; cClientSocket::cClientSocket(void) { memset(m_DataSockets, 0, sizeof(cTBSocket*) * si_Count); + m_Prio = false; Reset(); } @@ -143,8 +144,14 @@ bool cClientSocket::CheckConnection(void) { if(Command("CAPS FILTERS", 220)) Filters = ",FILTERS"; - isyslog("Streamdev: Connected to server %s:%d using capabilities TSPIDS%s", - RemoteIp().c_str(), RemotePort(), Filters); + const char *Prio = ""; + if(Command("CAPS PRIO", 220)) { + Prio = ",PRIO"; + m_Prio = true; + } + + isyslog("Streamdev: Connected to server %s:%d using capabilities TSPIDS%s%s", + RemoteIp().c_str(), RemotePort(), Filters, Prio); return true; } @@ -242,7 +249,7 @@ bool cClientSocket::SetChannelDevice(const cChannel *Channel) { CMD_LOCK; std::string command = (std::string)"TUNE " - + (const char*)Channel->GetChannelID().ToString(); + + (const char*)Channel->GetChannelID().ToString(); if (!Command(command, 220)) { if (errno == 0) esyslog("ERROR: Streamdev: Couldn't tune %s:%d to channel %s", @@ -252,6 +259,21 @@ bool cClientSocket::SetChannelDevice(const cChannel *Channel) { return true; } +bool cClientSocket::SetPriority(int Priority) { + if (!CheckConnection()) return false; + + CMD_LOCK; + + std::string command = (std::string)"PRIO " + (const char*)itoa(Priority); + if (!Command(command, 220)) { + if (errno == 0) + esyslog("Streamdev: Failed to update priority on %s:%d", RemoteIp().c_str(), + RemotePort()); + return false; + } + return true; +} + bool cClientSocket::SetPid(int Pid, bool On) { if (!CheckConnection()) return false; @@ -260,8 +282,8 @@ bool cClientSocket::SetPid(int Pid, bool On) { std::string command = (std::string)(On ? "ADDP " : "DELP ") + (const char*)itoa(Pid); if (!Command(command, 220)) { if (errno == 0) - esyslog("Streamdev: Pid %d not available from %s:%d", Pid, LocalIp().c_str(), - LocalPort()); + esyslog("Streamdev: Pid %d not available from %s:%d", Pid, RemoteIp().c_str(), + RemotePort()); return false; } return true; @@ -277,7 +299,7 @@ bool cClientSocket::SetFilter(ushort Pid, uchar Tid, uchar Mask, bool On) { if (!Command(command, 220)) { if (errno == 0) esyslog("Streamdev: Filter %hu, %hhu, %hhu not available from %s:%d", - Pid, Tid, Mask, LocalIp().c_str(), LocalPort()); + Pid, Tid, Mask, RemoteIp().c_str(), RemotePort()); return false; } return true; diff --git a/client/socket.h b/client/socket.h index 3b86304..1608bb4 100644 --- a/client/socket.h +++ b/client/socket.h @@ -1,5 +1,5 @@ /* - * $Id: socket.h,v 1.6.2.1 2010/06/08 05:56:15 schmirl Exp $ + * $Id: socket.h,v 1.6.2.2 2010/08/18 10:26:18 schmirl Exp $ */ #ifndef VDR_STREAMDEV_CLIENT_CONNECTION_H @@ -20,6 +20,7 @@ private: cTBSocket *m_DataSockets[si_Count]; cMutex m_Mutex; char m_Buffer[BUFSIZ + 1]; // various uses + bool m_Prio; // server supports command PRIO protected: /* Send Command, and return true if the command results in Expected. @@ -45,6 +46,8 @@ public: bool CreateDataConnection(eSocketId Id); bool CloseDataConnection(eSocketId Id); bool SetChannelDevice(const cChannel *Channel); + bool SupportsPrio() { return m_Prio; } + bool SetPriority(int Priority); bool SetPid(int Pid, bool On); bool SetFilter(ushort Pid, uchar Tid, uchar Mask, bool On); bool CloseDvr(void); |