loadServicelist(CONFIGDIR"/enigma2/lamedb");
}
+void eDVBDB::parseServiceData(ePtr<eDVBService> s, std::string str)
+{
+ while ((!str.empty()) && str[1]==':') // new: p:, f:, c:%02d...
+ {
+ size_t c=str.find(',');
+ char p=str[0];
+ std::string v;
+ if (c == std::string::npos)
+ {
+ v=str.substr(2);
+ str="";
+ } else
+ {
+ v=str.substr(2, c-2);
+ str=str.substr(c+1);
+ }
+// eDebug("%c ... %s", p, v.c_str());
+ if (p == 'p')
+ s->m_provider_name=v;
+ else if (p == 'f')
+ {
+ sscanf(v.c_str(), "%x", &s->m_flags);
+ } else if (p == 'c')
+ {
+ int cid, val;
+ sscanf(v.c_str(), "%02d%x", &cid, &val);
+ s->setCacheEntry((eDVBService::cacheID)cid,val);
+ } else if (p == 'C')
+ {
+ int val;
+ sscanf(v.c_str(), "%04x", &val);
+ s->m_ca.push_front((uint16_t)val);
+ }
+ }
+}
+
/* THIS CODE IS BAD. it should be replaced by somethine better. */
void eDVBDB::loadServicelist(const char *file)
{
fgets(line, 256, f);
if (strlen(line))
line[strlen(line)-1]=0;
- std::string str=line;
-
- if (str[1]!=':') // old ... (only service_provider)
- {
+ if (line[1]!=':') // old ... (only service_provider)
s->m_provider_name=line;
- } else
- while ((!str.empty()) && str[1]==':') // new: p:, f:, c:%02d...
- {
- size_t c=str.find(',');
- char p=str[0];
- std::string v;
- if (c == std::string::npos)
- {
- v=str.substr(2);
- str="";
- } else
- {
- v=str.substr(2, c-2);
- str=str.substr(c+1);
- }
-// eDebug("%c ... %s", p, v.c_str());
- if (p == 'p')
- s->m_provider_name=v;
- else if (p == 'f')
- {
- sscanf(v.c_str(), "%x", &s->m_flags);
- } else if (p == 'c')
- {
- int cid, val;
- sscanf(v.c_str(), "%02d%x", &cid, &val);
- s->setCacheEntry((eDVBService::cacheID)cid,val);
- } else if (p == 'C')
- {
- int val;
- sscanf(v.c_str(), "%04x", &val);
- s->m_ca.push_front((uint16_t)val);
- }
- }
+ else
+ parseServiceData(s, line);
addService(ref, s);
}
void saveServicelist();
void saveServicelist(const char *file);
void reloadBouquets();
+ void parseServiceData(ePtr<eDVBService> s, std::string str);
};
#ifndef SWIG
case 6:
m_filesize = atoll(line);
break;
+ case 7:
+ m_service_data = line;
+ break;
default:
break;
}
FILE *f = fopen(filename.c_str(), "w");
if (!f)
return -ENOENT;
- fprintf(f, "%s\n%s\n%s\n%d\n%s\n%d\n%lld\n", ref.toString().c_str(), m_name.c_str(), m_description.c_str(), m_time_create, m_tags.c_str(), m_length, m_filesize );
+ fprintf(f, "%s\n%s\n%s\n%d\n%s\n%d\n%lld\n%s\n", ref.toString().c_str(), m_name.c_str(), m_description.c_str(), m_time_create, m_tags.c_str(), m_length, m_filesize, m_service_data.c_str() );
fclose(f);
return 0;
}
public:
eDVBMetaParser();
int parseFile(const std::string &basename);
-
int parseMeta(const std::string &filename);
int parseRecordings(const std::string &filename);
int updateMeta(const std::string &basename);
-
- int m_data_ok;
-
+
eServiceReferenceDVB m_ref;
- std::string m_name, m_description;
- int m_time_create, m_length;
+ int m_data_ok, m_time_create, m_length;
+ std::string m_name, m_description, m_tags, m_service_data;
long long m_filesize;
-
- std::string m_tags;
};
#endif
RESULT eServiceFactoryDVB::lookupService(ePtr<eDVBService> &service, const eServiceReference &ref)
{
- // TODO: handle the listing itself
- // if (ref.... == -1) .. return "... bouquets ...";
- // could be also done in another serviceFactory (with seperate ID) to seperate actual services and lists
- // TODO: cache
- ePtr<iDVBChannelList> db;
- ePtr<eDVBResourceManager> res;
-
- int err;
- if ((err = eDVBResourceManager::getInstance(res)) != 0)
+ if (!ref.path.empty()) // playback
{
- eDebug("no resource manager");
- return err;
+ eDVBMetaParser parser;
+ int ret=parser.parseFile(ref.path);
+ service = new eDVBService;
+ if (!ret)
+ eDVBDB::getInstance()->parseServiceData(service, parser.m_service_data);
}
- if ((err = res->getChannelList(db)) != 0)
+ else
{
- eDebug("no channel list");
- return err;
- }
+ // TODO: handle the listing itself
+ // if (ref.... == -1) .. return "... bouquets ...";
+ // could be also done in another serviceFactory (with seperate ID) to seperate actual services and lists
+ // TODO: cache
+ ePtr<iDVBChannelList> db;
+ ePtr<eDVBResourceManager> res;
+
+ int err;
+ if ((err = eDVBResourceManager::getInstance(res)) != 0)
+ {
+ eDebug("no resource manager");
+ return err;
+ }
+ if ((err = res->getChannelList(db)) != 0)
+ {
+ eDebug("no channel list");
+ return err;
+ }
/* we are sure to have a ..DVB reference as the info() call was forwarded here according to it's ID. */
- if ((err = db->getService((eServiceReferenceDVB&)ref, service)) != 0)
- {
- eDebug("getService failed!");
- return err;
+ if ((err = db->getService((eServiceReferenceDVB&)ref, service)) != 0)
+ {
+ eDebug("getService failed!");
+ return err;
+ }
}
return 0;
eDVBServicePlay::~eDVBServicePlay()
{
+ if (m_is_pvr)
+ {
+ eDVBMetaParser meta;
+ int ret=meta.parseFile(m_reference.path);
+ if (!ret)
+ {
+ char tmp[255];
+ meta.m_service_data="";
+ sprintf(tmp, "f:%x", m_dvb_service->m_flags);
+ meta.m_service_data += tmp;
+ // cached pids
+ for (int x=0; x < eDVBService::cacheMax; ++x)
+ {
+ int entry = m_dvb_service->getCacheEntry((eDVBService::cacheID)x);
+ if (entry != -1)
+ {
+ sprintf(tmp, ",c:%02d%04x", x, entry);
+ meta.m_service_data += tmp;
+ }
+ }
+ meta.updateMeta(m_reference.path);
+ }
+ }
delete m_subtitle_widget;
}
m_first_program_info = 1;
eServiceReferenceDVB &service = (eServiceReferenceDVB&)m_reference;
- r = m_service_handler.tune(service, m_is_pvr, m_cue);
+ r = m_service_handler.tune(service, m_is_pvr, m_cue, false, m_dvb_service);
/* inject EIT if there is a stored one */
if (m_is_pvr)
ePtr<iStaticServiceInformation> i = new eStaticServiceDVBPVRInformation(m_reference);
return i->getName(m_reference, name);
}
- if (m_dvb_service)
+ else if (m_dvb_service)
{
m_dvb_service->getName(m_reference, name);
if (name.empty())
anything in the best case, or destroy the default setting in
case the real default is not yet available.)
*/
- if (m_dvb_service && !m_is_pvr && ((i != -1)
+ if (m_dvb_service && ((i != -1)
|| ((m_dvb_service->getCacheEntry(eDVBService::cAPID) == -1) && (m_dvb_service->getCacheEntry(eDVBService::cAC3PID)==-1))))
{
if (apidtype == eDVBAudio::aMPEG)
ac3_delay = m_dvb_service->getCacheEntry(eDVBService::cAC3DELAY);
pcm_delay = m_dvb_service->getCacheEntry(eDVBService::cPCMDELAY);
}
- else // subservice or recording
+ else // subservice
{
eServiceReferenceDVB ref;
m_service_handler.getServiceReference(ref);
m_decoder->setAudioChannel(achannel);
/* don't worry about non-existing services, nor pvr services */
- if (m_dvb_service && !m_is_pvr)
+ if (m_dvb_service)
{
/* (audio pid will be set in selectAudioTrack */
m_dvb_service->setCacheEntry(eDVBService::cVPID, vpid);
int ret = doPrepare();
if (!ret)
{
- eEPGCache::getInstance()->Lock();
- const eit_event_struct *event = 0;
eServiceReferenceDVB ref = m_ref.getParentServiceReference();
+ ePtr<eDVBResourceManager> res_mgr;
+ eDVBMetaParser meta;
+ std::string service_data;
if (!ref.valid())
ref = m_ref;
- if ( eit_event_id != -1 )
- {
- eDebug("query epg event id %d", eit_event_id);
- eEPGCache::getInstance()->lookupEventId(ref, eit_event_id, event);
- }
- if ( !event && (begTime != -1 && endTime != -1) )
+ if (!eDVBResourceManager::getInstance(res_mgr))
{
- time_t queryTime = begTime + ((endTime-begTime)/2);
- tm beg, end, query;
- localtime_r(&begTime, &beg);
- localtime_r(&endTime, &end);
- localtime_r(&queryTime, &query);
- eDebug("query stime %d:%d:%d, etime %d:%d:%d, qtime %d:%d:%d",
- beg.tm_hour, beg.tm_min, beg.tm_sec,
- end.tm_hour, end.tm_min, end.tm_sec,
- query.tm_hour, query.tm_min, query.tm_sec);
- eEPGCache::getInstance()->lookupEventTime(ref, queryTime, event);
- }
- if ( event )
- {
- eDebug("found event.. store to disc");
- std::string fname = filename;
- fname.erase(fname.length()-2, 2);
- fname+="eit";
- int fd = open(fname.c_str(), O_CREAT|O_WRONLY, 0777);
- if (fd>-1)
+ ePtr<iDVBChannelList> db;
+ if (!res_mgr->getChannelList(db))
{
- int evLen=HILO(event->descriptors_loop_length)+12/*EIT_LOOP_SIZE*/;
- int wr = ::write( fd, (unsigned char*)event, evLen );
- if ( wr != evLen )
- eDebug("eit write error (%m)");
- ::close(fd);
+ ePtr<eDVBService> service;
+ if (!db->getService(ref, service))
+ {
+ char tmp[255];
+ sprintf(tmp, "f:%x", service->m_flags);
+ service_data += tmp;
+ // cached pids
+ for (int x=0; x < eDVBService::cacheMax; ++x)
+ {
+ int entry = service->getCacheEntry((eDVBService::cacheID)x);
+ if (entry != -1)
+ {
+ sprintf(tmp, ",c:%02d%04x", x, entry);
+ service_data += tmp;
+ }
+ }
+ }
}
}
- eEPGCache::getInstance()->Unlock();
-
- }
- if (ret)
- return ret;
- else
- {
- eDVBMetaParser meta;
meta.m_time_create = begTime;
meta.m_ref = m_ref;
meta.m_data_ok = 1;
+ meta.m_service_data = service_data;
if (name)
meta.m_name = name;
if (descr)
meta.m_description = descr;
ret = meta.updateMeta(filename) ? -255 : 0;
+ if (!ret)
+ {
+ const eit_event_struct *event = 0;
+ eEPGCache::getInstance()->Lock();
+ if ( eit_event_id != -1 )
+ {
+ eDebug("query epg event id %d", eit_event_id);
+ eEPGCache::getInstance()->lookupEventId(ref, eit_event_id, event);
+ }
+ if ( !event && (begTime != -1 && endTime != -1) )
+ {
+ time_t queryTime = begTime + ((endTime-begTime)/2);
+ tm beg, end, query;
+ localtime_r(&begTime, &beg);
+ localtime_r(&endTime, &end);
+ localtime_r(&queryTime, &query);
+ eDebug("query stime %d:%d:%d, etime %d:%d:%d, qtime %d:%d:%d",
+ beg.tm_hour, beg.tm_min, beg.tm_sec,
+ end.tm_hour, end.tm_min, end.tm_sec,
+ query.tm_hour, query.tm_min, query.tm_sec);
+ eEPGCache::getInstance()->lookupEventTime(ref, queryTime, event);
+ }
+ if ( event )
+ {
+ eDebug("found event.. store to disc");
+ std::string fname = filename;
+ fname.erase(fname.length()-2, 2);
+ fname+="eit";
+ int fd = open(fname.c_str(), O_CREAT|O_WRONLY, 0777);
+ if (fd>-1)
+ {
+ int evLen=HILO(event->descriptors_loop_length)+12/*EIT_LOOP_SIZE*/;
+ int wr = ::write( fd, (unsigned char*)event, evLen );
+ if ( wr != evLen )
+ eDebug("eit write error (%m)");
+ ::close(fd);
+ }
+ }
+ eEPGCache::getInstance()->Unlock();
+ }
}
return ret;
}