|
MythTV master
|
This is a specialization of DTVRecorder used to handle streams from V4L2 recorders. More...
#include <libmythtv/recorders/v4l2encrecorder.h>
Public Member Functions | |
| V4L2encRecorder (TVRec *rec, V4LChannel *channel) | |
| void | run (void) override |
| run() starts the recording process, and does not exit until the recording is complete. More... | |
| bool | Open (void) |
| bool | IsOpen (void) const |
| void | Close (void) |
| void | StartNewFile (void) override |
| bool | PauseAndWait (std::chrono::milliseconds timeout=500ms) override |
| If m_requestPause is true, sets pause and blocks up to timeout milliseconds or until unpaused, whichever is sooner. More... | |
Public Member Functions inherited from V4LRecorder | |
| V4LRecorder (TVRec *rec) | |
| ~V4LRecorder () override | |
| 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) | |
| ~DTVRecorder () override | |
| 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... | |
| void | SetOptionsFromProfile (RecordingProfile *profile, const QString &videodev, const QString &audiodev, const QString &vbidev) 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) |
| MPEGStreamData * | GetStreamData (void) const |
| void | Reset (void) override |
| Reset the recorder to the startup state. More... | |
| void | ClearStatistics (void) override |
| RecordingQuality * | GetRecordingQuality (const RecordingInfo *r) const override |
| Returns a report about the current recordings quality. More... | |
| void | HandlePAT (const ProgramAssociationTable *_pat) override |
| void | HandleCAT (const ConditionalAccessTable *) override |
| void | HandlePMT (uint progNum, const ProgramMapTable *_pmt) 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) | |
| ~RecorderBase () override | |
| 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 (MythMediaBuffer *Buffer) |
| Tells recorder to use an externally created ringbuffer. More... | |
| virtual void | SetOption (const QString &name, const QString &value) |
| Set an specific option. More... | |
| virtual void | SetOption (const QString &name, int value) |
| Set an specific integer option. More... | |
| void | SetBoolOption (const QString &name, bool value) |
| Set an specific boolean option. More... | |
| virtual void | SetVideoFilters (QString &filters)=0 |
| Tells recorder which filters to use. More... | |
| virtual void | SetOptionsFromProfile (RecordingProfile *profile, const QString &videodev, const QString &audiodev, const QString &vbidev)=0 |
| Sets basic recorder options. More... | |
| void | SetNextRecording (const RecordingInfo *ri, MythMediaBuffer *Buffer) |
| Sets next recording info, to be applied as soon as practical. More... | |
| virtual void | Initialize (void)=0 |
| This is called between SetOptionsFromProfile() and run() to initialize any devices, etc. More... | |
| void | run (void) override=0 |
| run() starts the recording process, and does not exit until the recording is complete. More... | |
| virtual void | Reset (void)=0 |
| Reset the recorder to the startup state. More... | |
| virtual bool | IsErrored (void)=0 |
| Tells us whether an unrecoverable error has been encountered. More... | |
| virtual long long | GetFramesWritten (void)=0 |
| Returns number of frames written to disk. More... | |
| virtual int | GetVideoFd (void)=0 |
| Returns file descriptor of recorder device. 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 &map) const |
| bool | GetKeyframeDurations (long long start, long long end, frm_pos_map_t &map) const |
| virtual void | StopRecording (void) |
| StopRecording() signals to the recorder that it should stop recording and exit cleanly. More... | |
| 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 RecordingQuality * | GetRecordingQuality (const RecordingInfo *ri) const |
| Returns a report about the current recordings quality. 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 (std::chrono::milliseconds timeout=1s) |
| 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 | HandlePAT (const ProgramAssociationTable *pat)=0 |
| virtual void | HandleCAT (const ConditionalAccessTable *cat)=0 |
| virtual void | HandlePMT (uint program_num, const ProgramMapTable *pmt)=0 |
| virtual void | HandleEncryptionStatus (uint program_number, bool encrypted)=0 |
| virtual void | HandleSplice (const SpliceInformationTable *) |
| virtual void | HandleSingleProgramPAT (ProgramAssociationTable *, bool insert)=0 |
| virtual void | HandleSingleProgramPMT (ProgramMapTable *, bool insert)=0 |
| virtual void | HandleTDT (const TimeDateTable *)=0 |
| virtual void | HandleNIT (const NetworkInformationTable *)=0 |
| virtual void | HandleSDT (uint tsid, const ServiceDescriptionTable *)=0 |
| virtual void | HandleSTT (const SystemTimeTable *)=0 |
| virtual void | HandleMGT (const MasterGuideTable *)=0 |
| virtual void | HandleVCT (uint pid, const VirtualChannelTable *)=0 |
| virtual bool | ProcessTSPacket (const TSPacket &tspacket)=0 |
| virtual bool | ProcessVideoTSPacket (const TSPacket &tspacket)=0 |
| virtual bool | ProcessAudioTSPacket (const TSPacket &tspacket)=0 |
| virtual void | FindPSKeyFrames (const uint8_t *buffer, uint len)=0 |
Protected Member Functions | |
| bool | StartEncoding (void) |
| bool | StopEncoding (void) |
| void | SetIntOption (RecordingProfile *profile, const QString &name) |
| void | SetStrOption (RecordingProfile *profile, const QString &name) |
| void | SetOptionsFromProfile (RecordingProfile *profile, const QString &videodev, const QString &audiodev, const QString &vbidev) override |
| Sets basic recorder options. More... | |
Protected Member Functions inherited from V4LRecorder | |
| int | OpenVBIDevice (void) |
| void | CloseVBIDevice (void) |
| void | RunVBIDevice (void) |
| virtual bool | IsHelperRequested (void) const |
| 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 | FindH2645Keyframes (const TSPacket *tspacket) |
| void | HandleH2645Keyframe (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 new_cnt) |
| 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 (std::chrono::milliseconds timeout=100ms) |
| If m_requestPause is true, sets pause and blocks up to timeout milliseconds or until unpaused, whichever is sooner. More... | |
| virtual void | ResetForNewFile (void)=0 |
| virtual void | SetRecordingStatus (RecStatus::Type status, const QString &file, int line) |
| virtual void | ClearStatistics (void) |
| virtual void | FinishRecording (void) |
| 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, uint64_t frame) |
| Note a change in video frame rate in the recordedmark table. More... | |
| void | VideoScanChange (SCAN_t scan, uint64_t frame) |
| Note a change in video scan type 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 (std::chrono::milliseconds 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 |
Private Attributes | |
| V4LChannel * | m_channel {nullptr} |
| V4L2encStreamHandler * | m_streamHandler {nullptr} |
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 RecorderBase * | CreateRecorder (TVRec *tvrec, ChannelBase *channel, RecordingProfile &profile, const GeneralDBOptions &genOpt) |
Protected Attributes inherited from V4LRecorder | |
| QString | m_audioDeviceName |
| QString | m_vbiDeviceName |
| int | m_vbiMode {VBIMode::None} |
| uint | m_ntscVbiWidth {0} |
| uint | m_ntscVbiStartLine {0} |
| uint | m_ntscVbiLineCount {0} |
| VBI608Extractor * | m_vbi608 {nullptr} |
| VBIThread * | m_vbiThread {nullptr} |
| int | m_vbiFd {-1} |
| volatile bool | m_requestHelper {false} |
Protected Attributes inherited from DTVRecorder | |
| int | m_streamFd {-1} |
| QString | m_recordingType {"all"} |
| MythTimer | m_pesTimer |
| QElapsedTimer | m_audioTimer |
| uint32_t | m_startCode {0xffffffff} |
| int | m_firstKeyframe {-1} |
| unsigned long long | m_lastGopSeen {0} |
| unsigned long long | m_lastSeqSeen {0} |
| unsigned long long | m_lastKeyframeSeen {0} |
| unsigned int | m_audioBytesRemaining {0} |
| unsigned int | m_videoBytesRemaining {0} |
| unsigned int | m_otherBytesRemaining {0} |
| int | m_progressiveSequence {0} |
| int | m_repeatPict {0} |
| bool | m_pesSynced {false} |
| bool | m_seenSps {false} |
| H2645Parser * | m_h2645Parser {nullptr} |
| bool | m_waitForKeyframeOption {true} |
| Wait for the a GOP/SEQ-start before sending data. More... | |
| bool | m_hasWrittenOtherKeyframe {false} |
| QString | m_error |
| non-empty iff irrecoverable recording error detected More... | |
| MPEGStreamData * | m_streamData {nullptr} |
| bool | m_bufferPackets {false} |
| std::vector< unsigned char > | m_payloadBuffer |
| QRecursiveMutex | m_pidLock |
| ProgramAssociationTable * | m_inputPat {nullptr} |
| PAT on input side. More... | |
| ProgramMapTable * | m_inputPmt {nullptr} |
| PMT on input side. More... | |
| bool | m_hasNoAV {false} |
| bool | m_recordMpts {false} |
| bool | m_recordMptsOnly {false} |
| MythTimer | m_recordMptsTimer |
| std::array< uint8_t, 0x1fff+1 > | m_streamId {0} |
| std::array< uint8_t, 0x1fff+1 > | m_pidStatus {0} |
| std::array< uint8_t, 0x1fff+1 > | m_continuityCounter {0} |
| std::vector< TSPacket > | m_scratch |
| int | m_minimumRecordingQuality {95} |
| bool | m_usePts {false} |
| std::array< uint64_t, 256 > | m_tsCount {0} |
| std::array< int64_t, 256 > | m_tsLast {} |
| std::array< int64_t, 256 > | m_tsFirst {} |
| std::array< QDateTime, 256 > | m_tsFirstDt {} |
| QAtomicInt | m_packetCount {0} |
| QAtomicInt | m_continuityErrorCount {0} |
| unsigned long long | m_framesSeenCount {0} |
| unsigned long long | m_framesWrittenCount {0} |
| double | m_totalDuration {0.0} |
| Total milliseconds that have passed since the start of the recording. More... | |
| double | m_tdBase {0.0} |
| Milliseconds from the start to m_tdTickCount = 0. More... | |
| uint64_t | m_tdTickCount {0} |
| Count of the number of equivalent interlaced fields that have passed since m_tdBase. More... | |
| MythAVRational | m_tdTickFramerate {0} |
| SCAN_t | m_scanType {SCAN_t::UNKNOWN_SCAN} |
| bool | m_musicChoice {false} |
| bool | m_useIForKeyframe {true} |
Protected Attributes inherited from RecorderBase | |
| TVRec * | m_tvrec {nullptr} |
| MythMediaBuffer * | m_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_ntscFrameRate {true} |
| double | m_videoFrameRate {29.97} |
| uint | m_videoAspect {0} |
| uint | m_videoHeight {0} |
| uint | m_videoWidth {0} |
| MythAVRational | m_frameRate {0} |
| RecordingInfo * | m_curRecording {nullptr} |
| QMutex | m_pauseLock |
| bool | m_requestPause {false} |
| bool | m_paused {false} |
| QWaitCondition | m_pauseWait |
| QWaitCondition | m_unpauseWait |
| bool | m_requestRecording {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 |
| MythMediaBuffer * | m_nextRingBuffer {nullptr} |
| RecordingInfo * | m_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 |
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 constexpr std::chrono::milliseconds | kTimeOfLatestDataIntervalTarget { 5s } |
| timeOfLatest update interval target in milliseconds. More... | |
This is a specialization of DTVRecorder used to handle streams from V4L2 recorders.
Note: make sure the v4l2 program is executable
Definition at line 29 of file v4l2encrecorder.h.
| V4L2encRecorder::V4L2encRecorder | ( | TVRec * | rec, |
| V4LChannel * | channel | ||
| ) |
Definition at line 43 of file v4l2encrecorder.cpp.
| void V4L2encRecorder::Close | ( | void | ) |
Definition at line 276 of file v4l2encrecorder.cpp.
Referenced by run().
|
inline |
Definition at line 37 of file v4l2encrecorder.h.
| bool V4L2encRecorder::Open | ( | void | ) |
Definition at line 238 of file v4l2encrecorder.cpp.
Referenced by V4L2encRecorder().
|
overridevirtual |
If m_requestPause is true, sets pause and blocks up to timeout milliseconds or until unpaused, whichever is sooner.
This is the where we actually do the pausing. For most recorders that need to do something special on pause, this is the method to overide.
| timeout | number of milliseconds to wait defaults to 100. |
Reimplemented from RecorderBase.
Definition at line 288 of file v4l2encrecorder.cpp.
Referenced by run().
|
overridevirtual |
run() starts the recording process, and does not exit until the recording is complete.
Implements RecorderBase.
Definition at line 132 of file v4l2encrecorder.cpp.
|
protected |
Definition at line 55 of file v4l2encrecorder.cpp.
Referenced by SetOptionsFromProfile().
|
overrideprotectedvirtual |
Sets basic recorder options.
SetOptionsFromProfile is used to tell the recorder about the recording profile as well as the devices to use.
Reimplemented from DTVRecorder.
Definition at line 75 of file v4l2encrecorder.cpp.
|
protected |
Definition at line 65 of file v4l2encrecorder.cpp.
Referenced by SetOptionsFromProfile().
|
protected |
Definition at line 323 of file v4l2encrecorder.cpp.
Referenced by PauseAndWait(), and run().
|
overridevirtual |
Reimplemented from RecorderBase.
Definition at line 122 of file v4l2encrecorder.cpp.
Referenced by run().
|
protected |
Definition at line 335 of file v4l2encrecorder.cpp.
Referenced by PauseAndWait(), and run().
|
private |
Definition at line 55 of file v4l2encrecorder.h.
|
private |
Definition at line 56 of file v4l2encrecorder.h.
Referenced by Close(), IsOpen(), Open(), run(), SetIntOption(), SetStrOption(), StartEncoding(), and StopEncoding().