Exemplo n.º 1
0
void
LookupVisitorTests::TestLookup()
{
  CLookupVisitor v;
  m_pChannels->foreach(v);
  CChannel::doEvents(0.5);

  // By now, everyone should be connected.

  CChannelList::ChannelIterator p = m_pChannels->begin();
  while(p != m_pChannels->end()) {
    EQMSG((*p)->getName(), true, (*p)->isConnected());

    p++;
  }
}
Exemplo n.º 2
0
void CAdZapMenu::Init()
{
	CChannelList *channelList = CNeutrinoApp::getInstance()->channelList;
	channelId = channelList ? channelList->getActiveChannel_ChannelID() : -1;
	if(channelList)
		channelName = channelList->getActiveChannelName();
	evtlist.clear();
	CEitManager::getInstance()->getEventsServiceKey(channelId & 0xFFFFFFFFFFFFULL, evtlist);
	monitorLifeTime.tv_sec = 0;
	if (!evtlist.empty())
	{
		sort(evtlist.begin(), evtlist.end(), sortByDateTime);
		monitorLifeTime.tv_sec = getMonitorLifeTime();
		Update();
	}
	printf("CAdZapMenu::%s: monitorLifeTime.tv_sec: %d\n", __func__, (uint) monitorLifeTime.tv_sec);
}
Exemplo n.º 3
0
void
LookupVisitorTests::Stock()
{
  for (int i =0; i < nNames; i++) {
    CUnitChannel* pChannel = new CUnitChannel(Names[i]);
    m_pChannels->push_back(*pChannel);
  }
}
Exemplo n.º 4
0
int CEventListHandler::exec(CMenuTarget* parent, const std::string &/*actionKey*/)
{
	int           res = menu_return::RETURN_REPAINT;
	EventList     *e;
	CChannelList  *channelList;


	if (parent)
		parent->hide();

	e = new EventList;

	channelList = CNeutrinoApp::getInstance()->channelList;

	e->exec(live_channel_id, channelList->getActiveChannelName()); // UTF-8
	delete e;

	return res;
}
void CEpgScan::ConfigureEIT()
{
	CEitManager::getInstance()->clearChannelFilters();
	if (g_settings.epg_save_mode == 0)
		return;

	int count = 0;

	for (unsigned j = 0; j < TVfavList->Bouquets.size(); ++j) {
		CChannelList * clist = TVfavList->Bouquets[j]->channelList;
		for (unsigned i = 0; i < clist->Size(); i++) {
			CZapitChannel * chan = clist->getChannelFromIndex(i);
			CEitManager::getInstance()->addChannelFilter(chan->getOriginalNetworkId(), chan->getTransportStreamId(), chan->getServiceId());
			count++;
		}
	}
	for (unsigned j = 0; j < RADIOfavList->Bouquets.size(); ++j) {
		CChannelList * clist = RADIOfavList->Bouquets[j]->channelList;
		for (unsigned i = 0; i < clist->Size(); i++) {
			CZapitChannel * chan = clist->getChannelFromIndex(i);
			CEitManager::getInstance()->addChannelFilter(chan->getOriginalNetworkId(), chan->getTransportStreamId(), chan->getServiceId());
			count++;
		}
	}
	INFO("added %d channels to EIT white list\n", count);
}
Exemplo n.º 6
0
void 
LookupVisitorTests::BuildDataTest()
{
  CLookupVisitor v;
  m_pChannels->foreach(v);

  CChannel::doEvents(0.5);	// Connect and data should be there.

  CBuildChannelData  bv;
  m_pChannels->foreach(bv);	// Collect channel data.

  CBuildChannelData::ChannelItemIterator  p = bv.begin();
  int i = 0;
  while(p != bv.end()) {
    EQ(Names[i], p->first);
    CBuildChannelData::ChannelData info = p->second;
    ASSERT(info.m_sValue != "");
    // ASSERT(info.m_sUnits != "");
    ASSERT(info.m_Updated != 0);
    p++;
    i++;
  }
}
Exemplo n.º 7
0
void CAdZapMenu::Settings()
{
    CChannelList *channelList = CNeutrinoApp::getInstance()->channelList;
    channelId =
	channelList ? channelList->getActiveChannel_ChannelID() : -1;
    if (channelId < 0)
	return;
    channelName = channelList->getActiveChannelName();

    CMenuWidget *menu =
	new CMenuWidget(LOCALE_ADZAP, "settings", width);
    menu->addItem(new
		  CMenuSeparator(CMenuSeparator::LINE |
				 CMenuSeparator::STRING,
				 LOCALE_ADZAP_SWITCHBACK));
    neutrino_locale_t minute = LOCALE_ADZAP_MINUTE;
    for (int shortcut = 1; shortcut < 10; shortcut++) {
	char actionKey[2];
	actionKey[0] = '0' + shortcut;
	actionKey[1] = 0;
	bool selected = g_settings.adzap_zapBackPeriod == 60 * shortcut;
	menu->addItem(new
		      CMenuForwarder(minute, true, "", this, actionKey,
				     CRCInput::convertDigitToKey
				     (shortcut)), selected);
	minute = LOCALE_ADZAP_MINUTES;
    }

    menu->addItem(new
		  CMenuSeparator(CMenuSeparator::LINE |
				 CMenuSeparator::STRING,
				 LOCALE_ADZAP_COMMIT));
    menu->addItem(new
		  CMenuForwarder(LOCALE_ADZAP_ENABLE, true, "", this,
				 "enable", CRCInput::RC_green,
				 NEUTRINO_ICON_BUTTON_GREEN));
    menu->addItem(new
		  CMenuForwarder(LOCALE_ADZAP_DISABLE, true, "", this,
				 "disable", CRCInput::RC_red,
				 NEUTRINO_ICON_BUTTON_RED));

    CChannelEventList evtlist;
    sectionsd_getEventsServiceKey(azm->channelId & 0xFFFFFFFFFFFFULL,
				  evtlist);
    azm->monitorLifeTime.tv_sec = 0;
    if (!evtlist.empty()) {
	sort(evtlist.begin(), evtlist.end(), sortByDateTime);
	CChannelEventList::iterator eli;
	struct timespec ts;
	clock_gettime(CLOCK_REALTIME, &ts);
	for (eli = evtlist.begin(); eli != evtlist.end(); ++eli) {
	    if ((uint) eli->startTime + eli->duration > ts.tv_sec) {
		azm->monitorLifeTime.tv_sec =
		    (uint) eli->startTime + eli->duration;
		azm->Update();
		break;
	    }
	}
    }

    menu->addItem(new
		  CMenuForwarder(LOCALE_ADZAP_MONITOR,
				 azm->monitorLifeTime.tv_sec, "", this,
				 "monitor", CRCInput::RC_blue,
				 NEUTRINO_ICON_BUTTON_BLUE));

    monitor = false;
    menu->exec(NULL, "");
    menu->hide();
    delete menu;
    Update();
}
Exemplo n.º 8
0
void *CAdZapMenu::Run(void *)
{
    while (azm->running) {
	CChannelList *channelList = NULL;
	t_channel_id curChannelId;

	if (azm->monitor) {
	    struct timespec ts;
	    clock_gettime(CLOCK_REALTIME, &ts);
	    ts.tv_sec += 1;

	    sem_timedwait(&azm->sem, &ts);

	    if (azm->monitor && (azm->monitorLifeTime.tv_sec > ts.tv_sec)) {
		channelList = CNeutrinoApp::getInstance()->channelList;
		curChannelId =
		    channelList ? channelList->getActiveChannel_ChannelID()
		    : -1;
		if (!azm->armed && (azm->channelId != curChannelId)) {
		    azm->armed = true;
		    clock_gettime(CLOCK_REALTIME, &azm->zapBackTime);
		    azm->zapBackTime.tv_sec +=
			g_settings.adzap_zapBackPeriod -
			ZAPBACK_ALERT_PERIOD;
		    azm->alerted = false;
		} else if (azm->channelId == curChannelId) {
		    azm->armed = false;
		    azm->alerted = false;
		}
	    } else {
		azm->monitor = false;
		azm->armed = false;
		azm->alerted = false;
	    }
	} else if (azm->armed)
	    sem_timedwait(&azm->sem, &azm->zapBackTime);
	else
	    sem_wait(&azm->sem);

	if (azm->armed) {
	    struct timespec ts;
	    clock_gettime(CLOCK_REALTIME, &ts);
	    if (ts.tv_sec >= azm->zapBackTime.tv_sec) {
		if (!channelList) {
		    channelList = CNeutrinoApp::getInstance()->channelList;
		    curChannelId =
			channelList ?
			channelList->getActiveChannel_ChannelID() : -1;
		}
		if (!azm->alerted) {
		    if (azm->channelId != curChannelId) {
			std::string name =
			    g_Locale->getText(LOCALE_ADZAP_ANNOUNCE);
			name += "\n" + azm->channelName;
			ShowHintUTF(LOCALE_ADZAP, name.c_str());
		    }
		    azm->alerted = true;
		    azm->zapBackTime.tv_sec += ZAPBACK_ALERT_PERIOD;
		} else {
		    azm->alerted = false;
		    if (channelList)
			channelList->zapTo_ChannelID(azm->channelId);
		    azm->armed = false;
		}
	    }
	}
    }
    return NULL;
}
int CAudioSelectMenuHandler::doMenu ()
{
	int mode = CNeutrinoApp::getInstance()->getMode();
	if (mode == NeutrinoMessages::mode_webtv) {
		CMoviePlayerGui::getInstance(true).selectAudioPid();
		return menu_return::RETURN_EXIT;
	}
	CMenuWidget AudioSelector(LOCALE_AUDIOSELECTMENUE_HEAD, NEUTRINO_ICON_AUDIO, width);

	CSubtitleChangeExec SubtitleChanger;

	//show cancel button if configured in usermenu settings
	if (g_settings.personalize[SNeutrinoSettings::P_UMENU_SHOW_CANCEL])
		AudioSelector.addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL);
	else
		AudioSelector.addItem(GenericMenuSeparator);

	unsigned int shortcut_num = 1;

	uint p_count = g_RemoteControl->current_PIDs.APIDs.size();
	// -- setup menue due to Audio PIDs
	for( uint i=0; i < p_count; i++ )
	{
		char apid[5];
		sprintf(apid, "%d", i);
		CMenuForwarder *fw = new CMenuForwarder(g_RemoteControl->current_PIDs.APIDs[i].desc,
				true, NULL, this, apid, CRCInput::convertDigitToKey(i + 1));
		fw->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true);
		AudioSelector.addItem(fw, (i == g_RemoteControl->current_PIDs.PIDs.selected_apid));
		shortcut_num = i+1;
	}
	if (p_count)
		AudioSelector.addItem(GenericMenuSeparatorLine);

	// -- setup menue for to Dual Channel Stereo
	CMenuOptionChooser* oj = new CMenuOptionChooser(LOCALE_AUDIOMENU_ANALOG_MODE,
			&g_settings.audio_AnalogMode,
			AUDIOMENU_ANALOGOUT_OPTIONS, AUDIOMENU_ANALOGOUT_OPTION_COUNT,
			true, audioSetupNotifier, CRCInput::RC_red);

	AudioSelector.addItem( oj );

	if (!g_settings.easymenu) {
		oj = new CMenuOptionChooser(LOCALE_AUDIOMENU_ANALOG_OUT, &g_settings.analog_out,
				OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT,
				true, audioSetupNotifier, CRCInput::RC_green);
		AudioSelector.addItem( oj );
	}

	CChannelList *channelList = CNeutrinoApp::getInstance ()->channelList;
	int curnum = channelList->getActiveChannelNumber();
	CZapitChannel * cc = channelList->getChannel(curnum);

	bool sep_added = false;
	if(cc)
	{
		for (int i = 0 ; i < (int)cc->getSubtitleCount() ; ++i)
		{
			CZapitAbsSub* s = cc->getChannelSub(i);
			if (s->thisSubType == CZapitAbsSub::DVB) {
				CZapitDVBSub* sd = reinterpret_cast<CZapitDVBSub*>(s);
				printf("[neutrino] adding DVB subtitle %s pid %x\n", sd->ISO639_language_code.c_str(), sd->pId);
				if(!sep_added)
				{
					sep_added = true;
					AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_SUBTITLES_HEAD));
				}
				char spid[10];
				snprintf(spid,sizeof(spid), "DVB:%d", sd->pId);
				char item[64];
				snprintf(item,sizeof(item), "DVB: %s (pid %x)", sd->ISO639_language_code.c_str(), sd->pId);
				AudioSelector.addItem(new CMenuForwarder(item /*sd->ISO639_language_code.c_str()*/,
							sd->pId != dvbsub_getpid(), NULL, &SubtitleChanger, spid, CRCInput::convertDigitToKey(++shortcut_num)));
			}
			if (s->thisSubType == CZapitAbsSub::TTX)
			{
				CZapitTTXSub* sd = reinterpret_cast<CZapitTTXSub*>(s);
				printf("[neutrino] adding TTX subtitle %s pid %x mag %X page %x\n", sd->ISO639_language_code.c_str(), sd->pId, sd->teletext_magazine_number, sd->teletext_page_number);
				if(!sep_added)
				{
					sep_added = true;
					AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_SUBTITLES_HEAD));
				}
				char spid[64];
				int page = ((sd->teletext_magazine_number & 0xFF) << 8) | sd->teletext_page_number;
				int pid = sd->pId;
				snprintf(spid,sizeof(spid), "TTX:%d:%03X:%s", sd->pId, page, sd->ISO639_language_code.c_str());
				char item[64];
				snprintf(item,sizeof(item), "TTX: %s (pid %x page %03X)", sd->ISO639_language_code.c_str(), sd->pId, page);
				AudioSelector.addItem(new CMenuForwarder(item /*sd->ISO639_language_code.c_str()*/,
							!tuxtx_subtitle_running(&pid, &page, NULL), NULL, &SubtitleChanger, spid, CRCInput::convertDigitToKey(++shortcut_num)));
			}
		}

		if(sep_added) {
			CMenuForwarder * item = new CMenuForwarder(LOCALE_SUBTITLES_STOP, true, NULL, &SubtitleChanger, "off", CRCInput::RC_stop);
			item->setItemButton(NEUTRINO_ICON_BUTTON_STOP, false);
			AudioSelector.addItem(item);
		}
	}

	AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_AUDIOMENU_VOLUME_ADJUST));

	/* setting volume percent to zapit with channel_id/apid = 0 means current channel and pid */
	CVolume::getInstance()->SetCurrentChannel(0);
	CVolume::getInstance()->SetCurrentPid(0);
	int percent[p_count];
	for (uint i=0; i < p_count; i++) {
		percent[i] = CZapit::getInstance()->GetPidVolume(0, g_RemoteControl->current_PIDs.APIDs[i].pid, g_RemoteControl->current_PIDs.APIDs[i].is_ac3);
		AudioSelector.addItem(new CMenuOptionNumberChooser(g_RemoteControl->current_PIDs.APIDs[i].desc,
					&percent[i], i == g_RemoteControl->current_PIDs.PIDs.selected_apid,
					0, 999, CVolume::getInstance()));
	}

	return AudioSelector.exec(NULL, "");
}
Exemplo n.º 10
0
void CAdZapMenu::Run()
{
	set_threadname("CAdZapMenu::Run");
	while (true)
	{
		CChannelList *channelList = NULL;
		t_channel_id curChannelId = -1;

		if (monitor)
		{
			clock_gettime(CLOCK_REALTIME, &ts);
			ts.tv_sec += 1;

			sem_timedwait(&sem, &ts);

			if (monitor && (monitorLifeTime.tv_sec > ts.tv_sec))
			{
				channelList = CNeutrinoApp::getInstance()->channelList;
				curChannelId = channelList ? channelList->getActiveChannel_ChannelID() : -1;
				if (!armed && (channelId != curChannelId))
				{
					armed = true;
					clock_gettime(CLOCK_REALTIME, &zapBackTime);
					zapBackTime.tv_sec += g_settings.adzap_zapBackPeriod - ZAPBACK_ALERT_PERIOD;
					alerted = false;
				}
				else if (channelId == curChannelId)
				{
					armed = false;
					alerted = false;
				}
			}
			else
			{
				monitor = false;
				armed = false;
				alerted = false;
			}
		}
		else if (armed)
		{
			if (g_settings.adzap_writeData)
			{
				clock_gettime(CLOCK_REALTIME, &ts);
				ts.tv_sec += 1;

				sem_timedwait(&sem, &ts);
			}
			else
				sem_timedwait(&sem, &zapBackTime);
		}
		else
			sem_wait(&sem);

		if (armed)
		{
			clock_gettime(CLOCK_REALTIME, &ts);
			if (ts.tv_sec >= zapBackTime.tv_sec)
			{
				if (!channelList)
				{
					channelList = CNeutrinoApp::getInstance()->channelList;
					curChannelId = channelList ? channelList->getActiveChannel_ChannelID() : -1;
				}
				if (!alerted)
				{
					if (channelId != curChannelId)
					{
						char name[1024];
						snprintf(name, sizeof(name)-1, g_Locale->getText(LOCALE_ADZAP_ANNOUNCE), ZAPBACK_ALERT_PERIOD, channelName.c_str());
						ShowHint(LOCALE_ADZAP, name);
					}
					alerted = true;
					zapBackTime.tv_sec += ZAPBACK_ALERT_PERIOD;
				}
				else
				{
					alerted = false;
					if ((channelId != curChannelId) && channelList)
						channelList->zapTo_ChannelID(channelId);
					armed = false;
				}
			}
		}

		if (g_settings.adzap_writeData && (monitor || armed))
			WriteData();
		else
			RemoveData();
	}
}
Exemplo n.º 11
0
int CAudioSelectMenuHandler::doMenu ()
{
	CMenuWidget AudioSelector(LOCALE_APIDSELECTOR_HEAD, "audio", 360);
	unsigned int count;
	CSubtitleChangeExec SubtitleChanger;

	for(count=0; count < g_RemoteControl->current_PIDs.APIDs.size(); count++ ) {
		char apid[5];
		sprintf(apid, "%d", count);
		AudioSelector.addItem(new CMenuForwarderNonLocalized(
					g_RemoteControl->current_PIDs.APIDs[count].desc, true, NULL,
					APIDChanger, apid, CRCInput::convertDigitToKey(count + 1)),
				(count == g_RemoteControl->current_PIDs.PIDs.selected_apid));
	}

	// -- setup menue for to Dual Channel Stereo
	AudioSelector.addItem(GenericMenuSeparatorLine);

	CMenuOptionChooser* oj = new CMenuOptionChooser(LOCALE_AUDIOMENU_ANALOGOUT,
				&g_settings.audio_AnalogMode,
				AUDIOMENU_ANALOGOUT_OPTIONS, AUDIOMENU_ANALOGOUT_OPTION_COUNT,
				true, audioSetupNotifier, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED);

	AudioSelector.addItem( oj );

	CChannelList *channelList = CNeutrinoApp::getInstance ()->channelList;
	int curnum = channelList->getActiveChannelNumber();
	CZapitChannel * cc = channelList->getChannel(curnum);

	bool sep_added = false;
	if(cc) 
	{
		bool subs_running = false;
		for (int i = 0 ; i < (int)cc->getSubtitleCount() ; ++i) 
		{
			CZapitAbsSub* s = cc->getChannelSub(i);
			if (s->thisSubType == CZapitAbsSub::DVB) {
				CZapitDVBSub* sd = reinterpret_cast<CZapitDVBSub*>(s);
				fprintf(stderr, "[neutrino] adding DVB subtitle %s pid 0x%x\n", sd->ISO639_language_code.c_str(), sd->pId);
				if(!sep_added) {
					sep_added = true;
					AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_SUBTITLES_HEAD));
				}
				char spid[10];
				snprintf(spid,sizeof(spid), "DVB:%d", sd->pId);
				char item[64];
				snprintf(item,sizeof(item), "DVB: %s (pid %03X)", sd->ISO639_language_code.c_str(), sd->pId);
				bool this_sub_running = (sd->pId == dvbsub_getpid());
				subs_running |= this_sub_running;
				AudioSelector.addItem(new CMenuForwarderNonLocalized(item /*sd->ISO639_language_code.c_str()*/,
							!this_sub_running, NULL, &SubtitleChanger, spid, CRCInput::convertDigitToKey(++count)));
			} else if (s->thisSubType == CZapitAbsSub::TTX) {
				CZapitTTXSub* sd = reinterpret_cast<CZapitTTXSub*>(s);
				fprintf(stderr, "[neutrino] adding TTX subtitle %s pid %X mag %d page %d\n",
					sd->ISO639_language_code.c_str(), sd->pId, sd->teletext_magazine_number, sd->teletext_page_number);
				if(!sep_added) {
					sep_added = true;
					AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_SUBTITLES_HEAD));
				}
				char spid[64];
				int page = ((sd->teletext_magazine_number & 0xFF) << 8) | sd->teletext_page_number;
				int pid = sd->pId;
				snprintf(spid,sizeof(spid), "TTX:%d:%03X:%s", sd->pId, page, sd->ISO639_language_code.c_str()); 
				char item[64];
				snprintf(item,sizeof(item), "TTX: %s (pid %X page %03X)", sd->ISO639_language_code.c_str(), sd->pId, page);
				bool this_sub_running = tuxtx_subtitle_running(&pid, &page, NULL);
				subs_running |= this_sub_running;
				AudioSelector.addItem(new CMenuForwarderNonLocalized(item /*sd->ISO639_language_code.c_str()*/,
							!this_sub_running, NULL, &SubtitleChanger, spid, CRCInput::convertDigitToKey(++count)));
			}
		}
		
		if(sep_added) {
			if (subs_running)
				AudioSelector.addItem(new CMenuForwarder(LOCALE_SUBTITLES_STOP, true, NULL, &SubtitleChanger, "off", CRCInput::RC_stop));
		} else {
			// subtitles might not be available, but started by zapit anyway, as it remembers pids
			dvbsub_stop();
			tuxtx_stop_subtitle();
		}
	}
	AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_VOLUME_ADJUSTMENT));

	int percent[g_RemoteControl->current_PIDs.APIDs.size()];
	CZapitClient zapit;
	for(count = 0; count < g_RemoteControl->current_PIDs.APIDs.size(); count++ ) {
		zapit.getVolumePercent((unsigned int *) &percent[count], g_RemoteControl->current_PIDs.APIDs[count].pid);
		AudioSelector.addItem(new CMenuOptionNumberChooser(NONEXISTANT_LOCALE, &percent[count],
			count == g_RemoteControl->current_PIDs.PIDs.selected_apid,
			0, 999, audioSetupNotifier, 0, 0, NONEXISTANT_LOCALE,
			g_RemoteControl->current_PIDs.APIDs[count].desc));
	}

	return AudioSelector.exec(NULL, "");
}
Exemplo n.º 12
0
int CAudioSelectMenuHandler::doMenu ()
{
	AudioSelector = new CMenuWidget(LOCALE_AUDIOSELECTMENUE_HEAD, NEUTRINO_ICON_AUDIO, width);

	CSubtitleChangeExec SubtitleChanger(playback);

	//show cancel button if configured in usermenu settings
	if (g_settings.personalize[SNeutrinoSettings::P_UMENU_SHOW_CANCEL])
		AudioSelector->addIntroItems(NONEXISTANT_LOCALE, LOCALE_AUDIOSELECTMENUE_VOLUME, CMenuWidget::BTN_TYPE_CANCEL);
	else
		AudioSelector->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_AUDIOSELECTMENUE_VOLUME));
	apid_offset = AudioSelector->getItemsCount();
	AudioSelector->addKey(CRCInput::RC_right, this, "+");
	AudioSelector->addKey(CRCInput::RC_left, this, "-");
	AudioSelector->addKey(CRCInput::RC_red, this, "x");
	AudioSelector->addKey(CRCInput::RC_green, this, "x");
	AudioSelector->addKey(CRCInput::RC_yellow, this, "x");
	AudioSelector->addKey(CRCInput::RC_blue, this, "x");

	bool is_mp = mp->Playing();

	p_count = is_mp ? mp->getAPIDCount() : g_RemoteControl->current_PIDs.APIDs.size();
	sel_apid = is_mp ? mp->getAPID() : g_RemoteControl->current_PIDs.PIDs.selected_apid;

	int _apid[p_count];
	int _perc_val[p_count];
	unsigned int _is_ac3[p_count];
	std::string _perc_str[p_count];
	perc_val = _perc_val;
	perc_str = _perc_str;
	is_ac3 = _is_ac3;
	apid = _apid;
	chan = is_mp ? mp->getChannelId() : 0;

	// -- setup menue due to Audio PIDs
	for (int i = 0; i < p_count; i++)
	{
		if (is_mp) {
			mp->getAPID(i, apid[i], is_ac3[i]);
		} else {
			apid[i] = g_RemoteControl->current_PIDs.APIDs[i].pid;
			is_ac3[i] = g_RemoteControl->current_PIDs.APIDs[i].is_ac3;
		}
		perc_val[i] = CZapit::getInstance()->GetPidVolume(chan, apid[i], is_ac3[i]);
		perc_str[i] = to_string(perc_val[i]) + "%";

		CMenuForwarder *fw = new CMenuForwarder(is_mp ? mp->getAPIDDesc(i).c_str() : g_RemoteControl->current_PIDs.APIDs[i].desc, 
				true, perc_str[i], this, "s", CRCInput::convertDigitToKey(i + 1));
		fw->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true);
		fw->setMarked(sel_apid == i);

		AudioSelector->addItem(fw, sel_apid == i);
	}
	unsigned int shortcut_num = p_count;
