MythTV  master
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
V4LRecorder Class Reference

Abstract base class for Video4Linux based recorders. More...

#include <v4lrecorder.h>

Inheritance diagram for V4LRecorder:
Inheritance graph
[legend]
Collaboration diagram for V4LRecorder:
Collaboration graph
[legend]

Public Member Functions

 V4LRecorder (TVRec *rec)
 
virtual ~V4LRecorder ()
 
void StopRecording (void) override
 StopRecording() signals to the recorder that it should stop recording and exit cleanly. More...
 
void SetOption (const QString &name, const QString &value) override
 Set an specific option. More...
 
void SetOption (const QString &name, int value) override
 handles the "wait_for_seqstart" option. More...
 
- Public Member Functions inherited from DTVRecorder
 DTVRecorder (TVRec *rec)
 
virtual ~DTVRecorder ()
 
void SetOptionsFromProfile (RecordingProfile *profile, const QString &videodev, const QString &, const QString &) override
 Sets basic recorder options. More...
 
bool IsErrored (void) override
 Tells us whether an unrecoverable error has been encountered. More...
 
long long GetFramesWritten (void) override
 Returns number of frames written to disk. More...
 
void SetVideoFilters (QString &) override
 Tells recorder which filters to use. More...
 
void Initialize (void) override
 This is called between SetOptionsFromProfile() and run() to initialize any devices, etc. More...
 
int GetVideoFd (void) override
 Returns file descriptor of recorder device. More...
 
virtual void SetStreamData (MPEGStreamData *data)
 
MPEGStreamDataGetStreamData (void) const
 
void Reset (void) override
 Reset the recorder to the startup state. More...
 
void ClearStatistics (void) override
 
RecordingQualityGetRecordingQuality (const RecordingInfo *) const override
 Returns a report about the current recordings quality. More...
 
void HandlePAT (const ProgramAssociationTable *) override
 
void HandleCAT (const ConditionalAccessTable *) override
 
void HandlePMT (uint progNum, const ProgramMapTable *) override
 
void HandleEncryptionStatus (uint, bool) override
 
void HandleSingleProgramPAT (ProgramAssociationTable *pat, bool insert) override
 
void HandleSingleProgramPMT (ProgramMapTable *pmt, bool insert) override
 
void HandleSTT (const SystemTimeTable *) override
 
void HandleVCT (uint, const VirtualChannelTable *) override
 
void HandleMGT (const MasterGuideTable *) override
 
void HandleTDT (const TimeDateTable *) override
 
void HandleNIT (const NetworkInformationTable *) override
 
void HandleSDT (uint, const ServiceDescriptionTable *) override
 
bool ProcessTSPacket (const TSPacket &tspacket) override
 
bool ProcessVideoTSPacket (const TSPacket &tspacket) override
 
bool ProcessAudioTSPacket (const TSPacket &tspacket) override
 
bool ProcessAVTSPacket (const TSPacket &tspacket)
 Common code for processing either audio or video packets. More...
 
- Public Member Functions inherited from RecorderBase
 RecorderBase (TVRec *rec)
 
virtual ~RecorderBase ()
 
void SetFrameRate (double rate)
 Sets the video frame rate. More...
 
void SetRecording (const RecordingInfo *pginfo)
 Changes the Recording from the one set initially with SetOptionsFromProfile(). More...
 
void SetRingBuffer (RingBuffer *rbuf)
 Tells recorder to use an externally created ringbuffer. More...
 
void SetBoolOption (const QString &name, bool value)
 Set an specific boolean option. More...
 
void SetNextRecording (const RecordingInfo *, RingBuffer *)
 Sets next recording info, to be applied as soon as practical. More...
 
void run (void) override=0
 run() starts the recording process, and does not exit until the recording is complete. More...
 
long long GetKeyframePosition (long long desired) const
 Returns closest keyframe position before the desired frame. More...
 
bool GetKeyframePositions (long long start, long long end, frm_pos_map_t &) const
 
bool GetKeyframeDurations (long long start, long long end, frm_pos_map_t &) const
 
virtual bool IsRecording (void)
 Tells whether the StartRecorder() loop is running. More...
 
virtual bool IsRecordingRequested (void)
 Tells us if StopRecording() has been called. More...
 
