00001
00007 #ifndef DBOX2RECORDER_H_
00008 #define DBOX2RECORDER_H_
00009
00010
00011 #include <time.h>
00012
00013
00014 #include "dtvrecorder.h"
00015
00016 class DBox2Channel;
00017 class QHttp;
00018
00019 typedef struct stream_meta_
00020 {
00021 int socket;
00022 int bufferIndex;
00023 unsigned char *buffer;
00024 } stream_meta;
00025
00026 class DBox2Recorder;
00027 class DBox2Relay : public QObject
00028 {
00029 Q_OBJECT
00030
00031 public:
00032 DBox2Relay(DBox2Recorder *rec) : m_rec(rec) {}
00033 void SetRecorder(DBox2Recorder*);
00034
00035 public slots:
00036 void httpRequestFinished(int id, bool error);
00037
00038 private:
00039 DBox2Recorder *m_rec;
00040 QMutex m_lock;
00041 };
00042
00043 class DBox2Recorder : public DTVRecorder
00044 {
00045 friend class DBox2Relay;
00046
00047 public:
00048 DBox2Recorder(TVRec *rec, DBox2Channel *channel);
00049 ~DBox2Recorder() { TeardownAll(); }
00050
00051
00052 void SetOption(const QString &name, const QString &value);
00053 void SetOption(const QString &name, int value);
00054 void SetOptionsFromProfile(RecordingProfile *profile,
00055 const QString &videodev,
00056 const QString &audiodev,
00057 const QString &vbidev);
00058
00059
00060 void StartRecording(void);
00061 bool Open(void);
00062 void ChannelChanged(void);
00063 void ChannelChanging(void);
00064
00065 private:
00066
00067 void httpRequestFinished(int id, bool error);
00068 void TeardownAll(void);
00069 void CreatePAT(unsigned char *ts_packet);
00070 int getPMTSectionID(unsigned char *buffer, int pmtPID);
00071 void updatePMTSectionID(unsigned char *buffer, int pmtPID);
00072 int processStream(stream_meta *stream);
00073 void initStream(stream_meta *meta);
00074 int OpenStream(void);
00075 bool RequestStream(void);
00076 bool RequestInfo(void);
00077 int findTSHeader(unsigned char *buffer, int len);
00078 void Close(void);
00079 void ProcessTSPacket(unsigned char *tspacket, int len);
00080
00081 private:
00082
00083 int m_cardid;
00084 unsigned char *m_patPacket;
00085 int pat_cc;
00086 int pkts_until_pat;
00087 int m_pidPAT;
00088 vector<int> m_pids;
00089 int m_pmtPID;
00090 int m_ac3PID;
00091 int m_sectionID;
00092 DBox2Channel *m_channel;
00093
00094
00095 int port;
00096 int httpPort;
00097 QString ip;
00098 bool isOpen;
00099 QHttp *http;
00100 DBox2Relay *m_relay;
00101 int m_lastPIDRequestID;
00102 int m_lastInfoRequestID;
00103 time_t lastpacket;
00104 int bufferSize;
00105 stream_meta transportStream;
00106 int m_videoWidth;
00107 int m_videoHeight;
00108 QString m_videoFormat;
00109 bool _request_abort;
00110 };
00111
00112 #endif