diff options
author | lordjaxom <lordjaxom> | 2005-02-10 22:24:26 +0000 |
---|---|---|
committer | lordjaxom <lordjaxom> | 2005-02-10 22:24:26 +0000 |
commit | ab8f0c75f39b57cd1e28545259fb08bb7b4925b3 (patch) | |
tree | 7b640887ef77c02bc09ffa0156684d76afa2492a /server | |
parent | c1cb77c3f8c7c0b3469e1d110f4e9a96bac16178 (diff) | |
download | vdr-plugin-streamdev-ab8f0c75f39b57cd1e28545259fb08bb7b4925b3.tar.gz vdr-plugin-streamdev-ab8f0c75f39b57cd1e28545259fb08bb7b4925b3.tar.bz2 |
- implemented audio track selection for http
Diffstat (limited to 'server')
-rw-r--r-- | server/connectionHTTP.c | 14 | ||||
-rw-r--r-- | server/connectionHTTP.h | 7 | ||||
-rw-r--r-- | server/connectionVTP.c | 4 | ||||
-rw-r--r-- | server/livestreamer.c | 131 | ||||
-rw-r--r-- | server/livestreamer.h | 28 | ||||
-rw-r--r-- | server/streamer.c | 26 | ||||
-rw-r--r-- | server/streamer.h | 15 |
7 files changed, 100 insertions, 125 deletions
diff --git a/server/connectionHTTP.c b/server/connectionHTTP.c index 914f87d..b8d1b36 100644 --- a/server/connectionHTTP.c +++ b/server/connectionHTTP.c @@ -1,5 +1,5 @@ /* - * $Id: connectionHTTP.c,v 1.5 2005/02/08 19:54:52 lordjaxom Exp $ + * $Id: connectionHTTP.c,v 1.6 2005/02/10 22:24:26 lordjaxom Exp $ */ #include "server/connectionHTTP.h" @@ -8,6 +8,7 @@ cConnectionHTTP::cConnectionHTTP(void): cServerConnection("HTTP") { m_Channel = NULL; + m_Apid = 0; m_ListChannel = NULL; m_LiveStreamer = NULL; m_Status = hsRequest; @@ -56,7 +57,7 @@ bool cConnectionHTTP::Command(char *Cmd) { cDevice *device = GetDevice(m_Channel, 0); if (device != NULL) { device->SwitchChannel(m_Channel, false); - if (m_LiveStreamer->SetChannel(m_Channel, m_StreamType)) { + if (m_LiveStreamer->SetChannel(m_Channel, m_StreamType, m_Apid)) { m_LiveStreamer->SetDevice(device); m_Startup = true; if (m_StreamType == stES && (m_Channel->Vpid() == 0 @@ -111,8 +112,9 @@ void cConnectionHTTP::Flushed(void) { } bool cConnectionHTTP::CmdGET(char *Opts) { - cChannel *chan; + const cChannel *chan; char *ep; + int apid = 0; Opts = skipspace(Opts); while (*Opts == '/') @@ -138,13 +140,17 @@ bool cConnectionHTTP::CmdGET(char *Opts) { ; *ep = '\0'; + Dprintf("before channelfromstring\n"); if (strncmp(Opts, "channels.htm", 12) == 0) { m_ListChannel = Channels.First(); m_Status = hsHeaders; - } else if ((chan = ChannelFromString(Opts)) != NULL) { + } else if ((chan = ChannelFromString(Opts, &apid)) != NULL) { m_Channel = chan; + m_Apid = apid; + Dprintf("Apid is %d\n", apid); m_Status = hsHeaders; } + Dprintf("after channelfromstring\n"); return true; } diff --git a/server/connectionHTTP.h b/server/connectionHTTP.h index 5b8abbe..6e43d28 100644 --- a/server/connectionHTTP.h +++ b/server/connectionHTTP.h @@ -1,5 +1,5 @@ /* - * $Id: connectionHTTP.h,v 1.1 2004/12/30 22:44:18 lordjaxom Exp $ + * $Id: connectionHTTP.h,v 1.2 2005/02/10 22:24:26 lordjaxom Exp $ */ #ifndef VDR_STREAMDEV_SERVERS_CONNECTIONHTTP_H @@ -21,8 +21,9 @@ private: hsListing, }; - cChannel *m_Channel; - cChannel *m_ListChannel; + const cChannel *m_Channel; + int m_Apid; + const cChannel *m_ListChannel; cStreamdevLiveStreamer *m_LiveStreamer; eStreamType m_StreamType; eHTTPStatus m_Status; diff --git a/server/connectionVTP.c b/server/connectionVTP.c index 2162ae0..1930148 100644 --- a/server/connectionVTP.c +++ b/server/connectionVTP.c @@ -1,5 +1,5 @@ /* - * $Id: connectionVTP.c,v 1.4 2005/02/08 17:22:35 lordjaxom Exp $ + * $Id: connectionVTP.c,v 1.5 2005/02/10 22:24:26 lordjaxom Exp $ */ #include "server/connectionVTP.h" @@ -92,7 +92,7 @@ bool cConnectionVTP::CmdCAPS(char *Opts) { } bool cConnectionVTP::CmdPROV(char *Opts) { - cChannel *chan; + const cChannel *chan; int prio; char *ep; diff --git a/server/livestreamer.c b/server/livestreamer.c index e69d3d3..b920ca4 100644 --- a/server/livestreamer.c +++ b/server/livestreamer.c @@ -5,6 +5,8 @@ #include "remux/ts2es.h" #include "common.h" +// --- cStreamdevLiveReceiver ------------------------------------------------- + cStreamdevLiveReceiver::cStreamdevLiveReceiver(cStreamdevLiveStreamer *Streamer, int Ca, int Priority, const int *Pids): cReceiver(Ca, Priority, 0, Pids), @@ -18,30 +20,29 @@ cStreamdevLiveReceiver::~cStreamdevLiveReceiver() Detach(); } -void cStreamdevLiveReceiver::Activate(bool On) -{ - m_Streamer->Activate(On); -} - void cStreamdevLiveReceiver::Receive(uchar *Data, int Length) { int p = m_Streamer->Receive(Data, Length); if (p != Length) m_Streamer->ReportOverflow(Length - p); } +// --- cStreamdevLiveStreamer ------------------------------------------------- + cStreamdevLiveStreamer::cStreamdevLiveStreamer(int Priority): - cStreamdevStreamer("streamdev-livestreaming") { - m_Priority = Priority; - m_NumPids = 0; - m_StreamType = stTSPIDS; - m_Channel = NULL; - m_Device = NULL; - m_Receiver = NULL; - m_Remux = NULL; - m_PESRemux = NULL; + cStreamdevStreamer("streamdev-livestreaming"), + m_Priority(Priority), + m_NumPids(0), + m_StreamType(stTSPIDS), + m_Channel(NULL), + m_Device(NULL), + m_Receiver(NULL), + m_PESRemux(NULL), + m_Remux(NULL) +{ } -cStreamdevLiveStreamer::~cStreamdevLiveStreamer() { +cStreamdevLiveStreamer::~cStreamdevLiveStreamer() +{ Dprintf("Desctructing Live streamer\n"); delete m_Receiver; delete m_Remux; @@ -50,21 +51,12 @@ cStreamdevLiveStreamer::~cStreamdevLiveStreamer() { #endif } -void cStreamdevLiveStreamer::Detach(void) { - m_Device->Detach(m_Receiver); -} - -void cStreamdevLiveStreamer::Attach(void) { - m_Device->AttachReceiver(m_Receiver); -} - -void cStreamdevLiveStreamer::Start(cTBSocket *Socket) { - Dprintf("LIVESTREAMER START\n"); - cStreamdevStreamer::Start(Socket); -} - -bool cStreamdevLiveStreamer::SetPid(int Pid, bool On) { +bool cStreamdevLiveStreamer::SetPid(int Pid, bool On) +{ int idx; + + if (Pid == 0) + return true; if (On) { for (idx = 0; idx < m_NumPids; ++idx) { @@ -100,7 +92,7 @@ bool cStreamdevLiveStreamer::SetPid(int Pid, bool On) { return true; } -bool cStreamdevLiveStreamer::SetChannel(const cChannel *Channel, eStreamType StreamType) +bool cStreamdevLiveStreamer::SetChannel(const cChannel *Channel, eStreamType StreamType, int Apid) { Dprintf("Initializing Remuxer for full channel transfer\n"); printf("ca pid: %d\n", Channel->Ca()); @@ -109,29 +101,38 @@ bool cStreamdevLiveStreamer::SetChannel(const cChannel *Channel, eStreamType Str switch (m_StreamType) { case stES: { - int pid = ISRADIO(Channel) ? Channel->Apid(0) : Channel->Vpid(); + int pid = ISRADIO(m_Channel) ? m_Channel->Apid(0) : m_Channel->Vpid(); + if (Apid != 0) + pid = Apid; m_Remux = new cTS2ESRemux(pid); return SetPid(pid, true); } case stPES: - m_PESRemux = new cRemux(Channel->Vpid(), Channel->Apids(), Channel->Dpids(), - Channel->Spids(), false); - return SetPid(Channel->Vpid(), true) - && SetPid(Channel->Apid(0), true) - && SetPid(Channel->Apid(1), true) - && SetPid(Channel->Dpid(0), true); + Dprintf("PES\n"); + m_PESRemux = new cRemux(m_Channel->Vpid(), m_Channel->Apids(), m_Channel->Dpids(), + m_Channel->Spids(), false); + if (Apid != 0) + return SetPid(m_Channel->Vpid(), true) + && SetPid(Apid, true); + else + return SetPid(m_Channel->Vpid(), true) + && SetPid(m_Channel->Apid(0), true) + && SetPid(m_Channel->Dpid(0), true); case stPS: - m_Remux = new cTS2PSRemux(Channel->Vpid(), Channel->Apid(0), 0, 0, 0, true); - return SetPid(Channel->Vpid(), true) - && SetPid(Channel->Apid(0), true); + m_Remux = new cTS2PSRemux(m_Channel->Vpid(), m_Channel->Apid(0), 0, 0, 0, true); + return SetPid(m_Channel->Vpid(), true) + && SetPid(m_Channel->Apid(0), true); case stTS: - return SetPid(Channel->Vpid(), true) - && SetPid(Channel->Apid(0), true) - && SetPid(Channel->Apid(1), true) - && SetPid(Channel->Dpid(0), true); + if (Apid != 0) + return SetPid(m_Channel->Vpid(), true) + && SetPid(Apid, true); + else + return SetPid(m_Channel->Vpid(), true) + && SetPid(m_Channel->Apid(0), true) + && SetPid(m_Channel->Dpid(0), true); case stTSPIDS: Dprintf("pid streaming mode\n"); @@ -140,8 +141,8 @@ bool cStreamdevLiveStreamer::SetChannel(const cChannel *Channel, eStreamType Str return false; } -bool cStreamdevLiveStreamer::SetFilter(u_short Pid, u_char Tid, u_char Mask, - bool On) { +bool cStreamdevLiveStreamer::SetFilter(u_short Pid, u_char Tid, u_char Mask, bool On) +{ #if 0 Dprintf("setting filter\n"); if (On) { @@ -195,49 +196,19 @@ void cStreamdevLiveStreamer::Del(int Count) case stTS: case stTSPIDS: cStreamdevStreamer::Del(Count); + break; case stPES: m_PESRemux->Del(Count); + break; default: abort(); } } -// TODO: Remuxer einbinden -#if 0 -uchar *cStreamdevLiveStreamer::Process(const uchar *Data, int &Count, int &Result) { - uchar *remuxed = m_Remux != NULL ? m_Remux->Process(Data, Count, Result) - : cStreamdevStreamer::Process(Data, Count, Result); - if (remuxed) { - /*if (Socket()->Type() == SOCK_DGRAM) { - free(m_Buffer); - Result += 12; - m_Buffer = MALLOC(uchar, Result); - m_Buffer[0] = 0x01; - m_Buffer[1] = 0x02; - m_Buffer[2] = 0x03; - m_Buffer[3] = 0x04; - m_Buffer[4] = (Result & 0xff000000) >> 24; - m_Buffer[5] = (Result & 0xff0000) >> 16; - m_Buffer[6] = (Result & 0xff00) >> 8; - m_Buffer[7] = (Result & 0xff); - m_Buffer[8] = (m_Sequence & 0xff000000) >> 24; - m_Buffer[9] = (m_Sequence & 0xff0000) >> 16; - m_Buffer[10] = (m_Sequence & 0xff00) >> 8; - m_Buffer[11] = (m_Sequence & 0xff); - memcpy(m_Buffer + 12, Data, Result - 12); - if (m_Sequence++ == 0x7fffffff) - m_Sequence = 0; - return m_Buffer; - }*/ - return remuxed; - } - return NULL; -} -#endif - -std::string cStreamdevLiveStreamer::Report(void) { +std::string cStreamdevLiveStreamer::Report(void) +{ std::string result; if (m_Device != NULL) diff --git a/server/livestreamer.h b/server/livestreamer.h index 4e6632e..cd0cda6 100644 --- a/server/livestreamer.h +++ b/server/livestreamer.h @@ -8,13 +8,11 @@ #include "server/livefilter.h" #include "common.h" -#if MAXRECEIVEPIDS < 16 -# error Too few receiver pids allowed! Please contact sascha@akv-soft.de! -#endif - class cTSRemux; class cRemux; +// --- cStreamdevLiveReceiver ------------------------------------------------- + class cStreamdevLiveReceiver: public cReceiver { friend class cStreamdevLiveStreamer; @@ -26,11 +24,12 @@ protected: virtual void Receive(uchar *Data, int Length); public: - cStreamdevLiveReceiver(cStreamdevLiveStreamer *Streamer, int Ca, int Priority, - const int *Pids); + cStreamdevLiveReceiver(cStreamdevLiveStreamer *Streamer, int Ca, int Priority, const int *Pids); virtual ~cStreamdevLiveReceiver(); }; +// --- cStreamdevLiveStreamer ------------------------------------------------- + class cStreamdevLiveStreamer: public cStreamdevStreamer { private: int m_Priority; @@ -42,7 +41,6 @@ private: cStreamdevLiveReceiver *m_Receiver; cRemux *m_PESRemux; cTSRemux *m_Remux; - uchar *m_Buffer; public: cStreamdevLiveStreamer(int Priority); @@ -50,20 +48,26 @@ public: void SetDevice(cDevice *Device) { m_Device = Device; } bool SetPid(int Pid, bool On); - bool SetChannel(const cChannel *Channel, eStreamType StreamType); + bool SetChannel(const cChannel *Channel, eStreamType StreamType, int Apid = 0); bool SetFilter(u_short Pid, u_char Tid, u_char Mask, bool On); virtual int Put(const uchar *Data, int Count); virtual uchar *Get(int &Count); virtual void Del(int Count); - virtual void Detach(void); - virtual void Attach(void); + virtual void Attach(void) { Dprintf("attach %p\n", m_Device);m_Device->AttachReceiver(m_Receiver); } + virtual void Detach(void) { m_Device->Detach(m_Receiver); } - virtual void Start(cTBSocket *Socket); - // Statistical purposes: virtual std::string Report(void); }; +// --- cStreamdevLiveReceiver reverse inlines --------------------------------- + +inline void cStreamdevLiveReceiver::Activate(bool On) +{ + Dprintf("LiveReceiver->Activate()\n"); + m_Streamer->Activate(On); +} + #endif // VDR_STREAMDEV_LIVESTREAMER_H diff --git a/server/streamer.c b/server/streamer.c index eee3d63..2205f74 100644 --- a/server/streamer.c +++ b/server/streamer.c @@ -1,5 +1,5 @@ /* - * $Id: streamer.c,v 1.5 2005/02/09 19:47:09 lordjaxom Exp $ + * $Id: streamer.c,v 1.6 2005/02/10 22:24:26 lordjaxom Exp $ */ #include <vdr/ringbuffer.h> @@ -13,6 +13,8 @@ #include "tools/socket.h" #include "common.h" +// --- cStreamdevWriter ------------------------------------------------------- + cStreamdevWriter::cStreamdevWriter(cTBSocket *Socket, cStreamdevStreamer *Streamer): cThread("streamdev-writer"), m_Streamer(Streamer), @@ -29,6 +31,7 @@ cStreamdevWriter::~cStreamdevWriter() void cStreamdevWriter::Action(void) { + Dprintf("Writer start\n"); int max = 0; m_Active = true; while (m_Active) { @@ -49,13 +52,15 @@ void cStreamdevWriter::Action(void) Dprintf("Max. Transmit Blocksize was: %d\n", max); } +// --- cStreamdevStreamer ----------------------------------------------------- + cStreamdevStreamer::cStreamdevStreamer(const char *Name): cThread(Name), m_Active(false), m_Writer(NULL), m_RingBuffer(new cRingBufferLinear(STREAMERBUFSIZE, TS_SIZE * 2, true, "streamdev-streamer")), - m_SendBuffer(new cRingBufferLinear(WRITERBUFSIZE, MAXTRANSMITBLOCKSIZE)) + m_SendBuffer(new cRingBufferLinear(WRITERBUFSIZE, TS_SIZE * 2)) { m_RingBuffer->SetTimeouts(0, 100); m_SendBuffer->SetTimeouts(0, 100); @@ -71,12 +76,14 @@ cStreamdevStreamer::~cStreamdevStreamer() void cStreamdevStreamer::Start(cTBSocket *Socket) { + Dprintf("start streamer\n"); m_Writer = new cStreamdevWriter(Socket, this); Attach(); } void cStreamdevStreamer::Activate(bool On) { + Dprintf("activate streamer\n"); if (On && !m_Active) { m_Writer->Start(); cThread::Start(); @@ -92,21 +99,6 @@ void cStreamdevStreamer::Stop(void) } } -int cStreamdevStreamer::Put(const uchar *Data, int Count) -{ - return m_SendBuffer->Put(Data, Count); -} - -uchar *cStreamdevStreamer::Get(int &Count) -{ - return m_SendBuffer->Get(Count); -} - -void cStreamdevStreamer::Del(int Count) -{ - return m_SendBuffer->Del(Count); -} - void cStreamdevStreamer::Action(void) { int max = 0; diff --git a/server/streamer.h b/server/streamer.h index ff6411d..4db30a8 100644 --- a/server/streamer.h +++ b/server/streamer.h @@ -1,5 +1,5 @@ /* - * $Id: streamer.h,v 1.3 2005/02/08 19:54:52 lordjaxom Exp $ + * $Id: streamer.h,v 1.4 2005/02/10 22:24:26 lordjaxom Exp $ */ #ifndef VDR_STREAMDEV_STREAMER_H @@ -12,10 +12,11 @@ class cTBSocket; class cStreamdevStreamer; -#define MAXTRANSMITBLOCKSIZE TS_SIZE*10 #define STREAMERBUFSIZE MEGABYTE(4) #define WRITERBUFSIZE KILOBYTE(192) +// --- cStreamdevWriter ------------------------------------------------------- + class cStreamdevWriter: public cThread { private: cStreamdevStreamer *m_Streamer; @@ -30,6 +31,8 @@ public: virtual ~cStreamdevWriter(); }; +// --- cStreamdevStreamer ----------------------------------------------------- + class cStreamdevStreamer: public cThread { private: bool m_Active; @@ -40,8 +43,6 @@ private: protected: virtual void Action(void); - //const cTBSocket *Socket(void) const { return m_Socket; } - public: cStreamdevStreamer(const char *Name); virtual ~cStreamdevStreamer(); @@ -53,9 +54,9 @@ public: int Receive(uchar *Data, int Length) { return m_RingBuffer->Put(Data, Length); } void ReportOverflow(int Bytes) { m_RingBuffer->ReportOverflow(Bytes); } - virtual int Put(const uchar *Data, int Count); - virtual uchar *Get(int &Count); - virtual void Del(int Count); + virtual int Put(const uchar *Data, int Count) { return m_SendBuffer->Put(Data, Count); } + virtual uchar *Get(int &Count) { return m_SendBuffer->Get(Count); } + virtual void Del(int Count) { m_SendBuffer->Del(Count); } virtual void Detach(void) = 0; virtual void Attach(void) = 0; |