virtual void Pause (bool clear=true)
 Pause tells recorder to pause, it should not block. More...
 
virtual void Unpause (void)
 Unpause tells recorder to unpause. More...
 
virtual bool IsPaused (bool holding_lock=false) const
 Returns true iff recorder is paused. More...
 
virtual bool WaitForPause (int timeout=1000)
 WaitForPause blocks until recorder is actually paused, or timeout milliseconds elapse. More...
 
double GetFrameRate (void) const
 Returns the latest frame rate. More...
 
virtual bool CheckForRingBufferSwitch (void)
 If requested, switch to new RingBuffer/ProgramInfo objects. More...
 
void SavePositionMap (bool force=false, bool finished=false)
 Save the seektable to the DB. More...
 
- Public Member Functions inherited from MPEGStreamListener
virtual void HandleSplice (const SpliceInformationTable *)
 

Protected Member Functions

int OpenVBIDevice (void)
 
void CloseVBIDevice (void)
 
void RunVBIDevice (void)
 
virtual bool IsHelperRequested (void) const
 
virtual void FormatTT (struct VBIData *)
 
virtual void FormatCC (uint, uint)
 
- Protected Member Functions inherited from DTVRecorder
virtual void InitStreamData (void)
 
void FinishRecording (void) override
 Flushes the ringbuffer, and if this is not a live LiveTV recording saves the position map and filesize. More...
 
void ResetForNewFile (void) override
 
void HandleKeyframe (int64_t extra)
 This save the current frame to the position maps and handles ringbuffer switching. More...
 
void HandleTimestamps (int stream_id, int64_t pts, int64_t dts)
 
void UpdateFramesWritten (void)
 
void BufferedWrite (const TSPacket &tspacket, bool insert=false)
 
bool FindAudioKeyframes (const TSPacket *tspacket)
 
bool FindMPEG2Keyframes (const TSPacket *tspacket)
 Locates the keyframes and saves them to the position map. More...
 
bool FindH264Keyframes (const TSPacket *tspacket)
 This searches the TS packet to identify keyframes. More...
 
void HandleH264Keyframe (void)
 This save the current frame to the position maps and handles ringbuffer switching. More...
 
void FindPSKeyFrames (const uint8_t *buffer, uint len) override
 
bool FindOtherKeyframes (const TSPacket *tspacket)
 Non-Audio/Video data. More...
 
bool CheckCC (uint pid, uint cc)
 
virtual QString GetSIStandard (void) const
 
virtual void SetCAMPMT (const ProgramMapTable *)
 
virtual void UpdateCAMTimeOffset (void)
 
- Protected Member Functions inherited from RecorderBase
void SetIntOption (RecordingProfile *profile, const QString &name)
 Convenience function used to set integer options from a profile. More...
 
void SetStrOption (RecordingProfile *profile, const QString &name)
 Convenience function used to set QString options from a profile. More...
 
virtual bool PauseAndWait (int timeout=100)
 If m_request_pause is true, sets pause and blocks up to timeout milliseconds or until unpaused, whichever is sooner. More...
 
virtual void SetRecordingStatus (RecStatus::Type status, const QString &file, int line)
 
virtual void StartNewFile (void)
 
void SetPositionMapType (MarkTypes type)
 Set seektable type. More...
 
void AspectChange (uint aspect, long long frame)
 Note a change in aspect ratio in the recordedmark table. More...
 
void ResolutionChange (uint width, uint height, long long frame)
 Note a change in video size in the recordedmark table. More...
 
void FrameRateChange (uint framerate, long long frame)
 Note a change in video frame rate in the recordedmark table. More...
 
void VideoCodecChange (AVCodecID vCodec)
 Note a change in video codec. More...
 
void AudioCodecChange (AVCodecID aCodec)
 Note a change in audio codec. More...
 
void SetDuration (uint64_t duration)
 Note the total duration in the recordedmark table. More...
 
void SetTotalFrames (uint64_t total_frames)
 Note the total frames in the recordedmark table. More...
 
void TryWriteProgStartMark (const frm_pos_map_t &durationDeltaCopy)
 
- Protected Member Functions inherited from MPEGStreamListener
virtual ~MPEGStreamListener ()=default
 
- Protected Member Functions inherited from MPEGSingleProgramStreamListener
virtual ~MPEGSingleProgramStreamListener ()=default
 
