00001
00002
00003 #ifndef MPEGRECORDER_H_
00004 #define MPEGRECORDER_H_
00005
00006 #include "recorderbase.h"
00007
00008 struct AVFormatContext;
00009 struct AVPacket;
00010
00011 class MpegRecorder : public RecorderBase
00012 {
00013 public:
00014 MpegRecorder(TVRec*);
00015 ~MpegRecorder();
00016 void TeardownAll(void);
00017
00018 void SetOption(const QString &opt, int value);
00019 void SetOption(const QString &name, const QString &value);
00020 void SetVideoFilters(QString&) {}
00021
00022 void SetOptionsFromProfile(RecordingProfile *profile,
00023 const QString &videodev,
00024 const QString &audiodev,
00025 const QString &vbidev);
00026
00027 void Initialize(void) {}
00028 void StartRecording(void);
00029 void StopRecording(void);
00030 void Reset(void);
00031
00032 void Pause(bool clear = true);
00033 bool PauseAndWait(int timeout = 100);
00034
00035 bool IsRecording(void) { return recording; }
00036 bool IsErrored(void) { return errored; }
00037
00038 long long GetFramesWritten(void) { return framesWritten; }
00039
00040 bool Open(void);
00041 int GetVideoFd(void) { return chanfd; }
00042
00043 long long GetKeyframePosition(long long desired);
00044
00045 void SetNextRecording(const ProgramInfo*, RingBuffer*);
00046
00047 private:
00048 bool SetupRecording(void);
00049 void FinishRecording(void);
00050 void HandleKeyframe(void);
00051
00052 void ProcessData(unsigned char *buffer, int len);
00053
00054 bool OpenMpegFileAsInput(void);
00055 bool OpenV4L2DeviceAsInput(void);
00056 bool SetIVTVDeviceOptions(int chanfd);
00057 bool SetV4L2DeviceOptions(int chanfd);
00058 bool SetVBIOptions(int chanfd);
00059 uint GetFilteredStreamType(void) const;
00060 uint GetFilteredAudioSampleRate(void) const;
00061 uint GetFilteredAudioLayer(void) const;
00062 uint GetFilteredAudioBitRate(uint audio_layer) const;
00063
00064 void ResetForNewFile(void);
00065
00066 bool deviceIsMpegFile;
00067 int bufferSize;
00068
00069
00070 QString card;
00071 QString driver;
00072 uint32_t version;
00073 bool usingv4l2;
00074 bool has_buggy_vbi;
00075 bool has_v4l2_vbi;
00076 bool requires_special_pause;
00077
00078
00079 bool recording;
00080 bool encoding;
00081 bool errored;
00082
00083
00084 bool cleartimeonpause;
00085
00086
00087 long long framesWritten;
00088
00089
00090 int width, height;
00091 int bitrate, maxbitrate, streamtype, aspectratio;
00092 int audtype, audsamplerate, audbitratel1, audbitratel2, audbitratel3;
00093 int audvolume;
00094 unsigned int language;
00095
00096
00097 int chanfd;
00098 int readfd;
00099
00100
00101 int keyframedist;
00102 bool gopset;
00103 unsigned int leftovers;
00104 long long lastpackheaderpos;
00105 long long lastseqstart;
00106 long long numgops;
00107
00108
00109 unsigned char *buildbuffer;
00110 unsigned int buildbuffersize;
00111
00112 static const int audRateL1[];
00113 static const int audRateL2[];
00114 static const int audRateL3[];
00115 static const char *streamType[];
00116 static const char *aspectRatio[];
00117 static const unsigned int kBuildBufferMaxSize;
00118 };
00119 #endif