summaryrefslogtreecommitdiff
path: root/server/connection.c
diff options
context:
space:
mode:
Diffstat (limited to 'server/connection.c')
-rw-r--r--server/connection.c72
1 files changed, 1 insertions, 71 deletions
diff --git a/server/connection.c b/server/connection.c
index 1cd1d21..764ca02 100644
--- a/server/connection.c
+++ b/server/connection.c
@@ -9,17 +9,10 @@
#include <vdr/tools.h>
#include <vdr/thread.h>
-#include <vdr/transfer.h>
#include <string.h>
#include <stdarg.h>
#include <errno.h>
-// device occupied timeout to prevent VDR main loop to immediately switch back
-// when streamdev switched the live TV channel.
-// Note that there is still a gap between the GetDevice() and SetOccupied()
-// calls where the VDR main loop could strike
-#define STREAMDEVTUNETIMEOUT 5
-
cServerConnection::cServerConnection(const char *Protocol, int Type):
cTBSocket(Type),
m_Protocol(Protocol),
@@ -28,9 +21,7 @@ cServerConnection::cServerConnection(const char *Protocol, int Type):
m_ReadBytes(0),
m_WriteBytes(0),
m_WriteIndex(0),
- m_Streamer(NULL),
- m_OccupiedDev(NULL),
- m_SwitchTo(NULL)
+ m_Streamer(NULL)
{
}
@@ -206,66 +197,5 @@ bool cServerConnection::Close()
return cTBSocket::Close();
}
-bool cServerConnection::UsedByLiveTV(cDevice *device)
-{
- return device == cTransferControl::ReceiverDevice() ||
- (device->IsPrimaryDevice() && device->HasDecoder() && !device->Replaying());
-}
-
-cDevice *cServerConnection::SwitchDevice(const cChannel *Channel, int Priority)
-{
- // turn off the streams of this connection
- Detach();
-
- cDevice *device = cDevice::GetDevice(Channel, Priority, false);
- if (!device) {
- // can't switch - continue the current stream
- Attach();
- dsyslog("streamdev: GetDevice failed for channel %d (%s) at priority %d (PrimaryDevice=%d, ActualDevice=%d)", Channel->Number(), Channel->Name(), Priority, cDevice::PrimaryDevice()->CardIndex(), cDevice::ActualDevice()->CardIndex());
- }
- else if (!device->IsTunedToTransponder(Channel) && UsedByLiveTV(device)) {
- // make sure VDR main loop doesn't switch back
- device->SetOccupied(STREAMDEVTUNETIMEOUT);
- if (device->SwitchChannel(Channel, false)) {
- // switched away live TV
- m_OccupiedDev = device;
- m_SwitchTo = Channel;
- }
- else {
- dsyslog("streamdev: SwitchChannel (live) failed for channel %d (%s) at priority %d (PrimaryDevice=%d, ActualDevice=%d, device=%d)", Channel->Number(), Channel->Name(), Priority, cDevice::PrimaryDevice()->CardIndex(), cDevice::ActualDevice()->CardIndex(), device->CardIndex());
- device->SetOccupied(0);
- device = NULL;
- }
- }
- else if (!device->SwitchChannel(Channel, false)) {
- dsyslog("streamdev: SwitchChannel failed for channel %d (%s) at priority %d (PrimaryDevice=%d, ActualDevice=%d, device=%d)", Channel->Number(), Channel->Name(), Priority, cDevice::PrimaryDevice()->CardIndex(), cDevice::ActualDevice()->CardIndex(), device->CardIndex());
- device = NULL;
- }
- return device;
-}
-
-bool cServerConnection::ProvidesChannel(const cChannel *Channel, int Priority)
-{
- cDevice *device = cDevice::GetDevice(Channel, Priority, false, true);
- if (!device)
- dsyslog("streamdev: No device provides channel %d (%s) at priority %d", Channel->Number(), Channel->Name(), Priority);
- return device;
-}
-
-void cServerConnection::MainThreadHook()
-{
- if (m_SwitchTo)
- {
- // switched away live TV. Try previous channel on other device first
- if (!Channels.SwitchTo(cDevice::CurrentChannel())) {
- // switch to streamdev channel otherwise
- Channels.SwitchTo(m_SwitchTo->Number());
- Skins.Message(mtInfo, tr("Streaming active"));
- }
- m_OccupiedDev->SetOccupied(0);
- m_SwitchTo = NULL;
- }
-}
-
cString cServerConnection::ToText() const
{ return cString::sprintf("%s\t%s:%d", Protocol(), RemoteIp().c_str(), RemotePort()); }