- Protected Member Functions inherited from DVBMainStreamListener
virtual ~DVBMainStreamListener ()=default
 
- Protected Member Functions inherited from ATSCMainStreamListener
virtual ~ATSCMainStreamListener ()=default
 
- Protected Member Functions inherited from TSPacketListener
virtual ~TSPacketListener ()=default
 
- Protected Member Functions inherited from TSPacketListenerAV
virtual ~TSPacketListenerAV ()=default
 
- Protected Member Functions inherited from PSStreamListener
virtual ~PSStreamListener ()=default
 

Protected Attributes

QString m_audiodevice
 
QString m_vbidevice
 
int m_vbimode {VBIMode::None}
 
struct VBIDatam_pal_vbi_cb {nullptr}
 
struct vbim_pal_vbi_tt {nullptr}
 
uint m_ntsc_vbi_width {0}
 
uint m_ntsc_vbi_start_line {0}
 
uint m_ntsc_vbi_line_count {0}
 
VBI608Extractorm_vbi608 {nullptr}
 
VBIThreadm_vbi_thread {nullptr}
 
QList< struct txtbuffertype * > m_textbuffer
 
int m_vbi_fd {-1}
 
volatile bool m_request_helper {false}
 
- Protected Attributes inherited from DTVRecorder
int m_stream_fd {-1}
 
QString m_recording_type {"all"}
 
QTime m_audio_timer
 
uint32_t m_start_code {0xffffffff}
 
int m_first_keyframe {-1}
 
unsigned long long m_last_gop_seen {0}
 
unsigned long long m_last_seq_seen {0}
 
unsigned long long m_last_keyframe_seen {0}
 
unsigned int m_audio_bytes_remaining {0}
 
unsigned int m_video_bytes_remaining {0}
 
unsigned int m_other_bytes_remaining {0}
 
int m_progressive_sequence {0}
 
int m_repeat_pict {0}
 
bool m_pes_synced {false}
 
bool m_seen_sps {false}
 
H264Parser m_h264_parser
 
bool m_wait_for_keyframe_option {true}
 Wait for the a GOP/SEQ-start before sending data. More...
 
bool m_has_written_other_keyframe {false}
 
QString m_error
 non-empty iff irrecoverable recording error detected More...
 
MPEGStreamDatam_stream_data {nullptr}
 
bool m_buffer_packets {false}
 
vector< unsigned char > m_payload_buffer
 
QMutex m_pid_lock {QMutex::Recursive}
 
ProgramAssociationTablem_input_pat {nullptr}
 PAT on input side. More...
 
ProgramMapTablem_input_pmt {nullptr}
 PMT on input side. More...
 
bool m_has_no_av {false}
 
bool m_record_mpts {false}
 
bool m_record_mpts_only {false}
 
unsigned char m_stream_id [0x1fff+1]
 
unsigned char m_pid_status [0x1fff+1]
 
unsigned char m_continuity_counter [0x1fff+1]
 
vector< TSPacketm_scratch
 
int m_minimum_recording_quality
 
bool m_use_pts {false}
 
uint64_t m_ts_count [256]
 
int64_t m_ts_last [256]
 
int64_t m_ts_first [256]
 
QDateTime m_ts_first_dt [256]
 
QAtomicInt m_packet_count {0}
 
QAtomicInt m_continuity_error_count {0}
 
unsigned long long m_frames_seen_count {0}
 
unsigned long long m_frames_written_count {0}
 
double m_total_duration {0.0}
 
double m_td_base {0.0}
 
uint64_t m_td_tick_count {0}
 
FrameRate m_td_tick_framerate {0}
 
bool m_music_choice {false}
 
- Protected Attributes inherited from RecorderBase
TVRecm_tvrec {nullptr}
 
RingBufferm_ringBuffer {nullptr}
 
bool m_weMadeBuffer {true}
 
AVContainer m_containerFormat {formatUnknown}
 
AVCodecID m_primaryVideoCodec {AV_CODEC_ID_NONE}
 
AVCodecID m_primaryAudioCodec {AV_CODEC_ID_NONE}
 
QString m_videocodec {"rtjpeg"}
 
QString m_videodevice
 
bool m_ntsc {true}
 
bool m_ntsc_framerate {true}
 
double m_video_frame_rate {29.97}
 