#if !HAVE_SPARK_HARDWARE && !HAVE_DUCKBOX_HARDWARE
	if (p_count)
		AudioSelector->addItem(GenericMenuSeparatorLine);

	// -- setup menue for to Dual Channel Stereo
	CMenuOptionChooser* oj = new CMenuOptionChooser(LOCALE_AUDIOMENU_ANALOG_MODE,
			&g_settings.audio_AnalogMode,
			AUDIOMENU_ANALOGOUT_OPTIONS, AUDIOMENU_ANALOGOUT_OPTION_COUNT,
			true, audioSetupNotifier, CRCInput::RC_red);

	AudioSelector->addItem( oj );

	oj = new CMenuOptionChooser(LOCALE_AUDIOMENU_ANALOG_OUT, &g_settings.analog_out,
			OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT,
			true, audioSetupNotifier, CRCInput::RC_green);
	AudioSelector->addItem( oj );
#endif

	CZapitChannel * cc = NULL;
	int subtitleCount = 0;
	if (is_mp) {
		subtitleCount = mp->getSubtitleCount();
	} else {
		CChannelList *channelList = CNeutrinoApp::getInstance ()->channelList;
		int curnum = channelList->getActiveChannelNumber();
		cc = channelList->getChannel(curnum);
		subtitleCount = (int)cc->getSubtitleCount();
	}

	bool sep_added = false;
	if (subtitleCount > 0)
	{
		bool sub_active = false;

		for (int i = 0 ; i < subtitleCount ; ++i)
		{
			CZapitAbsSub* s = is_mp ? mp->getChannelSub(i, &s) : cc->getChannelSub(i);
			if (!s)
				continue;

			if (!sep_added)
			{
				sep_added = true;
				AudioSelector->addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_SUBTITLES_HEAD));
			}

			bool ena = false;
			bool add = true;
			char spid[64];
			char item[64];

			if (s->thisSubType == CZapitAbsSub::DVB) {
				CZapitDVBSub* sd = reinterpret_cast<CZapitDVBSub*>(s);
				// printf("[neutrino] adding DVB subtitle %s pid %x\n", sd->ISO639_language_code.c_str(), sd->pId);
				snprintf(spid,sizeof(spid), "DVB:%d", sd->pId);
				snprintf(item,sizeof(item), "DVB: %s (pid %x)", sd->ISO639_language_code.c_str(), sd->pId);
				ena = sd->pId != (is_mp ? mp->getCurrentSubPid(CZapitAbsSub::DVB) : dvbsub_getpid());
			} else if (s->thisSubType == CZapitAbsSub::TTX) {
				CZapitTTXSub* sd = reinterpret_cast<CZapitTTXSub*>(s);
				// printf("[neutrino] adding TTX subtitle %s pid %x mag %X page %x\n", sd->ISO639_language_code.c_str(), sd->pId, sd->teletext_magazine_number, sd->teletext_page_number);
				int page = ((sd->teletext_magazine_number & 0xFF) << 8) | sd->teletext_page_number;
				int pid = sd->pId;
				snprintf(spid,sizeof(spid), "TTX:%d:%03X:%s", sd->pId, page, sd->ISO639_language_code.c_str());
				snprintf(item,sizeof(item), "TTX: %s (pid %x page %03X)", sd->ISO639_language_code.c_str(), sd->pId, page);
				ena = !tuxtx_subtitle_running(&pid, &page, NULL);
			} else if (is_mp && s->thisSubType == CZapitAbsSub::SUB) {
				// printf("[neutrino] adding SUB subtitle %s pid %x\n", s->ISO639_language_code.c_str(), s->pId);
				snprintf(spid,sizeof(spid), "SUB:%d", s->pId);
				snprintf(item,sizeof(item), "SUB: %s (pid %x)", s->ISO639_language_code.c_str(), s->pId);
				ena = s->pId != mp->getCurrentSubPid(CZapitAbsSub::SUB);
			} else
				add = false;

			if (add)
				AudioSelector->addItem(new CMenuForwarder(item, ena,
							NULL, &SubtitleChanger, spid, CRCInput::convertDigitToKey(++shortcut_num)));
			if (is_mp)
				delete s;

			sub_active |= !ena;
		}

		if (sub_active) {
			CMenuForwarder * item = new CMenuForwarder(LOCALE_SUBTITLES_STOP, true, NULL, &SubtitleChanger, "off", CRCInput::RC_stop);
			item->setItemButton(NEUTRINO_ICON_BUTTON_STOP, false);
			AudioSelector->addItem(item);
		}
	}

