1
0
mirror of https://github.com/rofafor/vdr-plugin-femon.git synced 2023-10-10 13:36:53 +02:00

Added debug() and error() macros.

This commit is contained in:
Rolf Ahrenberg 2009-10-01 12:13:35 +03:00
parent 554dac9674
commit 44fa48c59f
6 changed files with 55 additions and 53 deletions

View File

@ -377,7 +377,7 @@ VDR Plugin 'femon' Revision History
- Added a mutex to receiver class.
- Added 1080/720/576/480 format symbols into status window.
2009-09-26: Version 1.7.5
2009-10-01: Version 1.7.5
- Changed H.264 parser to show display aspect ratio.
- Removed error logging from unimplemented ioctl functions.

10
femon.c
View File

@ -50,13 +50,13 @@ cPluginFemon::cPluginFemon()
// Initialize any member variables here.
// DON'T DO ANYTHING ELSE THAT MAY HAVE SIDE EFFECTS, REQUIRE GLOBAL
// VDR OBJECTS TO EXIST OR PRODUCE ANY OUTPUT!
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
}
cPluginFemon::~cPluginFemon()
{
// Clean up after yourself!
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
}
const char *cPluginFemon::CommandLineHelp(void)
@ -96,7 +96,7 @@ void cPluginFemon::Housekeeping(void)
cOsdObject *cPluginFemon::MainMenuAction(void)
{
// Perform the action when selected from the main VDR menu.
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
if (cReplayControl::NowReplaying() || (Channels.Count() <= 0))
Skins.Message(mtInfo, tr("Femon not available"));
else
@ -274,7 +274,7 @@ public:
cMenuFemonSetup::cMenuFemonSetup(void)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
dispmodes[eFemonModeBasic] = tr("basic");
dispmodes[eFemonModeTransponder] = tr("transponder");
dispmodes[eFemonModeStream] = tr("stream");
@ -353,7 +353,7 @@ void cMenuFemonSetup::Setup(void)
void cMenuFemonSetup::Store(void)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
femonConfig = data;
SetupStore("HideMenu", femonConfig.hidemenu);
SetupStore("DisplayMode", femonConfig.displaymode);

View File

@ -119,7 +119,7 @@ bool cFemonH264::processVideo(const uint8_t *buf, int len)
if (!aud_found) {
switch (buf[4] >> 5) {
case 0: case 3: case 5: // I_FRAME
//Dprintf("H.264: Found NAL AUD at offset %d/%d\n", int(buf - start), len);
//debug("H.264: Found NAL AUD at offset %d/%d\n", int(buf - start), len);
aud_found = true;
break;
case 1: case 4: case 6: // P_FRAME;
@ -132,7 +132,7 @@ bool cFemonH264::processVideo(const uint8_t *buf, int len)
case NAL_SPS:
if (!sps_found) {
//Dprintf("H.264: Found NAL SPS at offset %d/%d\n", int(buf - start), len);
//debug("H.264: Found NAL SPS at offset %d/%d\n", int(buf - start), len);
int nal_len = nalUnescape(nal_data, buf + 4, int(end - buf - 4));
consumed = parseSPS(nal_data, nal_len);
if (consumed > 0)
@ -142,7 +142,7 @@ bool cFemonH264::processVideo(const uint8_t *buf, int len)
case NAL_SEI:
if (!sei_found) {
//Dprintf("H.264: Found NAL SEI at offset %d/%d\n", iny(buf - start), len);
//debug("H.264: Found NAL SEI at offset %d/%d\n", iny(buf - start), len);
int nal_len = nalUnescape(nal_data, buf + 4, int(end - buf - 4));
consumed = parseSEI(nal_data, nal_len);
if (consumed > 0)
@ -163,7 +163,7 @@ bool cFemonH264::processVideo(const uint8_t *buf, int len)
if (aud_found) {
m_VideoHandler->SetVideoCodec(VIDEO_CODEC_H264);
if (sps_found) {
//Dprintf("H.264 SPS: size %dx%d, aspect %d format %d framerate %.2f bitrate %.0f\n", m_Width, m_Height, m_AspectRatio, m_Format, m_FrameRate, m_BitRate);
//debug("H.264 SPS: size %dx%d, aspect %d format %d framerate %.2f bitrate %.0f\n", m_Width, m_Height, m_AspectRatio, m_Format, m_FrameRate, m_BitRate);
m_VideoHandler->SetVideoFormat(m_Format);
m_VideoHandler->SetVideoSize(m_Width, m_Height);
m_VideoHandler->SetVideoAspectRatio(m_AspectRatio);
@ -171,7 +171,7 @@ bool cFemonH264::processVideo(const uint8_t *buf, int len)
m_VideoHandler->SetVideoBitrate(m_BitRate);
}
if (sei_found) {
//Dprintf("H.264 SEI: scan %d\n", m_Scan);
//debug("H.264 SEI: scan %d\n", m_Scan);
m_VideoHandler->SetVideoScan(m_Scan);
}
}
@ -244,7 +244,7 @@ int cFemonH264::parseSPS(const uint8_t *buf, int len)
bs.skipBits(4); // reserved_zero_4bits
level_idc = bs.getU8(); // level_idc
bs.skipUeGolomb(); // seq_parameter_set_id
//Dprintf("H.264 SPS: profile_idc %d level_idc %d\n", profile_idc, level_idc);
//debug("H.264 SPS: profile_idc %d level_idc %d\n", profile_idc, level_idc);
switch (profile_idc) {
case 66: // baseline profile
case 77: // main profile
@ -492,9 +492,9 @@ int cFemonH264::parseSPS(const uint8_t *buf, int len)
width = bs.getUeGolomb() + 1; // pic_width_in_mbs_minus1
height = bs.getUeGolomb() + 1; // pic_height_in_mbs_minus1
frame_mbs_only_flag = bs.getBit(); // frame_mbs_only_flag
//Dprintf("H.264 SPS: pic_width: %u mbs\n", width);
//Dprintf("H.264 SPS: pic_height: %u mbs\n", height);
//Dprintf("H.264 SPS: frame only flag: %d\n", frame_mbs_only_flag);
//debug("H.264 SPS: pic_width: %u mbs\n", width);
//debug("H.264 SPS: pic_height: %u mbs\n", height);
//debug("H.264 SPS: frame only flag: %d\n", frame_mbs_only_flag);
width *= 16;
height *= 16 * (frame_mbs_only_flag ? 1 : 2);
if (!frame_mbs_only_flag)
@ -506,7 +506,7 @@ int cFemonH264::parseSPS(const uint8_t *buf, int len)
crop_right = bs.getUeGolomb(); // frame_crop_rigth_offset
crop_top = bs.getUeGolomb(); // frame_crop_top_offset
crop_bottom = bs.getUeGolomb(); // frame_crop_bottom_offset
//Dprintf("H.264 SPS: cropping %d %d %d %d\n", crop_left, crop_top, crop_right, crop_bottom);
//debug("H.264 SPS: cropping %d %d %d %d\n", crop_left, crop_top, crop_right, crop_bottom);
width -= 2 * (crop_left + crop_right);
if (frame_mbs_only_flag)
height -= 2 * (crop_top + crop_bottom);
@ -518,7 +518,7 @@ int cFemonH264::parseSPS(const uint8_t *buf, int len)
if (bs.getBit()) { // aspect_ratio_info_present
uint32_t aspect_ratio_idc, sar_width = 0, sar_height = 0;
aspect_ratio_idc = bs.getU8(); // aspect_ratio_idc
//Dprintf("H.264 SPS: aspect_ratio_idc %d\n", aspect_ratio_idc);
//debug("H.264 SPS: aspect_ratio_idc %d\n", aspect_ratio_idc);
if (aspect_ratio_idc == 255) { // extended sar
sar_width = bs.getU16(); // sar_width
sar_height = bs.getU16(); // sar_height
@ -543,7 +543,7 @@ int cFemonH264::parseSPS(const uint8_t *buf, int len)
}
else
aspect_ratio = s_DAR[index].dar;
//Dprintf("H.264 SPS: DAR %dx%d (%d)\n", sar_width, sar_height, aspect_ratio);
//debug("H.264 SPS: DAR %dx%d (%d)\n", sar_width, sar_height, aspect_ratio);
}
}
if (bs.getBit()) // overscan_info_present_flag
@ -553,7 +553,7 @@ int cFemonH264::parseSPS(const uint8_t *buf, int len)
video_format = bs.getBits(3); // video_format
if (video_format < sizeof(s_VideoFormats) / sizeof(s_VideoFormats[0])) {
format = s_VideoFormats[video_format];
//Dprintf("H.264 SPS: video format %d\n", format);
//debug("H.264 SPS: video format %d\n", format);
}
bs.skipBit(); // video_full_range_flag
if (bs.getBit()) { // colour_description_present_flag
@ -689,7 +689,7 @@ int cFemonH264::parseSEI(const uint8_t *buf, int len)
break;
}
}
//Dprintf("H.264 SEI: pic struct %d scan type %d\n", pic_struct, scan);
//debug("H.264 SEI: pic struct %d scan type %d\n", pic_struct, scan);
for (int i = 0; i < s_SeiNumClockTsTable[pic_struct]; ++i) {
if (bs.getBit()) { // clock_timestamp_flag[i]
int full_timestamp_flag;
@ -707,7 +707,7 @@ int cFemonH264::parseSEI(const uint8_t *buf, int len)
scan = VIDEO_SCAN_RESERVED;
break;
}
//Dprintf("H.264 SEI: scan type %d\n", scan);
//debug("H.264 SEI: scan type %d\n", scan);
bs.skipBit(); // nuit_field_based_flag
bs.skipBits(5); // counting_type
full_timestamp_flag = bs.getBit(); // full_timestamp_flag

View File

@ -150,7 +150,7 @@ cFemonOsd *cFemonOsd::pInstance = NULL;
cFemonOsd *cFemonOsd::Instance(bool create)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
if ((pInstance == NULL) && create)
{
pInstance = new cFemonOsd();
@ -186,30 +186,30 @@ cFemonOsd::cFemonOsd()
m_Mutex()
{
int tmp;
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
memset(&m_FrontendStatus, 0, sizeof(m_FrontendStatus));
memset(&m_FrontendInfo, 0, sizeof(m_FrontendInfo));
m_SvdrpConnection.handle = -1;
m_Font = cFont::CreateFont(Setup.FontSml, min(max(Setup.FontSmlSize, MINFONTSIZE), MAXFONTSIZE));
if (!m_Font || !m_Font->Height()) {
m_Font = new cFemonDummyFont;
esyslog("ERROR: cFemonOsd::cFemonOsd() cannot create required font.");
error("cFemonOsd::cFemonOsd() cannot create required font.");
}
tmp = 5 * bmSymbol[SYMBOL_LOCK].Width() + 6 * OSDSPACING;
if (OSDWIDTH < tmp) {
esyslog("ERROR: cFemonOsd::cFemonOsd() OSD width (%d) smaller than required (%d).", OSDWIDTH, tmp);
error("cFemonOsd::cFemonOsd() OSD width (%d) smaller than required (%d).", OSDWIDTH, tmp);
OSDWIDTH = tmp;
}
tmp = OSDINFOHEIGHT + OSDROWHEIGHT + OSDSTATUSHEIGHT;
if (OSDHEIGHT < tmp) {
esyslog("ERROR: cFemonOsd::cFemonOsd() OSD height (%d) smaller than required (%d).", OSDHEIGHT, tmp);
error("cFemonOsd::cFemonOsd() OSD height (%d) smaller than required (%d).", OSDHEIGHT, tmp);
OSDHEIGHT = tmp;
}
}
cFemonOsd::~cFemonOsd(void)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
m_Sleep.Signal();
if (Running())
Cancel(3);
@ -503,7 +503,7 @@ void cFemonOsd::DrawInfoWindow(void)
void cFemonOsd::Action(void)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
cTimeMs t;
SvdrpCommand_v1_0 cmd;
cmd.command = cString::sprintf("PLUG %s INFO\r\n", PLUGIN_NAME_I18N);
@ -574,7 +574,7 @@ void cFemonOsd::Action(void)
void cFemonOsd::Show(void)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
int apid[2] = {0, 0};
int dpid[2] = {0, 0};
eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack();
@ -583,7 +583,7 @@ void cFemonOsd::Show(void)
if (m_Frontend >= 0) {
if (ioctl(m_Frontend, FE_GET_INFO, &m_FrontendInfo) < 0) {
if (!femonConfig.usesvdrp)
esyslog("ERROR: cFemonOsd::Show() cannot read frontend info.");
error("cFemonOsd::Show() cannot read frontend info.");
close(m_Frontend);
m_Frontend = -1;
memset(&m_FrontendInfo, 0, sizeof(m_FrontendInfo));
@ -595,7 +595,7 @@ void cFemonOsd::Show(void)
return;
}
else {
esyslog("ERROR: cFemonOsd::Show() cannot open frontend device.");
error("cFemonOsd::Show() cannot open frontend device.");
return;
}
@ -633,7 +633,7 @@ void cFemonOsd::Show(void)
void cFemonOsd::ChannelSwitch(const cDevice * device, int channelNumber)
{
Dprintf("%s(%d,%d)\n", __PRETTY_FUNCTION__, device->DeviceNumber(), channelNumber);
debug("%s(%d,%d)\n", __PRETTY_FUNCTION__, device->DeviceNumber(), channelNumber);
int apid[2] = {0, 0};
int dpid[2] = {0, 0};
eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack();
@ -645,7 +645,7 @@ void cFemonOsd::ChannelSwitch(const cDevice * device, int channelNumber)
if (m_Frontend >= 0) {
if (ioctl(m_Frontend, FE_GET_INFO, &m_FrontendInfo) < 0) {
if (!femonConfig.usesvdrp)
esyslog("ERROR: cFemonOsd::ChannelSwitch() cannot read frontend info.");
error("cFemonOsd::ChannelSwitch() cannot read frontend info.");
close(m_Frontend);
m_Frontend = -1;
memset(&m_FrontendInfo, 0, sizeof(m_FrontendInfo));
@ -657,7 +657,7 @@ void cFemonOsd::ChannelSwitch(const cDevice * device, int channelNumber)
return;
}
else {
esyslog("ERROR: cFemonOsd::ChannelSwitch() cannot open frontend device.");
error("cFemonOsd::ChannelSwitch() cannot open frontend device.");
return;
}
@ -678,7 +678,7 @@ void cFemonOsd::ChannelSwitch(const cDevice * device, int channelNumber)
void cFemonOsd::SetAudioTrack(int Index, const char * const *Tracks)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
int apid[2] = {0, 0};
int dpid[2] = {0, 0};
eTrackType track = cDevice::PrimaryDevice()->GetCurrentAudioTrack();
@ -699,7 +699,7 @@ void cFemonOsd::SetAudioTrack(int Index, const char * const *Tracks)
bool cFemonOsd::DeviceSwitch(int direction)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
int device = cDevice::ActualDevice()->DeviceNumber();
direction = sgn(direction);
if (device >= 0) {
@ -715,7 +715,7 @@ bool cFemonOsd::DeviceSwitch(int direction)
device = cDevice::NumDevices() - 1;
}
if (cDevice::GetDevice(device)->ProvidesChannel(channel, 0)) {
Dprintf("%s(%d) device(%d)\n", __PRETTY_FUNCTION__, direction, device);
debug("%s(%d) device(%d)\n", __PRETTY_FUNCTION__, direction, device);
cStatus::MsgChannelSwitch(cDevice::PrimaryDevice(), 0);
cControl::Shutdown();
cDevice::GetDevice(device)->SwitchChannel(channel, true);
@ -747,14 +747,14 @@ bool cFemonOsd::SvdrpConnect(void)
m_SvdrpPlugin->Service("SvdrpCommand-v1.0", &cmd);
if (cmd.responseCode != 214) {
m_SvdrpPlugin->Service("SvdrpConnection-v1.0", &m_SvdrpConnection); // close connection
esyslog("ERROR: cFemonOsd::SvdrpConnect() cannot find plugin '%s' on server %s.", PLUGIN_NAME_I18N, *m_SvdrpConnection.serverIp);
error("cFemonOsd::SvdrpConnect() cannot find plugin '%s' on server %s.", PLUGIN_NAME_I18N, *m_SvdrpConnection.serverIp);
}
}
else
esyslog("ERROR: cFemonOsd::SvdrpConnect() cannot connect to SVDRP server.");
error("cFemonOsd::SvdrpConnect() cannot connect to SVDRP server.");
}
else
esyslog("ERROR: cFemonOsd::SvdrpConnect() cannot find plugin '%s'.", SVDRPPLUGIN);
error("cFemonOsd::SvdrpConnect() cannot find plugin '%s'.", SVDRPPLUGIN);
}
return m_SvdrpConnection.handle >= 0;
}
@ -770,19 +770,19 @@ bool cFemonOsd::SvdrpTune(void)
m_SvdrpPlugin->Service("SvdrpCommand-v1.0", &cmd);
if (cmd.responseCode == 250)
return true;
esyslog("ERROR: cFemonOsd::SvdrpTune() cannot tune server channel.");
error("cFemonOsd::SvdrpTune() cannot tune server channel.");
}
else
esyslog("ERROR: cFemonOsd::SvdrpTune() invalid channel.");
error("cFemonOsd::SvdrpTune() invalid channel.");
}
else
esyslog("ERROR: cFemonOsd::SvdrpTune() unexpected connection state.");
error("cFemonOsd::SvdrpTune() unexpected connection state.");
return false;
}
double cFemonOsd::GetVideoBitrate(void)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
double value = 0.0;
if (m_Receiver)
@ -793,7 +793,7 @@ double cFemonOsd::GetVideoBitrate(void)
double cFemonOsd::GetAudioBitrate(void)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
double value = 0.0;
if (m_Receiver)
@ -804,7 +804,7 @@ double cFemonOsd::GetAudioBitrate(void)
double cFemonOsd::GetDolbyBitrate(void)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
double value = 0.0;
if (m_Receiver)

View File

@ -37,7 +37,7 @@ cFemonReceiver::cFemonReceiver(tChannelID ChannelID, int Ca, int Vtype, int Vpid
m_AC3Bitrate(0),
m_AC3Valid(false)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
m_VideoBuffer.SetTimeouts(0, 100);
m_AudioBuffer.SetTimeouts(0, 100);
@ -68,13 +68,13 @@ cFemonReceiver::cFemonReceiver(tChannelID ChannelID, int Ca, int Vtype, int Vpid
cFemonReceiver::~cFemonReceiver(void)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
Deactivate();
}
void cFemonReceiver::Deactivate(void)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
if (m_Active) {
m_Active = false;
m_Sleep.Signal();
@ -86,7 +86,7 @@ void cFemonReceiver::Deactivate(void)
void cFemonReceiver::Activate(bool On)
{
Dprintf("%s(%d)\n", __PRETTY_FUNCTION__, On);
debug("%s(%d)\n", __PRETTY_FUNCTION__, On);
if (On)
Start();
else
@ -127,7 +127,7 @@ void cFemonReceiver::Receive(uchar *Data, int Length)
void cFemonReceiver::Action(void)
{
Dprintf("%s()\n", __PRETTY_FUNCTION__);
debug("%s()\n", __PRETTY_FUNCTION__);
cTimeMs calcPeriod(0);
m_Active = true;

View File

@ -14,9 +14,11 @@
#include <vdr/tools.h>
#ifdef DEBUG
#define Dprintf(x...) printf(x);
#define debug(x...) dsyslog("FEMON: " x);
#define error(x...) esyslog("ERROR: " x);
#else
#define Dprintf(x...) ;
#define debug(x...) ;
#define error(x...) esyslog("ERROR: " x);
#endif
#define ELEMENTS(x) (sizeof(x) / sizeof(x[0]))