mirror of
https://projects.vdr-developer.org/git/vdr-plugin-streamdev.git
synced 2023-10-10 17:16:51 +00:00
Snapshot 2010-09-15
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: device.c,v 1.26 2010/06/08 05:55:17 schmirl Exp $
|
||||
* $Id: device.c,v 1.27 2010/08/18 10:26:55 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;
|
||||
}
|
||||
|
||||
@@ -107,7 +109,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);
|
||||
@@ -118,6 +120,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;
|
||||
@@ -140,6 +145,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();
|
||||
@@ -301,3 +308,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();
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: device.h,v 1.9 2009/06/23 10:26:54 schmirl Exp $
|
||||
* $Id: device.h,v 1.10 2010/08/18 10:26:55 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;
|
||||
@@ -59,6 +60,7 @@ public:
|
||||
#endif
|
||||
virtual bool IsTunedToTransponder(const cChannel *Channel);
|
||||
|
||||
static void UpdatePriority(void);
|
||||
static bool Init(void);
|
||||
static bool ReInit(void);
|
||||
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: socket.c,v 1.13 2010/06/08 05:55:17 schmirl Exp $
|
||||
* $Id: socket.c,v 1.15 2010/08/18 10:26:55 schmirl Exp $
|
||||
*/
|
||||
|
||||
#include <tools/select.h>
|
||||
@@ -20,6 +20,7 @@ cClientSocket ClientSocket;
|
||||
cClientSocket::cClientSocket(void)
|
||||
{
|
||||
memset(m_DataSockets, 0, sizeof(cTBSocket*) * si_Count);
|
||||
m_Prio = false;
|
||||
Reset();
|
||||
}
|
||||
|
||||
@@ -142,8 +143,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;
|
||||
}
|
||||
|
||||
@@ -241,7 +248,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",
|
||||
@@ -251,6 +258,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;
|
||||
|
||||
@@ -259,8 +281,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;
|
||||
@@ -276,7 +298,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;
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: socket.h,v 1.7 2010/06/08 05:55:17 schmirl Exp $
|
||||
* $Id: socket.h,v 1.8 2010/08/18 10:26:55 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);
|
||||
|
@@ -3,7 +3,7 @@
|
||||
*
|
||||
* See the README file for copyright information and how to reach the author.
|
||||
*
|
||||
* $Id: streamdev-client.c,v 1.2 2010/07/19 13:49:25 schmirl Exp $
|
||||
* $Id: streamdev-client.c,v 1.3 2010/08/18 10:26:56 schmirl Exp $
|
||||
*/
|
||||
|
||||
#include "streamdev-client.h"
|
||||
@@ -52,4 +52,8 @@ bool cPluginStreamdevClient::SetupParse(const char *Name, const char *Value) {
|
||||
return StreamdevClientSetup.SetupParse(Name, Value);
|
||||
}
|
||||
|
||||
void cPluginStreamdevClient::MainThreadHook(void) {
|
||||
cStreamdevDevice::UpdatePriority();
|
||||
}
|
||||
|
||||
VDRPLUGINCREATOR(cPluginStreamdevClient); // Don't touch this!
|
||||
|
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* $Id: streamdev-client.h,v 1.2 2010/07/19 13:49:25 schmirl Exp $
|
||||
* $Id: streamdev-client.h,v 1.3 2010/08/18 10:26:56 schmirl Exp $
|
||||
*/
|
||||
|
||||
#ifndef VDR_STREAMDEVCLIENT_H
|
||||
@@ -23,6 +23,7 @@ public:
|
||||
virtual cOsdObject *MainMenuAction(void);
|
||||
virtual cMenuSetupPage *SetupMenu(void);
|
||||
virtual bool SetupParse(const char *Name, const char *Value);
|
||||
virtual void MainThreadHook(void);
|
||||
};
|
||||
|
||||
#endif // VDR_STREAMDEVCLIENT_H
|
||||
|
Reference in New Issue
Block a user