mirror of
https://projects.vdr-developer.org/git/vdr-plugin-streamdev.git
synced 2023-10-10 19:16:51 +02:00
Added streamdev-client support for upcoming streamdev-server versions
with purely priority driven precedence.
This commit is contained in:
parent
a1797719de
commit
2e8aefd2fe
2
HISTORY
2
HISTORY
@ -1,6 +1,8 @@
|
|||||||
VDR Plugin 'streamdev' Revision History
|
VDR Plugin 'streamdev' Revision History
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
|
- Added streamdev-client support for upcoming streamdev-server versions
|
||||||
|
with purely priority driven precedence.
|
||||||
- API change of VDR 1.7.26: "avoid device" is no longer available
|
- API change of VDR 1.7.26: "avoid device" is no longer available
|
||||||
- Fixed ProvidesChannel() on client always returning true since the new timeout
|
- Fixed ProvidesChannel() on client always returning true since the new timeout
|
||||||
option has been added.
|
option has been added.
|
||||||
|
@ -19,6 +19,14 @@
|
|||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
#ifndef LIVEPRIORITY
|
||||||
|
#define LIVEPRIORITY 0
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifndef TRANSFERPRIORITY
|
||||||
|
#define TRANSFERPRIORITY -1
|
||||||
|
#endif
|
||||||
|
|
||||||
#define VIDEOBUFSIZE MEGABYTE(3)
|
#define VIDEOBUFSIZE MEGABYTE(3)
|
||||||
|
|
||||||
cStreamdevDevice *cStreamdevDevice::m_Device = NULL;
|
cStreamdevDevice *cStreamdevDevice::m_Device = NULL;
|
||||||
@ -89,7 +97,11 @@ bool cStreamdevDevice::IsTunedToTransponder(const cChannel *Channel)
|
|||||||
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;
|
bool res = false;
|
||||||
|
#if APIVERSNUM >= 10725
|
||||||
|
bool prio = Priority == IDLEPRIORITY || Priority >= this->Priority();
|
||||||
|
#else
|
||||||
bool prio = Priority < 0 || Priority > this->Priority();
|
bool prio = Priority < 0 || Priority > this->Priority();
|
||||||
|
#endif
|
||||||
bool ndr = false;
|
bool ndr = false;
|
||||||
|
|
||||||
if (!StreamdevClientSetup.StartClient || Channel == m_DenyChannel)
|
if (!StreamdevClientSetup.StartClient || Channel == m_DenyChannel)
|
||||||
@ -114,7 +126,24 @@ bool cStreamdevDevice::ProvidesChannel(const cChannel *Channel, int Priority,
|
|||||||
&& TRANSPONDER(Channel, m_Channel))
|
&& TRANSPONDER(Channel, m_Channel))
|
||||||
res = true;
|
res = true;
|
||||||
else {
|
else {
|
||||||
|
if (Priority == LIVEPRIORITY)
|
||||||
|
{
|
||||||
|
if (ClientSocket.ServerVersion() >= 100)
|
||||||
|
{
|
||||||
|
Priority = StreamdevClientSetup.LivePriority;
|
||||||
|
UpdatePriority(true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (StreamdevClientSetup.LivePriority >= 0)
|
||||||
|
Priority = StreamdevClientSetup.LivePriority;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
res = prio && ClientSocket.ProvidesChannel(Channel, Priority);
|
res = prio && ClientSocket.ProvidesChannel(Channel, Priority);
|
||||||
|
|
||||||
|
if (ClientSocket.ServerVersion() >= 100)
|
||||||
|
UpdatePriority(false);
|
||||||
ndr = true;
|
ndr = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,14 +345,21 @@ bool cStreamdevDevice::ReInit(void) {
|
|||||||
return StreamdevClientSetup.StartClient ? Init() : true;
|
return StreamdevClientSetup.StartClient ? Init() : true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cStreamdevDevice::UpdatePriority(void) {
|
void cStreamdevDevice::UpdatePriority(bool SwitchingChannels) {
|
||||||
if (m_Device) {
|
if (m_Device) {
|
||||||
m_Device->Lock();
|
m_Device->Lock();
|
||||||
if (m_Device->m_UpdatePriority && ClientSocket.DataSocket(siLive)) {
|
if (m_Device->m_UpdatePriority && ClientSocket.DataSocket(siLive)) {
|
||||||
int Priority = m_Device->Priority();
|
int Priority = m_Device->Priority();
|
||||||
// override TRANSFERPRIORITY (-1) with live TV priority from setup
|
// override TRANSFERPRIORITY (-1) with live TV priority from setup
|
||||||
if (m_Device == cDevice::ActualDevice() && Priority == -1)
|
if (m_Device == cDevice::ActualDevice() && Priority == TRANSFERPRIORITY) {
|
||||||
Priority = StreamdevClientSetup.LivePriority;
|
Priority = StreamdevClientSetup.LivePriority;
|
||||||
|
// temporarily lower priority
|
||||||
|
if (SwitchingChannels)
|
||||||
|
Priority--;
|
||||||
|
if (Priority < 0 && ClientSocket.ServerVersion() < 100)
|
||||||
|
Priority = 0;
|
||||||
|
|
||||||
|
}
|
||||||
if (m_Device->m_Priority != Priority && ClientSocket.SetPriority(Priority))
|
if (m_Device->m_Priority != Priority && ClientSocket.SetPriority(Priority))
|
||||||
m_Device->m_Priority = Priority;
|
m_Device->m_Priority = Priority;
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public:
|
|||||||
virtual int SignalStrength(void) const;
|
virtual int SignalStrength(void) const;
|
||||||
virtual int SignalQuality(void) const;
|
virtual int SignalQuality(void) const;
|
||||||
|
|
||||||
static void UpdatePriority(void);
|
static void UpdatePriority(bool SwitchingChannels = false);
|
||||||
static void DenyChannel(const cChannel *Channel) { m_DenyChannel = Channel; }
|
static void DenyChannel(const cChannel *Channel) { m_DenyChannel = Channel; }
|
||||||
static bool Init(void);
|
static bool Init(void);
|
||||||
static bool ReInit(void);
|
static bool ReInit(void);
|
||||||
|
@ -7,6 +7,10 @@
|
|||||||
#include "client/setup.h"
|
#include "client/setup.h"
|
||||||
#include "client/device.h"
|
#include "client/device.h"
|
||||||
|
|
||||||
|
#ifndef MINPRIORITY
|
||||||
|
#define MINPRIORITY -MAXPRIORITY
|
||||||
|
#endif
|
||||||
|
|
||||||
cStreamdevClientSetup StreamdevClientSetup;
|
cStreamdevClientSetup StreamdevClientSetup;
|
||||||
|
|
||||||
cStreamdevClientSetup::cStreamdevClientSetup(void) {
|
cStreamdevClientSetup::cStreamdevClientSetup(void) {
|
||||||
@ -16,7 +20,7 @@ cStreamdevClientSetup::cStreamdevClientSetup(void) {
|
|||||||
StreamFilters = false;
|
StreamFilters = false;
|
||||||
HideMenuEntry = false;
|
HideMenuEntry = false;
|
||||||
LivePriority = 0;
|
LivePriority = 0;
|
||||||
MinPriority = -MAXPRIORITY;
|
MinPriority = MINPRIORITY;
|
||||||
MaxPriority = MAXPRIORITY;
|
MaxPriority = MAXPRIORITY;
|
||||||
#if APIVERSNUM >= 10700
|
#if APIVERSNUM >= 10700
|
||||||
NumProvidedSystems = 1;
|
NumProvidedSystems = 1;
|
||||||
@ -55,9 +59,9 @@ cStreamdevClientMenuSetupPage::cStreamdevClientMenuSetupPage(void) {
|
|||||||
Add(new cMenuEditIntItem (tr("Remote Port"), &m_NewSetup.RemotePort, 0, 65535));
|
Add(new cMenuEditIntItem (tr("Remote Port"), &m_NewSetup.RemotePort, 0, 65535));
|
||||||
Add(new cMenuEditIntItem (tr("Timeout (s)"), &m_NewSetup.Timeout, 1, 15));
|
Add(new cMenuEditIntItem (tr("Timeout (s)"), &m_NewSetup.Timeout, 1, 15));
|
||||||
Add(new cMenuEditBoolItem(tr("Filter Streaming"), &m_NewSetup.StreamFilters));
|
Add(new cMenuEditBoolItem(tr("Filter Streaming"), &m_NewSetup.StreamFilters));
|
||||||
Add(new cMenuEditIntItem (tr("Live TV Priority"), &m_NewSetup.LivePriority, 0, MAXPRIORITY));
|
Add(new cMenuEditIntItem (tr("Live TV Priority"), &m_NewSetup.LivePriority, MINPRIORITY, MAXPRIORITY));
|
||||||
Add(new cMenuEditIntItem (tr("Minimum Priority"), &m_NewSetup.MinPriority, -MAXPRIORITY, MAXPRIORITY));
|
Add(new cMenuEditIntItem (tr("Minimum Priority"), &m_NewSetup.MinPriority, MINPRIORITY, MAXPRIORITY));
|
||||||
Add(new cMenuEditIntItem (tr("Maximum Priority"), &m_NewSetup.MaxPriority, -MAXPRIORITY, MAXPRIORITY));
|
Add(new cMenuEditIntItem (tr("Maximum Priority"), &m_NewSetup.MaxPriority, MINPRIORITY, MAXPRIORITY));
|
||||||
#if APIVERSNUM >= 10715
|
#if APIVERSNUM >= 10715
|
||||||
Add(new cMenuEditIntItem (tr("Broadcast Systems / Cost"), &m_NewSetup.NumProvidedSystems, 1, 15));
|
Add(new cMenuEditIntItem (tr("Broadcast Systems / Cost"), &m_NewSetup.NumProvidedSystems, 1, 15));
|
||||||
#elif APIVERSNUM >= 10700
|
#elif APIVERSNUM >= 10700
|
||||||
|
@ -23,6 +23,7 @@ cClientSocket ClientSocket;
|
|||||||
cClientSocket::cClientSocket(void)
|
cClientSocket::cClientSocket(void)
|
||||||
{
|
{
|
||||||
memset(m_DataSockets, 0, sizeof(cTBSocket*) * si_Count);
|
memset(m_DataSockets, 0, sizeof(cTBSocket*) * si_Count);
|
||||||
|
m_ServerVersion = 0;
|
||||||
m_Prio = false;
|
m_Prio = false;
|
||||||
m_Abort = false;
|
m_Abort = false;
|
||||||
m_LastSignalUpdate = 0;
|
m_LastSignalUpdate = 0;
|
||||||
@ -153,23 +154,38 @@ bool cClientSocket::CheckConnection(void) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!Command("CAPS TSPIDS", 220)) {
|
unsigned int major, minor;
|
||||||
Close();
|
if (sscanf(buffer.c_str(), "%*u VTP/%u.%u", &major, &minor) == 2)
|
||||||
return false;
|
m_ServerVersion = major * 100 + minor;
|
||||||
|
|
||||||
|
if (m_ServerVersion == 0) {
|
||||||
|
if (!Command("CAPS TSPIDS", 220)) {
|
||||||
|
Close();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const char *Filters = "";
|
||||||
|
if(Command("CAPS FILTERS", 220))
|
||||||
|
Filters = ",FILTERS";
|
||||||
|
|
||||||
|
const char *Prio = "";
|
||||||
|
if(Command("CAPS PRIO", 220)) {
|
||||||
|
Prio = ",PRIO";
|
||||||
|
m_Prio = true;
|
||||||
|
}
|
||||||
|
isyslog("streamdev-client: Connected to server %s:%d using capabilities TSPIDS%s%s",
|
||||||
|
RemoteIp().c_str(), RemotePort(), Filters, Prio);
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
const char *Filters = "";
|
if(!Command("VERS 1.0", 220)) {
|
||||||
if(Command("CAPS FILTERS", 220))
|
Close();
|
||||||
Filters = ",FILTERS";
|
return false;
|
||||||
|
}
|
||||||
const char *Prio = "";
|
|
||||||
if(Command("CAPS PRIO", 220)) {
|
|
||||||
Prio = ",PRIO";
|
|
||||||
m_Prio = true;
|
m_Prio = true;
|
||||||
|
isyslog("streamdev-client: Connected to server %s:%d using protocol version %u.%u",
|
||||||
|
RemoteIp().c_str(), RemotePort(), major, minor);
|
||||||
}
|
}
|
||||||
|
|
||||||
isyslog("streamdev-client: Connected to server %s:%d using capabilities TSPIDS%s%s",
|
|
||||||
RemoteIp().c_str(), RemotePort(), Filters, Prio);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ private:
|
|||||||
cTBSocket *m_DataSockets[si_Count];
|
cTBSocket *m_DataSockets[si_Count];
|
||||||
cMutex m_Mutex;
|
cMutex m_Mutex;
|
||||||
char m_Buffer[BUFSIZ + 1]; // various uses
|
char m_Buffer[BUFSIZ + 1]; // various uses
|
||||||
|
unsigned int m_ServerVersion;
|
||||||
bool m_Prio; // server supports command PRIO
|
bool m_Prio; // server supports command PRIO
|
||||||
bool m_Abort; // quit command pending
|
bool m_Abort; // quit command pending
|
||||||
|
|
||||||
@ -52,6 +53,7 @@ public:
|
|||||||
bool CloseDataConnection(eSocketId Id);
|
bool CloseDataConnection(eSocketId Id);
|
||||||
bool SetChannelDevice(const cChannel *Channel);
|
bool SetChannelDevice(const cChannel *Channel);
|
||||||
bool SupportsPrio() { return m_Prio; }
|
bool SupportsPrio() { return m_Prio; }
|
||||||
|
unsigned int ServerVersion() { return m_ServerVersion; }
|
||||||
bool SetPriority(int Priority);
|
bool SetPriority(int Priority);
|
||||||
bool SetPid(int Pid, bool On);
|
bool SetPid(int Pid, bool On);
|
||||||
bool SetFilter(ushort Pid, uchar Tid, uchar Mask, bool On);
|
bool SetFilter(ushort Pid, uchar Tid, uchar Mask, bool On);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user