uint m_videoAspect {0}
 
uint m_videoHeight {0}
 
uint m_videoWidth {0}
 
FrameRate m_frameRate {0}
 
RecordingInfom_curRecording {nullptr}
 
QMutex m_pauseLock
 
bool m_request_pause {false}
 
bool m_paused {false}
 
QWaitCondition m_pauseWait
 
QWaitCondition m_unpauseWait
 
bool m_request_recording {false}
 True if API call has requested a recording be [re]started. More...
 
bool m_recording {false}
 True while recording is actually being performed. More...
 
QWaitCondition m_recordingWait
 
QMutex m_nextRingBufferLock
 
RingBufferm_nextRingBuffer {nullptr}
 
RecordingInfom_nextRecording {nullptr}
 
MythTimer m_ringBufferCheckTimer
 
MarkTypes m_positionMapType {MARK_GOP_BYFRAME}
 
QMutex m_positionMapLock
 
frm_pos_map_t m_positionMap
 
frm_pos_map_t m_positionMapDelta
 
frm_pos_map_t m_durationMap
 
frm_pos_map_t m_durationMapDelta
 
MythTimer m_positionMapTimer
 
qint64 m_estimatedProgStartMS {0}
 
long long m_lastSavedKeyframe {0}
 
long long m_lastSavedDuration {0}
 
QMutex m_statisticsLock
 
QAtomicInt m_timeOfFirstDataIsSet
 
QDateTime m_timeOfFirstData
 
QAtomicInt m_timeOfLatestDataCount
 
QAtomicInt m_timeOfLatestDataPacketInterval
 
QDateTime m_timeOfLatestData
 
MythTimer m_timeOfLatestDataTimer
 
RecordingGaps m_recordingGaps
 

Friends

class VBIThread
 

Additional Inherited Members

- Public Types inherited from RecorderBase
enum  AspectRatio {
  ASPECT_UNKNOWN = 0x00, ASPECT_1_1 = 0x01, ASPECT_4_3 = 0x02, ASPECT_16_9 = 0x03,
  ASPECT_2_21_1 = 0x04, ASPECT_CUSTOM = 0x05
}
 
- Static Public Member Functions inherited from RecorderBase
static RecorderBaseCreateRecorder (TVRec *tvrec, ChannelBase *channel, const RecordingProfile &profile, const GeneralDBOptions &genOpt)
 
- Static Protected Attributes inherited from DTVRecorder
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. More...
 
static const unsigned char kPayloadStartSeen = 0x2
 
- Static Protected Attributes inherited from RecorderBase
static const uint kTimeOfLatestDataIntervalTarget = 5000
 timeOfLatest update interval target in milliseconds. More...
 

Detailed Description

Abstract base class for Video4Linux based recorders.

Definition at line 24 of file v4lrecorder.h.

Constructor & Destructor Documentation

◆ V4LRecorder()

V4LRecorder::V4LRecorder ( TVRec rec)
inlineexplicit

Definition at line 28 of file v4lrecorder.h.

◆ ~V4LRecorder()

V4LRecorder::~V4LRecorder ( )
virtual

Definition at line 29 of file v4lrecorder.cpp.

Member Function Documentation

◆ StopRecording()

void V4LRecorder::StopRecording ( void  )
overridevirtual

StopRecording() signals to the recorder that it should stop recording and exit cleanly.

This function should block until recorder has finished up.

Reimplemented from RecorderBase.

Definition at line 46 of file v4lrecorder.cpp.

Referenced by NuppelVideoRecorder::doWriteThread(), and VBIThread::~VBIThread().

◆ SetOption() [1/2]

void V4LRecorder::SetOption ( const QString &  name,
const QString &  value 
)
overridevirtual

Set an specific option.

Base options include: codec, videodevice, tvformat (ntsc,ntsc-jp,pal-m), vbiformat ("none","pal teletext","ntsc").

Reimplemented from DTVRecorder.

Definition at line 59 of file v4lrecorder.cpp.

Referenced by V4L2encRecorder::SetIntOption(), MpegRecorder::SetOption(), NuppelVideoRecorder::SetOption(), V4L2encRecorder::SetOptionsFromProfile(), and V4L2encRecorder::SetStrOption().

◆ SetOption() [2/2]

