MpegRecorder Class Reference

#include <mpegrecorder.h>

Inheritance diagram for MpegRecorder:
V4LRecorder DeviceReaderCB DTVRecorder RecorderBase MPEGStreamListener MPEGSingleProgramStreamListener DVBMainStreamListener ATSCMainStreamListener TSPacketListener TSPacketListenerAV

List of all members.

Public Member Functions

 MpegRecorder (TVRec *)
 ~MpegRecorder ()
void TeardownAll (void)
void SetOption (const QString &opt, int value)
 handles the "wait_for_seqstart" option.
void SetOption (const QString &name, const QString &value)
 Set an specific option.
void SetVideoFilters (QString &)
 Tells recorder which filters to use.
void SetOptionsFromProfile (RecordingProfile *profile, const QString &videodev, const QString &audiodev, const QString &vbidev)
 Sets basic recorder options.
void Initialize (void)
 This is called between SetOptionsFromProfile() and run() to initialize any devices, etc.
void run (void)
 run() starts the recording process, and does not exit until the recording is complete.
void StopRecording (void)
 StopRecording() signals to the recorder that it should stop recording and exit cleanly.
void Reset (void)
 Reset the recorder to the startup state.
void Pause (bool clear=true)
 Pause tells recorder to pause, it should not block.
bool PauseAndWait (int timeout=100)
 If request_pause is true, sets pause and blocks up to timeout milliseconds or until unpaused, whichever is sooner.
bool IsRecording (void)
 Tells whether the StartRecorder() loop is running.
bool Open (void)
int GetVideoFd (void)
 Returns file descriptor of recorder device.
virtual void SetStreamData (void)
bool ProcessTSPacket (const TSPacket &tspacket)
virtual void ReaderPaused (int fd)
virtual void PriorityEvent (int fd)

Private Member Functions

void SetIntOption (RecordingProfile *profile, const QString &name)
 Convenience function used to set integer options from a profile.
void SetStrOption (RecordingProfile *profile, const QString &name)
 Convenience function used to set QString options from a profile.
bool OpenMpegFileAsInput (void)
bool OpenV4L2DeviceAsInput (void)
bool SetV4L2DeviceOptions (int chanfd)
bool SetVideoCaptureFormat (int chanfd)
bool SetLanguageMode (int chanfd)
 Set audio language mode.
bool SetRecordingVolume (int chanfd)
bool SetVBIOptions (int chanfd)
uint GetFilteredStreamType (void) const
uint GetFilteredAudioSampleRate (void) const
uint GetFilteredAudioLayer (void) const
uint GetFilteredAudioBitRate (uint audio_layer) const
void RestartEncoding (void)
bool StartEncoding (int fd)
bool StopEncoding (int fd)
void SetBitrate (int bitrate, int maxbitrate, const QString &reason)
void HandleResolutionChanges (void)
virtual void FormatCC (uint code1, uint code2)

Private Attributes

bool deviceIsMpegFile
int bufferSize
QString card
QString driver
uint32_t version
bool supports_sliced_vbi
QMutex start_stop_encoding_lock
bool cleartimeonpause
int width
int height
int bitrate
int maxbitrate
int streamtype
int aspectratio
int audtype
int audsamplerate
int audbitratel1
int audbitratel2
int audbitratel3
int audvolume
unsigned int language
 0 is Main Lang; 1 is SAP Lang; 2 is Dual
unsigned int low_mpeg4avgbitrate
unsigned int low_mpeg4peakbitrate
unsigned int medium_mpeg4avgbitrate
unsigned int medium_mpeg4peakbitrate
unsigned int high_mpeg4avgbitrate
unsigned int high_mpeg4peakbitrate
int chanfd
int readfd
DeviceReadBuffer_device_read_buffer

Static Private Attributes

static const int audRateL1 []
static const int audRateL2 []
static const int audRateL3 []
static const char * streamType []
static const char * aspectRatio []
static const unsigned int kBuildBufferMaxSize

Detailed Description

Definition at line 14 of file mpegrecorder.h.


Constructor & Destructor Documentation

MpegRecorder::MpegRecorder ( TVRec rec  ) 

Definition at line 79 of file mpegrecorder.cpp.

MpegRecorder::~MpegRecorder (  ) 

Definition at line 108 of file mpegrecorder.cpp.


Member Function Documentation

void MpegRecorder::TeardownAll ( void   ) 

Definition at line 113 of file mpegrecorder.cpp.

Referenced by ~MpegRecorder().

void MpegRecorder::SetOption ( const QString &  name,
int  value 
) [virtual]

