diff options
author | Sascha Volkenandt <sascha@akv-soft.de> | 2004-01-02 23:13:00 +0100 |
---|---|---|
committer | Sascha Volkenandt <sascha@akv-soft.de> | 2004-01-02 23:13:00 +0100 |
commit | 4a775c82c82597c65345b3b1fdad71792ef2e486 (patch) | |
tree | d3a5fc2a34e6746f8d7ee51e793ff3645bf3e814 /receiver.c | |
download | vdr-plugin-osdpip-4a775c82c82597c65345b3b1fdad71792ef2e486.tar.gz vdr-plugin-osdpip-4a775c82c82597c65345b3b1fdad71792ef2e486.tar.bz2 |
Release version 0.0.1v0.0.1
- Initial revision.
Diffstat (limited to 'receiver.c')
-rw-r--r-- | receiver.c | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/receiver.c b/receiver.c new file mode 100644 index 0000000..22a481c --- /dev/null +++ b/receiver.c @@ -0,0 +1,56 @@ +#include "receiver.h" +#include "remux/ts2es.h" + +#include <vdr/channels.h> +#include <vdr/ringbuffer.h> + +cOsdPipReceiver::cOsdPipReceiver(const cChannel *Channel, + cRingBufferLinear *ESBuffer): + cReceiver(Channel->Ca(), 0, 2, Channel->Vpid(), Channel->Apid1()) { + m_TSBuffer = new cRingBufferLinear(MEGABYTE(3), TS_SIZE * 2, true); + m_ESBuffer = ESBuffer; + m_Remux = new cTS2ESRemux(Channel->Vpid()); + m_Active = false; +} + +cOsdPipReceiver::~cOsdPipReceiver() { + Detach(); + delete m_Remux; + delete m_TSBuffer; +} + +void cOsdPipReceiver::Activate(bool On) { + if (On) + Start(); + else if (m_Active) { + m_Active = false; + Cancel(3); + } +} + +void cOsdPipReceiver::Receive(uchar *Data, int Length) { + int put = m_TSBuffer->Put(Data, Length); + if (put != Length) + esyslog("osdpip: ringbuffer overflow (%d bytes dropped)", Length - put); +} + +void cOsdPipReceiver::Action(void) { + dsyslog("osdpip: receiver thread started (pid=%d)", getpid()); + + m_Active = true; + while (m_Active) { + int r; + const uchar *b = m_TSBuffer->Get(r); + if (b) { + int Count = r, Result; + uchar *p = m_Remux->Process(b, Count, Result); + m_TSBuffer->Del(Count); + + if (p) + m_ESBuffer->Put(p, Result); + } else + usleep(1); // this keeps the CPU load low + } + + dsyslog("osdpip: receiver thread ended (pid=%d)", getpid()); +} |