2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
25 #include "TuxBoxUtil.h"
27 #include "filesystem/CurlFile.h"
28 #include "dialogs/GUIDialogContextMenu.h"
29 #include "Application.h"
30 #include "ApplicationMessenger.h"
31 #include "GUIInfoManager.h"
32 #include "video/VideoInfoTag.h"
33 #include "guilib/GUIWindowManager.h"
34 #include "dialogs/GUIDialogOK.h"
35 #include "dialogs/GUIDialogYesNo.h"
36 #include "filesystem/File.h"
38 #include "settings/AdvancedSettings.h"
40 #include "guilib/LocalizeStrings.h"
41 #include "StringUtils.h"
42 #include "utils/XBMCTinyXML.h"
45 using namespace XFILE;
49 CTuxBoxService g_tuxboxService;
51 CTuxBoxService::CTuxBoxService() : CThread("TuxBoxService")
54 CTuxBoxService::~CTuxBoxService()
57 CTuxBoxUtil::CTuxBoxUtil(void)
59 sCurSrvData.requested_audio_channel = 0;
60 sZapstream.initialized = false;
61 sZapstream.available = false;
63 CTuxBoxUtil::~CTuxBoxUtil(void)
66 bool CTuxBoxService::Start()
68 if(g_advancedSettings.m_iTuxBoxEpgRequestTime != 0)
77 void CTuxBoxService::Stop()
79 CLog::Log(LOGDEBUG, "%s - Stopping CTuxBoxService thread", __FUNCTION__);
82 void CTuxBoxService::OnStartup()
84 CLog::Log(LOGDEBUG, "%s - Starting CTuxBoxService thread", __FUNCTION__);
85 SetPriority( GetMinPriority() );
87 void CTuxBoxService::OnExit()
89 CThread::m_bStop = true;
91 bool CTuxBoxService::IsRunning()
93 return !CThread::m_bStop;
95 void CTuxBoxService::Process()
97 CStdString strCurrentServiceName = g_tuxbox.sCurSrvData.service_name;
100 while(!CThread::m_bStop && g_application.m_pPlayer->IsPlaying())
102 strURL = g_application.CurrentFileItem().GetPath();
103 if(!URIUtils::IsTuxBox(strURL))
106 int iRequestTimer = g_advancedSettings.m_iTuxBoxEpgRequestTime *1000; //seconds
107 Sleep(iRequestTimer);
110 if(g_tuxbox.GetHttpXML(url,"currentservicedata"))
112 CLog::Log(LOGDEBUG, "%s - receive current service data was successful", __FUNCTION__);
113 if(!strCurrentServiceName.IsEmpty()&&
114 !strCurrentServiceName.Equals("NULL") &&
115 !g_tuxbox.sCurSrvData.service_name.IsEmpty() &&
116 !g_tuxbox.sCurSrvData.service_name.Equals("-") &&
117 !g_tuxbox.vVideoSubChannel.mode)
119 //Detect Channel Change
120 //We need to detect the channel on the TuxBox Device!
121 //On changing the channel on the device we will loose the stream and mplayer seems not able to detect it to stop
122 if (strCurrentServiceName != g_tuxbox.sCurSrvData.service_name && g_application.m_pPlayer->IsPlaying() && !g_tuxbox.sZapstream.available)
124 CLog::Log(LOGDEBUG," - ERROR: Non controlled channel change detected! Stopping current playing stream!");
125 CApplicationMessenger::Get().MediaStop();
129 //Update infomanager from tuxbox client
130 g_infoManager.UpdateFromTuxBox();
133 CLog::Log(LOGDEBUG, "%s - Could not receive current service data", __FUNCTION__);
136 bool CTuxBoxUtil::CreateNewItem(const CFileItem& item, CFileItem& item_new)
139 item_new.SetLabel(item.GetLabel());
140 item_new.SetPath(item.GetPath());
141 item_new.SetArt("thumb", item.GetArt("thumb"));
143 if(g_tuxbox.GetZapUrl(item.GetPath(), item_new))
145 if(vVideoSubChannel.mode)
146 vVideoSubChannel.current_name = item_new.GetLabel()+" ("+vVideoSubChannel.current_name+")";
151 if(!sBoxStatus.recording.Equals("1")) //Don't Show this Dialog, if the Box is in Recording mode! A previos YN Dialog was send to user!
153 CLog::Log(LOGDEBUG, "%s ---------------------------------------------------------", __FUNCTION__);
154 CLog::Log(LOGDEBUG, "%s - WARNING: Zaping Failed no Zap Point found!", __FUNCTION__);
155 CLog::Log(LOGDEBUG, "%s ---------------------------------------------------------", __FUNCTION__);
156 CStdString strText = StringUtils::Format(g_localizeStrings.Get(21334).c_str(), item.GetLabel().c_str());
157 CGUIDialogOK::ShowAndGetInput(21331, strText, 21333, 0);
162 bool CTuxBoxUtil::ParseBouquets(TiXmlElement *root, CFileItemList &items, CURL &url, CStdString strFilter, CStdString strChild)
164 CStdString strOptions, strPort;
165 TiXmlElement *pRootElement =root;
166 TiXmlNode *pNode = NULL;
167 TiXmlNode *pIt = NULL;
170 strOptions = url.GetOptions();
174 CLog::Log(LOGWARNING, "%s - No %s found", __FUNCTION__, strChild.c_str());
177 if (strFilter.IsEmpty())
179 pNode = pRootElement->FirstChild(strChild.c_str());
182 CLog::Log(LOGWARNING, "%s - No %s found", __FUNCTION__,strChild.c_str());
187 pIt = pNode->FirstChild("name");
190 CStdString strItemName = pIt->FirstChild()->Value();
192 pIt = pNode->FirstChild("reference");
195 CStdString strItemPath = pIt->FirstChild()->Value();
196 // add. bouquets to item list!
197 CFileItemPtr pItem(new CFileItem);
198 pItem->m_bIsFolder = true;
199 pItem->SetLabel(strItemName);
202 fileUrl.SetProtocol("tuxbox");
203 fileUrl.SetUserName(url.GetUserName());
204 fileUrl.SetPassword(url.GetPassWord());
205 fileUrl.SetHostName(url.GetHostName());
206 if (url.GetPort() != 0 && url.GetPort() != 80)
207 fileUrl.SetPort(url.GetPort());
208 fileUrl.SetOptions(url.GetOptions());
209 fileUrl.SetOption("reference", strItemPath);
210 pItem->SetPath(fileUrl.Get());
214 CLog::Log(LOGDEBUG, "%s - Name: %s", __FUNCTION__,strItemName.c_str());
215 CLog::Log(LOGDEBUG, "%s - Adress: %s", __FUNCTION__,pItem->GetPath().c_str());
218 pNode = pNode->NextSibling(strChild.c_str());
223 bool CTuxBoxUtil::ParseBouquetsEnigma2(TiXmlElement *root, CFileItemList &items, CURL &url, CStdString& strFilter, CStdString& strChild)
226 TiXmlElement *pRootElement = root;
227 TiXmlNode *pNode = NULL;
228 TiXmlNode *pIt = NULL;
233 CLog::Log(LOGWARNING, "%s - No %s found", __FUNCTION__, strChild.c_str());
236 if (strFilter.IsEmpty())
238 pNode = pRootElement->FirstChildElement("e2bouquet");
241 CLog::Log(LOGWARNING, "%s - No %s found", __FUNCTION__,strChild.c_str());
246 CFileItemPtr pItem(new CFileItem);
247 pIt = pNode->FirstChildElement("e2servicereference");
248 CStdString strItemPath = pIt->FirstChild()->Value();
249 pIt = pNode->FirstChildElement("e2servicename");
250 CStdString strItemName = pIt->FirstChild()->Value();
251 pItem->m_bIsFolder = true;
252 pItem->SetLabel(strItemName);
255 fileUrl.SetProtocol("tuxbox");
256 fileUrl.SetHostName(url.GetHostName());
257 if (url.GetPort() != 0 && url.GetPort() != 80)
258 fileUrl.SetPort(url.GetPort());
259 fileUrl.SetFileName(strItemName + "/");
260 pItem->SetPath(fileUrl.Get());
263 pNode = pNode->NextSiblingElement("e2bouquet");
268 bool CTuxBoxUtil::ParseChannels(TiXmlElement *root, CFileItemList &items, CURL &url, CStdString strFilter, CStdString strChild)
271 TiXmlElement *pRootElement =root;
272 TiXmlNode *pNode = NULL;
273 TiXmlNode *pIt = NULL;
274 TiXmlNode *pIta = NULL;
279 CLog::Log(LOGWARNING, "%s - No %ss found", __FUNCTION__,strChild.c_str());
282 if(!strFilter.IsEmpty())
284 pNode = pRootElement->FirstChild(strChild.c_str());
287 CLog::Log(LOGWARNING, "%s - No %s found", __FUNCTION__,strChild.c_str());
292 pIt = pNode->FirstChild("name");
295 CStdString strItemName = pIt->FirstChild()->Value();
297 pIt = pNode->FirstChild("reference");
298 if (strFilter.Equals(pIt->FirstChild()->Value()))
300 pIt = pNode->FirstChild("service");
303 CLog::Log(LOGWARNING, "%s - No service found", __FUNCTION__);
308 pIta = pIt->FirstChild("name");
311 strItemName = pIta->FirstChild()->Value();
313 pIta = pIt->FirstChild("reference");
316 CStdString strItemPath = pIta->FirstChild()->Value();
317 // channel listing add. to item list!
318 CFileItemPtr pbItem(new CFileItem);
319 pbItem->m_bIsFolder = false;
320 pbItem->SetLabel(strItemName);
321 pbItem->SetLabelPreformated(true);
324 fileUrl.SetProtocol("tuxbox");
325 fileUrl.SetUserName(url.GetUserName());
326 fileUrl.SetPassword(url.GetPassWord());
327 fileUrl.SetHostName(url.GetHostName());
328 if (url.GetPort() != 0 && url.GetPort() != 80)
329 fileUrl.SetPort(url.GetPort());
330 fileUrl.SetFileName("cgi-bin/zapTo");
331 fileUrl.SetOption("path", strItemPath+".ts");
332 pbItem->SetPath(fileUrl.Get());
334 pbItem->SetArt("thumb", GetPicon(strItemName)); //Set Picon Image
337 CLog::Log(LOGDEBUG, "%s - Name: %s", __FUNCTION__,strItemName.c_str());
338 CLog::Log(LOGDEBUG, "%s - Adress: %s", __FUNCTION__,pbItem->GetPath().c_str());
344 pIt = pIt->NextSibling("service");
348 pNode = pNode->NextSibling(strChild.c_str());
354 bool CTuxBoxUtil::ParseChannelsEnigma2(TiXmlElement *root, CFileItemList &items, CURL &url, CStdString& strFilter, CStdString& strChild)
356 TiXmlElement *pRootElement = root;
357 TiXmlNode *pNode = NULL;
358 TiXmlNode *pIt = NULL;
359 TiXmlNode *pIta = NULL;
360 TiXmlNode *pItb = NULL;
365 CLog::Log(LOGWARNING, "%s - No %ss found", __FUNCTION__,strChild.c_str());
368 if(!strFilter.IsEmpty())
370 pNode = pRootElement->FirstChild(strChild.c_str());
373 CLog::Log(LOGWARNING, "%s - No %s found", __FUNCTION__,strChild.c_str());
378 pIt = pNode->FirstChildElement("e2servicename");
379 CStdString bqtName = pIt->FirstChild()->Value();
380 pIt = pNode->FirstChildElement("e2servicelist");
381 pIta = pIt->FirstChildElement("e2service");
384 pItb = pIta->FirstChildElement("e2servicereference");
385 CStdString strItemPath = pItb->FirstChild()->Value();
386 pItb = pIta->FirstChildElement("e2servicename");
387 CStdString strItemName = pItb->FirstChild()->Value();
388 if(bqtName == url.GetShareName())
390 CFileItemPtr pbItem(new CFileItem);
391 pbItem->m_bIsFolder = false;
392 pbItem->SetLabel(strItemName);
395 fileUrl.SetProtocol("http");
396 fileUrl.SetHostName(url.GetHostName());
397 fileUrl.SetPort(8001);
398 fileUrl.SetFileName(strItemPath);
399 pbItem->SetPath(fileUrl.Get());
401 pbItem->SetMimeType("video/mpeg2");
403 CLog::Log(LOGDEBUG, "%s - Name: %s", __FUNCTION__,strItemName.c_str());
404 CLog::Log(LOGDEBUG, "%s - Adress: %s", __FUNCTION__,pbItem->GetPath().c_str());
406 pIta = pIta->NextSiblingElement("e2service");
408 pNode = pNode->NextSiblingElement("e2bouquet");
413 bool CTuxBoxUtil::ZapToUrl(CURL url, const CStdString &pathOption)
416 CStdString strZapUrl, strPostUrl, strZapName, strFilter;
417 //Extract the ZAP to Service String
419 strFilter = pathOption.Left(pathOption.size()-3);
420 //Get the Service Name
424 urlx.SetProtocol("http");
425 urlx.SetUserName(url.GetUserName());
426 urlx.SetPassword(url.GetPassWord());
427 urlx.SetHostName(url.GetHostName());
428 if (url.GetPort() != 0 && url.GetPort() != 80)
429 urlx.SetPort(url.GetPort());
431 postUrl.SetFileName("cgi-bin/zapTo");
432 postUrl.SetOption("path", strFilter);
434 //Check Recording State!
435 if(GetHttpXML(urlx,"boxstatus"))
437 if(sBoxStatus.recording.Equals("1"))
439 CLog::Log(LOGDEBUG, "%s ---------------------------------------------------------", __FUNCTION__);
440 CLog::Log(LOGDEBUG, "%s - WARNING: Device is Recording! Record Mode is: %s", __FUNCTION__,sBoxStatus.recording.c_str());
441 CLog::Log(LOGDEBUG, "%s ---------------------------------------------------------", __FUNCTION__);
442 CGUIDialogYesNo* dialog = (CGUIDialogYesNo*)g_windowManager.GetWindow(WINDOW_DIALOG_YES_NO);
445 //Target TuxBox is in Recording mode! Are you sure to stream ?YN
446 dialog->SetHeading(21331);
447 dialog->SetLine( 0, 21332);
448 dialog->SetLine( 1, 21335);
449 dialog->SetLine( 2, "" );
451 if (!dialog->IsConfirmed())
453 //DialogYN = NO -> Return false!
462 if(http.Open(postUrl))
465 CLog::Log(LOGDEBUG, "%s - Zapped to: %s", __FUNCTION__,postUrl.Get().c_str());
468 GetHttpXML(urlx,"streaminfo");
470 //Extract StreamInformations
472 //PMT must be a valid value to be sure that the ZAP is OK and we can stream!
473 while(sStrmInfo.pmt.Equals("ffffffffh") && iRetry!=10) //try 10 Times
475 CLog::Log(LOGDEBUG, "%s - Requesting STREAMINFO! TryCount: %i!", __FUNCTION__,iRetry);
476 GetHttpXML(urlx,"streaminfo");
481 // PMT Not Valid? Try Time 10 reached, checking for advancedSettings m_iTuxBoxZapWaitTime
482 if(sStrmInfo.pmt.Equals("ffffffffh") && g_advancedSettings.m_iTuxBoxZapWaitTime > 0 )
485 CLog::Log(LOGDEBUG, "%s - Starting TuxBox ZapWaitTimer!", __FUNCTION__);
486 while(sStrmInfo.pmt.Equals("ffffffffh") && iRetry!=10) //try 10 Times
488 CLog::Log(LOGDEBUG, "%s - Requesting STREAMINFO! TryCount: %i!", __FUNCTION__,iRetry);
489 GetHttpXML(urlx,"streaminfo");
491 if(sStrmInfo.pmt.Equals("ffffffffh"))
493 CLog::Log(LOGERROR, "%s - STREAMINFO ERROR! Could not receive all data, TryCount: %i!", __FUNCTION__,iRetry);
494 CLog::Log(LOGERROR, "%s - PMT is: %s (not a Valid Value)! Waiting %i sec.", __FUNCTION__,sStrmInfo.pmt.c_str(), g_advancedSettings.m_iTuxBoxZapWaitTime);
495 Sleep(g_advancedSettings.m_iTuxBoxZapWaitTime*1000);
500 //PMT Failed! No StreamInformations availible.. closing stream
501 if (sStrmInfo.pmt.Equals("ffffffffh"))
503 CLog::Log(LOGERROR, "%s-------------------------------------------------------------", __FUNCTION__);
504 CLog::Log(LOGERROR, "%s - STREAMINFO ERROR! Could not receive all data, TryCount: %i!", __FUNCTION__,iRetry);
505 CLog::Log(LOGERROR, "%s - PMT is: %s (not a Valid Value)! There is nothing to Stream!", __FUNCTION__,sStrmInfo.pmt.c_str());
506 CLog::Log(LOGERROR, "%s - The Stream will stopped!", __FUNCTION__);
507 CLog::Log(LOGERROR, "%s-------------------------------------------------------------", __FUNCTION__);
511 GetHttpXML(urlx,"currentservicedata");
513 GetHttpXML(urlx,"boxstatus");
515 GetHttpXML(urlx,"boxinfo");
517 GetHttpXML(urlx,"serviceepg");
522 bool CTuxBoxUtil::GetZapUrl(const CStdString& strPath, CFileItem &items )
525 CStdString strOptions = url.GetOptions();
526 if (strOptions.IsEmpty())
529 if (url.HasOption("path"))
531 if(ZapToUrl(url, url.GetOption("path")))
533 //Check VideoSubChannels
534 if(GetHttpXML(url,"currentservicedata")) //Update Currentservicedata
536 //Detect VideoSubChannels
537 CStdString strVideoSubChannelName, strVideoSubChannelPID;
538 if(GetVideoSubChannels(strVideoSubChannelName,strVideoSubChannelPID ))
540 // new videosubchannel selected! settings options to new video zap id
541 // zap again now to new videosubchannel
542 if(ZapToUrl(url, strVideoSubChannelPID + ".ts"))
544 vVideoSubChannel.mode = true;
545 vVideoSubChannel.current_name = strVideoSubChannelName;
549 vVideoSubChannel.mode= false;
552 CStdString strStreamURL, strVideoStream;
553 CStdString strLabel, strLabel2;
554 CStdString strAudioChannelName, strAudioChannelPid;
556 sAudioChannel sRequestedAudioChannel;
558 if (!GetGUIRequestedAudioChannel(sRequestedAudioChannel))
560 if (g_advancedSettings.m_bTuxBoxSendAllAPids && sCurSrvData.audio_channels.size() > 1)
562 for (vector<sAudioChannel>::iterator sChannel = sCurSrvData.audio_channels.begin(); sChannel!=sCurSrvData.audio_channels.end(); ++sChannel)
564 if (sChannel->pid != sRequestedAudioChannel.pid)
565 strAPids += "," + sChannel->pid.Right(4);
567 CLog::Log(LOGDEBUG, "%s - Sending all audio pids: %s%s", __FUNCTION__, strAudioChannelPid.c_str(), strAPids.c_str());
569 strVideoStream = StringUtils::Format("0,%s,%s,%s%s",
570 sStrmInfo.pmt.Left(4).c_str(),
571 sStrmInfo.vpid.Left(4).c_str(),
572 sStrmInfo.apid.Left(4).c_str(),
576 strVideoStream = StringUtils::Format("0,%s,%s,%s",
577 sStrmInfo.pmt.Left(4).c_str(),
578 sStrmInfo.vpid.Left(4).c_str(),
579 sStrmInfo.apid.Left(4).c_str());
582 strVideoStream = StringUtils::Format("0,%s,%s,%s",
583 sStrmInfo.pmt.Left(4).c_str(),
584 sStrmInfo.vpid.Left(4).c_str(),
585 strAudioChannelPid.Left(4).c_str());
588 streamURL.SetProtocol("http");
589 streamURL.SetUserName(url.GetUserName());
590 streamURL.SetPassword(url.GetPassWord());
591 streamURL.SetHostName(url.GetHostName());
592 streamURL.SetPort(g_advancedSettings.m_iTuxBoxStreamtsPort);
593 streamURL.SetFileName(strVideoStream.c_str());
595 if (!g_tuxbox.sZapstream.initialized)
596 g_tuxbox.InitZapstream(strPath);
598 // Use the Zapstream service when available.
599 if (g_tuxbox.sZapstream.available)
601 sAudioChannel sSelectedAudioChannel;
602 if (GetRequestedAudioChannel(sSelectedAudioChannel))
604 if (sSelectedAudioChannel.pid != sStrmInfo.apid)
606 if (SetAudioChannel(strPath, sSelectedAudioChannel))
607 CLog::Log(LOGDEBUG, "%s - Zapstream: Requested audio channel is %s, pid %s.", __FUNCTION__, sSelectedAudioChannel.name.c_str(), sSelectedAudioChannel.pid.c_str());
610 streamURL.SetFileName("");
611 streamURL.SetPort(g_advancedSettings.m_iTuxBoxZapstreamPort);
614 if (g_application.m_pPlayer->IsPlaying() && !g_tuxbox.sZapstream.available)
615 CApplicationMessenger::Get().MediaStop();
617 strLabel = StringUtils::Format("%s: %s %s-%s",
618 items.GetLabel().c_str(),
619 sCurSrvData.current_event_date.c_str(),
620 sCurSrvData.current_event_start.c_str(),
621 sCurSrvData.current_event_start.c_str());
622 strLabel2 = StringUtils::Format("%s", sCurSrvData.current_event_description.c_str());
625 CStdString strGenre, strTitle;
626 strGenre = StringUtils::Format("%s %s - (%s: %s)",
627 g_localizeStrings.Get(143).c_str(), sCurSrvData.current_event_description.c_str(),
628 g_localizeStrings.Get(209).c_str(), sCurSrvData.next_event_description.c_str());
629 strTitle = StringUtils::Format("%s", sCurSrvData.current_event_details.c_str());
630 int iDuration = atoi(sCurSrvData.current_event_duration.c_str());
632 items.GetVideoInfoTag()->m_genre = StringUtils::Split(strGenre, g_advancedSettings.m_videoItemSeparator); // VIDEOPLAYER_GENRE: current_event_description (Film Name)
633 items.GetVideoInfoTag()->m_strTitle = strTitle; // VIDEOPLAYER_TITLE: current_event_details (Film beschreibung)
634 items.GetVideoInfoTag()->m_duration = iDuration; //VIDEOPLAYER_DURATION: current_event_duration (laufzeit in sec.)
636 items.SetPath(streamURL.Get());
637 items.m_iDriveType = url.GetPort(); // Dirty Hack! But i need to hold the Port ;)
638 items.SetLabel(items.GetLabel()); // VIDEOPLAYER_DIRECTOR: service_name (Program Name)
639 items.SetLabel2(sCurSrvData.current_event_description); // current_event_description (Film Name)
640 items.m_bIsFolder = false;
641 items.SetMimeType("video/x-mpegts");
648 // Notice: Zapstream is a streamts enhancement from PLi development team.
649 // If you are using a non-PLi based image you might not have Zapstream installed.
650 bool CTuxBoxUtil::InitZapstream(const CStdString& strPath)
657 g_tuxbox.sZapstream.initialized = true;
659 if (!g_advancedSettings.m_bTuxBoxZapstream)
661 CLog::Log(LOGDEBUG, "%s - Zapstream is disabled in advancedsettings.xml.", __FUNCTION__);
662 return g_tuxbox.sZapstream.available = false;
665 url.SetProtocol("http");
668 url.SetPort(g_advancedSettings.m_iTuxBoxZapstreamPort);
670 while (iTryConnect < 3)
672 http.SetTimeout(iTimeout);
677 CHttpHeader h = http.GetHttpHeader();
678 CStdString strValue = h.GetValue("server");
680 if (strValue.Find("zapstream") >= 0 )
682 CLog::Log(LOGDEBUG, "%s - Zapstream is available on port %i.", __FUNCTION__, g_advancedSettings.m_iTuxBoxZapstreamPort);
683 return g_tuxbox.sZapstream.available = true;
691 CLog::Log(LOGDEBUG, "%s - Zapstream is not available on port %i.", __FUNCTION__, g_advancedSettings.m_iTuxBoxZapstreamPort);
694 bool CTuxBoxUtil::SetAudioChannel( const CStdString& strPath, const AUDIOCHANNEL& sAC )
701 url.SetProtocol("http");
702 url.SetFileName("cgi-bin/setAudio");
703 url.SetOptions("?channel=1&language=" + sAC.pid);
706 g_tuxbox.sZapstream.initialized = true;
708 while (iTryConnect < 3)
710 http.SetTimeout(iTimeout);
724 bool CTuxBoxUtil::GetHttpXML(CURL url,CStdString strRequestType)
726 // Check and Set URL Request Option
727 if(!strRequestType.IsEmpty())
729 if(strRequestType.Equals("streaminfo"))
731 url.SetOptions("xml/streaminfo");
733 else if(strRequestType.Equals("currentservicedata"))
735 url.SetOptions("xml/currentservicedata");
737 else if(strRequestType.Equals("boxstatus"))
739 url.SetOptions("xml/boxstatus");
741 else if(strRequestType.Equals("boxinfo"))
743 url.SetOptions("xml/boxinfo");
745 else if(strRequestType.Equals("serviceepg"))
747 url.SetOptions("xml/serviceepg");
751 CLog::Log(LOGERROR, "%s - Request Type is not defined! You requested: %s", __FUNCTION__,strRequestType.c_str());
757 CLog::Log(LOGERROR, "%s - strRequestType Request Type is Empty!", __FUNCTION__);
761 // Clean Up the URL, so we have a clean request!
771 int size_total = (int)http.GetLength();
775 // read response from server into string buffer
777 strTmp.reserve(size_total);
779 while( (size_read = http.Read( buffer, sizeof(buffer)-1) ) > 0 )
781 buffer[size_read] = 0;
783 data_size += size_read;
786 // parse returned xml
788 TiXmlElement *XMLRoot=NULL;
789 strTmp.Replace("></",">-</"); //FILL EMPTY ELEMENTS WITH "-"!
790 doc.Parse(strTmp, http.GetServerReportedCharset());
793 XMLRoot = doc.RootElement();
794 CStdString strRoot = XMLRoot->Value();
795 if( strRoot.Equals("streaminfo"))
796 return StreamInformations(XMLRoot);
797 if(strRoot.Equals("currentservicedata"))
798 return CurrentServiceData(XMLRoot);
799 if(strRoot.Equals("boxstatus"))
800 return BoxStatus(XMLRoot);
801 if(strRoot.Equals("boxinfo"))
802 return BoxInfo(XMLRoot);
803 if(strRoot.Equals("serviceepg") || strRoot.Equals("service_epg"))
804 return ServiceEPG(XMLRoot);
806 CLog::Log(LOGERROR, "%s - Unable to parse xml", __FUNCTION__);
807 CLog::Log(LOGERROR, "%s - Request String: %s", __FUNCTION__,strRoot.c_str());
812 CLog::Log(LOGERROR, "%s - http length is invalid!", __FUNCTION__);
816 CLog::Log(LOGERROR, "%s - Open URL Failed! Unable to get XML structure", __FUNCTION__);
819 bool CTuxBoxUtil::StreamInformations(TiXmlElement *pRootElement)
823 http://192.168.0.110:31339/0,0065,01ff,0200,0201,0203,01ff
825 http://getIP:31339/0,pmtpid,vpid,apid,apids,apids,pcrpid;
827 vpid,pmtpid,pcrpid,apid --> xml/streaminfo
828 apids --> /xml/currentservicedata
830 apid: is the defined audio stream!
831 Normal Stereo: http://192.168.0.110:31339/0,0065,01ff,0200,0201,0203,01ff
832 Normal English: http://192.168.0.110:31339/0,0065,01ff,0201,,,01ff
833 Normal DD5.1/AC3: http://192.168.0.110:31339/0,0065,01ff,0203,,,01ff
836 TiXmlNode *pNode = NULL;
837 TiXmlNode *pIt = NULL;
838 if(pRootElement != NULL)
840 CStdString strRoot = pRootElement->Value();
841 pNode = pRootElement->FirstChild("frontend");
844 sStrmInfo.frontend = pNode->FirstChild()->Value();
845 CLog::Log(LOGDEBUG, "%s - Frontend: %s", __FUNCTION__, sStrmInfo.frontend.c_str());
847 pNode = pRootElement->FirstChild("service");
850 CLog::Log(LOGDEBUG, "%s - Service", __FUNCTION__);
851 pIt = pNode->FirstChild("name");
854 sStrmInfo.service_name = pIt->FirstChild()->Value();
855 CLog::Log(LOGDEBUG, "%s - Name: %s", __FUNCTION__, sStrmInfo.service_name.c_str());
857 pIt = pNode->FirstChild("reference");
860 sStrmInfo.service_reference = pIt->FirstChild()->Value();
861 CLog::Log(LOGDEBUG, "%s - Reference: %s", __FUNCTION__, sStrmInfo.service_reference.c_str());
865 pNode = pRootElement->FirstChild("provider");
866 if(pNode && pNode->FirstChild())
868 sStrmInfo.provider= pNode->FirstChild()->Value();
869 CLog::Log(LOGDEBUG, "%s - Provider: %s", __FUNCTION__, sStrmInfo.provider.c_str());
871 pNode = pRootElement->FirstChild("vpid");
874 sStrmInfo.vpid = pNode->FirstChild()->Value();
875 CLog::Log(LOGDEBUG, "%s - Vpid: %s", __FUNCTION__, sStrmInfo.vpid.c_str());
877 pNode = pRootElement->FirstChild("apid");
880 sStrmInfo.apid = pNode->FirstChild()->Value();
881 CLog::Log(LOGDEBUG, "%s - Apid: %s", __FUNCTION__, sStrmInfo.apid.c_str());
883 pNode = pRootElement->FirstChild("pcrpid");
886 sStrmInfo.pcrpid = pNode->FirstChild()->Value();
887 CLog::Log(LOGDEBUG, "%s - PcrPid: %s", __FUNCTION__, sStrmInfo.pcrpid.c_str());
889 pNode = pRootElement->FirstChild("tpid");
892 sStrmInfo.tpid = pNode->FirstChild()->Value();
893 CLog::Log(LOGDEBUG, "%s - Tpid: %s", __FUNCTION__, sStrmInfo.tpid.c_str());
895 pNode = pRootElement->FirstChild("tsid");
898 sStrmInfo.tsid = pNode->FirstChild()->Value();
899 CLog::Log(LOGDEBUG, "%s - Tsid: %s", __FUNCTION__, sStrmInfo.tsid.c_str());
901 pNode = pRootElement->FirstChild("onid");
904 sStrmInfo.onid = pNode->FirstChild()->Value();
905 CLog::Log(LOGDEBUG, "%s - Onid: %s", __FUNCTION__, sStrmInfo.onid.c_str());
907 pNode = pRootElement->FirstChild("sid");
910 sStrmInfo.sid = pNode->FirstChild()->Value();
911 CLog::Log(LOGDEBUG, "%s - Sid: %s", __FUNCTION__, sStrmInfo.sid.c_str());
913 pNode = pRootElement->FirstChild("pmt");
916 sStrmInfo.pmt = pNode->FirstChild()->Value();
917 CLog::Log(LOGDEBUG, "%s - Pmt: %s", __FUNCTION__, sStrmInfo.pmt.c_str());
919 pNode = pRootElement->FirstChild("video_format");
922 sStrmInfo.video_format = pNode->FirstChild()->Value();
923 CLog::Log(LOGDEBUG, "%s - Video Format: %s", __FUNCTION__, sStrmInfo.video_format.c_str());
925 pNode = pRootElement->FirstChild("supported_crypt_systems");
928 sStrmInfo.supported_crypt_systems = pNode->FirstChild()->Value();
929 CLog::Log(LOGDEBUG, "%s - Supported Crypt Systems: %s", __FUNCTION__, sStrmInfo.supported_crypt_systems.c_str());
931 pNode = pRootElement->FirstChild("used_crypt_systems");
934 sStrmInfo.used_crypt_systems = pNode->FirstChild()->Value();
935 CLog::Log(LOGDEBUG, "%s - Used Crypt Systems: %s", __FUNCTION__, sStrmInfo.used_crypt_systems.c_str());
937 pNode = pRootElement->FirstChild("satellite");
940 sStrmInfo.satellite = pNode->FirstChild()->Value();
941 CLog::Log(LOGDEBUG, "%s - Satellite: %s", __FUNCTION__, sStrmInfo.satellite.c_str());
943 pNode = pRootElement->FirstChild("frequency");
946 sStrmInfo.frequency = pNode->FirstChild()->Value();
947 CLog::Log(LOGDEBUG, "%s - Frequency: %s", __FUNCTION__, sStrmInfo.frequency.c_str());
949 pNode = pRootElement->FirstChild("symbol_rate");
952 sStrmInfo.symbol_rate = pNode->FirstChild()->Value();
953 CLog::Log(LOGDEBUG, "%s - Symbol Rate: %s", __FUNCTION__, sStrmInfo.symbol_rate.c_str());
955 pNode = pRootElement->FirstChild("polarisation");
958 sStrmInfo.polarisation = pNode->FirstChild()->Value();
959 CLog::Log(LOGDEBUG, "%s - Polarisation: %s", __FUNCTION__, sStrmInfo.polarisation.c_str());
961 pNode = pRootElement->FirstChild("inversion");
964 sStrmInfo.inversion = pNode->FirstChild()->Value();
965 CLog::Log(LOGDEBUG, "%s - Inversion: %s", __FUNCTION__, sStrmInfo.inversion.c_str());
967 pNode = pRootElement->FirstChild("fec");
970 sStrmInfo.fec = pNode->FirstChild()->Value();
971 CLog::Log(LOGDEBUG, "%s - Fec: %s", __FUNCTION__, sStrmInfo.fec.c_str());
973 pNode = pRootElement->FirstChild("snr");
976 sStrmInfo.snr = pNode->FirstChild()->Value();
977 CLog::Log(LOGDEBUG, "%s - Snr: %s", __FUNCTION__, sStrmInfo.snr.c_str());
979 pNode = pRootElement->FirstChild("agc");
982 sStrmInfo.agc = pNode->FirstChild()->Value();
983 CLog::Log(LOGDEBUG, "%s - Agc: %s", __FUNCTION__, sStrmInfo.agc.c_str());
985 pNode = pRootElement->FirstChild("ber");
988 sStrmInfo.ber = pNode->FirstChild()->Value();
989 CLog::Log(LOGDEBUG, "%s - ber: %s", __FUNCTION__, sStrmInfo.ber.c_str());
991 pNode = pRootElement->FirstChild("lock");
994 sStrmInfo.lock = pNode->FirstChild()->Value();
995 CLog::Log(LOGDEBUG, "%s - Lock: %s", __FUNCTION__, sStrmInfo.lock.c_str());
997 pNode = pRootElement->FirstChild("sync");
1000 sStrmInfo.sync = pNode->FirstChild()->Value();
1001 CLog::Log(LOGDEBUG, "%s - Sync: %s", __FUNCTION__, sStrmInfo.sync.c_str());
1007 bool CTuxBoxUtil::CurrentServiceData(TiXmlElement *pRootElement)
1009 TiXmlNode *pNode = NULL;
1010 TiXmlNode *pIt = NULL;
1011 TiXmlNode *pVal = NULL;
1014 CLog::Log(LOGDEBUG, "%s - Current Service Data", __FUNCTION__);
1015 pNode = pRootElement->FirstChild("service");
1018 CLog::Log(LOGDEBUG, "%s - Service", __FUNCTION__);
1019 pIt = pNode->FirstChild("name");
1022 sCurSrvData.service_name = pIt->FirstChild()->Value();
1023 CLog::Log(LOGDEBUG, "%s - Service Name: %s", __FUNCTION__, pIt->FirstChild()->Value());
1025 pIt = pNode->FirstChild("reference");
1028 sCurSrvData.service_reference = pIt->FirstChild()->Value();
1029 CLog::Log(LOGDEBUG, "%s - Service Reference: %s", __FUNCTION__, pIt->FirstChild()->Value());
1033 pNode = pRootElement->FirstChild("audio_channels");
1036 CLog::Log(LOGDEBUG, "%s - Audio Channels", __FUNCTION__);
1039 pIt = pNode->FirstChild("channel");
1040 sCurSrvData.audio_channels.clear();
1044 sAudioChannel newChannel;
1046 pVal = pIt->FirstChild("pid");
1048 newChannel.pid = pVal->FirstChild()->Value();
1050 pVal = pIt->FirstChild("selected");
1052 newChannel.selected = pVal->FirstChild()->Value();
1054 pVal = pIt->FirstChild("name");
1056 newChannel.name = pVal->FirstChild()->Value();
1058 CLog::Log(LOGDEBUG, "%s - Audio Channels: Channel %i -> PID: %s Selected: %s Name: %s", __FUNCTION__, i, newChannel.pid.c_str(), newChannel.selected.c_str(), newChannel.name.c_str() );
1061 sCurSrvData.audio_channels.push_back( newChannel );
1062 pIt = pIt->NextSibling("channel");
1065 pNode = pRootElement->FirstChild("audio_track");
1068 sCurSrvData.audio_track = pNode->FirstChild()->Value();
1069 CLog::Log(LOGDEBUG, "%s - Audio Track: %s", __FUNCTION__, pNode->FirstChild()->Value() );
1071 pNode = pRootElement->FirstChild("video_channels");
1074 CLog::Log(LOGDEBUG, "%s - Video Channels", __FUNCTION__);
1075 pIt = pNode->FirstChild("service");
1078 vVideoSubChannel.name.clear();
1079 vVideoSubChannel.reference.clear();
1080 vVideoSubChannel.selected.clear();
1084 pVal = pIt->FirstChild("name");
1087 vVideoSubChannel.name.push_back(pVal->FirstChild()->Value());
1088 CLog::Log(LOGDEBUG, "%s - Video Sub Channel %i: Name: %s", __FUNCTION__, i,pVal->FirstChild()->Value());
1090 pVal = pIt->FirstChild("reference");
1093 vVideoSubChannel.reference.push_back(pVal->FirstChild()->Value());
1094 CLog::Log(LOGDEBUG, "%s - Video Sub Channel %i: Reference: %s", __FUNCTION__, i,pVal->FirstChild()->Value());
1096 pVal = pIt->FirstChild("selected");
1099 vVideoSubChannel.selected.push_back(pVal->FirstChild()->Value());
1100 CLog::Log(LOGDEBUG, "%s - Video Sub Channel %i: Selected: %s", __FUNCTION__, i,pVal->FirstChild()->Value());
1102 pIt = pIt->NextSibling("service");
1108 vVideoSubChannel.name.clear();
1109 vVideoSubChannel.reference.clear();
1110 vVideoSubChannel.selected.clear();
1113 pNode = pRootElement->FirstChild("current_event");
1116 CLog::Log(LOGDEBUG, "%s - Current Event", __FUNCTION__);
1117 pIt = pNode->FirstChild("date");
1120 sCurSrvData.current_event_date = pIt->FirstChild()->Value();
1121 CLog::Log(LOGDEBUG, "%s - Date: %s", __FUNCTION__, pIt->FirstChild()->Value());
1123 pIt = pNode->FirstChild("time");
1126 sCurSrvData.current_event_time = pIt->FirstChild()->Value();
1127 CLog::Log(LOGDEBUG, "%s - Time: %s", __FUNCTION__, pIt->FirstChild()->Value());
1130 pIt = pNode->FirstChild("start");
1133 sCurSrvData.current_event_start = pIt->FirstChild()->Value();
1134 CLog::Log(LOGDEBUG, "%s - Start: %s", __FUNCTION__, pIt->FirstChild()->Value());
1137 pIt = pNode->FirstChild("duration");
1140 sCurSrvData.current_event_duration = pIt->FirstChild()->Value();
1141 CLog::Log(LOGDEBUG, "%s - Duration: %s", __FUNCTION__, pIt->FirstChild()->Value());
1144 pIt = pNode->FirstChild("description");
1147 sCurSrvData.current_event_description = pIt->FirstChild()->Value();
1148 CLog::Log(LOGDEBUG, "%s - Description: %s", __FUNCTION__, pIt->FirstChild()->Value());
1150 pIt = pNode->FirstChild("details");
1153 sCurSrvData.current_event_details = pIt->FirstChild()->Value();
1154 CLog::Log(LOGDEBUG, "%s - Details: %s", __FUNCTION__, pIt->FirstChild()->Value());
1157 pNode = pRootElement->FirstChild("next_event");
1160 CLog::Log(LOGDEBUG, "%s - Next Event", __FUNCTION__);
1161 pIt = pNode->FirstChild("date");
1164 sCurSrvData.next_event_date = pIt->FirstChild()->Value();
1165 CLog::Log(LOGDEBUG, "%s - Date: %s", __FUNCTION__, pIt->FirstChild()->Value());
1167 pIt = pNode->FirstChild("time");
1170 sCurSrvData.next_event_time = pIt->FirstChild()->Value();
1171 CLog::Log(LOGDEBUG, "%s - Time: %s", __FUNCTION__, pIt->FirstChild()->Value());
1174 pIt = pNode->FirstChild("start");
1177 sCurSrvData.next_event_start = pIt->FirstChild()->Value();
1178 CLog::Log(LOGDEBUG, "%s - Start: %s", __FUNCTION__, pIt->FirstChild()->Value());
1181 pIt = pNode->FirstChild("duration");
1184 sCurSrvData.next_event_duration = pIt->FirstChild()->Value();
1185 CLog::Log(LOGDEBUG, "%s - Duration: %s", __FUNCTION__, pIt->FirstChild()->Value());
1188 pIt = pNode->FirstChild("description");
1191 sCurSrvData.next_event_description = pIt->FirstChild()->Value();
1192 CLog::Log(LOGDEBUG, "%s - Description: %s", __FUNCTION__, pIt->FirstChild()->Value());
1194 pIt = pNode->FirstChild("details");
1197 sCurSrvData.next_event_details = pIt->FirstChild()->Value();
1198 CLog::Log(LOGDEBUG, "%s - Details: %s", __FUNCTION__, pIt->FirstChild()->Value());
1206 bool CTuxBoxUtil::BoxStatus(TiXmlElement *pRootElement)
1208 //Tuxbox Controll Commands
1210 /cgi-bin/admin?command=wakeup
1211 /cgi-bin/admin?command=standby
1212 /cgi-bin/admin?command=shutdown
1213 /cgi-bin/admin?command=reboot
1214 /cgi-bin/admin?command=restart
1217 TiXmlNode *pNode = NULL;
1221 CLog::Log(LOGDEBUG, "%s - BoxStatus", __FUNCTION__);
1222 pNode = pRootElement->FirstChild("current_time");
1225 sBoxStatus.current_time = pNode->FirstChild()->Value();
1226 CLog::Log(LOGDEBUG, "%s - Current Time: %s", __FUNCTION__, pNode->FirstChild()->Value());
1228 pNode = pRootElement->FirstChild("standby");
1231 sBoxStatus.standby = pNode->FirstChild()->Value();
1232 CLog::Log(LOGDEBUG, "%s - Standby: %s", __FUNCTION__, pNode->FirstChild()->Value());
1234 pNode = pRootElement->FirstChild("recording");
1237 sBoxStatus.recording = pNode->FirstChild()->Value();
1238 CLog::Log(LOGDEBUG, "%s - Recording: %s", __FUNCTION__, pNode->FirstChild()->Value());
1240 pNode = pRootElement->FirstChild("mode");
1243 sBoxStatus.mode = pNode->FirstChild()->Value();
1244 CLog::Log(LOGDEBUG, "%s - Mode: %s", __FUNCTION__, pNode->FirstChild()->Value());
1246 pNode = pRootElement->FirstChild("ip");
1249 if (sBoxStatus.ip != pNode->FirstChild()->Value() )
1251 g_tuxbox.sZapstream.initialized = false;
1252 g_tuxbox.sZapstream.available = false;
1254 sBoxStatus.ip = pNode->FirstChild()->Value();
1255 CLog::Log(LOGDEBUG, "%s - Ip: %s", __FUNCTION__, pNode->FirstChild()->Value());
1261 bool CTuxBoxUtil::BoxInfo(TiXmlElement *pRootElement)
1263 TiXmlNode *pNode = NULL;
1264 TiXmlNode *pIt = NULL;
1268 CLog::Log(LOGDEBUG, "%s - BoxInfo", __FUNCTION__);
1269 pNode = pRootElement->FirstChild("image");
1272 CLog::Log(LOGDEBUG, "%s - Image", __FUNCTION__);
1273 pIt = pNode->FirstChild("version");
1276 sBoxInfo.image_version = pIt->FirstChild()->Value();
1277 CLog::Log(LOGDEBUG, "%s - Image Version: %s", __FUNCTION__, pIt->FirstChild()->Value());
1279 pIt = pNode->FirstChild("url");
1282 sBoxInfo.image_url = pIt->FirstChild()->Value();
1283 CLog::Log(LOGDEBUG, "%s - Image Url: %s", __FUNCTION__, pIt->FirstChild()->Value());
1285 pIt = pNode->FirstChild("comment");
1288 sBoxInfo.image_comment = pIt->FirstChild()->Value();
1289 CLog::Log(LOGDEBUG, "%s - Image Comment: %s", __FUNCTION__, pIt->FirstChild()->Value());
1291 pIt = pNode->FirstChild("catalog");
1294 sBoxInfo.image_catalog = pIt->FirstChild()->Value();
1295 CLog::Log(LOGDEBUG, "%s - Image Catalog: %s", __FUNCTION__, pIt->FirstChild()->Value());
1298 pNode = pRootElement->FirstChild("firmware");
1301 sBoxInfo.firmware = pNode->FirstChild()->Value();
1302 CLog::Log(LOGDEBUG, "%s - Firmware: %s", __FUNCTION__, pNode->FirstChild()->Value());
1304 pNode = pRootElement->FirstChild("fpfirmware");
1307 sBoxInfo.fpfirmware = pNode->FirstChild()->Value();
1308 CLog::Log(LOGDEBUG, "%s - FP Firmware: %s", __FUNCTION__, pNode->FirstChild()->Value());
1310 pNode = pRootElement->FirstChild("webinterface");
1313 sBoxInfo.webinterface = pNode->FirstChild()->Value();
1314 CLog::Log(LOGDEBUG, "%s - Web Interface: %s", __FUNCTION__, pNode->FirstChild()->Value());
1316 pNode = pRootElement->FirstChild("model");
1319 sBoxInfo.model = pNode->FirstChild()->Value();
1320 CLog::Log(LOGDEBUG, "%s - Model: %s", __FUNCTION__, pNode->FirstChild()->Value());
1322 pNode = pRootElement->FirstChild("manufacturer");
1325 sBoxInfo.manufacturer = pNode->FirstChild()->Value();
1326 CLog::Log(LOGDEBUG, "%s - Manufacturer: %s", __FUNCTION__, pNode->FirstChild()->Value());
1328 pNode = pRootElement->FirstChild("processor");
1331 sBoxInfo.processor = pNode->FirstChild()->Value();
1332 CLog::Log(LOGDEBUG, "%s - Processor: %s", __FUNCTION__, pNode->FirstChild()->Value());
1334 pNode = pRootElement->FirstChild("usbstick");
1337 sBoxInfo.usbstick = pNode->FirstChild()->Value();
1338 CLog::Log(LOGDEBUG, "%s - USB Stick: %s", __FUNCTION__, pNode->FirstChild()->Value());
1340 pNode = pRootElement->FirstChild("disk");
1343 sBoxInfo.disk = pNode->FirstChild()->Value();
1344 CLog::Log(LOGDEBUG, "%s - Disk: %s", __FUNCTION__, pNode->FirstChild()->Value());
1350 bool CTuxBoxUtil::ServiceEPG(TiXmlElement *pRootElement)
1352 TiXmlNode *pNode = NULL;
1353 TiXmlNode *pIt = NULL;
1357 CLog::Log(LOGDEBUG, "%s - Service EPG", __FUNCTION__);
1358 pNode = pRootElement->FirstChild("service");
1361 CLog::Log(LOGDEBUG, "%s - Service", __FUNCTION__);
1362 pIt = pNode->FirstChild("reference");
1365 sServiceEPG.service_reference = pIt->FirstChild()->Value();
1366 CLog::Log(LOGDEBUG, "%s - Service Reference: %s", __FUNCTION__, pIt->FirstChild()->Value());
1368 pIt = pNode->FirstChild("name");
1371 sServiceEPG.service_name = pIt->FirstChild()->Value();
1372 CLog::Log(LOGDEBUG, "%s - Service Name: %s", __FUNCTION__, pIt->FirstChild()->Value());
1375 //Todo there is more then 1 event! Create a Event List!
1376 pNode = pRootElement->FirstChild("event");
1379 CLog::Log(LOGDEBUG, "%s - Event", __FUNCTION__);
1380 pIt = pNode->FirstChild("date");
1383 sServiceEPG.date = pIt->FirstChild()->Value();
1384 CLog::Log(LOGDEBUG, "%s - Date: %s", __FUNCTION__, pIt->FirstChild()->Value());
1386 pIt = pNode->FirstChild("time");
1389 sServiceEPG.time = pIt->FirstChild()->Value();
1390 CLog::Log(LOGDEBUG, "%s - Time: %s", __FUNCTION__, pIt->FirstChild()->Value());
1392 pIt = pNode->FirstChild("duration");
1395 sServiceEPG.duration = pIt->FirstChild()->Value();
1396 CLog::Log(LOGDEBUG, "%s - Duration: %s", __FUNCTION__, pIt->FirstChild()->Value());
1398 pIt = pNode->FirstChild("descritption");
1401 sServiceEPG.descritption = pIt->FirstChild()->Value();
1402 CLog::Log(LOGDEBUG, "%s - Descritption: %s", __FUNCTION__, pIt->FirstChild()->Value());
1404 pIt = pNode->FirstChild("genre");
1407 sServiceEPG.genre = pIt->FirstChild()->Value();
1408 CLog::Log(LOGDEBUG, "%s - Genre: %s", __FUNCTION__, pIt->FirstChild()->Value());
1410 pIt = pNode->FirstChild("genrecategory");
1413 sServiceEPG.genrecategory = pIt->FirstChild()->Value();
1414 CLog::Log(LOGDEBUG, "%s - Genrecategory: %s", __FUNCTION__, pIt->FirstChild()->Value());
1416 pIt = pNode->FirstChild("start");
1419 sServiceEPG.start = pIt->FirstChild()->Value();
1420 CLog::Log(LOGDEBUG, "%s - Start: %s", __FUNCTION__, pIt->FirstChild()->Value());
1422 pIt = pNode->FirstChild("details");
1425 sServiceEPG.details = pIt->FirstChild()->Value();
1426 CLog::Log(LOGDEBUG, "%s - Details: %s", __FUNCTION__, pIt->FirstChild()->Value());
1433 //PopUp and request the AudioChannel
1434 //No PopUp: On 1x detected AudioChannel
1435 bool CTuxBoxUtil::GetGUIRequestedAudioChannel(AUDIOCHANNEL& sRequestedAC)
1437 sRequestedAC = sCurSrvData.audio_channels[0];
1439 // Audio Selection is Disabled! Return false to use default values!
1440 if(!g_advancedSettings.m_bTuxBoxAudioChannelSelection)
1442 CLog::Log(LOGDEBUG, "%s - Audio Channel Selection is Disabled! Returning False to use the default values!", __FUNCTION__);
1446 // We have only one Audio Channel return false to use default values!
1447 if(sCurSrvData.audio_channels.size() == 1)
1450 // popup the context menu
1451 CContextButtons buttons;
1453 // add the needed Audio buttons
1454 for (unsigned int i = 0; i < sCurSrvData.audio_channels.size(); ++i)
1455 buttons.Add(i, sCurSrvData.audio_channels[i].name);
1457 int channel = CGUIDialogContextMenu::ShowAndGetChoice(buttons);
1460 sRequestedAC = sCurSrvData.audio_channels[channel];
1461 sCurSrvData.requested_audio_channel = channel;
1462 CLog::Log(LOGDEBUG, "%s - Audio channel %s requested.", __FUNCTION__, sRequestedAC.name.c_str());
1467 bool CTuxBoxUtil::GetRequestedAudioChannel(AUDIOCHANNEL& sRequestedAC)
1469 sRequestedAC = sCurSrvData.audio_channels[sCurSrvData.requested_audio_channel];
1473 bool CTuxBoxUtil::GetVideoSubChannels(CStdString& strVideoSubChannelName, CStdString& strVideoSubChannelPid)
1475 // no video sub channel return false!
1476 if(vVideoSubChannel.name.size() <= 0 || vVideoSubChannel.reference.size() <= 0)
1479 // IsPlaying, Stop it..
1480 if(g_application.m_pPlayer->IsPlaying())
1481 CApplicationMessenger::Get().MediaStop();
1483 // popup the context menu
1484 CContextButtons buttons;
1486 // add the needed Audio buttons
1487 for (unsigned int i = 0; i < vVideoSubChannel.name.size(); ++i)
1488 buttons.Add(i, vVideoSubChannel.name[i]);
1490 // get selected Video Sub Channel name and reference zap
1491 int channel = CGUIDialogContextMenu::ShowAndGetChoice(buttons);
1494 strVideoSubChannelName = vVideoSubChannel.name[channel];
1495 strVideoSubChannelPid = vVideoSubChannel.reference[channel];
1496 vVideoSubChannel.name.clear();
1497 vVideoSubChannel.reference.clear();
1498 vVideoSubChannel.selected.clear();
1503 //Input: Service Name (Channel Namne)
1504 //Output: picon url (on ERROR the default icon path will be returned)
1505 CStdString CTuxBoxUtil::GetPicon(CStdString strServiceName)
1507 if(!g_advancedSettings.m_bTuxBoxPictureIcon)
1509 CLog::Log(LOGDEBUG, "%s PictureIcon Detection is Disabled! Using default icon", __FUNCTION__);
1512 if (strServiceName.IsEmpty())
1514 CLog::Log(LOGDEBUG, "%s Service Name is Empty! Can not detect a PictureIcon. Using default icon!", __FUNCTION__);
1519 CStdString piconXML, piconPath, defaultPng;
1520 CStdString strName, strPng;
1521 piconPath = "special://xbmc/userdata/PictureIcon/Picon/";
1522 defaultPng = piconPath+"tuxbox.png";
1523 piconXML = "special://xbmc/userdata/PictureIcon/picon.xml";
1524 CXBMCTinyXML piconDoc;
1526 if (!CFile::Exists(piconXML))
1529 if (!piconDoc.LoadFile(piconXML))
1531 CLog::Log(LOGERROR, "Error loading %s, Line %d\n%s", piconXML.c_str(), piconDoc.ErrorRow(), piconDoc.ErrorDesc());
1535 TiXmlElement *pRootElement = piconDoc.RootElement();
1536 if (!pRootElement || strcmpi(pRootElement->Value(),"picon") != 0)
1538 CLog::Log(LOGERROR, "Error loading %s, no <picon> node", piconXML.c_str());
1542 TiXmlElement* pServices = pRootElement->FirstChildElement("services");
1543 TiXmlElement* pService;
1544 pService = pServices->FirstChildElement("service");
1547 if(pService->Attribute("name"))
1548 strName = StringUtils::Format("%s", pService->Attribute("name"));
1550 if(pService->Attribute("png"))
1551 strPng = StringUtils::Format("%s", pService->Attribute("png"));
1553 if(strName.Equals(strServiceName))
1555 strPng = StringUtils::Format("%s%s", piconPath.c_str(), strPng.c_str());
1557 CLog::Log(LOGDEBUG, "%s %s: Path is: %s", __FUNCTION__,strServiceName.c_str(), strPng.c_str());
1560 pService = pService->NextSiblingElement("service");
1566 // iMODE: 0 = TV, 1 = Radio, 2 = Data, 3 = Movies, 4 = Root
1567 // SUBMODE: 0 = n/a, 1 = All, 2 = Satellites, 2 = Providers, 4 = Bouquets
1568 CStdString CTuxBoxUtil::GetSubMode(int iMode, CStdString& strXMLRootString, CStdString& strXMLChildString)
1570 //Todo: add a setting: "Don't Use Request mode" to advanced.xml
1572 // MODE: 0 = TV, 1 = Radio, 2 = Data, 3 = Movies, 4 = Root
1573 // SUBMODE: 0 = n/a, 1 = All, 2 = Satellites, 2 = Providers, 4 = Bouquets
1575 CStdString strSubMode;
1577 if(iMode <0 || iMode >4)
1579 strSubMode = StringUtils::Format("xml/services?mode=0&submode=4");
1580 strXMLRootString = StringUtils::Format("bouquets");
1581 strXMLChildString = StringUtils::Format("bouquet");
1585 // popup the context menu
1587 // FIXME: Localize these
1588 CContextButtons choices;
1589 choices.Add(1, "All");
1590 choices.Add(2, "Satellites");
1591 choices.Add(3, "Providers");
1592 choices.Add(4, "Bouquets");
1594 int iSubMode = CGUIDialogContextMenu::ShowAndGetChoice(choices);
1597 strXMLRootString = StringUtils::Format("services");
1598 strXMLChildString = StringUtils::Format("service");
1600 else if (iSubMode == 2)
1602 strXMLRootString = StringUtils::Format("satellites");
1603 strXMLChildString = StringUtils::Format("satellite");
1605 else if (iSubMode == 3)
1607 strXMLRootString = StringUtils::Format("providers");
1608 strXMLChildString = StringUtils::Format("provider");
1610 else // if (iSubMode == 4 || iSubMode < 0)
1613 strXMLRootString = StringUtils::Format("bouquets");
1614 strXMLChildString = StringUtils::Format("bouquet");
1616 strSubMode = StringUtils::Format("xml/services?mode=%i&submode=%i",iMode,iSubMode);
1619 //Input: url/path of share/item file/folder
1620 //Output: the detected submode root and child string
1621 CStdString CTuxBoxUtil::DetectSubMode(CStdString strSubMode, CStdString& strXMLRootString, CStdString& strXMLChildString)
1623 //strSubMode = "xml/services?mode=0&submode=1"
1624 CStdString strFilter;
1625 int ipointMode = strSubMode.Find("?mode=");
1626 int ipointSubMode = strSubMode.Find("&submode=");
1628 strFilter = strSubMode.GetAt(ipointMode+6);
1630 if (ipointSubMode >=0)
1633 strTemp = strSubMode.GetAt(ipointSubMode+9);
1634 if(strTemp.Equals("1"))
1636 strXMLRootString = StringUtils::Format("unknowns");
1637 strXMLChildString = StringUtils::Format("unknown");
1639 else if(strTemp.Equals("2"))
1641 strXMLRootString = StringUtils::Format("satellites");
1642 strXMLChildString = StringUtils::Format("satellite");
1644 else if(strTemp.Equals("3"))
1646 strXMLRootString = StringUtils::Format("providers");
1647 strXMLChildString = StringUtils::Format("provider");
1649 else if(strTemp.Equals("4"))
1651 strXMLRootString = StringUtils::Format("bouquets");
1652 strXMLChildString = StringUtils::Format("bouquet");