Skip to content

Commit

Permalink
Adds RTPDataPacket/RTPFECPacket/RTPTSPacket stubs.
Browse files Browse the repository at this point in the history
This adds some implementation code as well, but it's really just there to help me flesh out the interfaces.
  • Loading branch information
daniel-kristjansson committed Feb 16, 2012
1 parent 3c4daaf commit 5eeee9c
Show file tree
Hide file tree
Showing 15 changed files with 582 additions and 132 deletions.
2 changes: 1 addition & 1 deletion mythtv/libs/libmythtv/dtvrecorder.h
Expand Up @@ -52,7 +52,7 @@ class DTVRecorder :

virtual void SetNextRecording(const ProgramInfo*, RingBuffer*);
virtual void SetStreamData(void);
void SetStreamData(MPEGStreamData* sd);
virtual void SetStreamData(MPEGStreamData* sd);
MPEGStreamData *GetStreamData(void) const { return _stream_data; }

virtual void Reset(void);
Expand Down
26 changes: 18 additions & 8 deletions mythtv/libs/libmythtv/iptvchannel.cpp
Expand Up @@ -8,14 +8,15 @@

// MythTV headers
#include "iptvstreamhandler.h"
#include "iptvrecorder.h"
#include "iptvchannel.h"
#include "mythlogging.h"
#include "mythdb.h"

#define LOC QString("IPTVChan(%1): ").arg(GetCardID())

IPTVChannel::IPTVChannel(TVRec *rec) :
DTVChannel(rec), m_open(false)
IPTVChannel::IPTVChannel(TVRec *rec, const QString&) :
DTVChannel(rec), m_open(false), m_recorder(NULL)
{
LOG(VB_CHANNEL, LOG_INFO, LOC + "ctor");
}
Expand Down Expand Up @@ -47,6 +48,16 @@ bool IPTVChannel::Open(void)
return m_open;
}

void IPTVChannel::SetRecorder(IPTVRecorder *rec)
{
QMutexLocker locker(&m_lock);
if (m_recorder && m_stream_handler && m_recorder->GetStreamData())
m_stream_handler->RemoveListener(m_recorder->GetStreamData());
m_recorder = rec;
if (m_recorder && m_stream_handler && m_recorder->GetStreamData())
m_stream_handler->AddListener(m_recorder->GetStreamData());
}

void IPTVChannel::Close(void)
{
LOG(VB_GENERAL, LOG_INFO, LOC + "Close()");
Expand All @@ -72,13 +83,12 @@ bool IPTVChannel::Tune(const QString &freqid, int finetune)

QHostAddress addr(QHostAddress::Any);

int ports[3];
ports[0] = 5555;
ports[1] = -1;
ports[2] = -1;
int ports[3] = { 5555, -1, -1, };
int bitrate = 5000000;

QString channel_id = QString("%1!%2!%3!%4")
.arg(addr.toString()).arg(ports[0]).arg(ports[1]).arg(ports[2]);
QString channel_id = QString("%1!%2!%3!%4!%5")
.arg(addr.toString()).arg(ports[0]).arg(ports[1]).arg(ports[2])
.arg(bitrate);

if (m_stream_handler)
IPTVStreamHandler::Return(m_stream_handler);
Expand Down
14 changes: 10 additions & 4 deletions mythtv/libs/libmythtv/iptvchannel.h
Expand Up @@ -16,17 +16,22 @@
#include "dtvchannel.h"

class IPTVStreamHandler;
class IPTVRecorder;

class IPTVChannel : public DTVChannel
{
public:
IPTVChannel(TVRec*);
IPTVChannel(TVRec*, const QString&);
~IPTVChannel();

// Commands
bool Open(void);
void Close(void);
bool Tune(const QString &freqid, int finetune);
virtual bool Open(void);
virtual void Close(void);
virtual bool Tune(const QString &freqid, int finetune);
virtual bool Tune(const DTVMultiplex&, QString) { return false; }

// Sets
void SetRecorder(IPTVRecorder*);

// Gets
bool IsOpen(void) const;
Expand All @@ -36,6 +41,7 @@ class IPTVChannel : public DTVChannel
volatile bool m_open;
QString m_last_channel_id;
IPTVStreamHandler *m_stream_handler;
IPTVRecorder *m_recorder;
};

#endif // _IPTV_CHANNEL_H_
Expand Down
26 changes: 22 additions & 4 deletions mythtv/libs/libmythtv/iptvrecorder.cpp
Expand Up @@ -7,8 +7,9 @@
*/

// MythTV headers
#include "iptvrecorder.h"
#include "mpegstreamdata.h"
#include "iptvrecorder.h"
#include "iptvchannel.h"

#define LOC QString("IPTVRec: ")

Expand All @@ -34,6 +35,8 @@ bool IPTVRecorder::Open(void)

LOG(VB_RECORD, LOG_INFO, LOC + "opened successfully");

m_channel->SetRecorder(this);

return true;
}

Expand All @@ -45,9 +48,19 @@ bool IPTVRecorder::IsOpen(void) const
void IPTVRecorder::Close(void)
{
LOG(VB_RECORD, LOG_INFO, LOC + "Close()");

m_channel->SetRecorder(NULL);

m_open = false;
}

void IPTVRecorder::SetStreamData(MPEGStreamData *data)
{
DTVRecorder::SetStreamData(data);
if (m_open)
m_channel->SetRecorder(this);
}

void IPTVRecorder::run(void)
{
LOG(VB_RECORD, LOG_INFO, LOC + "run -- begin");
Expand Down Expand Up @@ -84,16 +97,21 @@ void IPTVRecorder::run(void)
if (!IsRecordingRequested())
break;

{ // sleep 100 milliseconds unless StopRecording() or Unpause()
// is called, just to avoid running this too often.
QMutexLocker locker(&pauseLock);
if (!request_recording || request_pause)
continue;
unpauseWait.wait(&pauseLock, 100);
}

if (!_input_pmt)
{
LOG(VB_GENERAL, LOG_WARNING, LOC +
"Recording will not commence until a PMT is set.");
usleep(5000);
continue;
}

// TODO IMPLEMENT -- RTP/UDP reading..
usleep(100 * 1000);
}

LOG(VB_RECORD, LOG_INFO, LOC + "run -- ending...");
Expand Down
8 changes: 5 additions & 3 deletions mythtv/libs/libmythtv/iptvrecorder.h
Expand Up @@ -21,11 +21,13 @@ class IPTVRecorder : public DTVRecorder
IPTVRecorder(TVRec*, IPTVChannel*);
~IPTVRecorder();

bool Open(void);
virtual bool Open(void); // RecorderBase
virtual void Close(void); // RecorderBase
bool IsOpen(void) const;
void Close(void);

virtual void run(void);
virtual void SetStreamData(MPEGStreamData*); // DTVRecorder

virtual void run(void); // QRunnable

private:
IPTVChannel *m_channel;
Expand Down

0 comments on commit 5eeee9c

Please sign in to comment.