#if 0
	AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_AUDIOMENU_VOLUME_ADJUST));

	/* setting volume percent to zapit with channel_id/apid = 0 means current channel and pid */
	CVolume::getInstance()->SetCurrentChannel(0);
	CVolume::getInstance()->SetCurrentPid(0);
	int percent[p_count+1];//+1 avoid zero size
	for (uint i=0; i < p_count; i++) {
		percent[i] = CZapit::getInstance()->GetPidVolume(0, g_RemoteControl->current_PIDs.APIDs[i].pid, g_RemoteControl->current_PIDs.APIDs[i].is_ac3);
		AudioSelector.addItem(new CMenuOptionNumberChooser(g_RemoteControl->current_PIDs.APIDs[i].desc,
					&percent[i], i == g_RemoteControl->current_PIDs.PIDs.selected_apid,
					0, 999, CVolume::getInstance()));
	}
#endif

	int res = AudioSelector->exec(NULL, "");

	delete AudioSelector;
	AudioSelector = NULL;

	return res;
}
Exemplo n.º 13
0
int CAudioSelectMenuHandler::doMenu ()
{
	CMenuWidget AudioSelector(LOCALE_AUDIOSELECTMENUE_HEAD, NEUTRINO_ICON_AUDIO, width);

	CSubtitleChangeExec SubtitleChanger;
	
	//show cancel button if configured in usermenu settings
	if (g_settings.personalize[SNeutrinoSettings::P_UMENU_SHOW_CANCEL])
		AudioSelector.addIntroItems(NONEXISTANT_LOCALE, NONEXISTANT_LOCALE, CMenuWidget::BTN_TYPE_CANCEL);
	else
		AudioSelector.addItem(GenericMenuSeparator);

	unsigned int shortcut_num = 1;

	// -- setup menue due to Audio PIDs
	if (g_RemoteControl->current_PIDs.APIDs.size() > 1) 
	{
		uint p_count = g_RemoteControl->current_PIDs.APIDs.size();
		CMenuForwarderNonLocalized* fw[p_count];

	  	for( uint i=0; i < p_count; i++ ) 
		{
			char apid[5];
			sprintf(apid, "%d", i);
			fw[i] = new CMenuForwarderNonLocalized(g_RemoteControl->current_PIDs.APIDs[i].desc, true, NULL, this, apid, CRCInput::convertDigitToKey(i + 1));
			fw[i]->setItemButton(NEUTRINO_ICON_BUTTON_OKAY, true);
			AudioSelector.addItem(fw[i], (i == g_RemoteControl->current_PIDs.PIDs.selected_apid));
			shortcut_num = i+1;
	   	}
	   	AudioSelector.addItem(GenericMenuSeparatorLine);
	}
		
	// -- setup menue for to Dual Channel Stereo
	CMenuOptionChooser* oj = new CMenuOptionChooser(LOCALE_AUDIOMENU_ANALOG_MODE,
				&g_settings.audio_AnalogMode,
				AUDIOMENU_ANALOGOUT_OPTIONS, AUDIOMENU_ANALOGOUT_OPTION_COUNT,
			true, audioSetupNotifier, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED);

	AudioSelector.addItem( oj );

#ifndef EVOLUX // should be: HAVE_SPARK_HARDWARE
	oj = new CMenuOptionChooser(LOCALE_AUDIOMENU_ANALOG_OUT, &g_settings.analog_out,
			 OPTIONS_OFF0_ON1_OPTIONS, OPTIONS_OFF0_ON1_OPTION_COUNT, 
			true, audioSetupNotifier, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN);

	AudioSelector.addItem( oj );
#endif

	CChannelList *channelList = CNeutrinoApp::getInstance ()->channelList;
	int curnum = channelList->getActiveChannelNumber();
	CZapitChannel * cc = channelList->getChannel(curnum);

	bool sep_added = false;
	if(cc) 
	{
		for (int i = 0 ; i < (int)cc->getSubtitleCount() ; ++i) 
		{
			CZapitAbsSub* s = cc->getChannelSub(i);
			if (s->thisSubType == CZapitAbsSub::DVB) {
				CZapitDVBSub* sd = reinterpret_cast<CZapitDVBSub*>(s);
				printf("[neutrino] adding DVB subtitle %s pid %x\n", sd->ISO639_language_code.c_str(), sd->pId);
				if(!sep_added) 
				{
					sep_added = true;
					AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_SUBTITLES_HEAD));
				}
				char spid[10];
				snprintf(spid,sizeof(spid), "DVB:%d", sd->pId);
				char item[64];
				snprintf(item,sizeof(item), "DVB: %s (pid %x)", sd->ISO639_language_code.c_str(), sd->pId);
				AudioSelector.addItem(new CMenuForwarderNonLocalized(item /*sd->ISO639_language_code.c_str()*/,
							sd->pId != dvbsub_getpid(), NULL, &SubtitleChanger, spid, CRCInput::convertDigitToKey(++shortcut_num)));
			}
			if (s->thisSubType == CZapitAbsSub::TTX) 
			{
				CZapitTTXSub* sd = reinterpret_cast<CZapitTTXSub*>(s);
				printf("[neutrino] adding TTX subtitle %s pid %x mag %X page %x\n", sd->ISO639_language_code.c_str(), sd->pId, sd->teletext_magazine_number, sd->teletext_page_number);
				if(!sep_added) 
				{
					sep_added = true;
					AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_SUBTITLES_HEAD));
				}
				char spid[64];
				int page = ((sd->teletext_magazine_number & 0xFF) << 8) | sd->teletext_page_number;
				int pid = sd->pId;
				snprintf(spid,sizeof(spid), "TTX:%d:%03X:%s", sd->pId, page, sd->ISO639_language_code.c_str()); 
				char item[64];
				snprintf(item,sizeof(item), "TTX: %s (pid %x page %03X)", sd->ISO639_language_code.c_str(), sd->pId, page);
				AudioSelector.addItem(new CMenuForwarderNonLocalized(item /*sd->ISO639_language_code.c_str()*/,
							!tuxtx_subtitle_running(&pid, &page, NULL), NULL, &SubtitleChanger, spid, CRCInput::convertDigitToKey(++shortcut_num)));
			}
		}
		
		if(sep_added) 
			AudioSelector.addItem(new CMenuForwarder(LOCALE_SUBTITLES_STOP, true, NULL, &SubtitleChanger, "off", CRCInput::RC_stop));
	}

