- 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

@@ -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);
@@ -165,8 +166,8 @@ void CStreamInfo2::analyzeStream(AVFormatContext *avfc, unsigned int idx)
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
@@ -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<OpenThreads::Mutex> 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<OpenThreads::Mutex> lock(probe_mutex);
if(probebuf) {
if (probebuf)
{
delete [] probebuf;
probebuf = NULL;
}
@@ -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,7 +487,8 @@ int CStreamInfo2::doSignalStrengthLoop ()
if ((signal.min_snr == 0) || (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;
signal.old_snr = signal.snr;
@@ -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,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 * 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;
col++;
@@ -625,22 +662,30 @@ void CStreamInfo2::paint_signal_fe(struct bitrate br, struct feSignal s)
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));
@@ -709,7 +756,8 @@ void CStreamInfo2::paint (int /*mode*/)
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,7 +776,9 @@ 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;
@@ -772,12 +822,16 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
std::vector<row> 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,7 +841,8 @@ 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());
@@ -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,7 +865,8 @@ 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()))
@@ -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;
@@ -881,22 +940,28 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
std::string tmp_fps = "";
std::string tmp_ar = "";
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"];
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<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"];
if (details != " ")
details += ", ";
@@ -941,6 +1012,7 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
v.push_back(r);
}
}
}
// audio
r.key = g_Locale->getText (LOCALE_STREAMINFO_AUDIOTYPE);
@@ -952,10 +1024,13 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
r.col = COL_MENUCONTENT_TEXT;
v.push_back(r);
if (mp) {
if (mp)
{
std::string details(" ");
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"];
if (details != " ")
details += ", ";
@@ -968,12 +1043,14 @@ void CStreamInfo2::paint_techinfo(int xpos, int ypos)
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<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"];
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,7 +1156,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)) + ": "));
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);
std::string text = it->val.c_str();
it->f->RenderString (xpos + spaceoffset, ypos, box_width - spaceoffset, text, it->col);
@@ -1105,16 +1188,19 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos)
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,7 +1252,8 @@ 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;
@@ -1175,9 +1264,12 @@ void CStreamInfo2::paintCASystem(int xpos, int ypos)
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,9 +1279,11 @@ 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;
@@ -1227,12 +1321,14 @@ 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;
@@ -1243,7 +1339,8 @@ bool CStreamInfo2::ts_setup ()
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;
@@ -1304,24 +1403,35 @@ bool CStreamInfo2::update_rate ()
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<OpenThreads::Mutex> 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;
@@ -1365,11 +1475,13 @@ int CStreamInfo2::ts_close ()
if (probe_thread)
pthread_join(probe_thread, NULL);
if(dmx) {
if (dmx)
{
delete dmx;
dmx = NULL;
}
if(dmxbuf) {
if (dmxbuf)
{
delete [] dmxbuf;
dmxbuf = NULL;
}
@@ -1378,7 +1490,8 @@ int CStreamInfo2::ts_close ()
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);