13#define LOC QString("AnalogSigMon[%1](%2): ") \
14 .arg(m_inputid).arg(m_channel->GetDevice())
20 :
SignalMonitor(db_cardnum, _channel, _release_stream, _flags)
29 m_usingV4l2 = ((caps & V4L2_CAP_VIDEO_CAPTURE) != 0U);
30 LOG(VB_RECORD, LOG_INFO, QString(
"card '%1' driver '%2' version '%3'")
37 struct v4l2_queryctrl qctrl {};
38 qctrl.id = V4L2_CID_MPEG_AUDIO_ENCODING;
40 int audtype = V4L2_MPEG_AUDIO_ENCODING_AC3;
42 if (ioctl(videofd, VIDIOC_QUERYCTRL, &qctrl) != 0)
44 LOG(VB_GENERAL, LOG_ERR,
LOC +
45 "Unable to get supported audio codecs for verification." +
ENO);
49 struct v4l2_ext_control ext_ctrl {};
50 struct v4l2_ext_controls ext_ctrls {};
52 ext_ctrl.id = V4L2_CID_MPEG_AUDIO_ENCODING;
54 ext_ctrls.reserved[0] = 0;
56 ext_ctrls.ctrl_class = V4L2_CTRL_CLASS_MPEG;
57 ext_ctrls.controls = &ext_ctrl;
59 if (ioctl(videofd, VIDIOC_G_EXT_CTRLS, &ext_ctrls) != 0)
61 LOG(VB_GENERAL, LOG_ERR,
LOC +
62 "Unable to get current audio codecs for verification." +
ENO);
66 int current_audio = ext_ctrls.controls->value;
68 if (audtype != current_audio)
70 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Audio desired %1, current %2 "
78 ext_ctrl.id = V4L2_CID_MPEG_AUDIO_ENCODING;
79 ext_ctrl.value = audtype;
80 if (ioctl(videofd, VIDIOC_S_EXT_CTRLS, &ext_ctrls) == 0)
82 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Changed audio encoding "
90 LOG(VB_GENERAL, LOG_ERR,
LOC + QString(
"Failed to changed audio "
91 "encoding from %1 to %2.")
111 struct v4l2_format vfmt {};
112 vfmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
114 if ((ioctl(videofd, VIDIOC_G_FMT, &vfmt) == 0) &&
115 vfmt.fmt.pix.width &&
m_width == vfmt.fmt.pix.width &&
120 LOG(VB_RECORD, LOG_ERR, QString(
"hd-pvr resolution %1 x %2")
121 .arg(vfmt.fmt.pix.width).arg(vfmt.fmt.pix.height));
127 LOG(VB_RECORD, LOG_ERR, QString(
"hd-pvr stable at %1 x %2")
128 .arg(vfmt.fmt.pix.width).arg(vfmt.fmt.pix.height));
142 LOG(VB_RECORD, LOG_ERR,
"hd-pvr waiting for valid resolution");
171 bool isLocked =
false;
178 struct v4l2_tuner tuner {};
180 if (ioctl(videofd, VIDIOC_G_TUNER, &tuner, 0) < 0)
182 LOG(VB_GENERAL, LOG_ERR,
"Failed to probe signal (v4l2)" +
ENO);
186 isLocked = (tuner.signal != 0);
bool VerifyHDPVRaudio(int videofd)
bool handleHDPVR(int videofd)
AnalogSignalMonitor(int db_cardnum, V4LChannel *_channel, bool _release_stream, uint64_t _flags=kSigMon_WaitForSig)
void UpdateValues(void) override
This should be overridden to actually do signal monitoring.
std::chrono::milliseconds m_stableTime
static bool GetV4LInfo(int videofd, QString &input, QString &driver, uint32_t &version, uint32_t &capabilities)
virtual int GetFd(void) const
Returns file descriptor, -1 if it does not exist.
std::chrono::milliseconds elapsed(void)
Returns milliseconds elapsed since last start() or restart()
bool isRunning(void) const
Returns true if start() or restart() has been called at least once since construction and since any c...
void stop(void)
Stops timer, next call to isRunning() will return false and any calls to elapsed() or restart() will ...
void start(void)
starts measuring elapsed time.
bool IsGood() const
Returns true if the value is equal to the threshold, or on the right side of the threshold (depends o...
void SetValue(int _value)
Signal monitoring base class.
QRecursiveMutex m_statusLock
void SendMessageAllGood(void)
SignalMonitorValue m_signalLock
SignalMonitorValue m_scriptStatus
virtual bool IsAllGood(void) const
virtual void EmitStatus(void)
virtual void UpdateValues(void)
This should be overridden to actually do signal monitoring.
SignalMonitorValue m_signalStrength
Implements tuning for TV cards using the V4L driver API, both versions 1 and 2.
#define ENO
This can be appended to the LOG args with "+".
#define LOG(_MASK_, _LEVEL_, _QSTRING_)