handles the "wait_for_seqstart" option.

Reimplemented from V4LRecorder.

Definition at line 140 of file mpegrecorder.cpp.

Referenced by SetIntOption(), SetOption(), SetOptionsFromProfile(), and SetStrOption().

void MpegRecorder::SetOption ( const QString &  opt,
const QString &  value 
) [virtual]

Set an specific option.

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

Reimplemented from V4LRecorder.

Definition at line 213 of file mpegrecorder.cpp.

void MpegRecorder::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.

Reimplemented from DTVRecorder.

Definition at line 24 of file mpegrecorder.h.

void MpegRecorder::SetOptionsFromProfile ( RecordingProfile profile,
const QString &  videodev,
const QString &  audiodev,
const QString &  vbidev 
) [virtual]

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 290 of file mpegrecorder.cpp.

void MpegRecorder::Initialize ( void   )  [inline, virtual]

This is called between SetOptionsFromProfile() and run() to initialize any devices, etc.

Reimplemented from DTVRecorder.

Definition at line 31 of file mpegrecorder.h.

void MpegRecorder::run ( void   )  [virtual]

run() starts the recording process, and does not exit until the recording is complete.

See also:
StopRecording()

Implements RecorderBase.

Definition at line 901 of file mpegrecorder.cpp.

void MpegRecorder::StopRecording ( void   )  [virtual]

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

This function should block until recorder has finished up.

Reimplemented from V4LRecorder.

Definition at line 1179 of file mpegrecorder.cpp.

Referenced by TeardownAll().

