#include <dtvrecorder.h>

Definition at line 24 of file dtvrecorder.h.
Public Member Functions | |
| DTVRecorder (TVRec *rec) | |
| ~DTVRecorder () | |
| virtual void | SetOption (const QString &opt, const QString &value) |
| Set an specific option. | |
| virtual void | SetOption (const QString &name, int value) |
| handles the "wait_for_seqstart" and "pkt_buf_size" options. | |
| virtual void | StopRecording (void) |
| StopRecording() signals to the StartRecording() function that it should stop recording and exit cleanly. | |
| bool | IsRecording (void) |
| Tells whether the StartRecorder() loop is running. | |
| bool | IsErrored (void) |
| Tells us whether an unrecoverable error has been encountered. | |
| long long | GetKeyframePosition (long long desired) |
| Returns closest keyframe position before the desired frame. | |
| long long | GetFramesWritten (void) |
| Returns number of frames written to disk. | |
| void | SetVideoFilters (QString &) |
| Tells recorder which filters to use. | |
| void | Initialize (void) |
| This is called between SetOptionsFromProfile() and StartRecording() to initialize any devices, etc. | |
| int | GetVideoFd (void) |
| Returns file descriptor of recorder device. | |
| virtual void | SetNextRecording (const ProgramInfo *, RingBuffer *) |
| Sets next recording info, to be applied as soon as practical. | |
| virtual void | SetStreamData (MPEGStreamData *) |
| virtual MPEGStreamData * | GetStreamData (void) |
| virtual void | Reset () |
| Reset the recorder to the startup state. | |
Protected Member Functions | |
| void | FinishRecording (void) |
| Flushes the ringbuffer, and if this is not a live LiveTV recording saves the position map and filesize. | |
| void | ResetForNewFile (void) |
| void | HandleKeyframe () |
| This save the current frame to the position maps and handles ringbuffer switching. | |
| void | BufferedWrite (const TSPacket &tspacket) |
| bool | FindAudioKeyframes (const TSPacket *tspacket) |
| bool | FindMPEG2Keyframes (const TSPacket *tspacket) |
| Locates the keyframes and saves them to the position map. | |
| bool | FindH264Keyframes (const TSPacket *tspacket) |
| This searches the TS packet to identify keyframes. | |
| void | HandleH264Keyframe (void) |
| This save the current frame to the position maps and handles ringbuffer switching. | |
| bool | FindOtherKeyframes (const TSPacket *tspacket) |
| Non-Audio/Video data. | |
Protected Attributes | |
| int | _stream_fd |
| QString | _recording_type |
| QTime | _audio_timer |
| uint32_t | _start_code |
| int | _first_keyframe |
| unsigned long long | _last_gop_seen |
| unsigned long long | _last_seq_seen |
| unsigned long long | _last_keyframe_seen |
| bool | _pes_synced |
| bool | _seen_sps |
| H264::KeyframeSequencer | _h264_kf_seq |
| bool | _request_recording |
| True if API call has requested a recording be [re]started. | |
| bool | _wait_for_keyframe_option |
| Wait for the a GOP/SEQ-start before sending data. | |
| bool | _has_written_other_keyframe |
| bool | _recording |
| True iff recording is actually being performed. | |
| bool | _error |
| True iff irrecoverable recording error detected. | |
| unsigned char * | _buffer |
| int | _buffer_size |
| bool | _buffer_packets |
| vector< unsigned char > | _payload_buffer |
| unsigned long long | _frames_seen_count |
| unsigned long long | _frames_written_count |
Static Protected Attributes | |
| static const uint | kMaxKeyFrameDistance = 80 |
| If the number of regular frames detected since the last detected keyframe exceeds this value, then we begin marking random regular frames as keyframes. | |
| DTVRecorder::DTVRecorder | ( | TVRec * | rec | ) |
Definition at line 33 of file dtvrecorder.cpp.
| DTVRecorder::~DTVRecorder | ( | ) |
Definition at line 62 of file dtvrecorder.cpp.
| void DTVRecorder::SetOption | ( | const QString & | opt, | |
| const QString & | value | |||
| ) | [virtual] |
Set an specific option.
Base options include: codec, audiodevice, videodevice, vbidevice, tvformat (ntsc,ntsc-jp,pal-m), vbiformat ("none","pal teletext","ntsc").
Reimplemented from RecorderBase.
Reimplemented in DBox2Recorder.
Definition at line 66 of file dtvrecorder.cpp.
Referenced by DVBRecorder::SetOption(), HDHRRecorder::SetOptionsFromProfile(), and DVBRecorder::SetOptionsFromProfile().
| void DTVRecorder::SetOption | ( | const QString & | name, | |
| int | value | |||
| ) | [virtual] |
handles the "wait_for_seqstart" and "pkt_buf_size" options.
Reimplemented from RecorderBase.
Reimplemented in DBox2Recorder, and DVBRecorder.
Definition at line 77 of file dtvrecorder.cpp.
| virtual void DTVRecorder::StopRecording | ( | void | ) | [inline, virtual] |
StopRecording() signals to the StartRecording() function that it should stop recording and exit cleanly.
This function should block until StartRecording() has finished up.
Implements RecorderBase.
Reimplemented in DVBRecorder, and IPTVRecorder.
Definition at line 33 of file dtvrecorder.h.
Referenced by HDHRRecorder::TeardownAll().
| bool DTVRecorder::IsRecording | ( | void | ) | [inline, virtual] |
Tells whether the StartRecorder() loop is running.
Implements RecorderBase.
Definition at line 34 of file dtvrecorder.h.
| bool DTVRecorder::IsErrored | ( | void | ) | [inline, virtual] |
Tells us whether an unrecoverable error has been encountered.
Implements RecorderBase.
Definition at line 35 of file dtvrecorder.h.
| long long DTVRecorder::GetKeyframePosition | ( | long long | desired | ) | [virtual] |
Returns closest keyframe position before the desired frame.
This returns -1 if a keyframe position can not be found for a frame. This could be true if the keyframe has not yet been seen by the recorder(unlikely), or if a keyframe map does not exist or is not up to date. The latter can happen because the video is an external video, because the database is corrupted, or because this is a live recording and it is being read by a remote frontend faster than the keyframes can be saved to the database.
Implements RecorderBase.
Definition at line 132 of file dtvrecorder.cpp.
| long long DTVRecorder::GetFramesWritten | ( | void | ) | [inline, virtual] |
Returns number of frames written to disk.
It is not always safe to seek up to this frame in a player because frames may not be written in display order.
Implements RecorderBase.
Definition at line 38 of file dtvrecorder.h.
| void DTVRecorder::SetVideoFilters | ( | QString & | filters | ) | [inline, virtual] |
Tells recorder which filters to use.
These filters are used by frame grabber encoders to lower the bitrate while keeping quality good. They must execute quickly so that frames are not lost by the recorder.
Implements RecorderBase.
Definition at line 40 of file dtvrecorder.h.
| void DTVRecorder::Initialize | ( | void | ) | [inline, virtual] |
This is called between SetOptionsFromProfile() and StartRecording() to initialize any devices, etc.
Implements RecorderBase.
Definition at line 41 of file dtvrecorder.h.
| int DTVRecorder::GetVideoFd | ( | void | ) | [inline, virtual] |
Returns file descriptor of recorder device.
This is used by channel when only one open file descriptor is allowed on a device node. This is the case with video4linux devices and similar devices in BSD. It is not needed by newer drivers, such as those used for DVB.
Implements RecorderBase.
Definition at line 42 of file dtvrecorder.h.
| void DTVRecorder::SetNextRecording | ( | const ProgramInfo * | , | |
| RingBuffer * | ||||
| ) | [virtual] |
Sets next recording info, to be applied as soon as practical.
This should not lose any frames on the switchover, and should initialize the RingBuffer stream with headers as appropriate.
The switch does not have to happen immediately, but should happen soon. (i.e. it can wait for a key frame..)
This calls TVRec::RingBufferChanged() when the switch happens.
Implements RecorderBase.
Definition at line 374 of file dtvrecorder.cpp.
| virtual void DTVRecorder::SetStreamData | ( | MPEGStreamData * | ) | [inline, virtual] |
Reimplemented in DVBRecorder, FirewireRecorder, HDHRRecorder, and IPTVRecorder.
Definition at line 45 of file dtvrecorder.h.
Referenced by TVRec::SetupDTVSignalMonitor(), and TVRec::TuningNewRecorder().
| virtual MPEGStreamData* DTVRecorder::GetStreamData | ( | void | ) | [inline, virtual] |
Reimplemented in DVBRecorder, FirewireRecorder, HDHRRecorder, and IPTVRecorder.
Definition at line 46 of file dtvrecorder.h.
Referenced by FindAudioKeyframes(), FindOtherKeyframes(), TVRec::SetupDTVSignalMonitor(), TVRec::TuningFrequency(), TVRec::TuningOnSameMultiplex(), and TVRec::TuningShutdowns().
| void DTVRecorder::Reset | ( | ) | [virtual] |
Reset the recorder to the startup state.
This is used after Pause(bool), WaitForPause() and after the RingBuffer's StopReads() method has been called.
Implements RecorderBase.
Definition at line 169 of file dtvrecorder.cpp.
| void DTVRecorder::FinishRecording | ( | void | ) | [protected, virtual] |
Flushes the ringbuffer, and if this is not a live LiveTV recording saves the position map and filesize.
Implements RecorderBase.
Definition at line 107 of file dtvrecorder.cpp.
Referenced by IPTVRecorder::StartRecording(), HDHRRecorder::StartRecording(), FirewireRecorder::StartRecording(), DVBRecorder::StartRecording(), and DBox2Recorder::StartRecording().
| void DTVRecorder::ResetForNewFile | ( | void | ) | [protected, virtual] |
Implements RecorderBase.
Reimplemented in DVBRecorder.
Definition at line 143 of file dtvrecorder.cpp.
Referenced by Reset(), and DVBRecorder::ResetForNewFile().
| void DTVRecorder::HandleKeyframe | ( | void | ) | [protected] |
This save the current frame to the position maps and handles ringbuffer switching.
Definition at line 401 of file dtvrecorder.cpp.
Referenced by FindAudioKeyframes(), FindMPEG2Keyframes(), and FindOtherKeyframes().
| void DTVRecorder::BufferedWrite | ( | const TSPacket & | tspacket | ) | [protected] |
Reimplemented in DVBRecorder.
Definition at line 180 of file dtvrecorder.cpp.
Referenced by IPTVRecorder::HandleSingleProgramPAT(), HDHRRecorder::HandleSingleProgramPAT(), FirewireRecorder::HandleSingleProgramPAT(), DVBRecorder::HandleSingleProgramPAT(), IPTVRecorder::HandleSingleProgramPMT(), HDHRRecorder::HandleSingleProgramPMT(), FirewireRecorder::HandleSingleProgramPMT(), DVBRecorder::HandleSingleProgramPMT(), DBox2Recorder::processStream(), IPTVRecorder::ProcessTSPacket(), HDHRRecorder::ProcessTSPacket(), and FirewireRecorder::ProcessTSPacket().
Definition at line 313 of file dtvrecorder.cpp.
Referenced by DVBRecorder::ProcessAudioTSPacket(), IPTVRecorder::ProcessTSPacket(), HDHRRecorder::ProcessTSPacket(), and FirewireRecorder::ProcessTSPacket().
Locates the keyframes and saves them to the position map.
This searches for three magic integers in the stream. The picture start code 0x00000100, the GOP code 0x000001B8, and the sequence start code 0x000001B3. The GOP code is prefered, but is only required of MPEG1 streams, the sequence start code is a decent fallback for MPEG2 streams, and if all else fails we just look for the picture start codes and call every 16th frame a keyframe.
NOTE: This does not only find keyframes but also tracks the total frames as well. At least a couple times seeking has been broken by short-circuiting the search once a keyframe stream id has been found. This may work on some channels, but will break on others so algorithmic optimizations should be done with great care.
PES header format byte 0 byte 1 byte 2 byte 3 [byte 4 byte 5] 0x00 0x00 0x01 PESStreamID PES packet length
Definition at line 234 of file dtvrecorder.cpp.
Referenced by DBox2Recorder::processStream(), IPTVRecorder::ProcessTSPacket(), HDHRRecorder::ProcessTSPacket(), FirewireRecorder::ProcessTSPacket(), and DVBRecorder::ProcessVideoTSPacket().
This searches the TS packet to identify keyframes.
| TSPacket | Pointer the the TS packet data. |
Definition at line 431 of file dtvrecorder.cpp.
Referenced by IPTVRecorder::ProcessTSPacket(), HDHRRecorder::ProcessTSPacket(), and DVBRecorder::ProcessVideoTSPacket().
| void DTVRecorder::HandleH264Keyframe | ( | void | ) | [protected] |
This save the current frame to the position maps and handles ringbuffer switching.
Definition at line 556 of file dtvrecorder.cpp.
Referenced by FindH264Keyframes().
Non-Audio/Video data.
For streams which contain no audio/video, write just 1 key-frame at the start.
Definition at line 351 of file dtvrecorder.cpp.
Referenced by DVBRecorder::ProcessTSPacket().
int DTVRecorder::_stream_fd [protected] |
Definition at line 72 of file dtvrecorder.h.
Referenced by DVBRecorder::Close(), GetVideoFd(), DVBRecorder::IsOpen(), and DVBRecorder::Open().
QString DTVRecorder::_recording_type [protected] |
QTime DTVRecorder::_audio_timer [protected] |
uint32_t DTVRecorder::_start_code [protected] |
Definition at line 78 of file dtvrecorder.h.
Referenced by FindH264Keyframes(), FindMPEG2Keyframes(), and Reset().
int DTVRecorder::_first_keyframe [protected] |
Definition at line 79 of file dtvrecorder.h.
Referenced by BufferedWrite(), FindAudioKeyframes(), FindH264Keyframes(), FindMPEG2Keyframes(), HandleH264Keyframe(), HandleKeyframe(), DVBRecorder::ProcessAVTSPacket(), DVBRecorder::ProcessTSPacket(), and ResetForNewFile().
unsigned long long DTVRecorder::_last_gop_seen [protected] |
Definition at line 80 of file dtvrecorder.h.
Referenced by FindMPEG2Keyframes(), and ResetForNewFile().
unsigned long long DTVRecorder::_last_seq_seen [protected] |
Definition at line 81 of file dtvrecorder.h.
Referenced by FindMPEG2Keyframes(), and ResetForNewFile().
unsigned long long DTVRecorder::_last_keyframe_seen [protected] |
Definition at line 82 of file dtvrecorder.h.
Referenced by FindAudioKeyframes(), FindH264Keyframes(), FindMPEG2Keyframes(), FindOtherKeyframes(), and ResetForNewFile().
bool DTVRecorder::_pes_synced [protected] |
Definition at line 85 of file dtvrecorder.h.
Referenced by FindH264Keyframes(), and ResetForNewFile().
bool DTVRecorder::_seen_sps [protected] |
Definition at line 86 of file dtvrecorder.h.
Referenced by FindH264Keyframes(), IPTVRecorder::ProcessTSPacket(), HDHRRecorder::ProcessTSPacket(), DVBRecorder::ProcessVideoTSPacket(), and ResetForNewFile().
H264::KeyframeSequencer DTVRecorder::_h264_kf_seq [protected] |
Definition at line 87 of file dtvrecorder.h.
Referenced by FindH264Keyframes(), HandleH264Keyframe(), and ResetForNewFile().
bool DTVRecorder::_request_recording [protected] |
True if API call has requested a recording be [re]started.
Definition at line 90 of file dtvrecorder.h.
Referenced by SetOption(), IPTVRecorder::StartRecording(), HDHRRecorder::StartRecording(), FirewireRecorder::StartRecording(), DVBRecorder::StartRecording(), DBox2Recorder::StartRecording(), IPTVRecorder::StopRecording(), DVBRecorder::StopRecording(), and StopRecording().
bool DTVRecorder::_wait_for_keyframe_option [protected] |
Wait for the a GOP/SEQ-start before sending data.
Definition at line 92 of file dtvrecorder.h.
Referenced by BufferedWrite(), FindAudioKeyframes(), FindH264Keyframes(), FindMPEG2Keyframes(), DVBRecorder::ProcessAVTSPacket(), HDHRRecorder::ProcessTSPacket(), DVBRecorder::ProcessTSPacket(), SetOption(), and DVBRecorder::StartRecording().
bool DTVRecorder::_has_written_other_keyframe [protected] |
Definition at line 94 of file dtvrecorder.h.
Referenced by FindOtherKeyframes(), and ResetForNewFile().
bool DTVRecorder::_recording [protected] |
True iff recording is actually being performed.
Definition at line 98 of file dtvrecorder.h.
Referenced by IsRecording(), IPTVRecorder::StartRecording(), HDHRRecorder::StartRecording(), FirewireRecorder::StartRecording(), DVBRecorder::StartRecording(), DBox2Recorder::StartRecording(), IPTVRecorder::StopRecording(), DVBRecorder::StopRecording(), and IPTVRecorder::Unpause().
bool DTVRecorder::_error [protected] |
True iff irrecoverable recording error detected.
Definition at line 100 of file dtvrecorder.h.
Referenced by IsErrored(), IPTVRecorder::Open(), ResetForNewFile(), IPTVRecorder::StartRecording(), HDHRRecorder::StartRecording(), FirewireRecorder::StartRecording(), DVBRecorder::StartRecording(), and DBox2Recorder::StartRecording().
unsigned char* DTVRecorder::_buffer [protected] |
Definition at line 103 of file dtvrecorder.h.
Referenced by DVBRecorder::DVBRecorder(), SetOption(), and DVBRecorder::TeardownAll().
int DTVRecorder::_buffer_size [protected] |
Definition at line 104 of file dtvrecorder.h.
Referenced by DVBRecorder::DVBRecorder(), and SetOption().
bool DTVRecorder::_buffer_packets [protected] |
Definition at line 107 of file dtvrecorder.h.
Referenced by DVBRecorder::BufferedWrite(), BufferedWrite(), DVBRecorder::ProcessAudioTSPacket(), DBox2Recorder::processStream(), IPTVRecorder::ProcessTSPacket(), HDHRRecorder::ProcessTSPacket(), FirewireRecorder::ProcessTSPacket(), DVBRecorder::ProcessTSPacket(), and DVBRecorder::ProcessVideoTSPacket().
vector<unsigned char> DTVRecorder::_payload_buffer [protected] |
Definition at line 108 of file dtvrecorder.h.
Referenced by DVBRecorder::BufferedWrite(), BufferedWrite(), FindH264Keyframes(), FindMPEG2Keyframes(), FinishRecording(), HandleKeyframe(), DVBRecorder::HandleSingleProgramPAT(), DVBRecorder::HandleSingleProgramPMT(), and ResetForNewFile().
unsigned long long DTVRecorder::_frames_seen_count [protected] |
Definition at line 111 of file dtvrecorder.h.
Referenced by FindAudioKeyframes(), FindH264Keyframes(), FindMPEG2Keyframes(), FindOtherKeyframes(), and ResetForNewFile().
unsigned long long DTVRecorder::_frames_written_count [protected] |
Definition at line 112 of file dtvrecorder.h.
Referenced by FindAudioKeyframes(), FindH264Keyframes(), FindMPEG2Keyframes(), FindOtherKeyframes(), GetFramesWritten(), HandleH264Keyframe(), HandleKeyframe(), and ResetForNewFile().
const uint DTVRecorder::kMaxKeyFrameDistance = 80 [static, protected] |
If the number of regular frames detected since the last detected keyframe exceeds this value, then we begin marking random regular frames as keyframes.
Definition at line 118 of file dtvrecorder.h.
Referenced by FindMPEG2Keyframes().
1.5.5