Reimplemented some client device methods

This commit is contained in:
Frank Schmirler 2012-05-29 01:25:47 +02:00
parent 16f8c75918
commit 744dc6792c
3 changed files with 37 additions and 37 deletions

View File

@ -1,6 +1,7 @@
VDR Plugin 'streamdev' Revision History VDR Plugin 'streamdev' Revision History
--------------------------------------- ---------------------------------------
- Reimplemented some client device methods
- Proper fix for "client sends ABRT after TUNE". Obsoletes many hacks in client - Proper fix for "client sends ABRT after TUNE". Obsoletes many hacks in client
- Added CLOCK_MONOTONIC timestamp and thread id to Dprintf - Added CLOCK_MONOTONIC timestamp and thread id to Dprintf
- Silenced warning (thanks to Rolf Ahrenberg) - Silenced warning (thanks to Rolf Ahrenberg)

View File

@ -84,23 +84,19 @@ bool cStreamdevDevice::IsTunedToTransponder(const cChannel *Channel) const
bool cStreamdevDevice::IsTunedToTransponder(const cChannel *Channel) bool cStreamdevDevice::IsTunedToTransponder(const cChannel *Channel)
#endif #endif
{ {
bool res = false; return ClientSocket.DataSocket(siLive) != NULL &&
if (ClientSocket.DataSocket(siLive) != NULL m_Channel != NULL &&
&& TRANSPONDER(Channel, m_Channel) Channel->Transponder() == m_Channel->Transponder();
&& Channel->Ca() == CA_FTA
&& m_Channel->Ca() == CA_FTA)
res = true;
return res;
} }
bool cStreamdevDevice::ProvidesChannel(const cChannel *Channel, int Priority, bool cStreamdevDevice::ProvidesChannel(const cChannel *Channel, int Priority,
bool *NeedsDetachReceivers) const { bool *NeedsDetachReceivers) const {
bool res = false;
#if APIVERSNUM >= 10725 #if APIVERSNUM >= 10725
bool prio = Priority == IDLEPRIORITY || Priority >= this->Priority(); bool prio = Priority == IDLEPRIORITY || Priority >= this->Priority();
#else #else
bool prio = Priority < 0 || Priority > this->Priority(); bool prio = Priority < 0 || Priority > this->Priority();
#endif #endif
bool res = prio;
bool ndr = false; bool ndr = false;
if (!StreamdevClientSetup.StartClient || Channel == m_DenyChannel) if (!StreamdevClientSetup.StartClient || Channel == m_DenyChannel)
@ -121,29 +117,31 @@ bool cStreamdevDevice::ProvidesChannel(const cChannel *Channel, int Priority,
return false; return false;
} }
if (ClientSocket.DataSocket(siLive) != NULL if (IsTunedToTransponder(Channel)) {
&& TRANSPONDER(Channel, m_Channel)) if (Channel->Ca() < CA_ENCRYPTED_MIN ||
res = true; (Channel->Vpid() && HasPid(Channel->Vpid())) ||
else { (Channel->Apid(0) && HasPid(Channel->Apid(0))))
if (Priority == LIVEPRIORITY) res = true;
{ else
if (ClientSocket.ServerVersion() >= 100) ndr = true;
{ }
else if (prio) {
if (Priority == LIVEPRIORITY) {
if (ClientSocket.ServerVersion() >= 100) {
Priority = StreamdevClientSetup.LivePriority; Priority = StreamdevClientSetup.LivePriority;
UpdatePriority(true); UpdatePriority(true);
} }
else else {
{
if (StreamdevClientSetup.LivePriority >= 0) if (StreamdevClientSetup.LivePriority >= 0)
Priority = StreamdevClientSetup.LivePriority; Priority = StreamdevClientSetup.LivePriority;
} }
} }
res = prio && ClientSocket.ProvidesChannel(Channel, Priority); res = ClientSocket.ProvidesChannel(Channel, Priority);
ndr = Receiving();
if (ClientSocket.ServerVersion() >= 100) if (ClientSocket.ServerVersion() >= 100)
UpdatePriority(false); UpdatePriority(false);
ndr = true;
} }
if (NeedsDetachReceivers) if (NeedsDetachReceivers)
@ -154,6 +152,7 @@ bool cStreamdevDevice::ProvidesChannel(const cChannel *Channel, int Priority,
bool cStreamdevDevice::SetChannelDevice(const cChannel *Channel, bool cStreamdevDevice::SetChannelDevice(const cChannel *Channel,
bool LiveView) { bool LiveView) {
bool res;
Dprintf("SetChannelDevice Channel: %s, LiveView: %s\n", Channel->Name(), Dprintf("SetChannelDevice Channel: %s, LiveView: %s\n", Channel->Name(),
LiveView ? "true" : "false"); LiveView ? "true" : "false");
LOCK_THREAD; LOCK_THREAD;
@ -161,17 +160,23 @@ bool cStreamdevDevice::SetChannelDevice(const cChannel *Channel,
if (LiveView) if (LiveView)
return false; return false;
if (ClientSocket.DataSocket(siLive) != NULL if (Receiving() && IsTunedToTransponder(Channel) && (
&& TRANSPONDER(Channel, m_Channel) Channel->Ca() < CA_ENCRYPTED_MIN ||
&& Channel->Ca() == CA_FTA (Channel->Vpid() && HasPid(Channel->Vpid())) ||
&& m_Channel->Ca() == CA_FTA) (Channel->Apid(0) && HasPid(Channel->Apid(0))))) {
return true; res = true;
}
DetachAllReceivers(); else {
m_Channel = Channel; DetachAllReceivers();
bool r = ClientSocket.SetChannelDevice(m_Channel); m_Channel = Channel;
Dprintf("setchanneldevice r=%d\n", r); // Old servers delete cStreamdevLiveStreamer in ABRT.
return r; // Delete it now or it will happen after we tuned to new channel
if (ClientSocket.ServerVersion() < 100)
CloseDvr();
res = ClientSocket.SetChannelDevice(m_Channel);
}
Dprintf("setchanneldevice res=%d\n", res);
return res;
} }
bool cStreamdevDevice::SetPid(cPidHandle *Handle, int Type, bool On) { bool cStreamdevDevice::SetPid(cPidHandle *Handle, int Type, bool On) {

View File

@ -29,12 +29,6 @@
#define Dprintf(x...) #define Dprintf(x...)
#endif #endif
#if APIVERSNUM >= 10714
#define TRANSPONDER(c1, c2) (c1->Transponder() == c2->Transponder() && !c1->IsSourceType('V'))
#else
#define TRANSPONDER(c1, c2) (c1->Transponder() == c2->Transponder())
#endif
#define MAXPARSEBUFFER KILOBYTE(16) #define MAXPARSEBUFFER KILOBYTE(16)
/* Service ID for loop prevention */ /* Service ID for loop prevention */