void MpegRecorder::Reset ( void   )  [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.

Reimplemented from DTVRecorder.

Definition at line 1212 of file mpegrecorder.cpp.

void MpegRecorder::Pause ( bool  clear = true  )  [virtual]

Pause tells recorder to pause, it should not block.

Once paused the recorder calls tvrec->RecorderPaused().

Parameters:
clear if true any generated timecodes should be reset.
See also:
Unpause(), WaitForPause()

Reimplemented from RecorderBase.

Definition at line 1227 of file mpegrecorder.cpp.

bool MpegRecorder::PauseAndWait ( int  timeout = 100  )  [virtual]

If request_pause 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.

Parameters:
timeout number of milliseconds to wait defaults to 100.
Returns:
true if recorder is paused.

Reimplemented from RecorderBase.

Definition at line 1235 of file mpegrecorder.cpp.

Referenced by run().

bool MpegRecorder::IsRecording ( void   )  [inline, virtual]

Tells whether the StartRecorder() loop is running.

Reimplemented from RecorderBase.

Definition at line 39 of file mpegrecorder.h.

bool MpegRecorder::Open ( void   ) 

Definition at line 895 of file mpegrecorder.cpp.

Referenced by run().

int MpegRecorder::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.

Reimplemented from DTVRecorder.

Definition at line 42 of file mpegrecorder.h.

void MpegRecorder::SetStreamData ( void   )  [virtual]

Reimplemented from DTVRecorder.

Definition at line 1392 of file mpegrecorder.cpp.

Referenced by run().

bool MpegRecorder::ProcessTSPacket ( const TSPacket tspacket  )  [virtual]

Reimplemented from DTVRecorder.

Definition at line 1188 of file mpegrecorder.cpp.

virtual void MpegRecorder::ReaderPaused ( int  fd  )  [inline, virtual]

Implements DeviceReaderCB.

Definition at line 51 of file mpegrecorder.h.

virtual void MpegRecorder::PriorityEvent ( int  fd  )  [inline, virtual]

Implements DeviceReaderCB.

Definition at line 52 of file mpegrecorder.h.

void MpegRecorder::SetIntOption ( RecordingProfile profile,
const QString &  name 
) [private]

Convenience function used to set integer options from a profile.

See also:
SetOption(const QString&, int)

Reimplemented from RecorderBase.

Definition at line 344 of file mpegrecorder.cpp.

Referenced by SetOptionsFromProfile().

void MpegRecorder::SetStrOption ( RecordingProfile profile,
const QString &  name 
) [private]

Convenience function used to set QString options from a profile.

See also:
SetOption(const QString&, const QString&)

Reimplemented from RecorderBase.

Definition at line 352 of file mpegrecorder.cpp.

Referenced by SetOptionsFromProfile().

bool MpegRecorder::OpenMpegFileAsInput ( void   )  [private]

Definition at line 359 of file mpegrecorder.cpp.

Referenced by Open().

bool MpegRecorder::OpenV4L2DeviceAsInput ( void   )  [private]

Definition at line 374 of file mpegrecorder.cpp.

Referenced by Open().

bool MpegRecorder::SetV4L2DeviceOptions ( int  chanfd  )  [private]

Definition at line 746 of file mpegrecorder.cpp.

Referenced by OpenV4L2DeviceAsInput(), PauseAndWait(), and RestartEncoding().

bool MpegRecorder::SetVideoCaptureFormat ( int  chanfd  )  [private]

Definition at line 482 of file mpegrecorder.cpp.

Referenced by OpenV4L2DeviceAsInput().

bool MpegRecorder::SetLanguageMode ( int  chanfd  )  [private]

Set audio language mode.

Definition at line 511 of file mpegrecorder.cpp.

Referenced by OpenV4L2DeviceAsInput().

bool MpegRecorder::SetRecordingVolume ( int  chanfd  )  [private]

Definition at line 556 of file mpegrecorder.cpp.

Referenced by OpenV4L2DeviceAsInput().

bool MpegRecorder::SetVBIOptions ( int  chanfd  )  [private]

Definition at line 840 of file mpegrecorder.cpp.

Referenced by OpenV4L2DeviceAsInput().

uint MpegRecorder::GetFilteredStreamType ( void   )  const [private]

Definition at line 591 of file mpegrecorder.cpp.

Referenced by SetV4L2DeviceOptions().

uint MpegRecorder::GetFilteredAudioSampleRate ( void   )  const [private]

Definition at line 620 of file mpegrecorder.cpp.

Referenced by SetV4L2DeviceOptions().

uint MpegRecorder::GetFilteredAudioLayer ( void   )  const [private]

Definition at line 643 of file mpegrecorder.cpp.

Referenced by SetLanguageMode(), and SetV4L2DeviceOptions().

uint MpegRecorder::GetFilteredAudioBitRate ( uint  audio_layer  )  const [private]

Definition at line 662 of file mpegrecorder.cpp.

Referenced by SetV4L2DeviceOptions().

void MpegRecorder::RestartEncoding ( void   )  [private]

Definition at line 1289 of file mpegrecorder.cpp.

Referenced by run().

bool MpegRecorder::StartEncoding ( int  fd  )  [private]

Definition at line 1323 of file mpegrecorder.cpp.

Referenced by PauseAndWait(), RestartEncoding(), and run().

bool MpegRecorder::StopEncoding ( int  fd  )  [private]

Definition at line 1362 of file mpegrecorder.cpp.

Referenced by PauseAndWait(), RestartEncoding(), and run().

void MpegRecorder::SetBitrate ( int  bitrate,
int  maxbitrate,
const QString &  reason 
) [private]

Definition at line 1398 of file mpegrecorder.cpp.

Referenced by HandleResolutionChanges().

void MpegRecorder::HandleResolutionChanges ( void   )  [private]

Definition at line 1427 of file mpegrecorder.cpp.

Referenced by StartEncoding().

void MpegRecorder::FormatCC ( uint  code1,
uint  code2 
) [private, virtual]

Reimplemented from V4LRecorder.

Definition at line 1483 of file mpegrecorder.cpp.


Member Data Documentation

Definition at line 79 of file mpegrecorder.h.

Referenced by Open(), run(), and SetOptionsFromProfile().

int MpegRecorder::bufferSize [private]

Definition at line 80 of file mpegrecorder.h.

Referenced by OpenV4L2DeviceAsInput(), run(), and SetOptionsFromProfile().

QString MpegRecorder::card [private]

Definition at line 83 of file mpegrecorder.h.

Referenced by OpenV4L2DeviceAsInput().

QString MpegRecorder::driver [private]

Definition at line 85 of file mpegrecorder.h.

Referenced by OpenV4L2DeviceAsInput().

Definition at line 86 of file mpegrecorder.h.

Referenced by OpenV4L2DeviceAsInput(), and SetVBIOptions().

QMutex MpegRecorder::start_stop_encoding_lock [mutable, private]

Definition at line 89 of file mpegrecorder.h.

Referenced by OpenV4L2DeviceAsInput(), RestartEncoding(), StartEncoding(), and StopEncoding().

Definition at line 92 of file mpegrecorder.h.

Referenced by Pause().

int MpegRecorder::width [private]

Definition at line 95 of file mpegrecorder.h.

Referenced by SetOption(), and SetVideoCaptureFormat().

int MpegRecorder::height [private]

Definition at line 95 of file mpegrecorder.h.

Referenced by SetOption(), and SetVideoCaptureFormat().

int MpegRecorder::bitrate [private]

Definition at line 96 of file mpegrecorder.h.

Referenced by HandleResolutionChanges(), SetOption(), and SetV4L2DeviceOptions().

int MpegRecorder::maxbitrate [private]

Definition at line 96 of file mpegrecorder.h.

Referenced by HandleResolutionChanges(), SetOption(), and SetV4L2DeviceOptions().

int MpegRecorder::streamtype [private]

Definition at line 96 of file mpegrecorder.h.

Referenced by GetFilteredStreamType(), and SetOption().

Definition at line 96 of file mpegrecorder.h.

Referenced by SetOption(), and SetV4L2DeviceOptions().

int MpegRecorder::audtype [private]

Definition at line 97 of file mpegrecorder.h.

Referenced by GetFilteredAudioLayer(), SetOption(), and SetV4L2DeviceOptions().

Definition at line 97 of file mpegrecorder.h.

Referenced by GetFilteredAudioSampleRate(), and SetOption().

Definition at line 97 of file mpegrecorder.h.

Referenced by GetFilteredAudioBitRate(), and SetOption().

Definition at line 97 of file mpegrecorder.h.

Referenced by GetFilteredAudioBitRate(), and SetOption().

Definition at line 97 of file mpegrecorder.h.

Referenced by GetFilteredAudioBitRate(), and SetOption().

int MpegRecorder::audvolume [private]

Definition at line 98 of file mpegrecorder.h.

Referenced by SetOption(), and SetRecordingVolume().

unsigned int MpegRecorder::language [private]

0 is Main Lang; 1 is SAP Lang; 2 is Dual

Definition at line 99 of file mpegrecorder.h.

Referenced by SetLanguageMode(), and SetOption().

unsigned int MpegRecorder::low_mpeg4avgbitrate [private]

Definition at line 100 of file mpegrecorder.h.

Referenced by HandleResolutionChanges(), and SetOption().

unsigned int MpegRecorder::low_mpeg4peakbitrate [private]

Definition at line 101 of file mpegrecorder.h.

Referenced by HandleResolutionChanges(), and SetOption().

unsigned int MpegRecorder::medium_mpeg4avgbitrate [private]

Definition at line 102 of file mpegrecorder.h.

Referenced by HandleResolutionChanges(), and SetOption().

unsigned int MpegRecorder::medium_mpeg4peakbitrate [private]

Definition at line 103 of file mpegrecorder.h.

Referenced by HandleResolutionChanges(), and SetOption().

unsigned int MpegRecorder::high_mpeg4avgbitrate [private]

Definition at line 104 of file mpegrecorder.h.

Referenced by HandleResolutionChanges(), SetOption(), and SetV4L2DeviceOptions().

unsigned int MpegRecorder::high_mpeg4peakbitrate [private]

Definition at line 105 of file mpegrecorder.h.

Referenced by HandleResolutionChanges(), SetOption(), and SetV4L2DeviceOptions().

int MpegRecorder::chanfd [private]
int MpegRecorder::readfd [private]
const int MpegRecorder::audRateL1 [static, private]
Initial value:
{
    32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, 0
}

Definition at line 111 of file mpegrecorder.h.

Referenced by SetOption().

const int MpegRecorder::audRateL2 [static, private]
Initial value:
{
    32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, 0
}

Definition at line 112 of file mpegrecorder.h.

Referenced by SetOption().

const int MpegRecorder::audRateL3 [static, private]
Initial value:
{
    32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 0
}

Definition at line 113 of file mpegrecorder.h.

Referenced by SetOption().

const char * MpegRecorder::streamType [static, private]
Initial value:
{
    "MPEG-2 PS", "MPEG-2 TS",     "MPEG-1 VCD",    "PES AV",
    "",          "PES V",          "",             "PES A",
    "",          "",              "DVD",           "VCD",
    "SVCD",      "DVD-Special 1", "DVD-Special 2", 0
}

Definition at line 114 of file mpegrecorder.h.

Referenced by GetFilteredStreamType(), and SetOption().

const char * MpegRecorder::aspectRatio [static, private]
Initial value:
{
    "Square", "4:3", "16:9", "2.21:1", 0
}

Definition at line 115 of file mpegrecorder.h.

Referenced by SetOption().

const unsigned int MpegRecorder::kBuildBufferMaxSize [static, private]

Definition at line 116 of file mpegrecorder.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends
Generated on Fri Feb 10 06:42:08 2012 for MythTV by  doxygen 1.6.3