Moved remux from livestreamer to streamer

This commit is contained in:
Frank Schmirler 2014-08-10 15:57:16 +02:00
parent 703dffa0cb
commit 2d919997a8
4 changed files with 44 additions and 55 deletions

View File

@ -9,7 +9,6 @@
#include "remux/extern.h"
#include <vdr/transfer.h>
#include <vdr/ringbuffer.h>
#include "server/livestreamer.h"
#include "server/setup.h"
@ -339,23 +338,21 @@ cStreamdevLiveStreamer::cStreamdevLiveStreamer(const cServerConnection *Connecti
cStreamdevStreamer("streamdev-livestreaming", Connection),
m_Priority(Priority),
m_NumPids(0),
m_StreamType(StreamType),
m_Channel(Channel),
m_Device(NULL),
m_Receiver(NULL),
m_PatFilter(NULL),
m_Remux(NULL),
m_SwitchLive(false)
{
m_ReceiveBuffer = new cStreamdevBuffer(LIVEBUFSIZE, TS_SIZE *2, true, "streamdev-livestreamer"),
m_ReceiveBuffer->SetTimeouts(0, 100);
if (Priority == IDLEPRIORITY) {
SetChannel(Apid, Dpid);
SetChannel(StreamType, Apid, Dpid);
}
else {
m_Device = SwitchDevice(Channel, Priority);
if (m_Device)
SetChannel(Apid, Dpid);
SetChannel(StreamType, Apid, Dpid);
}
}
@ -365,7 +362,6 @@ cStreamdevLiveStreamer::~cStreamdevLiveStreamer()
Stop();
DELETENULL(m_PatFilter);
DELETENULL(m_Receiver);
delete m_Remux;
delete m_ReceiveBuffer;
}
@ -487,7 +483,7 @@ void cStreamdevLiveStreamer::StartReceiver(bool Force)
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");
//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 *Dpids = Dpid ? Dpid : m_Channel->Dpids();
switch (m_StreamType) {
switch (StreamType) {
case stES:
{
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];
else if (Dpid && Dpid[0])
pid = Dpid[0];
m_Remux = new cTS2ESRemux(pid);
SetRemux(new cTS2ESRemux(pid));
return SetPids(pid);
}
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());
#ifdef STREAMDEV_PS
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());
#endif
case stEXT:
m_Remux = new cExternRemux(Connection(), m_Channel, Apids, Dpids);
SetRemux(new cExternRemux(Connection(), m_Channel, Apids, Dpids));
// fall through
case stTS:
// This should never happen, but ...
@ -573,36 +569,14 @@ int cStreamdevLiveStreamer::Put(const uchar *Data, int Count)
int siCount;
uchar *siData = m_PatFilter->Get(siCount);
if (siData) {
if (m_Remux)
siCount = m_Remux->Put(siData, siCount);
else
siCount = cStreamdevStreamer::Put(siData, siCount);
siCount = cStreamdevStreamer::Put(siData, siCount);
if (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)
{
Dprintf("cStreamdevLiveStreamer::Attach()\n");

View File

@ -11,9 +11,6 @@
#define LIVEBUFSIZE (20000 * TS_SIZE)
namespace Streamdev {
class cTSRemux;
}
class cStreamdevPatFilter;
class cStreamdevLiveReceiver;
@ -28,13 +25,11 @@ private:
int m_Priority;
int m_Pids[MAXRECEIVEPIDS + 1];
int m_NumPids;
eStreamType m_StreamType;
const cChannel *m_Channel;
cDevice *m_Device;
cStreamdevLiveReceiver *m_Receiver;
cStreamdevBuffer *m_ReceiveBuffer;
cStreamdevPatFilter *m_PatFilter;
Streamdev::cTSRemux *m_Remux;
bool m_SwitchLive;
void StartReceiver(bool Force = false);
@ -47,7 +42,7 @@ private:
/* Find a suitable device and tune it to the requested channel. */
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:
virtual uchar* GetFromReceiver(int &Count) { return m_ReceiveBuffer->Get(Count); }
@ -71,9 +66,6 @@ public:
void Receive(uchar *Data, int Length);
virtual bool IsReceiving(void) const;
virtual uchar *Get(int &Count);
virtual void Del(int Count);
virtual void Attach(void);
virtual void Detach(void);

View File

@ -8,7 +8,6 @@
#include <unistd.h>
#include "server/streamer.h"
#include "server/suspend.h"
#include "tools/socket.h"
#include "tools/select.h"
#include "common.h"
@ -108,21 +107,37 @@ void cStreamdevWriter::Action(void)
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(const char *Name, const cServerConnection *Connection):
cThread(Name),
m_Connection(Connection),
m_Writer(NULL),
m_SendBuffer(new cStreamdevBuffer(WRITERBUFSIZE, TS_SIZE * 2))
m_Remux(new cRemuxDummy()),
m_Writer(NULL)
{
m_SendBuffer->SetTimeouts(100, 100);
}
cStreamdevStreamer::~cStreamdevStreamer()
{
Dprintf("Desctructing streamer\n");
delete m_SendBuffer;
delete m_Remux;
}
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);
}

View File

@ -9,6 +9,8 @@
#include <vdr/ringbuffer.h>
#include <vdr/tools.h>
#include "remux/tsremux.h"
class cTBSocket;
class cStreamdevStreamer;
class cServerConnection;
@ -65,16 +67,18 @@ public:
class cStreamdevStreamer: public cThread {
private:
const cServerConnection *m_Connection;
cStreamdevWriter *m_Writer;
cStreamdevBuffer *m_SendBuffer;
Streamdev::cTSRemux *m_Remux;
cStreamdevWriter *m_Writer;
cStreamdevBuffer *m_SendBuffer;
protected:
virtual uchar* GetFromReceiver(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);
bool IsRunning(void) const { return m_Writer; }
void SetRemux(Streamdev::cTSRemux *Remux) { delete m_Remux; m_Remux = Remux; }
public:
cStreamdevStreamer(const char *Name, const cServerConnection *Connection = NULL);
@ -87,8 +91,8 @@ public:
virtual bool IsReceiving(void) const = 0;
bool Abort(void);
virtual uchar *Get(int &Count) { return m_SendBuffer->Get(Count); }
virtual void Del(int Count) { m_SendBuffer->Del(Count); }
uchar *Get(int &Count) { return m_Remux->Get(Count); }
void Del(int Count) { m_Remux->Del(Count); }
virtual void Detach(void) {}
virtual void Attach(void) {}