6 #include <libsig_comp.h>
7 #include <lib/dvb/dvb.h>
8 #include <lib/base/ebase.h>
9 #include <lib/base/message.h>
10 #include <lib/base/thread.h>
11 #include <lib/base/eerror.h>
12 #include <lib/base/estring.h>
13 #include <lib/base/buffer.h>
17 #define RECORD_TELETEXT
18 #define RECORD_SUBTITLES
21 * \brief The DVBRecorder
23 * A class which can record a TS consisting of given pids. The
24 * recorder runs in a seperate thread and can be controlled
25 * asynchronously. Internally this is done with a \c eMessagePump.
26 * \todo Howto disable this warning?
29 class eDVBRecorder
: private eThread
, public Object
31 enum { stateRunning
= 1, stateStopped
= 0, stateError
= 2 }state
;
32 struct eDVBRecorderMessage
36 rWriteError
// disk full etc.
48 eDVBRecorderMessage() { }
49 eDVBRecorderMessage(eCode code
): code(code
) { }
50 eDVBRecorderMessage(eCode code
, const char *filename
): code(code
), filename(filename
) { }
51 eDVBRecorderMessage(eCode code
, int pid
): code(code
), pid(pid
) { }
52 eDVBRecorderMessage(eCode code
, void *data
, int len
): code(code
) { write
.data
=data
; write
.len
=len
; }
59 bool operator < (const pid_t
&p
) const
65 std::set
<pid_t
> pids
, newpids
;
66 eFixedMessagePump
<eDVBRecorderMessage
> rmessagepump
;
68 off64_t splitsize
, size
;
69 int splits
, dvrfd
, outfd
;
76 int written_since_last_sync
;
78 void gotBackMessage(const eDVBRecorderMessage
&msg
);
79 inline int flushBuffer();
80 int openFile(int suffix
=0);
82 __u8
*PmtData
, *PatData
;
83 unsigned int PmtCC
, PatCC
;
87 void PMTready(int error
);
91 eDVBRecorder(PMT
*, PAT
*);
95 void setWritePatPmtFlag() { writePatPmt
=true; }
97 eString
getFilename() { return filename
; }
100 * \brief Opens a file
102 * This call will open a new filename. It will close open files.
103 * \param filename Pointer to a filename. Existing files will be deleted. (life is cruel)
105 void open(const char *filename
);
110 * This call will add a PID to record. Recording doesn't start until using \c start().
111 * \sa eDVBRecorder::start
113 std::pair
<std::set
<eDVBRecorder::pid_t
>::iterator
,bool> addPID(int pid
, int flags
=0);
116 * \brief Removes a PID.
118 * This call will remove a PID.
120 void removePID(int pid
);
123 * \brief Start recording.
125 * This call will start the recording. You can stop it with \c stop().
126 * \sa eDVBRecorder::stop
131 * \brief Stop recording.
133 * This call will pause the recording. You can restart it (and append data) with \c start again.
138 * \brief Closes recording file.
140 * This will close the recorded file.
145 * \brief Writes a section into the stream.
147 * This will generate aligned ts packets and thus write a section to the stream. CRC must be calculated by caller.
148 * File must be already opened.
149 * Len will be fetched out of table.
151 void writeSection(void *data
, int pid
, unsigned int &cc
);
154 * \brief Adds a PID to running recording.
156 * This call will add a new PID to a running record. After add all new PIDs .. \c validatePIDs() must be called.
157 * \sa eDVBRecorder::addNewPID
159 void addNewPID(int pid
, int flags
=0);
162 * \brief Validate all PIDs.
164 * This call will remove all PID they never contains in the pmt, and add all new PIDs. All PIDs must set with \c addNewPID before.
165 * \sa eDVBRecorder::validatePIDs
169 enum { recWriteError
};
170 Signal1
<void,int> recMessage
;
171 eServiceReferenceDVB recRef
;
173 void SetSlice(int slice
);
178 #endif //DISABLE_FILE