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
|
||||
---------------------------------------
|
||||
|
||||
- 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
|
||||
- Fixed ProvidesChannel() on client always returning true since the new timeout
|
||||
option has been added.
|
||||
|
@ -19,6 +19,14 @@
|
||||
|
||||
using namespace std;
|
||||
|
||||
#ifndef LIVEPRIORITY
|
||||
#define LIVEPRIORITY 0
|
||||
#endif
|
||||
|
||||
#ifndef TRANSFERPRIORITY
|
||||
#define TRANSFERPRIORITY -1
|
||||
#endif
|
||||
|
||||
#define VIDEOBUFSIZE MEGABYTE(3)
|
||||
|
||||
cStreamdevDevice *cStreamdevDevice::m_Device = NULL;
|
||||
@ -89,7 +97,11 @@ bool cStreamdevDevice::IsTunedToTransponder(const cChannel *Channel)
|
||||
bool cStreamdevDevice::ProvidesChannel(const cChannel *Channel, int Priority,
|
||||
bool *NeedsDetachReceivers) const {
|
||||
bool res = false;
|
||||
#if APIVERSNUM >= 10725
|
||||
bool prio = Priority == IDLEPRIORITY || Priority >= this->Priority();
|
||||
#else
|
||||
bool prio = Priority < 0 || Priority > this->Priority();
|
||||
#endif
|
||||
bool ndr = false;
|
||||
|
||||
if (!StreamdevClientSetup.StartClient || Channel == m_DenyChannel)
|
||||
@ -114,7 +126,24 @@ bool cStreamdevDevice::ProvidesChannel(const cChannel *Channel, int Priority,
|
||||
&& TRANSPONDER(Channel, m_Channel))
|
||||
res = true;
|
||||
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);
|
||||
|
||||
if (ClientSocket.ServerVersion() >= 100)
|
||||
UpdatePriority(false);
|
||||
ndr = true;
|
||||
}
|
||||
|
||||
@ -316,14 +345,21 @@ bool cStreamdevDevice::ReInit(void) {
|
||||
return StreamdevClientSetup.StartClient ? Init() : true;
|
||||
}
|
||||
|
||||
void cStreamdevDevice::UpdatePriority(void) {
|
||||
void cStreamdevDevice::UpdatePriority(bool SwitchingChannels) {
|
||||
if (m_Device) {
|
||||
m_Device->Lock();
|
||||
if (m_Device->m_UpdatePriority && ClientSocket.DataSocket(siLive)) {
|
||||
int Priority = m_Device->Priority();
|
||||
// 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;
|
||||
// temporarily lower priority
|
||||
if (SwitchingChannels)
|
||||
Priority--;
|
||||
if (Priority < 0 && ClientSocket.ServerVersion() < 100)
|
||||
Priority = 0;
|
||||
|
||||
}
|
||||
if (m_Device->m_Priority != Priority && ClientSocket.SetPriority(Priority))
|
||||
m_Device->m_Priority = Priority;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ public:
|
||||
virtual int SignalStrength(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 bool Init(void);
|
||||
static bool ReInit(void);
|
||||
|
@ -7,6 +7,10 @@
|
||||
#include "client/setup.h"
|
||||
#include "client/device.h"
|
||||
|
||||
#ifndef MINPRIORITY
|
||||
#define MINPRIORITY -MAXPRIORITY
|
||||
#endif
|
||||
|
||||
cStreamdevClientSetup StreamdevClientSetup;
|
||||
|
||||
cStreamdevClientSetup::cStreamdevClientSetup(void) {
|
||||
@ -16,7 +20,7 @@ cStreamdevClientSetup::cStreamdevClientSetup(void) {
|
||||
StreamFilters = false;
|
||||
HideMenuEntry = false;
|
||||
LivePriority = 0;
|
||||
MinPriority = -MAXPRIORITY;
|
||||
MinPriority = MINPRIORITY;
|
||||
MaxPriority = MAXPRIORITY;
|
||||
#if APIVERSNUM >= 10700
|
||||
NumProvidedSystems = 1;
|
||||
@ -55,9 +59,9 @@ cStreamdevClientMenuSetupPage::cStreamdevClientMenuSetupPage(void) {
|
||||
Add(new cMenuEditIntItem (tr("Remote Port"), &m_NewSetup.RemotePort, 0, 65535));
|
||||
Add(new cMenuEditIntItem (tr("Timeout (s)"), &m_NewSetup.Timeout, 1, 15));
|
||||
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("Minimum Priority"), &m_NewSetup.MinPriority, -MAXPRIORITY, MAXPRIORITY));
|
||||
Add(new cMenuEditIntItem (tr("Maximum Priority"), &m_NewSetup.MaxPriority, -MAXPRIORITY, MAXPRIORITY));
|
||||
Add(new cMenuEditIntItem (tr("Live TV Priority"), &m_NewSetup.LivePriority, MINPRIORITY, MAXPRIORITY));
|
||||
Add(new cMenuEditIntItem (tr("Minimum Priority"), &m_NewSetup.MinPriority, MINPRIORITY, MAXPRIORITY));
|
||||
Add(new cMenuEditIntItem (tr("Maximum Priority"), &m_NewSetup.MaxPriority, MINPRIORITY, MAXPRIORITY));
|
||||
#if APIVERSNUM >= 10715
|
||||
Add(new cMenuEditIntItem (tr("Broadcast Systems / Cost"), &m_NewSetup.NumProvidedSystems, 1, 15));
|
||||
#elif APIVERSNUM >= 10700
|
||||
|
@ -23,6 +23,7 @@ cClientSocket ClientSocket;
|
||||
cClientSocket::cClientSocket(void)
|
||||
{
|
||||
memset(m_DataSockets, 0, sizeof(cTBSocket*) * si_Count);
|
||||
m_ServerVersion = 0;
|
||||
m_Prio = false;
|
||||
m_Abort = false;
|
||||
m_LastSignalUpdate = 0;
|
||||
@ -153,6 +154,11 @@ bool cClientSocket::CheckConnection(void) {
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned int major, minor;
|
||||
if (sscanf(buffer.c_str(), "%*u VTP/%u.%u", &major, &minor) == 2)
|
||||
m_ServerVersion = major * 100 + minor;
|
||||
|
||||
if (m_ServerVersion == 0) {
|
||||
if (!Command("CAPS TSPIDS", 220)) {
|
||||
Close();
|
||||
return false;
|
||||
@ -167,9 +173,19 @@ bool cClientSocket::CheckConnection(void) {
|
||||
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 {
|
||||
if(!Command("VERS 1.0", 220)) {
|
||||
Close();
|
||||
return false;
|
||||
}
|
||||
m_Prio = true;
|
||||
isyslog("streamdev-client: Connected to server %s:%d using protocol version %u.%u",
|
||||
RemoteIp().c_str(), RemotePort(), major, minor);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ private:
|
||||
cTBSocket *m_DataSockets[si_Count];
|
||||
cMutex m_Mutex;
|
||||
char m_Buffer[BUFSIZ + 1]; // various uses
|
||||
unsigned int m_ServerVersion;
|
||||
bool m_Prio; // server supports command PRIO
|
||||
bool m_Abort; // quit command pending
|
||||
|
||||
@ -52,6 +53,7 @@ public:
|
||||
bool CloseDataConnection(eSocketId Id);
|
||||
bool SetChannelDevice(const cChannel *Channel);
|
||||
bool SupportsPrio() { return m_Prio; }
|
||||
unsigned int ServerVersion() { return m_ServerVersion; }
|
||||
bool SetPriority(int Priority);
|
||||
bool SetPid(int Pid, bool On);
|
||||
bool SetFilter(ushort Pid, uchar Tid, uchar Mask, bool On);
|
||||
|
Loading…
Reference in New Issue
Block a user