void V4LRecorder::SetOption ( const QString &  name,
int  value 
)
inlineoverridevirtual

handles the "wait_for_seqstart" option.

Reimplemented from DTVRecorder.

Definition at line 33 of file v4lrecorder.h.

◆ OpenVBIDevice()

int V4LRecorder::OpenVBIDevice ( void  )
protected

Definition at line 96 of file v4lrecorder.cpp.

Referenced by NuppelVideoRecorder::run().

◆ CloseVBIDevice()

void V4LRecorder::CloseVBIDevice ( void  )
protected

Definition at line 225 of file v4lrecorder.cpp.

Referenced by NuppelVideoRecorder::KillChildren(), and ~V4LRecorder().

◆ RunVBIDevice()

void V4LRecorder::RunVBIDevice ( void  )
protected

Definition at line 246 of file v4lrecorder.cpp.

Referenced by VBIThread::run().

◆ IsHelperRequested()

bool V4LRecorder::IsHelperRequested ( void  ) const
protectedvirtual

◆ FormatTT()

virtual void V4LRecorder::FormatTT ( struct VBIData )
inlineprotectedvirtual

Reimplemented in NuppelVideoRecorder.

Definition at line 42 of file v4lrecorder.h.

Referenced by RunVBIDevice().

◆ FormatCC()

virtual void V4LRecorder::FormatCC ( uint  ,
uint   
)
inlineprotectedvirtual

Reimplemented in NuppelVideoRecorder, and MpegRecorder.

Definition at line 43 of file v4lrecorder.h.

Referenced by RunVBIDevice().

Friends And Related Function Documentation

◆ VBIThread

friend class VBIThread
friend

Definition at line 26 of file v4lrecorder.h.

Referenced by NuppelVideoRecorder::run().

Member Data Documentation

◆ m_audiodevice

QString V4LRecorder::m_audiodevice
protected

◆ m_vbidevice

QString V4LRecorder::m_vbidevice
protected

Definition at line 47 of file v4lrecorder.h.

Referenced by OpenVBIDevice(), and SetOption().

◆ m_vbimode

int V4LRecorder::m_vbimode {VBIMode::None}
protected

◆ m_pal_vbi_cb

struct VBIData* V4LRecorder::m_pal_vbi_cb {nullptr}
protected

Definition at line 49 of file v4lrecorder.h.

Referenced by CloseVBIDevice(), OpenVBIDevice(), and RunVBIDevice().

◆ m_pal_vbi_tt

struct vbi* V4LRecorder::m_pal_vbi_tt {nullptr}
protected

Definition at line 50 of file v4lrecorder.h.

Referenced by CloseVBIDevice(), OpenVBIDevice(), and RunVBIDevice().

◆ m_ntsc_vbi_width

uint V4LRecorder::m_ntsc_vbi_width {0}
protected

Definition at line 51 of file v4lrecorder.h.

Referenced by OpenVBIDevice(), and RunVBIDevice().

◆ m_ntsc_vbi_start_line

uint V4LRecorder::m_ntsc_vbi_start_line {0}
protected

Definition at line 52 of file v4lrecorder.h.

Referenced by OpenVBIDevice(), and RunVBIDevice().

◆ m_ntsc_vbi_line_count

uint V4LRecorder::m_ntsc_vbi_line_count {0}
protected

Definition at line 53 of file v4lrecorder.h.

Referenced by OpenVBIDevice(), and RunVBIDevice().

◆ m_vbi608

VBI608Extractor* V4LRecorder::m_vbi608 {nullptr}
protected

Definition at line 54 of file v4lrecorder.h.

Referenced by CloseVBIDevice(), OpenVBIDevice(), and RunVBIDevice().

◆ m_vbi_thread

VBIThread* V4LRecorder::m_vbi_thread {nullptr}
protected

◆ m_textbuffer

QList<struct txtbuffertype*> V4LRecorder::m_textbuffer
protected

Definition at line 56 of file v4lrecorder.h.

◆ m_vbi_fd

int V4LRecorder::m_vbi_fd {-1}
protected

Definition at line 57 of file v4lrecorder.h.

Referenced by CloseVBIDevice(), OpenVBIDevice(), and RunVBIDevice().

◆ m_request_helper

volatile bool V4LRecorder::m_request_helper {false}
protected

The documentation for this class was generated from the following files: