- streaminfo: minor re-formatations and whitespace cleanups

# Conflicts:
#	src/gui/streaminfo2.cpp
This commit is contained in:
2017-11-10 12:41:55 +01:00
parent 34acd9b262
commit 4ba276f746
2 changed files with 282 additions and 169 deletions

View File

@@ -71,8 +71,8 @@ extern CRemoteControl *g_RemoteControl; /* neutrino.cpp */
CStreamInfo2::CStreamInfo2() : fader(g_settings.theme.menu_Content_alpha) CStreamInfo2::CStreamInfo2() : fader(g_settings.theme.menu_Content_alpha)
{ {
frameBuffer = CFrameBuffer::getInstance (); frameBuffer = CFrameBuffer::getInstance ();
pip = NULL; pip = NULL;
signalbox = NULL; signalbox = NULL;
font_head = SNeutrinoSettings::FONT_TYPE_MENU_TITLE; font_head = SNeutrinoSettings::FONT_TYPE_MENU_TITLE;
font_info = SNeutrinoSettings::FONT_TYPE_MENU; font_info = SNeutrinoSettings::FONT_TYPE_MENU;
font_small = SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL; font_small = SNeutrinoSettings::FONT_TYPE_INFOBAR_SMALL;
@@ -84,7 +84,7 @@ CStreamInfo2::CStreamInfo2() : fader(g_settings.theme.menu_Content_alpha)
max_width = frameBuffer->getScreenWidth(true); max_width = frameBuffer->getScreenWidth(true);
max_height = frameBuffer->getScreenHeight(true); max_height = frameBuffer->getScreenHeight(true);
width = frameBuffer->getScreenWidth(); width = frameBuffer->getScreenWidth();
height = frameBuffer->getScreenHeight(); height = frameBuffer->getScreenHeight();
x = frameBuffer->getScreenX(); x = frameBuffer->getScreenX();
y = frameBuffer->getScreenY(); y = frameBuffer->getScreenY();
@@ -148,7 +148,8 @@ void CStreamInfo2::analyzeStream(AVFormatContext *avfc, unsigned int idx)
AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0); AVDictionaryEntry *lang = av_dict_get(st->metadata, "language", NULL, 0);
if (lang) if (lang)
m["language"] = getISO639Description(lang->value); m["language"] = getISO639Description(lang->value);
else { else
{
lang = av_dict_get(st->metadata, "lang", NULL, 0); lang = av_dict_get(st->metadata, "lang", NULL, 0);
if (lang) if (lang)
m["language"] = getISO639Description(lang->value); m["language"] = getISO639Description(lang->value);
@@ -158,15 +159,15 @@ void CStreamInfo2::analyzeStream(AVFormatContext *avfc, unsigned int idx)
avcodec_string(buf, sizeof(buf), st->codec, 0); avcodec_string(buf, sizeof(buf), st->codec, 0);
m["codec"] = buf; m["codec"] = buf;
size_t pos = m["codec"].find_first_of(":"); size_t pos = m["codec"].find_first_of(":");
if ( pos != std::string::npos) if (pos != std::string::npos)
m["codec"] = m["codec"].erase(0,pos+2); m["codec"] = m["codec"].erase(0,pos+2);
m["codec_type"] = av_get_media_type_string(st->codec->codec_type); m["codec_type"] = av_get_media_type_string(st->codec->codec_type);
m["codec_type"][0] ^= 'a' ^ 'A'; m["codec_type"][0] ^= 'a' ^ 'A';
m["pid"] = to_string(st->id); m["pid"] = to_string(st->id);
if (st->sample_aspect_ratio.num && // default if (st->sample_aspect_ratio.num && av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio))
av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) { {
AVRational display_aspect_ratio; AVRational display_aspect_ratio;
av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den,
st->codec->width * st->sample_aspect_ratio.num, st->codec->width * st->sample_aspect_ratio.num,
@@ -177,7 +178,8 @@ void CStreamInfo2::analyzeStream(AVFormatContext *avfc, unsigned int idx)
snprintf(buf, sizeof(buf), "%d:%d", display_aspect_ratio.num, display_aspect_ratio.den); snprintf(buf, sizeof(buf), "%d:%d", display_aspect_ratio.num, display_aspect_ratio.den);
m["dar"] = buf; m["dar"] = buf;
} }
if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO) { if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO)
{
if (st->avg_frame_rate.den && st->avg_frame_rate.num) if (st->avg_frame_rate.den && st->avg_frame_rate.num)
m["fps"] = fps_str(av_q2d(st->avg_frame_rate)); m["fps"] = fps_str(av_q2d(st->avg_frame_rate));
#if FF_API_R_FRAME_RATE #if FF_API_R_FRAME_RATE
@@ -230,7 +232,7 @@ void CStreamInfo2::analyzeStreams(AVFormatContext *avfc)
static cDemux * dmx = NULL; static cDemux * dmx = NULL;
#define TS_LEN 188 #define TS_LEN 188
#define TS_BUF_SIZE (1024 * 1024 * 8 / TS_LEN * TS_LEN) #define TS_BUF_SIZE (1024 * 1024 * 8 / TS_LEN * TS_LEN)
static int read_packet(void *opaque, uint8_t *buf, int buf_size) static int read_packet(void *opaque, uint8_t *buf, int buf_size)
{ {
@@ -245,9 +247,11 @@ int CStreamInfo2::readPacket(uint8_t *buf, int buf_size)
while (!abort_probing && (probebuf_length == probebuf_off) && (probebuf_off != probebuf_size)) while (!abort_probing && (probebuf_length == probebuf_off) && (probebuf_off != probebuf_size))
usleep(10000); usleep(10000);
if (!abort_probing) { if (!abort_probing)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(probe_mutex); OpenThreads::ScopedLock<OpenThreads::Mutex> lock(probe_mutex);
if (probebuf) { if (probebuf)
{
int len = std::min(buf_size, (int)(probebuf_length - probebuf_off)); int len = std::min(buf_size, (int)(probebuf_length - probebuf_off));
memcpy(buf, probebuf + probebuf_off, len); memcpy(buf, probebuf + probebuf_off, len);
probebuf_off += len; probebuf_off += len;
@@ -273,14 +277,18 @@ static int interrupt_cb(void *arg)
void CStreamInfo2::probeStreams() void CStreamInfo2::probeStreams()
{ {
if (mp) { if (mp)
{
AVFormatContext *avfc = mp->getPlayback()->GetAVFormatContext(); AVFormatContext *avfc = mp->getPlayback()->GetAVFormatContext();
if (avfc) { if (avfc)
{
analyzeStreams(avfc); analyzeStreams(avfc);
mp->getPlayback()->ReleaseAVFormatContext(); mp->getPlayback()->ReleaseAVFormatContext();
} }
probed = true; probed = true;
} else { }
else
{
#ifdef ENABLE_FFMPEG_LOGGING #ifdef ENABLE_FFMPEG_LOGGING
av_log_set_callback(log_callback); av_log_set_callback(log_callback);
#endif #endif
@@ -291,7 +299,8 @@ void CStreamInfo2::probeStreams()
int buffer_size = 188 * 128; int buffer_size = 188 * 128;
unsigned char *buffer = (unsigned char *) av_malloc(buffer_size); unsigned char *buffer = (unsigned char *) av_malloc(buffer_size);
AVFormatContext *avfc = avformat_alloc_context(); AVFormatContext *avfc = avformat_alloc_context();
if (!avfc) { if (!avfc)
{
av_freep(&buffer); av_freep(&buffer);
goto bye; goto bye;
} }
@@ -300,7 +309,8 @@ void CStreamInfo2::probeStreams()
avfc->interrupt_callback.opaque = (void *) this; avfc->interrupt_callback.opaque = (void *) this;
avioc = avio_alloc_context (buffer, buffer_size, 0, this, read_packet, NULL, NULL); avioc = avio_alloc_context (buffer, buffer_size, 0, this, read_packet, NULL, NULL);
if (!avioc) { if (!avioc)
{
av_freep(&buffer); av_freep(&buffer);
avformat_free_context(avfc); avformat_free_context(avfc);
goto bye; goto bye;
@@ -310,7 +320,8 @@ void CStreamInfo2::probeStreams()
avfc->flags |= AVFMT_FLAG_CUSTOM_IO; avfc->flags |= AVFMT_FLAG_CUSTOM_IO;
avfc->probesize = probebuf_size/2; avfc->probesize = probebuf_size/2;
if (!avformat_open_input(&avfc, "", NULL, NULL)) { if (!avformat_open_input(&avfc, "", NULL, NULL))
{
avformat_find_stream_info(avfc, NULL); avformat_find_stream_info(avfc, NULL);
analyzeStreams(avfc); analyzeStreams(avfc);
} }
@@ -320,7 +331,8 @@ void CStreamInfo2::probeStreams()
probed = true; probed = true;
bye: bye:
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(probe_mutex); OpenThreads::ScopedLock<OpenThreads::Mutex> lock(probe_mutex);
if(probebuf) { if (probebuf)
{
delete [] probebuf; delete [] probebuf;
probebuf = NULL; probebuf = NULL;
} }
@@ -364,7 +376,7 @@ int CStreamInfo2::doSignalStrengthLoop ()
#define BAR_WIDTH 150 #define BAR_WIDTH 150
#define BAR_HEIGHT 12 #define BAR_HEIGHT 12
int res = menu_return::RETURN_REPAINT; int res = menu_return::RETURN_REPAINT;
bool fadeout = false; bool fadeout = false;
neutrino_msg_t msg; neutrino_msg_t msg;
neutrino_msg_t postmsg = 0; neutrino_msg_t postmsg = 0;
@@ -379,13 +391,15 @@ int CStreamInfo2::doSignalStrengthLoop ()
bool repaint_bitrate = true; bool repaint_bitrate = true;
ts_setup (); ts_setup ();
frameBuffer->blit(); frameBuffer->blit();
while (1) { while (1)
{
neutrino_msg_data_t data; neutrino_msg_data_t data;
uint64_t timeoutEnd = CRCInput::calcTimeoutEnd_MS(10); uint64_t timeoutEnd = CRCInput::calcTimeoutEnd_MS(10);
g_RCInput->getMsgAbsoluteTimeout (&msg, &data, &timeoutEnd); g_RCInput->getMsgAbsoluteTimeout (&msg, &data, &timeoutEnd);
if (!mp) { if (!mp)
{
signal.sig = 100 * (frontend->getSignalStrength() & 0xFFFF) >> 16; signal.sig = 100 * (frontend->getSignalStrength() & 0xFFFF) >> 16;
signal.snr = 100 * (frontend->getSignalNoiseRatio() & 0xFFFF) >> 16; signal.snr = 100 * (frontend->getSignalNoiseRatio() & 0xFFFF) >> 16;
signal.ber = 100 * (frontend->getBitErrorRate() & 0xFFFF) >> 16; // FIXME? signal.ber = 100 * (frontend->getBitErrorRate() & 0xFFFF) >> 16; // FIXME?
@@ -393,22 +407,35 @@ int CStreamInfo2::doSignalStrengthLoop ()
bool got_rate = update_rate(); bool got_rate = update_rate();
if (got_rate && (lastb != bit_s)) { if (got_rate && (lastb != bit_s))
{
if (maxb < bit_s) if (maxb < bit_s)
rate.max_short_average = maxb = bit_s; rate.max_short_average = maxb = bit_s;
if ((cnt > 10) && ((minb == 0) || (minb > bit_s))) if ((cnt > 10) && ((minb == 0) || (minb > bit_s)))
rate.min_short_average = minb = bit_s; rate.min_short_average = minb = bit_s;
} }
if (paint_mode == 0) { if (paint_mode == 0)
{
if (cnt < 12) if (cnt < 12)
cnt++; cnt++;
int dx1 = x + 10; int dx1 = x + 10;
if (got_rate && (rate.short_average || lastb) && (lastb != bit_s)) { if (!mp && delay_counter > delay + 1)
if (repaint_bitrate) { {
CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel();
if (channel)
pmt_version = channel->getPmtVersion();
if (pmt_version != current_pmt_version)
delay_counter = 0;
}
if (got_rate && (rate.short_average || lastb) && (lastb != bit_s))
{
if (repaint_bitrate)
{
snprintf(tmp_str, sizeof(tmp_str), "%s:",g_Locale->getText(LOCALE_STREAMINFO_BITRATE)); snprintf(tmp_str, sizeof(tmp_str), "%s:",g_Locale->getText(LOCALE_STREAMINFO_BITRATE));
g_Font[font_info]->RenderString(dx1, average_bitrate_pos, spaceoffset, tmp_str, COL_MENUCONTENT_TEXT); g_Font[font_info]->RenderString(dx1, average_bitrate_pos, spaceoffset, tmp_str, COL_MENUCONTENT_TEXT);
snprintf(tmp_str, sizeof(tmp_str), " (%s)",g_Locale->getText(LOCALE_STREAMINFO_AVERAGE_BITRATE)); snprintf(tmp_str, sizeof(tmp_str), " (%s)",g_Locale->getText(LOCALE_STREAMINFO_AVERAGE_BITRATE));
g_Font[font_info]->RenderString(dx1 + spaceoffset + sw , average_bitrate_pos, box_width - spaceoffset - sw, tmp_str, COL_MENUCONTENT_TEXT); g_Font[font_info]->RenderString(dx1 + spaceoffset + sw , average_bitrate_pos, box_width - spaceoffset - sw, tmp_str, COL_MENUCONTENT_TEXT);
repaint_bitrate = false; repaint_bitrate = false;
@@ -427,7 +454,8 @@ int CStreamInfo2::doSignalStrengthLoop ()
g_Font[font_info]->RenderString (dx1 + spaceoffset, average_bitrate_pos, sw, currate, COL_MENUCONTENT_TEXT); g_Font[font_info]->RenderString (dx1 + spaceoffset, average_bitrate_pos, sw, currate, COL_MENUCONTENT_TEXT);
lastb = bit_s; lastb = bit_s;
} }
if((!mp && pmt_version != current_pmt_version && delay_counter > delay) || probed){ if ((!mp && pmt_version != current_pmt_version && delay_counter > delay) || probed)
{
probed = false; probed = false;
current_pmt_version = pmt_version; current_pmt_version = pmt_version;
paint_techinfo(techinfo_xpos, techinfo_ypos); paint_techinfo(techinfo_xpos, techinfo_ypos);
@@ -459,11 +487,12 @@ int CStreamInfo2::doSignalStrengthLoop ()
if ((signal.min_snr == 0) || (signal.min_snr > signal.snr)) if ((signal.min_snr == 0) || (signal.min_snr > signal.snr))
signal.min_snr = signal.snr; signal.min_snr = signal.snr;
if (got_rate) { if (got_rate)
paint_signal_fe(rate, signal); {
signal.old_sig = signal.sig; paint_signal_fe(rate, signal);
signal.old_snr = signal.snr; signal.old_sig = signal.sig;
signal.old_ber = signal.ber; signal.old_snr = signal.snr;
signal.old_ber = signal.ber;
} }
g_RCInput->getMsg_us(&msg, &data, 0); g_RCInput->getMsg_us(&msg, &data, 0);
@@ -490,23 +519,27 @@ int CStreamInfo2::doSignalStrengthLoop ()
} }
// switch paint mode // switch paint mode
if (msg == CRCInput::RC_red || msg == CRCInput::RC_blue || msg == CRCInput::RC_green || msg == CRCInput::RC_yellow) { if (msg == CRCInput::RC_red || msg == CRCInput::RC_blue || msg == CRCInput::RC_green || msg == CRCInput::RC_yellow)
{
hide (); hide ();
paint_mode = !paint_mode; paint_mode = !paint_mode;
paint (paint_mode); paint (paint_mode);
repaint_bitrate = true; repaint_bitrate = true;
continue; continue;
} }
else if(msg == CRCInput::RC_setup || msg == CRCInput::RC_home) { else if (msg == CRCInput::RC_setup || msg == CRCInput::RC_home)
{
res = menu_return::RETURN_EXIT_ALL; res = menu_return::RETURN_EXIT_ALL;
fadeout = true; fadeout = true;
} }
else if(CNeutrinoApp::getInstance()->listModeKey(msg)) { else if (CNeutrinoApp::getInstance()->listModeKey(msg))
{
postmsg = msg; postmsg = msg;
res = menu_return::RETURN_EXIT_ALL; res = menu_return::RETURN_EXIT_ALL;
fadeout = true; fadeout = true;
} }
else if (msg == (neutrino_msg_t) g_settings.key_screenshot) { else if (msg == (neutrino_msg_t) g_settings.key_screenshot)
{
CNeutrinoApp::getInstance ()->handleMsg (msg, data); CNeutrinoApp::getInstance ()->handleMsg (msg, data);
continue; continue;
} }
@@ -570,11 +603,14 @@ void CStreamInfo2::paint_signal_fe_box(int _x, int _y, int w, int h)
int xd; int xd;
int col = 0; int col = 0;
if (paint_mode == 0) { if (paint_mode == 0)
{
maxmin_x = _x; maxmin_x = _x;
xd = (w - 5 * fontW)/4; xd = (w - 5 * fontW)/4;
_x += 5 * fontW; _x += 5 * fontW;
} else { }
else
{
maxmin_x = _x + 40; maxmin_x = _x + 40;
xd = (w - 5 * fontW + 40)/5; xd = (w - 5 * fontW + 40)/5;
col = 1; col = 1;
@@ -584,17 +620,18 @@ void CStreamInfo2::paint_signal_fe_box(int _x, int _y, int w, int h)
g_Font[font_small]->RenderString(maxmin_x, y1 + (sheight * 2) +5, fw*3, "now", COL_MENUCONTENT_TEXT); g_Font[font_small]->RenderString(maxmin_x, y1 + (sheight * 2) +5, fw*3, "now", COL_MENUCONTENT_TEXT);
g_Font[font_small]->RenderString(maxmin_x, y1 + (sheight * 3) +5, fw*3, "min", COL_MENUCONTENT_TEXT); g_Font[font_small]->RenderString(maxmin_x, y1 + (sheight * 3) +5, fw*3, "min", COL_MENUCONTENT_TEXT);
if (!mp) { if (!mp)
{
g_Font[font_small]->RenderString(_x+xd*col, y1, fw*8, "BER [%]", COL_RED); g_Font[font_small]->RenderString(_x+xd*col, y1, fw*8, "BER [%]", COL_RED);
sig_text_ber_x = _x + 5 + xd * col; sig_text_ber_x = _x + 5 + xd * col;
col++; col++;
g_Font[font_small]->RenderString(_x+xd*col, y1, fw*8, "SNR [%]", COL_LIGHT_BLUE); g_Font[font_small]->RenderString(_x+xd*col, y1, fw*8, "SNR [%]", COL_LIGHT_BLUE);
sig_text_snr_x = _x + 5 + xd * col; sig_text_snr_x = _x + 5 + xd * col;
col++; col++;
g_Font[font_small]->RenderString(_x+xd*col, y1, fw*8, "SIG [%]", COL_GREEN); g_Font[font_small]->RenderString(_x+xd*col, y1, fw*8, "SIG [%]", COL_GREEN);
sig_text_sig_x = _x + 5 + xd * col; sig_text_sig_x = _x + 5 + xd * col;
col++; col++;
} }
@@ -610,9 +647,9 @@ void CStreamInfo2::paint_signal_fe_box(int _x, int _y, int w, int h)
void CStreamInfo2::paint_signal_fe(struct bitrate br, struct feSignal s) void CStreamInfo2::paint_signal_fe(struct bitrate br, struct feSignal s)
{ {
int x_now = sigBox_pos; int x_now = sigBox_pos;
int yt = sig_text_y + (sheight *2)+4; int yt = sig_text_y + (sheight *2)+4;
int yd; int yd;
static int old_x=0,old_y=0; static int old_x=0,old_y=0;
sigBox_pos++; sigBox_pos++;
sigBox_pos %= sigBox_w; sigBox_pos %= sigBox_w;
@@ -622,25 +659,33 @@ void CStreamInfo2::paint_signal_fe(struct bitrate br, struct feSignal s)
long value = (long) (bit_s / 1000ULL); long value = (long) (bit_s / 1000ULL);
SignalRenderStr(value, sig_text_rate_x, yt + sheight); SignalRenderStr(value, sig_text_rate_x, yt + sheight);
SignalRenderStr(br.max_short_average/ 1000ULL, sig_text_rate_x, yt); SignalRenderStr(br.max_short_average/ 1000ULL, sig_text_rate_x, yt);
SignalRenderStr(br.min_short_average/ 1000ULL, sig_text_rate_x, yt + (sheight * 2)); SignalRenderStr(br.min_short_average/ 1000ULL, sig_text_rate_x, yt + (sheight * 2));
if (mp || g_RemoteControl->current_PIDs.PIDs.vpid > 0 ){ if (mp || g_RemoteControl->current_PIDs.PIDs.vpid > 0)
{
yd = y_signal_fe (value, scaling, sigBox_h);// Video + Audio yd = y_signal_fe (value, scaling, sigBox_h);// Video + Audio
} else { }
else
{
yd = y_signal_fe (value, 512, sigBox_h); // Audio only yd = y_signal_fe (value, 512, sigBox_h); // Audio only
} }
if ((old_x == 0 && old_y == 0) || sigBox_pos == 1) { if ((old_x == 0 && old_y == 0) || sigBox_pos == 1)
{
old_x = sigBox_x+x_now; old_x = sigBox_x+x_now;
old_y = sigBox_y+sigBox_h-yd; old_y = sigBox_y+sigBox_h-yd;
} else { }
else
{
frameBuffer->paintLine(old_x, old_y, sigBox_x+x_now, sigBox_y+sigBox_h-yd, COL_YELLOW); //yellow frameBuffer->paintLine(old_x, old_y, sigBox_x+x_now, sigBox_y+sigBox_h-yd, COL_YELLOW); //yellow
old_x = sigBox_x+x_now; old_x = sigBox_x+x_now;
old_y = sigBox_y+sigBox_h-yd; old_y = sigBox_y+sigBox_h-yd;
} }
if (!mp) { if (!mp)
if (s.ber != s.old_ber) { {
if (s.ber != s.old_ber)
{
SignalRenderStr(s.ber, sig_text_ber_x, yt + sheight); SignalRenderStr(s.ber, sig_text_ber_x, yt + sheight);
SignalRenderStr(s.max_ber, sig_text_ber_x, yt); SignalRenderStr(s.max_ber, sig_text_ber_x, yt);
SignalRenderStr(s.min_ber, sig_text_ber_x, yt + (sheight * 2)); SignalRenderStr(s.min_ber, sig_text_ber_x, yt + (sheight * 2));
@@ -648,7 +693,8 @@ void CStreamInfo2::paint_signal_fe(struct bitrate br, struct feSignal s)
yd = y_signal_fe (s.ber, 100, sigBox_h); yd = y_signal_fe (s.ber, 100, sigBox_h);
frameBuffer->paintPixel(sigBox_x+x_now, sigBox_y+sigBox_h-yd, COL_RED); frameBuffer->paintPixel(sigBox_x+x_now, sigBox_y+sigBox_h-yd, COL_RED);
if (s.sig != s.old_sig) { if (s.sig != s.old_sig)
{
SignalRenderStr(s.sig, sig_text_sig_x, yt + sheight); SignalRenderStr(s.sig, sig_text_sig_x, yt + sheight);
SignalRenderStr(s.max_sig, sig_text_sig_x, yt); SignalRenderStr(s.max_sig, sig_text_sig_x, yt);
SignalRenderStr(s.min_sig, sig_text_sig_x, yt + (sheight * 2)); SignalRenderStr(s.min_sig, sig_text_sig_x, yt + (sheight * 2));
@@ -656,7 +702,8 @@ void CStreamInfo2::paint_signal_fe(struct bitrate br, struct feSignal s)
yd = y_signal_fe (s.sig, 100, sigBox_h); yd = y_signal_fe (s.sig, 100, sigBox_h);
frameBuffer->paintPixel(sigBox_x+x_now, sigBox_y+sigBox_h-yd, COL_GREEN); frameBuffer->paintPixel(sigBox_x+x_now, sigBox_y+sigBox_h-yd, COL_GREEN);
if (s.snr != s.old_snr) { if (s.snr != s.old_snr)
{
SignalRenderStr(s.snr, sig_text_snr_x, yt + sheight); SignalRenderStr(s.snr, sig_text_snr_x, yt + sheight);
SignalRenderStr(s.max_snr, sig_text_snr_x, yt); SignalRenderStr(s.max_snr, sig_text_snr_x, yt);
SignalRenderStr(s.min_snr, sig_text_snr_x, yt + (sheight * 2)); SignalRenderStr(s.min_snr, sig_text_snr_x, yt + (sheight * 2));
@@ -702,14 +749,15 @@ void CStreamInfo2::paint (int /*mode*/)
{ {
const char *head_string; const char *head_string;
width = frameBuffer->getScreenWidth(); width = frameBuffer->getScreenWidth();
height = frameBuffer->getScreenHeight(); height = frameBuffer->getScreenHeight();
x = frameBuffer->getScreenX(); x = frameBuffer->getScreenX();
y = frameBuffer->getScreenY(); y = frameBuffer->getScreenY();
int ypos = y + 5; int ypos = y + 5;
int xpos = x + 10; int xpos = x + 10;
if (paint_mode == 0) { if (paint_mode == 0)
{
// -- tech Infos, PIG, small signal graph // -- tech Infos, PIG, small signal graph
head_string = g_Locale->getText (LOCALE_STREAMINFO_HEAD); head_string = g_Locale->getText (LOCALE_STREAMINFO_HEAD);
CVFD::getInstance ()->setMode (CVFD::MODE_MENU_UTF8, head_string); CVFD::getInstance ()->setMode (CVFD::MODE_MENU_UTF8, head_string);
@@ -728,11 +776,13 @@ void CStreamInfo2::paint (int /*mode*/)
paint_techinfo (xpos, ypos); paint_techinfo (xpos, ypos);
paint_signal_fe_box (width - width/3 - 10, (y + 10 + height/3 + hheight), width/3, height/3 + hheight); paint_signal_fe_box (width - width/3 - 10, (y + 10 + height/3 + hheight), width/3, height/3 + hheight);
} else { }
else
{
delete signalbox; delete signalbox;
signalbox = NULL; signalbox = NULL;
// -- small PIG, small signal graph // -- small PIG, small signal graph
// -- paint backround, title pig, etc. // -- paint backround, title pig, etc.
frameBuffer->paintBoxRel (0, 0, max_width, max_height, COL_MENUCONTENT_PLUS_0); frameBuffer->paintBoxRel (0, 0, max_width, max_height, COL_MENUCONTENT_PLUS_0);
@@ -746,9 +796,9 @@ struct row {
std::string val; std::string val;
Font *f; Font *f;
int col; int col;
row(): f(g_Font[SNeutrinoSettings::FONT_TYPE_MENU]) row(): f(g_Font[SNeutrinoSettings::FONT_TYPE_MENU])
{ {
} }
}; };
void CStreamInfo2::paint_techinfo(int xpos, int ypos) void CStreamInfo2::paint_techinfo(int xpos, int ypos)
@@ -760,11 +810,11 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
box_width = width*2/3 - 10 - xpos; box_width = width*2/3 - 10 - xpos;
yypos = ypos; yypos = ypos;
if(box_h > 0) if (box_h > 0)
frameBuffer->paintBoxRel (0, ypos, box_width, box_h, COL_MENUCONTENT_PLUS_0); frameBuffer->paintBoxRel (0, ypos, box_width, box_h, COL_MENUCONTENT_PLUS_0);
CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel(); CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel();
if(!channel) if (!channel)
return; return;
ypos += iheight; ypos += iheight;
@@ -772,12 +822,16 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
std::vector<row> v; std::vector<row> v;
row r; row r;
if (mp) { if (mp)
if (CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webtv) { {
if (CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webtv || CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webradio)
{
// url // url
r.key = "URL"; r.key = "URL";
r.val = channel->getUrl(); r.val = channel->getUrl();
} else { }
else
{
// file // file
r.key = g_Locale->getText (LOCALE_MOVIEBROWSER_INFO_FILE); r.key = g_Locale->getText (LOCALE_MOVIEBROWSER_INFO_FILE);
r.val = mp->GetFile(); r.val = mp->GetFile();
@@ -787,10 +841,11 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
v.push_back(r); v.push_back(r);
//provider //provider
if ((CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webtv) && (channel->pname)) { if ((CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webtv) && (channel->pname))
{
std::string prov_name = channel->pname; std::string prov_name = channel->pname;
prov_name.erase( std::remove(prov_name.begin(), prov_name.end(), '['), prov_name.end() ); prov_name.erase(std::remove(prov_name.begin(), prov_name.end(), '['), prov_name.end());
prov_name.erase( std::remove(prov_name.begin(), prov_name.end(), ']'), prov_name.end() ); prov_name.erase(std::remove(prov_name.begin(), prov_name.end(), ']'), prov_name.end());
r.key = g_Locale->getText (LOCALE_CHANNELLIST_PROVS); r.key = g_Locale->getText (LOCALE_CHANNELLIST_PROVS);
r.key += ": "; r.key += ": ";
r.val = prov_name.c_str(); r.val = prov_name.c_str();
@@ -799,8 +854,9 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
} }
scaling = 8000; scaling = 8000;
}
} else { else
{
// channel // channel
r.key = g_Locale->getText (LOCALE_TIMERLIST_CHANNEL); r.key = g_Locale->getText (LOCALE_TIMERLIST_CHANNEL);
r.key += ": "; r.key += ": ";
@@ -809,10 +865,11 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
v.push_back(r); v.push_back(r);
//provider //provider
if(channel->pname){ if (channel->pname)
{
std::string prov_name = channel->pname; std::string prov_name = channel->pname;
size_t pos = prov_name.find_first_of("]"); size_t pos = prov_name.find_first_of("]");
if((pos != std::string::npos) && (pos+2 < prov_name.length())) if ((pos != std::string::npos) && (pos+2 < prov_name.length()))
prov_name=prov_name.substr(pos+2); prov_name=prov_name.substr(pos+2);
r.key = g_Locale->getText (LOCALE_CHANNELLIST_PROVS); r.key = g_Locale->getText (LOCALE_CHANNELLIST_PROVS);
r.key += ": "; r.key += ": ";
@@ -849,7 +906,8 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
v.push_back(r); v.push_back(r);
// video pid // video pid
if ( g_RemoteControl->current_PIDs.PIDs.vpid){ if (g_RemoteControl->current_PIDs.PIDs.vpid)
{
r.key = "Vpid: "; r.key = "Vpid: ";
i = g_RemoteControl->current_PIDs.PIDs.vpid; i = g_RemoteControl->current_PIDs.PIDs.vpid;
snprintf(buf, sizeof(buf), "0x%04X (%i)", i, i); snprintf(buf, sizeof(buf), "0x%04X (%i)", i, i);
@@ -860,10 +918,11 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
} }
#if BOXMODEL_UFS910 #if BOXMODEL_UFS910
if(mp || channel->getVideoPid()) { if (mp || channel->getVideoPid())
#else #else
if(((mp && IS_WEBCHAN(channel->getChannelID()) && CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webtv) || channel->getVideoPid()) && !(videoDecoder->getBlank())) { if (((mp && IS_WEBCHAN(channel->getChannelID()) && CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webtv) || channel->getVideoPid()) && !(videoDecoder->getBlank()))
#endif #endif
{
videoDecoder->getPictureInfo(xres, yres, framerate); videoDecoder->getPictureInfo(xres, yres, framerate);
if (yres == 1088) if (yres == 1088)
yres = 1080; yres = 1080;
@@ -880,23 +939,29 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
std::string tmp_fps = ""; std::string tmp_fps = "";
std::string tmp_ar = ""; std::string tmp_ar = "";
for (std::vector<std::map<std::string,std::string> >::iterator it = streamdata.begin(); it != streamdata.end(); ++it) for (std::vector<std::map<std::string,std::string> >::iterator it = streamdata.begin(); it != streamdata.end(); ++it)
if ((*it)["codec_type"].substr(0,5) == "Video") { {
tmp_ar = (*it)["dar"]; if ((*it)["codec_type"].substr(0,5) == "Video")
if (!tmp_ar.empty()) {
tmp_ar += " / "; tmp_ar = (*it)["dar"];
tmp_ar += (*it)["sar"]; if (!tmp_ar.empty())
tmp_fps = (*it)["fps"]; tmp_ar += " / ";
tmp_ar += (*it)["sar"];
tmp_fps = (*it)["fps"];
}
} }
// aspect ratio // aspect ratio
r.key = g_Locale->getText (LOCALE_STREAMINFO_ARATIO); r.key = g_Locale->getText (LOCALE_STREAMINFO_ARATIO);
r.key += ": "; r.key += ": ";
if (aspectRatio < 0 || aspectRatio > 4) { if (aspectRatio < 0 || aspectRatio > 4)
{
r.val = tmp_ar; r.val = tmp_ar;
if (r.val.empty()) if (r.val.empty())
r.val = g_Locale->getText (LOCALE_STREAMINFO_ARATIO_UNKNOWN); r.val = g_Locale->getText (LOCALE_STREAMINFO_ARATIO_UNKNOWN);
} else { }
else
{
const char *arr[] = { "N/A", "4:3", "14:9", "16:9", "20:9" }; const char *arr[] = { "N/A", "4:3", "14:9", "16:9", "20:9" };
r.val = arr[aspectRatio]; r.val = arr[aspectRatio];
} }
@@ -906,13 +971,16 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
// video framerate // video framerate
r.key = g_Locale->getText (LOCALE_STREAMINFO_FRAMERATE); r.key = g_Locale->getText (LOCALE_STREAMINFO_FRAMERATE);
r.key += ": "; r.key += ": ";
if (framerate < 0 || framerate > 7) { if (framerate < 0 || framerate > 7)
{
r.val = tmp_fps; r.val = tmp_fps;
if (r.val.empty()) if (r.val.empty())
r.val = g_Locale->getText (LOCALE_STREAMINFO_FRAMERATE_UNKNOWN); r.val = g_Locale->getText (LOCALE_STREAMINFO_FRAMERATE_UNKNOWN);
else else
r.val += "fps"; r.val += "fps";
} else { }
else
{
const char *arr[] = { "23.976fps", "24fps", "25fps", "29,976fps", "30fps", "50fps", "50,94fps", "60fps" }; const char *arr[] = { "23.976fps", "24fps", "25fps", "29,976fps", "30fps", "50fps", "50,94fps", "60fps" };
r.val = arr[framerate]; r.val = arr[framerate];
} }
@@ -924,10 +992,13 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
r.key = r.val = ""; r.key = r.val = "";
v.push_back(r); v.push_back(r);
if (mp) { if (mp)
{
std::string details(" "); std::string details(" ");
for (std::vector<std::map<std::string,std::string> >::iterator it = streamdata.begin(); it != streamdata.end(); ++it) for (std::vector<std::map<std::string,std::string> >::iterator it = streamdata.begin(); it != streamdata.end(); ++it)
if ((*it)["codec_type"].substr(0,5) == "Video") { {
if ((*it)["codec_type"].substr(0,5) == "Video")
{
details = (*it)["language"]; details = (*it)["language"];
if (details != " ") if (details != " ")
details += ", "; details += ", ";
@@ -940,6 +1011,7 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
r.col = COL_MENUCONTENT_TEXT; r.col = COL_MENUCONTENT_TEXT;
v.push_back(r); v.push_back(r);
} }
}
} }
// audio // audio
@@ -947,15 +1019,18 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
r.key += ": "; r.key += ": ";
std::string desc = "N/A"; std::string desc = "N/A";
if (!mp && !g_RemoteControl->current_PIDs.APIDs.empty()) if (!mp && !g_RemoteControl->current_PIDs.APIDs.empty())
desc = g_RemoteControl->current_PIDs.APIDs[g_RemoteControl->current_PIDs.PIDs.selected_apid].desc; desc = g_RemoteControl->current_PIDs.APIDs[g_RemoteControl->current_PIDs.PIDs.selected_apid].desc;
r.val = mp ? mp->getAPIDDesc(mp->getAPID()).c_str() : desc.c_str(); r.val = mp ? mp->getAPIDDesc(mp->getAPID()).c_str() : desc.c_str();
r.col = COL_MENUCONTENT_TEXT; r.col = COL_MENUCONTENT_TEXT;
v.push_back(r); v.push_back(r);
if (mp) { if (mp)
{
std::string details(" "); std::string details(" ");
for (std::vector<std::map<std::string,std::string> >::iterator it = streamdata.begin(); it != streamdata.end(); ++it) for (std::vector<std::map<std::string,std::string> >::iterator it = streamdata.begin(); it != streamdata.end(); ++it)
if ((*it)["codec_type"].substr(0,5) == "Audio") { {
if ((*it)["codec_type"].substr(0,5) == "Audio")
{
details = (*it)["language"]; details = (*it)["language"];
if (details != " ") if (details != " ")
details += ", "; details += ", ";
@@ -964,16 +1039,18 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
details.clear(); details.clear();
r.key = (*it)["codec_type"]; r.key = (*it)["codec_type"];
r.key += ": "; r.key += ": ";
r.val = details.c_str(); r.val = details.c_str();
r.col = COL_MENUCONTENT_TEXT; r.col = COL_MENUCONTENT_TEXT;
v.push_back(r); v.push_back(r);
} }
}
r.key = r.val = ""; r.key = r.val = "";
v.push_back(r); v.push_back(r);
// picon // picon
if (CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webtv || CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webradio) { if (CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webtv || CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webradio)
{
r.key = "Picon"; r.key = "Picon";
r.key += ": "; r.key += ": ";
snprintf(buf, sizeof(buf), "%llx.png", channel->getChannelID() & 0xFFFFFFFFFFFFULL); snprintf(buf, sizeof(buf), "%llx.png", channel->getChannelID() & 0xFFFFFFFFFFFFULL);
@@ -981,11 +1058,12 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
r.col = COL_MENUCONTENT_TEXT; r.col = COL_MENUCONTENT_TEXT;
v.push_back(r); v.push_back(r);
} }
}
} else { else
{
// audio pids // audio pids
if (!g_RemoteControl->current_PIDs.APIDs.empty()){ if (!g_RemoteControl->current_PIDs.APIDs.empty())
{
for (unsigned int li= 0; li < g_RemoteControl->current_PIDs.APIDs.size(); li++) for (unsigned int li= 0; li < g_RemoteControl->current_PIDs.APIDs.size(); li++)
{ {
r.key = li ? "" : "Apid(s): "; r.key = li ? "" : "Apid(s): ";
@@ -993,13 +1071,16 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
std::string strpid = to_string(i); std::string strpid = to_string(i);
std::string details(" "); std::string details(" ");
for (std::vector<std::map<std::string,std::string> >::iterator it = streamdata.begin(); it != streamdata.end(); ++it) for (std::vector<std::map<std::string,std::string> >::iterator it = streamdata.begin(); it != streamdata.end(); ++it)
if ((*it)["pid"] == strpid) { {
if ((*it)["pid"] == strpid)
{
details = (*it)["language"]; details = (*it)["language"];
if (details != " ") if (details != " ")
details += ", "; details += ", ";
details += (*it)["codec"]; details += (*it)["codec"];
break; break;
} }
}
if (details == " ") if (details == " ")
details.clear(); details.clear();
snprintf(buf, sizeof(buf), "0x%04X (%i)%s", i, i, details.c_str()); snprintf(buf, sizeof(buf), "0x%04X (%i)%s", i, i, details.c_str());
@@ -1058,7 +1139,8 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
v.push_back(r); v.push_back(r);
//vtxtpid //vtxtpid
if (g_RemoteControl->current_PIDs.PIDs.vtxtpid) { if (g_RemoteControl->current_PIDs.PIDs.vtxtpid)
{
r.key = "VTXTpid: "; r.key = "VTXTpid: ";
i = g_RemoteControl->current_PIDs.PIDs.vtxtpid; i = g_RemoteControl->current_PIDs.PIDs.vtxtpid;
snprintf(buf, sizeof(buf), "0x%04X (%i)", i, i); snprintf(buf, sizeof(buf), "0x%04X (%i)", i, i);
@@ -1074,16 +1156,17 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
spaceoffset = std::max(spaceoffset, g_Font[font_info]->getRenderWidth(std::string(g_Locale->getText(LOCALE_STREAMINFO_BITRATE)) + ": ")); spaceoffset = std::max(spaceoffset, g_Font[font_info]->getRenderWidth(std::string(g_Locale->getText(LOCALE_STREAMINFO_BITRATE)) + ": "));
for (std::vector<row>::iterator it = v.begin(); it != v.end(); ++it) { for (std::vector<row>::iterator it = v.begin(); it != v.end(); ++it)
{
it->f->RenderString (xpos, ypos, spaceoffset, it->key, COL_MENUCONTENT_TEXT); it->f->RenderString (xpos, ypos, spaceoffset, it->key, COL_MENUCONTENT_TEXT);
std::string text = it->val.c_str(); std::string text = it->val.c_str();
it->f->RenderString (xpos + spaceoffset, ypos, box_width - spaceoffset, text, it->col); it->f->RenderString (xpos + spaceoffset, ypos, box_width - spaceoffset, text, it->col);
ypos += it->f->getHeight(); ypos += it->f->getHeight();
} }
if(box_h == 0) if (box_h == 0)
box_h = ypos - ypos1; box_h = ypos - ypos1;
yypos = ypos; yypos = ypos;
if (!mp) if (!mp)
paintCASystem(xpos,ypos); paintCASystem(xpos,ypos);
} }
@@ -1093,7 +1176,7 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos)
{ {
int ypos1 = ypos; int ypos1 = ypos;
if(box_h2 > 0) if (box_h2 > 0)
frameBuffer->paintBoxRel (0, ypos, box_width, box_h2, COL_MENUCONTENT_PLUS_0); frameBuffer->paintBoxRel (0, ypos, box_width, box_h2, COL_MENUCONTENT_PLUS_0);
std::string casys[NUM_CAIDS]={"Irdeto:","Betacrypt:","Seca:","Viaccess:","Nagra:","Conax: ","Cryptoworks:","Videoguard:","EBU:","XCrypt:","PowerVU:"}; std::string casys[NUM_CAIDS]={"Irdeto:","Betacrypt:","Seca:","Viaccess:","Nagra:","Conax: ","Cryptoworks:","Videoguard:","EBU:","XCrypt:","PowerVU:"};
@@ -1102,19 +1185,22 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos)
char tmp[100]; char tmp[100];
CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel(); CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel();
if(!channel) if (!channel)
return; return;
for(int i = 0; i < NUM_CAIDS; i++) { for (int i = 0; i < NUM_CAIDS; i++)
{
array[i] = g_Font[font_small]->getRenderWidth(casys[i]); array[i] = g_Font[font_small]->getRenderWidth(casys[i]);
caids[i] = false; caids[i] = false;
} }
int acaid = 0; int acaid = 0;
FILE *f = fopen("/tmp/ecm.info", "rt"); FILE *f = fopen("/tmp/ecm.info", "rt");
if (f) { if (f)
{
char buf[80]; char buf[80];
if (fgets(buf, sizeof(buf), f) != NULL) { if (fgets(buf, sizeof(buf), f) != NULL)
{
int i = 0; int i = 0;
while (buf[i] != '0') while (buf[i] != '0')
i++; i++;
@@ -1125,9 +1211,11 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos)
int off = 0; int off = 0;
for(casys_map_iterator_t it = channel->camap.begin(); it != channel->camap.end(); ++it) { for (casys_map_iterator_t it = channel->camap.begin(); it != channel->camap.end(); ++it)
{
int idx = -1; int idx = -1;
switch(((*it) >> 8) & 0xFF) { switch(((*it) >> 8) & 0xFF)
{
case 0x06: case 0x06:
idx = 0; idx = 0;
break; break;
@@ -1164,20 +1252,24 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos)
default: default:
break; break;
} }
if(idx >= 0) { if (idx >= 0)
{
snprintf(tmp, sizeof(tmp)," 0x%04X", (*it)); snprintf(tmp, sizeof(tmp)," 0x%04X", (*it));
casys[idx] += tmp; casys[idx] += tmp;
caids[idx] = true; caids[idx] = true;
if(off < array[idx]) if (off < array[idx])
off = array[idx]; off = array[idx];
} }
} }
off+=4; off+=4;
bool cryptsysteme = true; bool cryptsysteme = true;
for(int ca_id = 0; ca_id < NUM_CAIDS; ca_id++){ for (int ca_id = 0; ca_id < NUM_CAIDS; ca_id++)
if(caids[ca_id] == true){ {
if(cryptsysteme){ if (caids[ca_id] == true)
{
if(cryptsysteme)
{
ypos += iheight; ypos += iheight;
g_Font[font_info]->RenderString(xpos , ypos, box_width, g_Locale->getText(LOCALE_STREAMINFO_CASYSTEMS), COL_MENUCONTENT_TEXT); g_Font[font_info]->RenderString(xpos , ypos, box_width, g_Locale->getText(LOCALE_STREAMINFO_CASYSTEMS), COL_MENUCONTENT_TEXT);
cryptsysteme = false; cryptsysteme = false;
@@ -1187,15 +1279,17 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos)
const char *tok = " "; const char *tok = " ";
std::string::size_type last_pos = casys[ca_id].find_first_not_of(tok, 0); std::string::size_type last_pos = casys[ca_id].find_first_not_of(tok, 0);
std::string::size_type pos = casys[ca_id].find_first_of(tok, last_pos); std::string::size_type pos = casys[ca_id].find_first_of(tok, last_pos);
while (std::string::npos != pos || std::string::npos != last_pos){ while (std::string::npos != pos || std::string::npos != last_pos)
{
int col = COL_MENUCONTENT_TEXT; int col = COL_MENUCONTENT_TEXT;
if (index > 0) { if (index > 0)
{
int id; int id;
if (1 == sscanf(casys[ca_id].substr(last_pos, pos - last_pos).c_str(), "%X", &id) && acaid == id) if (1 == sscanf(casys[ca_id].substr(last_pos, pos - last_pos).c_str(), "%X", &id) && acaid == id)
col = COL_MENUHEAD_TEXT; col = COL_MENUHEAD_TEXT;
} }
g_Font[font_small]->RenderString(xpos + width_txt, ypos, box_width, casys[ca_id].substr(last_pos, pos - last_pos), col); g_Font[font_small]->RenderString(xpos + width_txt, ypos, box_width, casys[ca_id].substr(last_pos, pos - last_pos), col);
if(index == 0) if (index == 0)
width_txt = off; width_txt = off;
else else
width_txt += g_Font[font_small]->getRenderWidth(casys[ca_id].substr(last_pos, pos - last_pos))+10; width_txt += g_Font[font_small]->getRenderWidth(casys[ca_id].substr(last_pos, pos - last_pos))+10;
@@ -1207,7 +1301,7 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos)
} }
} }
} }
if(box_h2 == 0) if (box_h2 == 0)
box_h2 = ypos - ypos1; box_h2 = ypos - ypos1;
} }
@@ -1227,23 +1321,26 @@ long delta_time_ms (struct timeval *tv, struct timeval *last_tv)
bool CStreamInfo2::ts_setup () bool CStreamInfo2::ts_setup ()
{ {
if (mp) { if (mp)
{
mp->GetReadCount(); mp->GetReadCount();
if (pthread_create(&probe_thread, NULL, probeStreams, this)) { if (pthread_create(&probe_thread, NULL, probeStreams, this))
fprintf(stderr, "creating probe_thread failed\n"); fprintf(stderr, "creating probe_thread failed\n");
} }
} else { else
{
probebuf_length = 0; probebuf_length = 0;
probebuf_off = 0; probebuf_off = 0;
abort_probing = false; abort_probing = false;
probed = false; probed = false;
dmx = new cDemux(0); dmx = new cDemux(0);
if(!dmx) if (!dmx)
return false; return false;
dmxbuf = new unsigned char[TS_BUF_SIZE]; dmxbuf = new unsigned char[TS_BUF_SIZE];
if(!dmxbuf){ if (!dmxbuf)
{
delete dmx; delete dmx;
dmx = NULL; dmx = NULL;
return false; return false;
@@ -1265,7 +1362,8 @@ bool CStreamInfo2::ts_setup ()
pids.push_back(0); pids.push_back(0);
pids.push_back(g_RemoteControl->current_PIDs.PIDs.pmtpid); pids.push_back(g_RemoteControl->current_PIDs.PIDs.pmtpid);
#else #else
if (pids.empty()) { if (pids.empty())
{
delete dmx; delete dmx;
dmx = NULL; dmx = NULL;
delete[] dmxbuf; delete[] dmxbuf;
@@ -1281,7 +1379,8 @@ bool CStreamInfo2::ts_setup ()
probebuf = new unsigned char[probebuf_size]; probebuf = new unsigned char[probebuf_size];
dmx->Start(true); dmx->Start(true);
if (pthread_create(&probe_thread, NULL, probeStreams, this)) { if (pthread_create(&probe_thread, NULL, probeStreams, this))
{
fprintf(stderr, "creating probe_thread failed\n"); fprintf(stderr, "creating probe_thread failed\n");
delete[] probebuf; delete[] probebuf;
probebuf = NULL; probebuf = NULL;
@@ -1298,30 +1397,41 @@ bool CStreamInfo2::ts_setup ()
bool CStreamInfo2::update_rate () bool CStreamInfo2::update_rate ()
{ {
if(!mp && !dmx) if (!mp && !dmx)
return 0; return 0;
int timeout = 100; int timeout = 100;
int b_len; int b_len;
if (mp) { if (mp)
{
usleep(timeout * 1000); usleep(timeout * 1000);
b_len = mp->GetReadCount(); b_len = mp->GetReadCount();
} else { }
else
{
b_len = dmx->Read(dmxbuf, TS_BUF_SIZE, timeout); b_len = dmx->Read(dmxbuf, TS_BUF_SIZE, timeout);
if (probebuf && b_len > TS_LEN - 1 && probebuf_length < probebuf_size) { if (probebuf && b_len > TS_LEN - 1 && probebuf_length < probebuf_size)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(probe_mutex); OpenThreads::ScopedLock<OpenThreads::Mutex> lock(probe_mutex);
if (probebuf) { if (probebuf)
{
int len = (b_len / TS_LEN) * TS_LEN; int len = (b_len / TS_LEN) * TS_LEN;
uint16_t vpid = g_RemoteControl->current_PIDs.PIDs.vpid; uint16_t vpid = g_RemoteControl->current_PIDs.PIDs.vpid;
if (vpid) { if (vpid)
{
unsigned char *p = dmxbuf, *p_end = dmxbuf + len; unsigned char *p = dmxbuf, *p_end = dmxbuf + len;
for (; probebuf_size - TS_LEN > probebuf_length && p < p_end; p += TS_LEN) for (; probebuf_size - TS_LEN > probebuf_length && p < p_end; p += TS_LEN)
if (vpid != (0x1fff & (p[1] << 8 | p[2]))) { {
if (vpid != (0x1fff & (p[1] << 8 | p[2])))
{
memcpy(probebuf + probebuf_length, p, TS_LEN); memcpy(probebuf + probebuf_length, p, TS_LEN);
probebuf_length += TS_LEN; probebuf_length += TS_LEN;
} }
} else { }
}
else
{
int n = std::min(len, (int) probebuf_size - (int) probebuf_length); int n = std::min(len, (int) probebuf_size - (int) probebuf_length);
memcpy(probebuf + probebuf_length, dmxbuf, n); memcpy(probebuf + probebuf_length, dmxbuf, n);
probebuf_length += n; probebuf_length += n;
@@ -1342,14 +1452,14 @@ bool CStreamInfo2::update_rate ()
d_tim_ms = delta_time_ms (&tv, &last_tv); d_tim_ms = delta_time_ms (&tv, &last_tv);
if (d_tim_ms <= 0) if (d_tim_ms <= 0)
d_tim_ms = 1; // ignore usecs d_tim_ms = 1; // ignore usecs
bit_s = (((uint64_t) b * 8000ULL) + ((uint64_t) d_tim_ms / 2ULL)) bit_s = (((uint64_t) b * 8000ULL) + ((uint64_t) d_tim_ms / 2ULL))
/ (uint64_t) d_tim_ms; / (uint64_t) d_tim_ms;
d_tim_ms = delta_time_ms (&tv, &first_tv); d_tim_ms = delta_time_ms (&tv, &first_tv);
if (d_tim_ms <= 0) if (d_tim_ms <= 0)
d_tim_ms = 1; // ignore usecs d_tim_ms = 1; // ignore usecs
abit_s = ((b_total * 8000ULL) + ((uint64_t) d_tim_ms / 2ULL)) abit_s = ((b_total * 8000ULL) + ((uint64_t) d_tim_ms / 2ULL))
/ (uint64_t) d_tim_ms; / (uint64_t) d_tim_ms;
@@ -1365,20 +1475,23 @@ int CStreamInfo2::ts_close ()
if (probe_thread) if (probe_thread)
pthread_join(probe_thread, NULL); pthread_join(probe_thread, NULL);
if(dmx) { if (dmx)
{
delete dmx; delete dmx;
dmx = NULL; dmx = NULL;
} }
if(dmxbuf) { if (dmxbuf)
{
delete [] dmxbuf; delete [] dmxbuf;
dmxbuf = NULL; dmxbuf = NULL;
} }
return 0; return 0;
} }
void CStreamInfo2::showSNR () void CStreamInfo2::showSNR ()
{ {
if (signalbox == NULL){ if (signalbox == NULL)
{
signalbox = new CSignalBox(width - width/3 - 10, y + 10 + 2*(height/3 + hheight) + 3*sheight, width/3, 2*iheight, frontend); signalbox = new CSignalBox(width - width/3 - 10, y + 10 + 2*(height/3 + hheight) + 3*sheight, width/3, 2*iheight, frontend);
signalbox->setColorBody(COL_MENUCONTENT_PLUS_0); signalbox->setColorBody(COL_MENUCONTENT_PLUS_0);
signalbox->setTextColor(COL_MENUCONTENT_TEXT); signalbox->setTextColor(COL_MENUCONTENT_TEXT);

View File

@@ -40,41 +40,41 @@ class CStreamInfo2 : public CMenuTarget
CFrameBuffer *frameBuffer; CFrameBuffer *frameBuffer;
CFrontend *frontend; CFrontend *frontend;
CComponentsPIP *pip; CComponentsPIP *pip;
CMoviePlayerGui *mp; CMoviePlayerGui *mp;
COSDFader fader; COSDFader fader;
int x; int x;
int y; int y;
int width; int width;
int height; int height;
int hheight,iheight,sheight; // head/info/small font height int hheight,iheight,sheight; // head/info/small font height
int max_height; // Frambuffer 0.. max int max_height; // Frambuffer 0.. max
int max_width; int max_width;
int yypos; int yypos;
int paint_mode; int paint_mode;
int font_head; int font_head;
int font_info; int font_info;
int font_small; int font_small;
int sigBox_x; int sigBox_x;
int sigBox_y; int sigBox_y;
int sigBox_w; int sigBox_w;
int sigBox_h; int sigBox_h;
int sigBox_pos; int sigBox_pos;
int sig_text_y; int sig_text_y;
int sig_text_ber_x; int sig_text_ber_x;
int sig_text_sig_x; int sig_text_sig_x;
int sig_text_snr_x; int sig_text_snr_x;
int sig_text_rate_x; int sig_text_rate_x;
int average_bitrate_pos; int average_bitrate_pos;
int techinfo_xpos, techinfo_ypos; int techinfo_xpos, techinfo_ypos;
int box_width; int box_width;
int spaceoffset; int spaceoffset;
unsigned int scaling; unsigned int scaling;
unsigned int pmt_version; unsigned int pmt_version;
int box_h,box_h2; int box_h,box_h2;
@@ -90,7 +90,7 @@ class CStreamInfo2 : public CMenuTarget
std::vector<std::map<std::string,std::string> > streamdata; std::vector<std::map<std::string,std::string> > streamdata;
int doSignalStrengthLoop(); int doSignalStrengthLoop();
struct timeval tv, last_tv, first_tv; struct timeval tv, last_tv, first_tv;
uint64_t bit_s; uint64_t bit_s;
@@ -118,7 +118,7 @@ class CStreamInfo2 : public CMenuTarget
void paintCASystem(int xpos, int ypos); void paintCASystem(int xpos, int ypos);
void paint_signal_fe_box(int x, int y, int w, int h); void paint_signal_fe_box(int x, int y, int w, int h);
void paint_signal_fe(struct bitrate rate, struct feSignal s); void paint_signal_fe(struct bitrate rate, struct feSignal s);
int y_signal_fe(unsigned long value, unsigned long max_range, int max_y); int y_signal_fe(unsigned long value, unsigned long max_range, int max_y);
void SignalRenderStr (unsigned int value, int x, int y); void SignalRenderStr (unsigned int value, int x, int y);
CSignalBox *signalbox; CSignalBox *signalbox;