MythTV  master
Recorder Subsystem
Collaboration diagram for Recorder Subsystem:

TVRec is the main class for handling recording. It is passed a ProgramInfo for the current and next recordings, and in turn creates three main worker classes:

RecorderBase
Recordings from device into RingBuffer.
ChannelBase
Changes the channel and other recording device attributes. Optional.
RingBuffer
Handles A/V file I/O, including streaming.

TVRec also presents the public face of a recordings to the MythTV Network Protocol, and hence the rest of MythTV. This means that any call to the RecorderBase, RingBuffer, or ChannelBase is marshalled via methods in the TVRec.

RecorderBase contains classes for recording MythTV's specialized Nuppel Video files, as well as classes for handling various hardware encoding devices such as MPEG2, HDTV, DVB and Firewire recorders. ChannelBase meanwhile only contains three subclasses, Channel for handling v4l and v4l2 devices, and DVBChannel and FirewireChannel, for handling DVB and Firewire respectively. Other channel changing hardware use ChannelBase's external channel changing program support. Finally, RingBuffer does all reading and writing of A/V files for both TV (playback) and TVRec, including streaming over network connections to the frontend's RingBuffer.

TVRec has four active states, the first three of which correspond to the same states in TV: kState_WatchingLiveTV, kState_WatchingPreRecorded, kState_WatchingRecording, and kState_RecordingOnly. When watching "Live TV" the recorder records whatever the frontend requests and streams it out using the RingBuffer, this may be to disk or over the network. When watching pre-recorded programs TVRec simply streams a file on disk out using the RingBuffer. When just watching a recording, TVRec continues a recording started as recording-only while simultaneously streaming out using the RingBuffer. Finally, when in the recording-only mode the recording is only saved to disk using RingBuffer and no streaming to the frontend is performed.

TVRec also has three additional states: kState_Error, kState_None, kState_ChangingState. The error state allows MythTV to know when something has gone wrong. The null or none state means the recorder is not doing anything and is ready for commands. Finally, the "ChangingState" state tells us that a state change request is pending, so other state changing commands should not be issued.

Todo:
Check if the TVRec is actually still passed a ProgramInfo for the current and next recordings
Todo:
Document the massive changes Daniel has made in the Vid and MultiRec branches