#ifdef EVOLUX
	AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_AUDIOMENU_VOLUME_ADJUSTMENT));

	int percent[g_RemoteControl->current_PIDs.APIDs.size()];
	audioSetupNotifierVolPercent->setChannelId(0);
	audioSetupNotifierVolPercent->setAPid(0);
	for(unsigned int count = 0; count < g_RemoteControl->current_PIDs.APIDs.size(); count++ ) {
		g_Zapit->getVolumePercent((unsigned int *) &percent[count], 0, g_RemoteControl->current_PIDs.APIDs[count].pid);
		int is_active = count == g_RemoteControl->current_PIDs.PIDs.selected_apid;
		AudioSelector.addItem(new CMenuOptionNumberChooser(NONEXISTANT_LOCALE, &percent[count],
			is_active,
			0, 999, audioSetupNotifierVolPercent, 0, 0, NONEXISTANT_LOCALE,
			g_RemoteControl->current_PIDs.APIDs[count].desc));
		if (is_active)
			g_settings.current_volume_percent = percent[count];
	}
#endif
	return AudioSelector.exec(NULL, "");
}
Exemplo n.º 14
0
int CAudioSelectMenuHandler::doMenu()
{
	CMenuWidget AudioSelector(LOCALE_APIDSELECTOR_HEAD, NEUTRINO_ICON_AUDIO);
	
	unsigned int count;
	
	CAPIDChangeExec APIDChanger;
	CSubtitleChangeExec SubtitleChanger;
	
	// audio pids
	for(count = 0; count < g_RemoteControl->current_PIDs.APIDs.size(); count++ ) 
	{
		char apid[5];
		sprintf(apid, "%d", count);
		AudioSelector.addItem(new CMenuForwarder(g_RemoteControl->current_PIDs.APIDs[count].desc, true, NULL, &APIDChanger, apid, CRCInput::convertDigitToKey(count + 1)), (count == g_RemoteControl->current_PIDs.PIDs.selected_apid));
	}

	if(g_RemoteControl->current_PIDs.APIDs.size())
		AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE));

	// analogue output
	AudioSelector.addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_ANALOGOUT, &g_settings.audio_AnalogMode, AUDIOMENU_ANALOGOUT_OPTIONS, AUDIOMENU_ANALOGOUT_OPTION_COUNT, true, audioSetupNotifier, CRCInput::RC_red, NEUTRINO_ICON_BUTTON_RED));
	
	// ac3
