mirror of
https://projects.vdr-developer.org/git/vdr-plugin-streamdev.git
synced 2023-10-10 19:16:51 +02:00
Moved remux from livestreamer to streamer
This commit is contained in:
parent
703dffa0cb
commit
2d919997a8
@ -9,7 +9,6 @@
|
|||||||
#include "remux/extern.h"
|
#include "remux/extern.h"
|
||||||
|
|
||||||
#include <vdr/transfer.h>
|
#include <vdr/transfer.h>
|
||||||
#include <vdr/ringbuffer.h>
|
|
||||||
|
|
||||||
#include "server/livestreamer.h"
|
#include "server/livestreamer.h"
|
||||||
#include "server/setup.h"
|
#include "server/setup.h"
|
||||||
@ -339,23 +338,21 @@ cStreamdevLiveStreamer::cStreamdevLiveStreamer(const cServerConnection *Connecti
|
|||||||
cStreamdevStreamer("streamdev-livestreaming", Connection),
|
cStreamdevStreamer("streamdev-livestreaming", Connection),
|
||||||
m_Priority(Priority),
|
m_Priority(Priority),
|
||||||
m_NumPids(0),
|
m_NumPids(0),
|
||||||
m_StreamType(StreamType),
|
|
||||||
m_Channel(Channel),
|
m_Channel(Channel),
|
||||||
m_Device(NULL),
|
m_Device(NULL),
|
||||||
m_Receiver(NULL),
|
m_Receiver(NULL),
|
||||||
m_PatFilter(NULL),
|
m_PatFilter(NULL),
|
||||||
m_Remux(NULL),
|
|
||||||
m_SwitchLive(false)
|
m_SwitchLive(false)
|
||||||
{
|
{
|
||||||
m_ReceiveBuffer = new cStreamdevBuffer(LIVEBUFSIZE, TS_SIZE *2, true, "streamdev-livestreamer"),
|
m_ReceiveBuffer = new cStreamdevBuffer(LIVEBUFSIZE, TS_SIZE *2, true, "streamdev-livestreamer"),
|
||||||
m_ReceiveBuffer->SetTimeouts(0, 100);
|
m_ReceiveBuffer->SetTimeouts(0, 100);
|
||||||
if (Priority == IDLEPRIORITY) {
|
if (Priority == IDLEPRIORITY) {
|
||||||
SetChannel(Apid, Dpid);
|
SetChannel(StreamType, Apid, Dpid);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
m_Device = SwitchDevice(Channel, Priority);
|
m_Device = SwitchDevice(Channel, Priority);
|
||||||
if (m_Device)
|
if (m_Device)
|
||||||
SetChannel(Apid, Dpid);
|
SetChannel(StreamType, Apid, Dpid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -365,7 +362,6 @@ cStreamdevLiveStreamer::~cStreamdevLiveStreamer()
|
|||||||
Stop();
|
Stop();
|
||||||
DELETENULL(m_PatFilter);
|
DELETENULL(m_PatFilter);
|
||||||
DELETENULL(m_Receiver);
|
DELETENULL(m_Receiver);
|
||||||
delete m_Remux;
|
|
||||||
delete m_ReceiveBuffer;
|
delete m_ReceiveBuffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -487,7 +483,7 @@ void cStreamdevLiveStreamer::StartReceiver(bool Force)
|
|||||||
DELETENULL(m_Receiver);
|
DELETENULL(m_Receiver);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cStreamdevLiveStreamer::SetChannel(const int* Apid, const int *Dpid)
|
bool cStreamdevLiveStreamer::SetChannel(eStreamType StreamType, const int* Apid, const int *Dpid)
|
||||||
{
|
{
|
||||||
Dprintf("Initializing Remuxer for full channel transfer\n");
|
Dprintf("Initializing Remuxer for full channel transfer\n");
|
||||||
//printf("ca pid: %d\n", Channel->Ca());
|
//printf("ca pid: %d\n", Channel->Ca());
|
||||||
@ -495,7 +491,7 @@ bool cStreamdevLiveStreamer::SetChannel(const int* Apid, const int *Dpid)
|
|||||||
const int *Apids = Apid ? Apid : m_Channel->Apids();
|
const int *Apids = Apid ? Apid : m_Channel->Apids();
|
||||||
const int *Dpids = Dpid ? Dpid : m_Channel->Dpids();
|
const int *Dpids = Dpid ? Dpid : m_Channel->Dpids();
|
||||||
|
|
||||||
switch (m_StreamType) {
|
switch (StreamType) {
|
||||||
case stES:
|
case stES:
|
||||||
{
|
{
|
||||||
int pid = ISRADIO(m_Channel) ? m_Channel->Apid(0) : m_Channel->Vpid();
|
int pid = ISRADIO(m_Channel) ? m_Channel->Apid(0) : m_Channel->Vpid();
|
||||||
@ -503,22 +499,22 @@ bool cStreamdevLiveStreamer::SetChannel(const int* Apid, const int *Dpid)
|
|||||||
pid = Apid[0];
|
pid = Apid[0];
|
||||||
else if (Dpid && Dpid[0])
|
else if (Dpid && Dpid[0])
|
||||||
pid = Dpid[0];
|
pid = Dpid[0];
|
||||||
m_Remux = new cTS2ESRemux(pid);
|
SetRemux(new cTS2ESRemux(pid));
|
||||||
return SetPids(pid);
|
return SetPids(pid);
|
||||||
}
|
}
|
||||||
|
|
||||||
case stPES:
|
case stPES:
|
||||||
m_Remux = new cTS2PESRemux(m_Channel->Vpid(), Apids, Dpids, m_Channel->Spids());
|
SetRemux(new cTS2PESRemux(m_Channel->Vpid(), Apids, Dpids, m_Channel->Spids()));
|
||||||
return SetPids(m_Channel->Vpid(), Apids, Dpids, m_Channel->Spids());
|
return SetPids(m_Channel->Vpid(), Apids, Dpids, m_Channel->Spids());
|
||||||
|
|
||||||
#ifdef STREAMDEV_PS
|
#ifdef STREAMDEV_PS
|
||||||
case stPS:
|
case stPS:
|
||||||
m_Remux = new cTS2PSRemux(m_Channel->Vpid(), Apids, Dpids, m_Channel->Spids());
|
SetRemux(new cTS2PSRemux(m_Channel->Vpid(), Apids, Dpids, m_Channel->Spids()));
|
||||||
return SetPids(m_Channel->Vpid(), Apids, Dpids, m_Channel->Spids());
|
return SetPids(m_Channel->Vpid(), Apids, Dpids, m_Channel->Spids());
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
case stEXT:
|
case stEXT:
|
||||||
m_Remux = new cExternRemux(Connection(), m_Channel, Apids, Dpids);
|
SetRemux(new cExternRemux(Connection(), m_Channel, Apids, Dpids));
|
||||||
// fall through
|
// fall through
|
||||||
case stTS:
|
case stTS:
|
||||||
// This should never happen, but ...
|
// This should never happen, but ...
|
||||||
@ -573,36 +569,14 @@ int cStreamdevLiveStreamer::Put(const uchar *Data, int Count)
|
|||||||
int siCount;
|
int siCount;
|
||||||
uchar *siData = m_PatFilter->Get(siCount);
|
uchar *siData = m_PatFilter->Get(siCount);
|
||||||
if (siData) {
|
if (siData) {
|
||||||
if (m_Remux)
|
|
||||||
siCount = m_Remux->Put(siData, siCount);
|
|
||||||
else
|
|
||||||
siCount = cStreamdevStreamer::Put(siData, siCount);
|
siCount = cStreamdevStreamer::Put(siData, siCount);
|
||||||
if (siCount)
|
if (siCount)
|
||||||
m_PatFilter->Del(siCount);
|
m_PatFilter->Del(siCount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (m_Remux)
|
|
||||||
return m_Remux->Put(Data, Count);
|
|
||||||
else
|
|
||||||
return cStreamdevStreamer::Put(Data, Count);
|
return cStreamdevStreamer::Put(Data, Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
uchar *cStreamdevLiveStreamer::Get(int &Count)
|
|
||||||
{
|
|
||||||
if (m_Remux)
|
|
||||||
return m_Remux->Get(Count);
|
|
||||||
else
|
|
||||||
return cStreamdevStreamer::Get(Count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cStreamdevLiveStreamer::Del(int Count)
|
|
||||||
{
|
|
||||||
if (m_Remux)
|
|
||||||
m_Remux->Del(Count);
|
|
||||||
else
|
|
||||||
cStreamdevStreamer::Del(Count);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cStreamdevLiveStreamer::Attach(void)
|
void cStreamdevLiveStreamer::Attach(void)
|
||||||
{
|
{
|
||||||
Dprintf("cStreamdevLiveStreamer::Attach()\n");
|
Dprintf("cStreamdevLiveStreamer::Attach()\n");
|
||||||
|
@ -11,9 +11,6 @@
|
|||||||
|
|
||||||
#define LIVEBUFSIZE (20000 * TS_SIZE)
|
#define LIVEBUFSIZE (20000 * TS_SIZE)
|
||||||
|
|
||||||
namespace Streamdev {
|
|
||||||
class cTSRemux;
|
|
||||||
}
|
|
||||||
class cStreamdevPatFilter;
|
class cStreamdevPatFilter;
|
||||||
class cStreamdevLiveReceiver;
|
class cStreamdevLiveReceiver;
|
||||||
|
|
||||||
@ -28,13 +25,11 @@ private:
|
|||||||
int m_Priority;
|
int m_Priority;
|
||||||
int m_Pids[MAXRECEIVEPIDS + 1];
|
int m_Pids[MAXRECEIVEPIDS + 1];
|
||||||
int m_NumPids;
|
int m_NumPids;
|
||||||
eStreamType m_StreamType;
|
|
||||||
const cChannel *m_Channel;
|
const cChannel *m_Channel;
|
||||||
cDevice *m_Device;
|
cDevice *m_Device;
|
||||||
cStreamdevLiveReceiver *m_Receiver;
|
cStreamdevLiveReceiver *m_Receiver;
|
||||||
cStreamdevBuffer *m_ReceiveBuffer;
|
cStreamdevBuffer *m_ReceiveBuffer;
|
||||||
cStreamdevPatFilter *m_PatFilter;
|
cStreamdevPatFilter *m_PatFilter;
|
||||||
Streamdev::cTSRemux *m_Remux;
|
|
||||||
bool m_SwitchLive;
|
bool m_SwitchLive;
|
||||||
|
|
||||||
void StartReceiver(bool Force = false);
|
void StartReceiver(bool Force = false);
|
||||||
@ -47,7 +42,7 @@ private:
|
|||||||
/* Find a suitable device and tune it to the requested channel. */
|
/* Find a suitable device and tune it to the requested channel. */
|
||||||
cDevice *SwitchDevice(const cChannel *Channel, int Priority);
|
cDevice *SwitchDevice(const cChannel *Channel, int Priority);
|
||||||
|
|
||||||
bool SetChannel(const int* Apid = NULL, const int* Dpid = NULL);
|
bool SetChannel(eStreamType StreamType, const int* Apid = NULL, const int* Dpid = NULL);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual uchar* GetFromReceiver(int &Count) { return m_ReceiveBuffer->Get(Count); }
|
virtual uchar* GetFromReceiver(int &Count) { return m_ReceiveBuffer->Get(Count); }
|
||||||
@ -71,9 +66,6 @@ public:
|
|||||||
void Receive(uchar *Data, int Length);
|
void Receive(uchar *Data, int Length);
|
||||||
virtual bool IsReceiving(void) const;
|
virtual bool IsReceiving(void) const;
|
||||||
|
|
||||||
virtual uchar *Get(int &Count);
|
|
||||||
virtual void Del(int Count);
|
|
||||||
|
|
||||||
virtual void Attach(void);
|
virtual void Attach(void);
|
||||||
virtual void Detach(void);
|
virtual void Detach(void);
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
#include "server/streamer.h"
|
#include "server/streamer.h"
|
||||||
#include "server/suspend.h"
|
|
||||||
#include "tools/socket.h"
|
#include "tools/socket.h"
|
||||||
#include "tools/select.h"
|
#include "tools/select.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -108,21 +107,37 @@ void cStreamdevWriter::Action(void)
|
|||||||
Dprintf("Max. Transmit Blocksize was: %d\n", max);
|
Dprintf("Max. Transmit Blocksize was: %d\n", max);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- cRemuxDummy ------------------------------------------------------------
|
||||||
|
|
||||||
|
class cRemuxDummy: public Streamdev::cTSRemux {
|
||||||
|
private:
|
||||||
|
cStreamdevBuffer m_Buffer;
|
||||||
|
public:
|
||||||
|
cRemuxDummy();
|
||||||
|
virtual int Put(const uchar *Data, int Count) { return m_Buffer.Put(Data, Count); }
|
||||||
|
virtual uchar *Get(int& Count) { return m_Buffer.Get(Count); }
|
||||||
|
virtual void Del(int Count) { return m_Buffer.Del(Count); }
|
||||||
|
};
|
||||||
|
|
||||||
|
cRemuxDummy::cRemuxDummy(): m_Buffer(WRITERBUFSIZE, TS_SIZE * 2)
|
||||||
|
{
|
||||||
|
m_Buffer.SetTimeouts(100, 100);
|
||||||
|
}
|
||||||
|
|
||||||
// --- cStreamdevStreamer -----------------------------------------------------
|
// --- cStreamdevStreamer -----------------------------------------------------
|
||||||
|
|
||||||
cStreamdevStreamer::cStreamdevStreamer(const char *Name, const cServerConnection *Connection):
|
cStreamdevStreamer::cStreamdevStreamer(const char *Name, const cServerConnection *Connection):
|
||||||
cThread(Name),
|
cThread(Name),
|
||||||
m_Connection(Connection),
|
m_Connection(Connection),
|
||||||
m_Writer(NULL),
|
m_Remux(new cRemuxDummy()),
|
||||||
m_SendBuffer(new cStreamdevBuffer(WRITERBUFSIZE, TS_SIZE * 2))
|
m_Writer(NULL)
|
||||||
{
|
{
|
||||||
m_SendBuffer->SetTimeouts(100, 100);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
cStreamdevStreamer::~cStreamdevStreamer()
|
cStreamdevStreamer::~cStreamdevStreamer()
|
||||||
{
|
{
|
||||||
Dprintf("Desctructing streamer\n");
|
Dprintf("Desctructing streamer\n");
|
||||||
delete m_SendBuffer;
|
delete m_Remux;
|
||||||
}
|
}
|
||||||
|
|
||||||
void cStreamdevStreamer::Start(cTBSocket *Socket)
|
void cStreamdevStreamer::Start(cTBSocket *Socket)
|
||||||
@ -163,3 +178,7 @@ void cStreamdevStreamer::Action(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int cStreamdevStreamer::Put(const uchar *Data, int Count) {
|
||||||
|
return m_Remux->Put(Data, Count);
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include <vdr/ringbuffer.h>
|
#include <vdr/ringbuffer.h>
|
||||||
#include <vdr/tools.h>
|
#include <vdr/tools.h>
|
||||||
|
|
||||||
|
#include "remux/tsremux.h"
|
||||||
|
|
||||||
class cTBSocket;
|
class cTBSocket;
|
||||||
class cStreamdevStreamer;
|
class cStreamdevStreamer;
|
||||||
class cServerConnection;
|
class cServerConnection;
|
||||||
@ -65,16 +67,18 @@ public:
|
|||||||
class cStreamdevStreamer: public cThread {
|
class cStreamdevStreamer: public cThread {
|
||||||
private:
|
private:
|
||||||
const cServerConnection *m_Connection;
|
const cServerConnection *m_Connection;
|
||||||
|
Streamdev::cTSRemux *m_Remux;
|
||||||
cStreamdevWriter *m_Writer;
|
cStreamdevWriter *m_Writer;
|
||||||
cStreamdevBuffer *m_SendBuffer;
|
cStreamdevBuffer *m_SendBuffer;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual uchar* GetFromReceiver(int &Count) = 0;
|
virtual uchar* GetFromReceiver(int &Count) = 0;
|
||||||
virtual void DelFromReceiver(int Count) = 0;
|
virtual void DelFromReceiver(int Count) = 0;
|
||||||
virtual int Put(const uchar *Data, int Count) { return m_SendBuffer->PutTS(Data, Count); }
|
virtual int Put(const uchar *Data, int Count);
|
||||||
virtual void Action(void);
|
virtual void Action(void);
|
||||||
|
|
||||||
bool IsRunning(void) const { return m_Writer; }
|
bool IsRunning(void) const { return m_Writer; }
|
||||||
|
void SetRemux(Streamdev::cTSRemux *Remux) { delete m_Remux; m_Remux = Remux; }
|
||||||
|
|
||||||
public:
|
public:
|
||||||
cStreamdevStreamer(const char *Name, const cServerConnection *Connection = NULL);
|
cStreamdevStreamer(const char *Name, const cServerConnection *Connection = NULL);
|
||||||
@ -87,8 +91,8 @@ public:
|
|||||||
virtual bool IsReceiving(void) const = 0;
|
virtual bool IsReceiving(void) const = 0;
|
||||||
bool Abort(void);
|
bool Abort(void);
|
||||||
|
|
||||||
virtual uchar *Get(int &Count) { return m_SendBuffer->Get(Count); }
|
uchar *Get(int &Count) { return m_Remux->Get(Count); }
|
||||||
virtual void Del(int Count) { m_SendBuffer->Del(Count); }
|
void Del(int Count) { m_Remux->Del(Count); }
|
||||||
|
|
||||||
virtual void Detach(void) {}
|
virtual void Detach(void) {}
|
||||||
virtual void Attach(void) {}
|
virtual void Attach(void) {}
|
||||||
|
Loading…
Reference in New Issue
Block a user