diff --git a/src/gui/streaminfo2.cpp b/src/gui/streaminfo2.cpp index 012d0705e..02160687b 100644 --- a/src/gui/streaminfo2.cpp +++ b/src/gui/streaminfo2.cpp @@ -71,8 +71,8 @@ extern CRemoteControl *g_RemoteControl; /* neutrino.cpp */ CStreamInfo2::CStreamInfo2() : fader(g_settings.theme.menu_Content_alpha) { frameBuffer = CFrameBuffer::getInstance (); - pip = NULL; - signalbox = NULL; + pip = NULL; + signalbox = NULL; font_head = SNeutrinoSettings::FONT_TYPE_MENU_TITLE; font_info = SNeutrinoSettings::FONT_TYPE_MENU; 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_height = frameBuffer->getScreenHeight(true); - width = frameBuffer->getScreenWidth(); + width = frameBuffer->getScreenWidth(); height = frameBuffer->getScreenHeight(); x = frameBuffer->getScreenX(); 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); if (lang) m["language"] = getISO639Description(lang->value); - else { + else + { lang = av_dict_get(st->metadata, "lang", NULL, 0); if (lang) 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); m["codec"] = buf; 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_type"] = av_get_media_type_string(st->codec->codec_type); m["codec_type"][0] ^= 'a' ^ 'A'; m["pid"] = to_string(st->id); - if (st->sample_aspect_ratio.num && // default - av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) { + if (st->sample_aspect_ratio.num && av_cmp_q(st->sample_aspect_ratio, st->codec->sample_aspect_ratio)) + { AVRational display_aspect_ratio; av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, 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); 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) m["fps"] = fps_str(av_q2d(st->avg_frame_rate)); #if FF_API_R_FRAME_RATE @@ -230,7 +232,7 @@ void CStreamInfo2::analyzeStreams(AVFormatContext *avfc) static cDemux * dmx = NULL; #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) { @@ -245,9 +247,11 @@ int CStreamInfo2::readPacket(uint8_t *buf, int buf_size) while (!abort_probing && (probebuf_length == probebuf_off) && (probebuf_off != probebuf_size)) usleep(10000); - if (!abort_probing) { + if (!abort_probing) + { OpenThreads::ScopedLock lock(probe_mutex); - if (probebuf) { + if (probebuf) + { int len = std::min(buf_size, (int)(probebuf_length - probebuf_off)); memcpy(buf, probebuf + probebuf_off, len); probebuf_off += len; @@ -273,14 +277,18 @@ static int interrupt_cb(void *arg) void CStreamInfo2::probeStreams() { - if (mp) { + if (mp) + { AVFormatContext *avfc = mp->getPlayback()->GetAVFormatContext(); - if (avfc) { + if (avfc) + { analyzeStreams(avfc); mp->getPlayback()->ReleaseAVFormatContext(); } probed = true; - } else { + } + else + { #ifdef ENABLE_FFMPEG_LOGGING av_log_set_callback(log_callback); #endif @@ -291,7 +299,8 @@ void CStreamInfo2::probeStreams() int buffer_size = 188 * 128; unsigned char *buffer = (unsigned char *) av_malloc(buffer_size); AVFormatContext *avfc = avformat_alloc_context(); - if (!avfc) { + if (!avfc) + { av_freep(&buffer); goto bye; } @@ -300,7 +309,8 @@ void CStreamInfo2::probeStreams() avfc->interrupt_callback.opaque = (void *) this; avioc = avio_alloc_context (buffer, buffer_size, 0, this, read_packet, NULL, NULL); - if (!avioc) { + if (!avioc) + { av_freep(&buffer); avformat_free_context(avfc); goto bye; @@ -310,7 +320,8 @@ void CStreamInfo2::probeStreams() avfc->flags |= AVFMT_FLAG_CUSTOM_IO; 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); analyzeStreams(avfc); } @@ -320,7 +331,8 @@ void CStreamInfo2::probeStreams() probed = true; bye: OpenThreads::ScopedLock lock(probe_mutex); - if(probebuf) { + if (probebuf) + { delete [] probebuf; probebuf = NULL; } @@ -364,7 +376,7 @@ int CStreamInfo2::doSignalStrengthLoop () #define BAR_WIDTH 150 #define BAR_HEIGHT 12 int res = menu_return::RETURN_REPAINT; - + bool fadeout = false; neutrino_msg_t msg; neutrino_msg_t postmsg = 0; @@ -379,13 +391,15 @@ int CStreamInfo2::doSignalStrengthLoop () bool repaint_bitrate = true; ts_setup (); frameBuffer->blit(); - while (1) { + while (1) + { neutrino_msg_data_t data; uint64_t timeoutEnd = CRCInput::calcTimeoutEnd_MS(10); g_RCInput->getMsgAbsoluteTimeout (&msg, &data, &timeoutEnd); - if (!mp) { + if (!mp) + { signal.sig = 100 * (frontend->getSignalStrength() & 0xFFFF) >> 16; signal.snr = 100 * (frontend->getSignalNoiseRatio() & 0xFFFF) >> 16; signal.ber = 100 * (frontend->getBitErrorRate() & 0xFFFF) >> 16; // FIXME? @@ -393,22 +407,35 @@ int CStreamInfo2::doSignalStrengthLoop () bool got_rate = update_rate(); - if (got_rate && (lastb != bit_s)) { + if (got_rate && (lastb != bit_s)) + { if (maxb < bit_s) rate.max_short_average = maxb = bit_s; if ((cnt > 10) && ((minb == 0) || (minb > bit_s))) rate.min_short_average = minb = bit_s; } - if (paint_mode == 0) { + if (paint_mode == 0) + { if (cnt < 12) cnt++; int dx1 = x + 10; - if (got_rate && (rate.short_average || lastb) && (lastb != bit_s)) { - if (repaint_bitrate) { + if (!mp && delay_counter > delay + 1) + { + 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)); 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)); g_Font[font_info]->RenderString(dx1 + spaceoffset + sw , average_bitrate_pos, box_width - spaceoffset - sw, tmp_str, COL_MENUCONTENT_TEXT); 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); 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; current_pmt_version = pmt_version; paint_techinfo(techinfo_xpos, techinfo_ypos); @@ -459,11 +487,12 @@ int CStreamInfo2::doSignalStrengthLoop () if ((signal.min_snr == 0) || (signal.min_snr > signal.snr)) signal.min_snr = signal.snr; - if (got_rate) { - paint_signal_fe(rate, signal); - signal.old_sig = signal.sig; - signal.old_snr = signal.snr; - signal.old_ber = signal.ber; + if (got_rate) + { + paint_signal_fe(rate, signal); + signal.old_sig = signal.sig; + signal.old_snr = signal.snr; + signal.old_ber = signal.ber; } g_RCInput->getMsg_us(&msg, &data, 0); @@ -490,23 +519,27 @@ int CStreamInfo2::doSignalStrengthLoop () } // 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 (); paint_mode = !paint_mode; paint (paint_mode); repaint_bitrate = true; 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; fadeout = true; } - else if(CNeutrinoApp::getInstance()->listModeKey(msg)) { + else if (CNeutrinoApp::getInstance()->listModeKey(msg)) + { postmsg = msg; res = menu_return::RETURN_EXIT_ALL; 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); continue; } @@ -570,11 +603,14 @@ void CStreamInfo2::paint_signal_fe_box(int _x, int _y, int w, int h) int xd; int col = 0; - if (paint_mode == 0) { + if (paint_mode == 0) + { maxmin_x = _x; xd = (w - 5 * fontW)/4; _x += 5 * fontW; - } else { + } + else + { maxmin_x = _x + 40; xd = (w - 5 * fontW + 40)/5; 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 * 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); - sig_text_ber_x = _x + 5 + xd * col; + sig_text_ber_x = _x + 5 + xd * col; col++; 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++; 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++; } @@ -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) { - int x_now = sigBox_pos; - int yt = sig_text_y + (sheight *2)+4; - int yd; + int x_now = sigBox_pos; + int yt = sig_text_y + (sheight *2)+4; + int yd; static int old_x=0,old_y=0; sigBox_pos++; 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); - 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.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 - } else { + } + else + { 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_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 old_x = sigBox_x+x_now; old_y = sigBox_y+sigBox_h-yd; } - if (!mp) { - if (s.ber != s.old_ber) { + if (!mp) + { + if (s.ber != s.old_ber) + { SignalRenderStr(s.ber, sig_text_ber_x, yt + sheight); SignalRenderStr(s.max_ber, sig_text_ber_x, yt); 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); 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.max_sig, sig_text_sig_x, yt); 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); 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.max_snr, sig_text_snr_x, yt); SignalRenderStr(s.min_snr, sig_text_snr_x, yt + (sheight * 2)); @@ -702,14 +749,15 @@ void CStreamInfo2::paint (int /*mode*/) { const char *head_string; - width = frameBuffer->getScreenWidth(); + width = frameBuffer->getScreenWidth(); height = frameBuffer->getScreenHeight(); x = frameBuffer->getScreenX(); y = frameBuffer->getScreenY(); int ypos = y + 5; int xpos = x + 10; - if (paint_mode == 0) { + if (paint_mode == 0) + { // -- tech Infos, PIG, small signal graph head_string = g_Locale->getText (LOCALE_STREAMINFO_HEAD); CVFD::getInstance ()->setMode (CVFD::MODE_MENU_UTF8, head_string); @@ -728,11 +776,13 @@ void CStreamInfo2::paint (int /*mode*/) paint_techinfo (xpos, ypos); paint_signal_fe_box (width - width/3 - 10, (y + 10 + height/3 + hheight), width/3, height/3 + hheight); - } else { + } + else + { delete signalbox; signalbox = NULL; - // -- small PIG, small signal graph + // -- small PIG, small signal graph // -- paint backround, title pig, etc. frameBuffer->paintBoxRel (0, 0, max_width, max_height, COL_MENUCONTENT_PLUS_0); @@ -746,9 +796,9 @@ struct row { std::string val; Font *f; 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) @@ -760,11 +810,11 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) box_width = width*2/3 - 10 - xpos; yypos = ypos; - if(box_h > 0) + if (box_h > 0) frameBuffer->paintBoxRel (0, ypos, box_width, box_h, COL_MENUCONTENT_PLUS_0); CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel(); - if(!channel) + if (!channel) return; ypos += iheight; @@ -772,12 +822,16 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) std::vector v; row r; - if (mp) { - if (CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webtv) { + if (mp) + { + if (CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webtv || CNeutrinoApp::getInstance()->getMode() == NeutrinoMessages::mode_webradio) + { // url r.key = "URL"; r.val = channel->getUrl(); - } else { + } + else + { // file r.key = g_Locale->getText (LOCALE_MOVIEBROWSER_INFO_FILE); r.val = mp->GetFile(); @@ -787,10 +841,11 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) v.push_back(r); //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; - 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 += ": "; r.val = prov_name.c_str(); @@ -799,8 +854,9 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) } scaling = 8000; - - } else { + } + else + { // channel r.key = g_Locale->getText (LOCALE_TIMERLIST_CHANNEL); r.key += ": "; @@ -809,10 +865,11 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) v.push_back(r); //provider - if(channel->pname){ + if (channel->pname) + { std::string prov_name = channel->pname; 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); r.key = g_Locale->getText (LOCALE_CHANNELLIST_PROVS); r.key += ": "; @@ -849,7 +906,8 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) v.push_back(r); // video pid - if ( g_RemoteControl->current_PIDs.PIDs.vpid){ + if (g_RemoteControl->current_PIDs.PIDs.vpid) + { r.key = "Vpid: "; i = g_RemoteControl->current_PIDs.PIDs.vpid; 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(mp || channel->getVideoPid()) { + if (mp || channel->getVideoPid()) #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 + { videoDecoder->getPictureInfo(xres, yres, framerate); if (yres == 1088) yres = 1080; @@ -880,23 +939,29 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) std::string tmp_fps = ""; std::string tmp_ar = ""; - for (std::vector >::iterator it = streamdata.begin(); it != streamdata.end(); ++it) - if ((*it)["codec_type"].substr(0,5) == "Video") { - tmp_ar = (*it)["dar"]; - if (!tmp_ar.empty()) - tmp_ar += " / "; - tmp_ar += (*it)["sar"]; - tmp_fps = (*it)["fps"]; + for (std::vector >::iterator it = streamdata.begin(); it != streamdata.end(); ++it) + { + if ((*it)["codec_type"].substr(0,5) == "Video") + { + tmp_ar = (*it)["dar"]; + if (!tmp_ar.empty()) + tmp_ar += " / "; + tmp_ar += (*it)["sar"]; + tmp_fps = (*it)["fps"]; + } } // aspect ratio r.key = g_Locale->getText (LOCALE_STREAMINFO_ARATIO); r.key += ": "; - if (aspectRatio < 0 || aspectRatio > 4) { + if (aspectRatio < 0 || aspectRatio > 4) + { r.val = tmp_ar; if (r.val.empty()) r.val = g_Locale->getText (LOCALE_STREAMINFO_ARATIO_UNKNOWN); - } else { + } + else + { const char *arr[] = { "N/A", "4:3", "14:9", "16:9", "20:9" }; r.val = arr[aspectRatio]; } @@ -906,13 +971,16 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) // video framerate r.key = g_Locale->getText (LOCALE_STREAMINFO_FRAMERATE); r.key += ": "; - if (framerate < 0 || framerate > 7) { + if (framerate < 0 || framerate > 7) + { r.val = tmp_fps; if (r.val.empty()) r.val = g_Locale->getText (LOCALE_STREAMINFO_FRAMERATE_UNKNOWN); else r.val += "fps"; - } else { + } + else + { const char *arr[] = { "23.976fps", "24fps", "25fps", "29,976fps", "30fps", "50fps", "50,94fps", "60fps" }; r.val = arr[framerate]; } @@ -924,10 +992,13 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) r.key = r.val = ""; v.push_back(r); - if (mp) { + if (mp) + { std::string details(" "); - for (std::vector >::iterator it = streamdata.begin(); it != streamdata.end(); ++it) - if ((*it)["codec_type"].substr(0,5) == "Video") { + for (std::vector >::iterator it = streamdata.begin(); it != streamdata.end(); ++it) + { + if ((*it)["codec_type"].substr(0,5) == "Video") + { details = (*it)["language"]; if (details != " ") details += ", "; @@ -940,6 +1011,7 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) r.col = COL_MENUCONTENT_TEXT; v.push_back(r); } + } } // audio @@ -947,15 +1019,18 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) r.key += ": "; std::string desc = "N/A"; 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.col = COL_MENUCONTENT_TEXT; v.push_back(r); - if (mp) { + if (mp) + { std::string details(" "); - for (std::vector >::iterator it = streamdata.begin(); it != streamdata.end(); ++it) - if ((*it)["codec_type"].substr(0,5) == "Audio") { + for (std::vector >::iterator it = streamdata.begin(); it != streamdata.end(); ++it) + { + if ((*it)["codec_type"].substr(0,5) == "Audio") + { details = (*it)["language"]; if (details != " ") details += ", "; @@ -964,16 +1039,18 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos) details.clear(); r.key = (*it)["codec_type"]; r.key += ": "; - r.val = details.c_str(); + r.val = details.c_str(); r.col = COL_MENUCONTENT_TEXT; v.push_back(r); } + } r.key = r.val = ""; v.push_back(r); // 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 += ": "; 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; v.push_back(r); } - - } else { - + } + else + { // 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++) { 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 details(" "); for (std::vector >::iterator it = streamdata.begin(); it != streamdata.end(); ++it) - if ((*it)["pid"] == strpid) { + { + if ((*it)["pid"] == strpid) + { details = (*it)["language"]; if (details != " ") details += ", "; details += (*it)["codec"]; break; } + } if (details == " ") details.clear(); 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); //vtxtpid - if (g_RemoteControl->current_PIDs.PIDs.vtxtpid) { + if (g_RemoteControl->current_PIDs.PIDs.vtxtpid) + { r.key = "VTXTpid: "; i = g_RemoteControl->current_PIDs.PIDs.vtxtpid; 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)) + ": ")); - for (std::vector::iterator it = v.begin(); it != v.end(); ++it) { + for (std::vector::iterator it = v.begin(); it != v.end(); ++it) + { it->f->RenderString (xpos, ypos, spaceoffset, it->key, COL_MENUCONTENT_TEXT); std::string text = it->val.c_str(); it->f->RenderString (xpos + spaceoffset, ypos, box_width - spaceoffset, text, it->col); ypos += it->f->getHeight(); } - if(box_h == 0) - box_h = ypos - ypos1; - yypos = ypos; + if (box_h == 0) + box_h = ypos - ypos1; + yypos = ypos; if (!mp) paintCASystem(xpos,ypos); } @@ -1093,7 +1176,7 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos) { int ypos1 = ypos; - if(box_h2 > 0) + if (box_h2 > 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:"}; @@ -1102,19 +1185,22 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos) char tmp[100]; CZapitChannel * channel = CZapit::getInstance()->GetCurrentChannel(); - if(!channel) + if (!channel) 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]); caids[i] = false; } int acaid = 0; FILE *f = fopen("/tmp/ecm.info", "rt"); - if (f) { + if (f) + { char buf[80]; - if (fgets(buf, sizeof(buf), f) != NULL) { + if (fgets(buf, sizeof(buf), f) != NULL) + { int i = 0; while (buf[i] != '0') i++; @@ -1125,9 +1211,11 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos) 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; - switch(((*it) >> 8) & 0xFF) { + switch(((*it) >> 8) & 0xFF) + { case 0x06: idx = 0; break; @@ -1164,20 +1252,24 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos) default: break; } - if(idx >= 0) { + if (idx >= 0) + { snprintf(tmp, sizeof(tmp)," 0x%04X", (*it)); casys[idx] += tmp; caids[idx] = true; - if(off < array[idx]) + if (off < array[idx]) off = array[idx]; } } off+=4; bool cryptsysteme = true; - for(int ca_id = 0; ca_id < NUM_CAIDS; ca_id++){ - if(caids[ca_id] == true){ - if(cryptsysteme){ + for (int ca_id = 0; ca_id < NUM_CAIDS; ca_id++) + { + if (caids[ca_id] == true) + { + if(cryptsysteme) + { ypos += iheight; g_Font[font_info]->RenderString(xpos , ypos, box_width, g_Locale->getText(LOCALE_STREAMINFO_CASYSTEMS), COL_MENUCONTENT_TEXT); cryptsysteme = false; @@ -1187,15 +1279,17 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos) const char *tok = " "; 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); - 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; - if (index > 0) { + if (index > 0) + { int id; if (1 == sscanf(casys[ca_id].substr(last_pos, pos - last_pos).c_str(), "%X", &id) && acaid == id) 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); - if(index == 0) + if (index == 0) width_txt = off; else 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; } @@ -1227,23 +1321,26 @@ long delta_time_ms (struct timeval *tv, struct timeval *last_tv) bool CStreamInfo2::ts_setup () { - if (mp) { + if (mp) + { 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"); - } - } else { + } + else + { probebuf_length = 0; probebuf_off = 0; abort_probing = false; probed = false; dmx = new cDemux(0); - if(!dmx) + if (!dmx) return false; dmxbuf = new unsigned char[TS_BUF_SIZE]; - if(!dmxbuf){ + if (!dmxbuf) + { delete dmx; dmx = NULL; return false; @@ -1265,7 +1362,8 @@ bool CStreamInfo2::ts_setup () pids.push_back(0); pids.push_back(g_RemoteControl->current_PIDs.PIDs.pmtpid); #else - if (pids.empty()) { + if (pids.empty()) + { delete dmx; dmx = NULL; delete[] dmxbuf; @@ -1281,7 +1379,8 @@ bool CStreamInfo2::ts_setup () probebuf = new unsigned char[probebuf_size]; 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"); delete[] probebuf; probebuf = NULL; @@ -1298,30 +1397,41 @@ bool CStreamInfo2::ts_setup () bool CStreamInfo2::update_rate () { - if(!mp && !dmx) + if (!mp && !dmx) return 0; int timeout = 100; int b_len; - if (mp) { + if (mp) + { usleep(timeout * 1000); b_len = mp->GetReadCount(); - } else { + } + else + { 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 lock(probe_mutex); - if (probebuf) { + if (probebuf) + { int len = (b_len / TS_LEN) * TS_LEN; uint16_t vpid = g_RemoteControl->current_PIDs.PIDs.vpid; - if (vpid) { + if (vpid) + { unsigned char *p = dmxbuf, *p_end = dmxbuf + 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); probebuf_length += TS_LEN; } - } else { + } + } + else + { int n = std::min(len, (int) probebuf_size - (int) probebuf_length); memcpy(probebuf + probebuf_length, dmxbuf, n); probebuf_length += n; @@ -1342,14 +1452,14 @@ bool CStreamInfo2::update_rate () d_tim_ms = delta_time_ms (&tv, &last_tv); 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)) / (uint64_t) d_tim_ms; d_tim_ms = delta_time_ms (&tv, &first_tv); 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)) / (uint64_t) d_tim_ms; @@ -1365,20 +1475,23 @@ int CStreamInfo2::ts_close () if (probe_thread) pthread_join(probe_thread, NULL); - if(dmx) { + if (dmx) + { delete dmx; - dmx = NULL; + dmx = NULL; } - if(dmxbuf) { + if (dmxbuf) + { delete [] dmxbuf; - dmxbuf = NULL; + dmxbuf = NULL; } return 0; } 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->setColorBody(COL_MENUCONTENT_PLUS_0); signalbox->setTextColor(COL_MENUCONTENT_TEXT); diff --git a/src/gui/streaminfo2.h b/src/gui/streaminfo2.h index c86c07c6a..7fe8db45a 100644 --- a/src/gui/streaminfo2.h +++ b/src/gui/streaminfo2.h @@ -40,41 +40,41 @@ class CStreamInfo2 : public CMenuTarget CFrameBuffer *frameBuffer; CFrontend *frontend; - CComponentsPIP *pip; - CMoviePlayerGui *mp; - COSDFader fader; + CComponentsPIP *pip; + CMoviePlayerGui *mp; + COSDFader fader; int x; int y; int width; int height; int hheight,iheight,sheight; // head/info/small font height - int max_height; // Frambuffer 0.. max - int max_width; + int max_height; // Frambuffer 0.. max + int max_width; int yypos; - int paint_mode; + int paint_mode; - int font_head; - int font_info; - int font_small; + int font_head; + int font_info; + int font_small; - int sigBox_x; - int sigBox_y; - int sigBox_w; - int sigBox_h; - int sigBox_pos; - int sig_text_y; - int sig_text_ber_x; - int sig_text_sig_x; - int sig_text_snr_x; - int sig_text_rate_x; - int average_bitrate_pos; + int sigBox_x; + int sigBox_y; + int sigBox_w; + int sigBox_h; + int sigBox_pos; + int sig_text_y; + int sig_text_ber_x; + int sig_text_sig_x; + int sig_text_snr_x; + int sig_text_rate_x; + int average_bitrate_pos; - int techinfo_xpos, techinfo_ypos; - int box_width; + int techinfo_xpos, techinfo_ypos; + int box_width; - int spaceoffset; + int spaceoffset; unsigned int scaling; unsigned int pmt_version; int box_h,box_h2; @@ -90,7 +90,7 @@ class CStreamInfo2 : public CMenuTarget std::vector > streamdata; - int doSignalStrengthLoop(); + int doSignalStrengthLoop(); struct timeval tv, last_tv, first_tv; uint64_t bit_s; @@ -118,7 +118,7 @@ class CStreamInfo2 : public CMenuTarget void paintCASystem(int xpos, int ypos); void paint_signal_fe_box(int x, int y, int w, int h); 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); CSignalBox *signalbox;