streaminfo: minor re-formatations and whitespace cleanups

Origin commit data
------------------
Commit: 63cd2d48d8
Author: vanhofen <vanhofen@gmx.de>
Date: 2017-11-06 (Mon, 06 Nov 2017)

Origin message was:
------------------
- streaminfo: minor re-formatations and whitespace cleanups
This commit is contained in:
vanhofen
2017-11-06 23:08:42 +01:00
parent 01cdf7ae68
commit b80fb0fe28
2 changed files with 277 additions and 173 deletions

View File

@@ -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);
@@ -165,8 +166,8 @@ void CStreamInfo2::analyzeStream(AVFormatContext *avfc, unsigned int idx)
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
@@ -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;
} }
@@ -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,28 +407,32 @@ 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(!mp && delay_counter > delay + 1){ if (!mp && delay_counter > delay + 1)
{
CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel(); CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel();
if (channel) if (channel)
pmt_version = channel->getPmtVersion(); pmt_version = channel->getPmtVersion();
if(pmt_version != current_pmt_version){ if (pmt_version != current_pmt_version)
delay_counter = 0; delay_counter = 0;
} }
} if (got_rate && (rate.short_average || lastb) && (lastb != bit_s))
if (got_rate && (rate.short_average || lastb) && (lastb != bit_s)) { {
if (repaint_bitrate) { 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);
@@ -436,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);
@@ -468,7 +487,8 @@ 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); paint_signal_fe(rate, signal);
signal.old_sig = signal.sig; signal.old_sig = signal.sig;
signal.old_snr = signal.snr; signal.old_snr = signal.snr;
@@ -499,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;
} }
@@ -579,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;
@@ -593,7 +620,8 @@ 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++;
@@ -634,22 +662,30 @@ void CStreamInfo2::paint_signal_fe(struct bitrate br, struct feSignal s)
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));
@@ -657,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));
@@ -665,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));
@@ -718,7 +756,8 @@ void CStreamInfo2::paint (int /*mode*/)
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);
@@ -737,7 +776,9 @@ 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;
@@ -781,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();
@@ -796,7 +841,8 @@ 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());
@@ -808,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 += ": ";
@@ -818,7 +865,8 @@ 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()))
@@ -858,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);
@@ -869,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;
@@ -890,22 +940,28 @@ 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") { {
if ((*it)["codec_type"].substr(0,5) == "Video")
{
tmp_ar = (*it)["dar"]; tmp_ar = (*it)["dar"];
if (!tmp_ar.empty()) if (!tmp_ar.empty())
tmp_ar += " / "; tmp_ar += " / ";
tmp_ar += (*it)["sar"]; tmp_ar += (*it)["sar"];
tmp_fps = (*it)["fps"]; 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];
} }
@@ -915,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];
} }
@@ -933,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 += ", ";
@@ -950,6 +1012,7 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
v.push_back(r); v.push_back(r);
} }
} }
}
// audio // audio
r.key = g_Locale->getText (LOCALE_STREAMINFO_AUDIOTYPE); r.key = g_Locale->getText (LOCALE_STREAMINFO_AUDIOTYPE);
@@ -961,10 +1024,13 @@ 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);
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 += ", ";
@@ -977,12 +1043,14 @@ 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);
} }
}
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);
@@ -990,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): ";
@@ -1002,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());
@@ -1068,7 +1140,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);
@@ -1084,7 +1157,8 @@ 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);
@@ -1115,16 +1189,19 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos)
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++;
@@ -1135,9 +1212,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;
@@ -1174,7 +1253,8 @@ 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;
@@ -1185,9 +1265,12 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos)
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;
@@ -1197,9 +1280,11 @@ 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;
@@ -1237,12 +1322,14 @@ 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;
@@ -1253,7 +1340,8 @@ bool CStreamInfo2::ts_setup ()
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;
@@ -1275,7 +1363,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;
@@ -1291,7 +1380,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;
@@ -1314,24 +1404,35 @@ bool CStreamInfo2::update_rate ()
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;
@@ -1375,11 +1476,13 @@ 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;
} }
@@ -1388,7 +1491,8 @@ int CStreamInfo2::ts_close ()
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);