00001
00002
00003 #ifndef MPEGRECORDER_H_
00004 #define MPEGRECORDER_H_
00005
00006 #include "v4lrecorder.h"
00007 #include "tspacket.h"
00008 #include "mpegstreamdata.h"
00009 #include "DeviceReadBuffer.h"
00010
00011 struct AVFormatContext;
00012 struct AVPacket;
00013
00014 class MpegRecorder : public V4LRecorder,
00015 public DeviceReaderCB
00016 {
00017 public:
00018 MpegRecorder(TVRec*);
00019 ~MpegRecorder();
00020 void TeardownAll(void);
00021
00022 void SetOption(const QString &opt, int value);
00023 void SetOption(const QString &name, const QString &value);
00024 void SetVideoFilters(QString&) {}
00025
00026 void SetOptionsFromProfile(RecordingProfile *profile,
00027 const QString &videodev,
00028 const QString &audiodev,
00029 const QString &vbidev);
00030
00031 void Initialize(void) {}
00032 void run(void);
00033 void StopRecording(void);
00034 void Reset(void);
00035
00036 void Pause(bool clear = true);
00037 bool PauseAndWait(int timeout = 100);
00038
00039 bool IsRecording(void) { return recording; }
00040
00041 bool Open(void);
00042 int GetVideoFd(void) { return chanfd; }
00043
00044
00045 virtual void SetStreamData(void);
00046
00047
00048 bool ProcessTSPacket(const TSPacket &tspacket);
00049
00050
00051 virtual void ReaderPaused(int fd) { pauseWait.wakeAll(); }
00052 virtual void PriorityEvent(int fd) { }
00053
00054 private:
00055 void SetIntOption(RecordingProfile *profile, const QString &name);
00056 void SetStrOption(RecordingProfile *profile, const QString &name);
00057
00058 bool OpenMpegFileAsInput(void);
00059 bool OpenV4L2DeviceAsInput(void);
00060 bool SetV4L2DeviceOptions(int chanfd);
00061 bool SetVideoCaptureFormat(int chanfd);
00062 bool SetLanguageMode(int chanfd);
00063 bool SetRecordingVolume(int chanfd);
00064 bool SetVBIOptions(int chanfd);
00065 uint GetFilteredStreamType(void) const;
00066 uint GetFilteredAudioSampleRate(void) const;
00067 uint GetFilteredAudioLayer(void) const;
00068 uint GetFilteredAudioBitRate(uint audio_layer) const;
00069
00070 void RestartEncoding(void);
00071 bool StartEncoding(void);
00072 void StopEncoding(void);
00073
00074 void SetBitrate(int bitrate, int maxbitrate, const QString & reason);
00075 void HandleResolutionChanges(void);
00076
00077 virtual void FormatCC(uint code1, uint code2);
00078
00079 bool deviceIsMpegFile;
00080 int bufferSize;
00081
00082
00083 QString card;
00084 QString driver;
00085 uint32_t version;
00086 bool supports_sliced_vbi;
00087
00088
00089 mutable QMutex start_stop_encoding_lock;
00090
00091
00092 bool cleartimeonpause;
00093
00094
00095 int width, height;
00096 int bitrate, maxbitrate, streamtype, aspectratio;
00097 int audtype, audsamplerate, audbitratel1, audbitratel2, audbitratel3;
00098 int audvolume;
00099 unsigned int language;
00100 unsigned int low_mpeg4avgbitrate;
00101 unsigned int low_mpeg4peakbitrate;
00102 unsigned int medium_mpeg4avgbitrate;
00103 unsigned int medium_mpeg4peakbitrate;
00104 unsigned int high_mpeg4avgbitrate;
00105 unsigned int high_mpeg4peakbitrate;
00106
00107
00108 int chanfd;
00109 int readfd;
00110
00111 static const int audRateL1[];
00112 static const int audRateL2[];
00113 static const int audRateL3[];
00114 static const char *streamType[];
00115 static const char *aspectRatio[];
00116 static const unsigned int kBuildBufferMaxSize;
00117
00118
00119 DeviceReadBuffer *_device_read_buffer;
00120 };
00121
00122 #endif