#if !defined (PLATFORM_COOLSTREAM)	
	AudioSelector.addItem(new CMenuOptionChooser(LOCALE_AUDIOMENU_HDMI_DD, &g_settings.hdmi_dd, AC3_OPTIONS, AC3_OPTION_COUNT, true, audioSetupNotifier, CRCInput::RC_green, NEUTRINO_ICON_BUTTON_GREEN ));
#endif

	//dvb/tuxtxt subs
	CChannelList * channelList = CNeutrinoApp::getInstance()->channelList;
	int curnum = channelList->getActiveChannelNumber();
	CZapitChannel * cc = channelList->getChannel(curnum);

	bool sep_added = false;
	if(cc) 
	{
		for (int i = 0 ; i < (int)cc->getSubtitleCount() ; ++i) 
		{
			CZapitAbsSub* s = cc->getChannelSub(i);
			
			//dvbsub
			if (s->thisSubType == CZapitAbsSub::DVB) 
			{
				CZapitDVBSub* sd = reinterpret_cast<CZapitDVBSub*>(s);
				printf("[CAudioSelectMenuHandler] adding DVB subtitle %s pid 0x%x\n", sd->ISO639_language_code.c_str(), sd->pId);
				if(!sep_added) 
				{
					sep_added = true;
					AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_SUBTITLES_HEAD));
				}
				char spid[10];
				//int pid = sd->pId;
				snprintf(spid,sizeof(spid), "DVB:%d", sd->pId);
				char item[64];
				//snprintf(item,sizeof(item), "DVB: %s (pid %x)", sd->ISO639_language_code.c_str(), sd->pId);
				snprintf(item, sizeof(item), "DVB: %s", sd->ISO639_language_code.c_str());
				AudioSelector.addItem(new CMenuForwarder(item, sd->pId != dvbsub_getpid() /* !dvbsub_getpid(&pid, NULL)*/, NULL, &SubtitleChanger, spid, CRCInput::convertDigitToKey(++count)));
			}
			
			//txtsub
			if (s->thisSubType == CZapitAbsSub::TTX) 
			{
				CZapitTTXSub* sd = reinterpret_cast<CZapitTTXSub*>(s);
				printf("[CAudioSelectMenuHandler] adding TTX subtitle %s pid 0x%x mag 0x%X page 0x%x\n", sd->ISO639_language_code.c_str(), sd->pId, sd->teletext_magazine_number, sd->teletext_page_number);
				if(!sep_added) 
				{
					sep_added = true;
					AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_SUBTITLES_HEAD));
				}
				char spid[64];
				int page = ((sd->teletext_magazine_number & 0xFF) << 8) | sd->teletext_page_number;
				int pid = sd->pId;
				snprintf(spid,sizeof(spid), "TTX:%d:%03X:%s", sd->pId, page, sd->ISO639_language_code.c_str()); 
				char item[64];
				//snprintf(item, sizeof(item), "TTX: %s (pid %x page %03X)", sd->ISO639_language_code.c_str(), sd->pId, page);
				snprintf(item, sizeof(item), "TTX: %s", sd->ISO639_language_code.c_str());
				AudioSelector.addItem(new CMenuForwarder(item,  !tuxtx_subtitle_running(&pid, &page, NULL), NULL, &SubtitleChanger, spid, CRCInput::convertDigitToKey(++count)));
			}
		}
		
		if(sep_added) 
		{
			AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE));
			AudioSelector.addItem(new CMenuForwarder(LOCALE_SUBTITLES_STOP, true, NULL, &SubtitleChanger, "off", CRCInput::RC_yellow, NEUTRINO_ICON_BUTTON_YELLOW ));
		}

	}
	
	// volume percent
	int percent[g_RemoteControl->current_PIDs.APIDs.size()];
	
	for(count = 0; count < g_RemoteControl->current_PIDs.APIDs.size(); count++ ) 
	{
		g_Zapit->getVolumePercent((unsigned int *) &percent[count], 0, g_RemoteControl->current_PIDs.APIDs[count].pid);
		int is_active = count == g_RemoteControl->current_PIDs.PIDs.selected_apid;
		
		if(!sep_added) 
		{
			sep_added = true;
			AudioSelector.addItem(new CMenuSeparator(CMenuSeparator::LINE | CMenuSeparator::STRING, LOCALE_AUDIOMENU_VOLUME_ADJUST));
		}
		
		AudioSelector.addItem(new CMenuOptionNumberChooser(NONEXISTANT_LOCALE, &percent[count],
			is_active,
			0, 100, audioSetupNotifierVolPercent, 0, 0, NONEXISTANT_LOCALE,
			g_RemoteControl->current_PIDs.APIDs[count].desc));
	}

	return AudioSelector.exec(NULL, "");
}