webtv channels integration port,

initial code (C) martii,
initial patch from jacek
This commit is contained in:
[CST] Focus
2014-08-27 17:32:26 +04:00
parent 415d516465
commit a473fe8194
49 changed files with 1000 additions and 190 deletions

View File

@@ -379,6 +379,7 @@ int CNeutrinoApp::loadSetup(const char * fname)
#endif
g_settings.make_hd_list = configfile.getInt32("make_hd_list", 1);
g_settings.make_webtv_list = configfile.getInt32("make_webtv_list", 1);
g_settings.make_new_list = configfile.getInt32("make_new_list", 1);
g_settings.make_removed_list = configfile.getInt32("make_removed_list", 1);
g_settings.keep_channel_numbers = configfile.getInt32("keep_channel_numbers", 0);
@@ -643,6 +644,21 @@ int CNeutrinoApp::loadSetup(const char * fname)
g_settings.plugin_hdd_dir = configfile.getString( "plugin_hdd_dir", "/media/sda1/plugins" );
g_settings.logo_hdd_dir = configfile.getString( "logo_hdd_dir", "/media/sda1/logos" );
int webtv_count = configfile.getInt32("webtv_xml_count", 0);
if (webtv_count) {
for (int i = 0; i < webtv_count; i++) {
std::string k = "webtv_xml_" + to_string(i);
std::string webtv_xml = configfile.getString(k, "");
if (webtv_xml.empty())
continue;
g_settings.webtv_xml.push_back(webtv_xml);
}
} else {
std::string webtv_xml = configfile.getString("webtv_xml", WEBTV_XML);
if (!file_size(webtv_xml.c_str()))
g_settings.webtv_xml.push_back(webtv_xml);
}
loadKeys();
g_settings.timeshift_pause = configfile.getInt32( "timeshift_pause", 1 );
@@ -667,7 +683,7 @@ int CNeutrinoApp::loadSetup(const char * fname)
g_settings.channellist_progressbar_design = configfile.getInt32("channellist_progressbar_design", g_settings.progressbar_design);
g_settings.channellist_foot = configfile.getInt32("channellist_foot" , 1);//default next Event
g_settings.channellist_new_zap_mode = configfile.getInt32("channellist_new_zap_mode", 1);
g_settings.channellist_sort_mode = configfile.getInt32("channellist_sort_mode", 0);//sort mode: alpha, freq, sat
g_settings.channellist_sort_mode = configfile.getInt32("channellist_sort_mode", 0);//sort mode: alpha, freq, sat
g_settings.channellist_numeric_adjust = configfile.getInt32("channellist_numeric_adjust", 0);
g_settings.channellist_show_channellogo = configfile.getInt32("channellist_show_channellogo", 1);
g_settings.channellist_show_numbers = configfile.getInt32("channellist_show_numbers", 1);
@@ -924,6 +940,7 @@ void CNeutrinoApp::saveSetup(const char * fname)
configfile.setInt32("ci_ignore_messages", g_settings.ci_ignore_messages);
configfile.setInt32( "make_hd_list", g_settings.make_hd_list);
configfile.setInt32( "make_webtv_list", g_settings.make_webtv_list);
configfile.setInt32( "make_new_list", g_settings.make_new_list);
configfile.setInt32( "make_removed_list", g_settings.make_removed_list);
configfile.setInt32( "keep_channel_numbers", g_settings.keep_channel_numbers);
@@ -1139,6 +1156,14 @@ void CNeutrinoApp::saveSetup(const char * fname)
configfile.setString ( "plugin_hdd_dir", g_settings.plugin_hdd_dir );
configfile.setString ( "logo_hdd_dir", g_settings.logo_hdd_dir );
int webtv_count = 0;
for (std::list<std::string>::iterator it = g_settings.webtv_xml.begin(); it != g_settings.webtv_xml.end(); ++it) {
std::string k = "webtv_xml_" + to_string(webtv_count);
configfile.setString(k, *it);
webtv_count++;
}
configfile.setInt32 ( "webtv_xml_count", g_settings.webtv_xml.size());
saveKeys();
configfile.setInt32( "timeshift_pause", g_settings.timeshift_pause );
@@ -1429,6 +1454,24 @@ void CNeutrinoApp::channelsInit(bool bOnly)
TIMER_STOP("[neutrino] sat took");
}
/* all WebTV channels */
if (g_settings.make_webtv_list) {
if (CServiceManager::getInstance()->GetAllWebTVChannels(zapitList)) {
/* all channels */
CBouquet* webtvBouquet = new CBouquet(0, g_Locale->getText(LOCALE_BOUQUETNAME_WEBTV), false, true);
webtvBouquet->channelList->SetChannelList(&zapitList);
TVallList->Bouquets.push_back(webtvBouquet);
/* provider */
webtvBouquet = new CBouquet(0, g_Locale->getText(LOCALE_BOUQUETNAME_WEBTV), false, true);
webtvBouquet->channelList->SetChannelList(&zapitList);
TVbouquetList->Bouquets.push_back(webtvBouquet);
/* "satellite" */
webtvBouquet = new CBouquet(0, g_Locale->getText(LOCALE_BOUQUETNAME_WEBTV), false, true);
webtvBouquet->channelList->SetChannelList(&zapitList);
TVsatList->Bouquets.push_back(webtvBouquet);
printf("[neutrino] got %d WebTV channels\n", (int)zapitList.size()); fflush(stdout);
}
}
/* all HD channels */
if (g_settings.make_hd_list) {
if (CServiceManager::getInstance()->GetAllHDChannels(zapitList)) {
@@ -1719,7 +1762,7 @@ void CNeutrinoApp::InitZapper()
tuxtxt_init();
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
if(channelList->getSize() && live_channel_id)
if(channelList->getSize() && live_channel_id && !IS_WEBTV(live_channel_id))
g_Sectionsd->setServiceChanged(live_channel_id, true );
}
@@ -1760,7 +1803,7 @@ void CNeutrinoApp::InitTimerdClient()
void CNeutrinoApp::InitZapitClient()
{
g_Zapit = new CZapitClient;
#define ZAPIT_EVENT_COUNT 28
#define ZAPIT_EVENT_COUNT 29
const CZapitClient::events zapit_event[ZAPIT_EVENT_COUNT] =
{
CZapitClient::EVT_ZAP_COMPLETE,
@@ -1790,7 +1833,8 @@ void CNeutrinoApp::InitZapitClient()
CZapitClient::EVT_SDT_CHANGED,
CZapitClient::EVT_PMT_CHANGED,
CZapitClient::EVT_TUNE_COMPLETE,
CZapitClient::EVT_BACK_ZAP_COMPLETE
CZapitClient::EVT_BACK_ZAP_COMPLETE,
CZapitClient::EVT_WEBTV_ZAP_COMPLETE,
};
for (int i = 0; i < ZAPIT_EVENT_COUNT; i++)
@@ -1890,6 +1934,7 @@ TIMER_START();
ZapStart_arg.video_mode = g_settings.video_Mode;
ZapStart_arg.ci_clock = g_settings.ci_clock;
ZapStart_arg.volume = g_settings.current_volume;
ZapStart_arg.webtv_xml = &g_settings.webtv_xml;
/* create decoders, read channels */
bool zapit_init = CZapit::getInstance()->Start(&ZapStart_arg);
@@ -2112,7 +2157,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu)
while( true ) {
g_RCInput->getMsg(&msg, &data, 100, ((g_settings.mode_left_right_key_tv == SNeutrinoSettings::VOLUME) && (g_RemoteControl->subChannels.size() < 1)) ? true : false); // 10 secs..
if( ( mode == mode_tv ) || ( ( mode == mode_radio ) ) ) {
if( ( mode == mode_tv ) || ( mode == mode_radio ) || ( mode == mode_webtv ) ) {
if( (msg == NeutrinoMessages::SHOW_EPG) /* || (msg == CRCInput::RC_info) */ ) {
InfoClock->enableInfoClock(false);
StopSubtitles();
@@ -2188,7 +2233,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu)
else if( msg == (neutrino_msg_t) g_settings.key_subchannel_down )
g_RemoteControl->subChannelDown();
g_InfoViewer->showSubchan();
}
}
else if ( msg == CRCInput::RC_left || msg == CRCInput::RC_right) {
switch (g_settings.mode_left_right_key_tv)
{
@@ -2204,7 +2249,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu)
quickZap(msg);
break;
}
}
}
else
quickZap( msg );
}
@@ -2246,7 +2291,10 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu)
g_PluginList->startPlugin_by_name(g_settings.onekey_plugin.c_str());
}
else if(msg == (neutrino_msg_t) g_settings.key_timeshift) {
CRecordManager::getInstance()->StartTimeshift();
if (mode == mode_webtv) {
CMoviePlayerGui::getInstance().Pause();
} else
CRecordManager::getInstance()->StartTimeshift();
}
else if (msg == (neutrino_msg_t) g_settings.key_current_transponder){
numericZap( msg );
@@ -2256,7 +2304,7 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu)
t_channel_id pip_channel_id = CZapit::getInstance()->GetPipChannelID();
if (pip_channel_id)
g_Zapit->stopPip();
else
else
StartPip(CZapit::getInstance()->GetCurrentChannelID());
}
else if (msg == (neutrino_msg_t) g_settings.key_pip_setup) {
@@ -2279,18 +2327,18 @@ void CNeutrinoApp::RealRun(CMenuWidget &mainMenu)
else if( msg == CRCInput::RC_page_up || msg == CRCInput::RC_page_down) {
quickZap(msg == CRCInput::RC_page_up ? CRCInput::RC_right : CRCInput::RC_left);
}
else if(msg == CRCInput::RC_rewind) {
else if(msg == CRCInput::RC_rewind && (mode != mode_webtv)) {
if(g_RemoteControl->is_video_started) {
t_channel_id live_channel_id = CZapit::getInstance()->GetCurrentChannelID();
if(CRecordManager::getInstance()->RecordingStatus(live_channel_id))
CMoviePlayerGui::getInstance().exec(NULL, "rtimeshift");
}
}
else if( msg == CRCInput::RC_record) {
else if( msg == CRCInput::RC_record && (mode != mode_webtv)) {
if (g_settings.recording_type != CNeutrinoApp::RECORDING_OFF)
CRecordManager::getInstance()->exec(NULL, "Record");
}
else if( msg == CRCInput::RC_stop ) {
else if( msg == CRCInput::RC_stop) {
CRecordManager::getInstance()->exec(NULL, "Stop_record");
}
else if( msg == CRCInput::RC_red ) {
@@ -2542,24 +2590,56 @@ void CNeutrinoApp::standbyToStandby(void)
}
}
void CNeutrinoApp::stopPlayBack(bool lock)
{
CMoviePlayerGui::getInstance().stopPlayBack();
g_Zapit->stopPlayBack();
if (lock)
CZapit::getInstance()->EnablePlayback(false);
}
void CNeutrinoApp::lockPlayBack(bool blank)
{
CMoviePlayerGui::getInstance().stopPlayBack();
g_Zapit->lockPlayBack();
if (blank)
videoDecoder->setBlank(true);
}
int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
{
int res = 0;
neutrino_msg_t msg = _msg;
if(msg == NeutrinoMessages::EVT_WEBTV_ZAP_COMPLETE) {
t_channel_id chid = *(t_channel_id *) data;
printf("EVT_WEBTV_ZAP_COMPLETE: %llx\n", chid);
if (mode == mode_standby) {
delete [] (unsigned char*) data;
} else {
CZapitChannel * cc = CZapit::getInstance()->GetCurrentChannel();
CMoviePlayerGui::getInstance().stopPlayBack();
if (CMoviePlayerGui::getInstance().PlayBackgroundStart(cc->getUrl(), cc->getName(), cc->getChannelID()))
delete [] (unsigned char*) data;
else
g_RCInput->postMsg(NeutrinoMessages::EVT_ZAP_FAILED, data);
}
return messages_return::handled;
}
if(msg == NeutrinoMessages::EVT_ZAP_COMPLETE) {
CZapit::getInstance()->GetAudioMode(g_settings.audio_AnalogMode);
if(g_settings.audio_AnalogMode < 0 || g_settings.audio_AnalogMode > 2)
g_settings.audio_AnalogMode = 0;
g_RCInput->killTimer(scrambled_timer);
if (mode != mode_webtv) {
scrambled_timer = g_RCInput->addTimer(10*1000*1000, true);
SelectSubtitles();
StartSubtitles(!g_InfoViewer->is_visible);
scrambled_timer = g_RCInput->addTimer(10*1000*1000, true);
SelectSubtitles();
StartSubtitles(!g_InfoViewer->is_visible);
/* update scan settings for manual scan to current channel */
CScanSetup::getInstance()->updateManualSettings();
/* update scan settings for manual scan to current channel */
CScanSetup::getInstance()->updateManualSettings();
}
}
if ((msg == NeutrinoMessages::EVT_TIMER)) {
if(data == scrambled_timer) {
@@ -2604,7 +2684,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
/* ================================== KEYS ================================================ */
if( msg == CRCInput::RC_ok || (!g_InfoViewer->virtual_zap_mode && (msg == CRCInput::RC_sat || msg == CRCInput::RC_favorites))) {
if( (mode == mode_tv) || (mode == mode_radio) || (mode == mode_ts)) {
if( (mode == mode_tv) || (mode == mode_radio) || (mode == mode_ts) || (mode == mode_webtv)) {
showChannelList(msg);
return messages_return::handled;
}
@@ -2850,8 +2930,10 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
printf("NeutrinoMessages::EVT_STREAM_START: fd %d\n", fd);
wakeupFromStandby();
if (!CStreamManager::getInstance()->AddClient(fd))
if (!CStreamManager::getInstance()->AddClient(fd)) {
close(fd);
g_RCInput->postMsg(NeutrinoMessages::EVT_STREAM_STOP, 0);
}
return messages_return::handled;
}
else if (msg == NeutrinoMessages::EVT_STREAM_STOP) {
@@ -2878,7 +2960,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
if ((!isTVMode) && (mode != mode_radio)) {
radioMode(true);
}
else if (isTVMode && (mode != mode_tv)) {
else if (isTVMode && (mode != mode_tv) && (mode != mode_webtv)) {
tvMode(true);
}
channelList->zapTo_ChannelID(eventinfo->channel_id);
@@ -2957,9 +3039,10 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
return messages_return::handled;
}
else if( msg == NeutrinoMessages::RELOAD_SETUP ) {
bool tmp = g_settings.make_hd_list;
bool tmp1 = g_settings.make_hd_list;
bool tmp2 = g_settings.make_webtv_list;
loadSetup(NEUTRINO_SETTINGS_FILE);
if(tmp != g_settings.make_hd_list)
if(tmp1 != g_settings.make_hd_list || tmp2 != g_settings.make_webtv_list)
g_Zapit->reinitChannels();
return messages_return::handled;
@@ -3049,7 +3132,7 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
return messages_return::handled;
}
else if( msg == NeutrinoMessages::CHANGEMODE ) {
printf("CNeutrinoApp::handleMsg: CHANGEMODE to %d rezap %d\n", data & mode_mask, (data & norezap) != norezap);
if((data & mode_mask)== mode_radio) {
if( mode != mode_radio ) {
radioMode((data & norezap) != norezap);
@@ -3078,6 +3161,17 @@ int CNeutrinoApp::handleMsg(const neutrino_msg_t _msg, neutrino_msg_data_t data)
lastMode=mode;
mode=mode_ts;
}
if((data & mode_mask)== mode_webtv) {
lastMode=mode;
mode=mode_webtv;
if ((data & norezap) != norezap) {
CZapitChannel * cc = CZapit::getInstance()->GetCurrentChannel();
if (cc && IS_WEBTV(cc->getChannelID())) {
CMoviePlayerGui::getInstance().stopPlayBack();
CMoviePlayerGui::getInstance().PlayBackgroundStart(cc->getUrl(), cc->getName(), cc->getChannelID());
}
}
}
}
else if( msg == NeutrinoMessages::VCR_ON ) {
if( mode != mode_scart ) {
@@ -3164,7 +3258,9 @@ void CNeutrinoApp::ExitRun(const bool /*write_si*/, int retcode)
dprintf(DEBUG_INFO, "exit\n");
StopSubtitles();
g_Zapit->stopPlayBack();
printf("###################################### CNeutrinoApp::ExitRun: g_Zapit->stopPlayBack()\n");fflush(stdout);
stopPlayBack();
printf("###################################### CNeutrinoApp::ExitRun: g_Zapit->stopPlayBack() done\n");fflush(stdout);
frameBuffer->paintBackground();
videoDecoder->ShowPicture(DATADIR "/neutrino/icons/shutdown.jpg");
@@ -3333,6 +3429,7 @@ void CNeutrinoApp::tvMode( bool rezap )
}
bool stopauto = (mode != mode_ts);
int oldmode = mode;
mode = mode_tv;
#ifdef ENABLE_PIP
pipDecoder->Pig(g_settings.pip_x, g_settings.pip_y,
@@ -3344,10 +3441,10 @@ void CNeutrinoApp::tvMode( bool rezap )
CRecordManager::getInstance()->StopAutoRecord();
//recordingstatus = 0;
}
frameBuffer->useBackground(false);
frameBuffer->paintBackground();
if (oldmode != mode_webtv) {
frameBuffer->useBackground(false);
frameBuffer->paintBackground();
}
g_RemoteControl->tvMode();
SetChannelMode(g_settings.channel_mode);
if( rezap ) {
@@ -3384,7 +3481,7 @@ void CNeutrinoApp::scartMode( bool bOnOff )
if( lastMode == mode_radio ) {
radioMode( false );
}
else if( lastMode == mode_tv ) {
else if( lastMode == mode_tv || lastMode == mode_webtv) {
tvMode( false );
}
else if( lastMode == mode_standby ) {
@@ -3424,8 +3521,9 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby )
#ifdef ENABLE_PIP
g_Zapit->stopPip();
#endif
CMoviePlayerGui::getInstance().stopPlayBack();
bool stream_status = CStreamManager::getInstance()->StreamStatus();
if((g_settings.epg_scan_mode == CEpgScan::MODE_OFF) && !fromDeepStandby &&
if((g_settings.epg_scan_mode == CEpgScan::MODE_OFF) && !fromDeepStandby &&
!CRecordManager::getInstance()->RecordingStatus() && !stream_status) {
g_Zapit->setStandby(true);
} else {
@@ -3506,6 +3604,7 @@ void CNeutrinoApp::standbyMode( bool bOnOff, bool fromDeepStandby )
CVFD::getInstance()->setMode(CVFD::MODE_TVRADIO);
CVFD::getInstance()->setBacklight(g_settings.backlight_tv);
CVFD::getInstance()->showVolume(g_settings.current_volume, true);
CZapit::getInstance()->EnablePlayback(true);
g_Zapit->setStandby(false);
@@ -3548,6 +3647,11 @@ void CNeutrinoApp::radioMode( bool rezap)
{
//printf("radioMode: rezap %s\n", rezap ? "yes" : "no");
INFO("rezap %d current mode %d", rezap, mode);
if (mode == mode_webtv) {
CMoviePlayerGui::getInstance().setLastMode(mode_unknown);
CMoviePlayerGui::getInstance().stopPlayBack();
CVFD::getInstance()->ShowIcon(FP_ICON_TV, false);
}
if (mode == mode_tv) {
CVFD::getInstance()->ShowIcon(FP_ICON_TV, false);
StopSubtitles();
@@ -3592,10 +3696,10 @@ void CNeutrinoApp::switchTvRadioMode(const int prev_mode)
tvMode();
else if(prev_mode == mode_radio && mode != mode_radio)
radioMode();
}else {
} else {
if (mode == mode_radio )
tvMode();
else if(mode == mode_tv)
else if(mode == mode_tv || mode == mode_webtv)
radioMode();
}
}
@@ -3814,8 +3918,8 @@ void stop_daemons(bool stopall, bool for_flash)
videoDecoder->SetCECMode((VIDEO_HDMI_CEC_MODE)0);
}
delete &CMoviePlayerGui::getInstance();
CZapit::getInstance()->Stop();
delete &CMoviePlayerGui::getInstance();
printf("zapit shutdown done\n");
if (!for_flash) {
CVFD::getInstance()->Clear();