MythTV master
mpegrecorder.h
Go to the documentation of this file.
1// -*- Mode: c++ -*-
2
3#ifndef MPEGRECORDER_H_
4#define MPEGRECORDER_H_
5
6#include "DeviceReadBuffer.h"
8#include "mpeg/tspacket.h"
9#include "v4lrecorder.h"
10
11struct AVFormatContext;
12struct AVPacket;
13
15 public DeviceReaderCB
16{
17 public:
18 explicit MpegRecorder(TVRec*rec)
19 : V4LRecorder(rec) {};
20 ~MpegRecorder() override { TeardownAll(); }
21 void TeardownAll(void);
22
23 void SetOption(const QString &opt, int value) override; // DTVRecorder
24 void SetOption(const QString &opt, const QString &value) override; // DTVRecorder
25 void SetVideoFilters(QString &/*filters*/) override {} // DTVRecorder
26
28 const QString &videodev,
29 const QString &audiodev,
30 const QString &vbidev) override; // DTVRecorder
31
32 void Initialize(void) override {} // DTVRecorder
33 void run(void) override; // RecorderBase
34 void Reset(void) override; // DTVRecorder
35
36 void Pause(bool clear = true) override; // RecorderBase
37 bool PauseAndWait(std::chrono::milliseconds timeout = 100ms) override; // RecorderBase
38
39 bool IsRecording(void) override // RecorderBase
40 { return m_recording; }
41
42 bool Open(void);
43 int GetVideoFd(void) override // DTVRecorder
44 { return m_chanfd; }
45
46 // TSPacketListener
47 bool ProcessTSPacket(const TSPacket &tspacket) override; // DTVRecorder
48
49 // DeviceReaderCB
50 void ReaderPaused(int /*fd*/) override // DeviceReaderCB
51 { m_pauseWait.wakeAll(); }
52 void PriorityEvent(int /*fd*/) override { } //DeviceReaderCB
53
54 private:
55 void InitStreamData(void) override; // DTVRecorder
56 void SetIntOption(RecordingProfile *profile, const QString &name);
57 void SetStrOption(RecordingProfile *profile, const QString &name);
58
59 bool OpenMpegFileAsInput(void);
60 bool OpenV4L2DeviceAsInput(void);
61 bool SetV4L2DeviceOptions(int chanfd);
62 bool SetVideoCaptureFormat(int chanfd);
63 bool SetLanguageMode(int chanfd);
64 bool SetRecordingVolume(int chanfd);
65 bool SetVBIOptions(int chanfd);
66 uint GetFilteredStreamType(void) const;
68 uint GetFilteredAudioLayer(void) const;
69 uint GetFilteredAudioBitRate(uint audio_layer) const;
70
71 bool RestartEncoding(void);
72 bool StartEncoding(void);
73 void StopEncoding(void);
74
75 void SetBitrate(int bitrate, int maxbitrate, const QString & reason);
76 bool HandleResolutionChanges(void);
77
78 void FormatCC(uint code1, uint code2) override; // V4LRecorder
79
80 bool m_deviceIsMpegFile {false};
81 int m_bufferSize {0};
82
83 // Driver info
84 QString m_card;
85 QString m_driver;
86 uint32_t m_version {0};
87 bool m_supportsSlicedVbi {false};
88
89 // State
90 mutable QRecursiveMutex m_startStopEncodingLock;
91
92 // Pausing state
93 bool m_clearTimeOnPause {false};
94
95 // Encoding info
96 int m_width {720};
97 int m_height {480};
98 int m_bitrate {4500};
99 int m_maxBitrate {6000};
102 int m_audType {2};
103 int m_audSampleRate {48000};
107 int m_audVolume {80};
109 unsigned int m_language {0};
110 unsigned int m_lowMpeg4AvgBitrate { 4500};
111 unsigned int m_lowMpeg4PeakBitrate { 6000};
112 unsigned int m_mediumMpeg4AvgBitrate { 9000};
113 unsigned int m_mediumMpeg4PeakBitrate {13500};
114 unsigned int m_highMpeg4AvgBitrate {13500};
115 unsigned int m_highMpeg4PeakBitrate {20200};
116
117 // Input file descriptors
118 int m_chanfd {-1};
119 int m_readfd {-1};
120
121 static const std::array<const int,14> kAudRateL1;
122 static const std::array<const int,14> kAudRateL2;
123 static const std::array<const int,14> kAudRateL3;
124 static const std::array<const std::string,15> kStreamType;
125 static const std::array<const std::string,4> kAspectRatio;
126 static const unsigned int kBuildBufferMaxSize;
127
128 // Buffer device reads
130};
131
132#endif
Buffers reads from device files.
QRecursiveMutex m_startStopEncodingLock
Definition: mpegrecorder.h:90
static const unsigned int kBuildBufferMaxSize
Definition: mpegrecorder.h:126
bool m_deviceIsMpegFile
Definition: mpegrecorder.h:80
void InitStreamData(void) override
unsigned int m_mediumMpeg4PeakBitrate
Definition: mpegrecorder.h:113
static const std::array< const int, 14 > kAudRateL1
Definition: mpegrecorder.h:121
void SetVideoFilters(QString &) override
Tells recorder which filters to use.
Definition: mpegrecorder.h:25
void SetOption(const QString &opt, int value) override
handles the "wait_for_seqstart" option.
void run(void) override
run() starts the recording process, and does not exit until the recording is complete.
bool m_clearTimeOnPause
Definition: mpegrecorder.h:93
unsigned int m_mediumMpeg4AvgBitrate
Definition: mpegrecorder.h:112
bool PauseAndWait(std::chrono::milliseconds timeout=100ms) override
If m_requestPause is true, sets pause and blocks up to timeout milliseconds or until unpaused,...
bool Open(void)
void ReaderPaused(int) override
Definition: mpegrecorder.h:50
bool SetV4L2DeviceOptions(int chanfd)
static const std::array< const int, 14 > kAudRateL2
Definition: mpegrecorder.h:122
void Reset(void) override
Reset the recorder to the startup state.
void SetOptionsFromProfile(RecordingProfile *profile, const QString &videodev, const QString &audiodev, const QString &vbidev) override
Sets basic recorder options.
static const std::array< const std::string, 15 > kStreamType
Definition: mpegrecorder.h:124
void TeardownAll(void)
bool ProcessTSPacket(const TSPacket &tspacket) override
void SetBitrate(int bitrate, int maxbitrate, const QString &reason)
QString m_driver
Definition: mpegrecorder.h:85
void SetStrOption(RecordingProfile *profile, const QString &name)
bool SetRecordingVolume(int chanfd)
DeviceReadBuffer * m_deviceReadBuffer
Definition: mpegrecorder.h:129
void Initialize(void) override
This is called between SetOptionsFromProfile() and run() to initialize any devices,...
Definition: mpegrecorder.h:32
uint32_t m_version
Definition: mpegrecorder.h:86
void SetIntOption(RecordingProfile *profile, const QString &name)
bool m_supportsSlicedVbi
Definition: mpegrecorder.h:87
uint GetFilteredAudioSampleRate(void) const
static const std::array< const std::string, 4 > kAspectRatio
Definition: mpegrecorder.h:125
bool RestartEncoding(void)
bool OpenMpegFileAsInput(void)
bool IsRecording(void) override
Tells whether the StartRecorder() loop is running.
Definition: mpegrecorder.h:39
unsigned int m_lowMpeg4PeakBitrate
Definition: mpegrecorder.h:111
QString m_card
Definition: mpegrecorder.h:84
bool OpenV4L2DeviceAsInput(void)
bool SetLanguageMode(int chanfd)
Set audio language mode.
uint GetFilteredAudioLayer(void) const
static const std::array< const int, 14 > kAudRateL3
Definition: mpegrecorder.h:123
~MpegRecorder() override
Definition: mpegrecorder.h:20
unsigned int m_highMpeg4PeakBitrate
Definition: mpegrecorder.h:115
bool HandleResolutionChanges(void)
unsigned int m_language
0 is Main Lang; 1 is SAP Lang; 2 is Dual
Definition: mpegrecorder.h:109
void StopEncoding(void)
void Pause(bool clear=true) override
Pause tells recorder to pause, it should not block.
unsigned int m_lowMpeg4AvgBitrate
Definition: mpegrecorder.h:110
uint GetFilteredAudioBitRate(uint audio_layer) const
bool SetVideoCaptureFormat(int chanfd)
void FormatCC(uint code1, uint code2) override
bool SetVBIOptions(int chanfd)
void PriorityEvent(int) override
Definition: mpegrecorder.h:52
uint GetFilteredStreamType(void) const
int GetVideoFd(void) override
Returns file descriptor of recorder device.
Definition: mpegrecorder.h:43
unsigned int m_highMpeg4AvgBitrate
Definition: mpegrecorder.h:114
bool StartEncoding(void)
MpegRecorder(TVRec *rec)
Definition: mpegrecorder.h:18
bool m_recording
True while recording is actually being performed.
Definition: recorderbase.h:321
QWaitCondition m_pauseWait
Definition: recorderbase.h:316
Used to access the data of a Transport Stream packet.
Definition: tspacket.h:208
This is the coordinating class of the Recorder Subsystem.
Definition: tv_rec.h:143
Abstract base class for Video4Linux based recorders.
Definition: v4lrecorder.h:17
unsigned int uint
Definition: freesurround.h:24
static void clear(SettingsMap &cache, SettingsMap &overrides, const QString &myKey)
Definition: mythdb.cpp:949