#include <byteswap.h>
#include <netinet/in.h>
-#include <dvbsi++/event_information_section.h>
-
#define INTERNAL_TELETEXT
#ifndef BYTE_ORDER
eStaticServiceDVBPVRInformation(const eServiceReference &ref);
RESULT getName(const eServiceReference &ref, std::string &name);
int getLength(const eServiceReference &ref);
-
+ RESULT getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &SWIG_OUTPUT, time_t start_time);
+
int getInfo(const eServiceReference &ref, int w);
std::string getInfoString(const eServiceReference &ref,int w);
};
}
}
+RESULT eStaticServiceDVBPVRInformation::getEvent(const eServiceReference &ref, ePtr<eServiceEvent> &evt, time_t start_time)
+{
+ if (!ref.path.empty())
+ {
+ ePtr<eServiceEvent> event = new eServiceEvent;
+ std::string filename = ref.path;
+ filename.erase(filename.length()-2, 2);
+ filename+="eit";
+ if (!event->parseFrom(filename, (m_parser.m_ref.getTransportStreamID().get()<<16)|m_parser.m_ref.getOriginalNetworkID().get()))
+ {
+ evt = event;
+ return 0;
+ }
+ }
+ evt = 0;
+ return -1;
+}
+
class eDVBPVRServiceOfflineOperations: public iServiceOfflineOperations
{
DECLARE_REF(eDVBPVRServiceOfflineOperations);
}
eDVBServicePlay::eDVBServicePlay(const eServiceReference &ref, eDVBService *service):
- m_reference(ref), m_dvb_service(service), m_is_paused(0), m_current_audio_channel(-1)
+ m_reference(ref), m_dvb_service(service), m_have_video_pid(0), m_is_paused(0)
{
m_is_primary = 1;
m_is_pvr = !m_reference.path.empty();
m_first_program_info = 1;
eServiceReferenceDVB &service = (eServiceReferenceDVB&)m_reference;
r = m_service_handler.tune(service, m_is_pvr, m_cue);
-
+
/* inject EIT if there is a stored one */
if (m_is_pvr)
{
std::string filename = service.path;
filename.erase(filename.length()-2, 2);
filename+="eit";
- int fd = ::open( filename.c_str(), O_RDONLY );
- if ( fd > -1 )
+ ePtr<eServiceEvent> event = new eServiceEvent;
+ if (!event->parseFrom(filename, (service.getTransportStreamID().get()<<16)|service.getOriginalNetworkID().get()))
{
- __u8 buf[4096];
- int rd = ::read(fd, buf, 4096);
- ::close(fd);
- if ( rd > 12 /*EIT_LOOP_SIZE*/ )
- {
- Event ev(buf);
- ePtr<eServiceEvent> event = new eServiceEvent;
- ePtr<eServiceEvent> empty;
- event->parseFrom(&ev, (service.getTransportStreamID().get()<<16)|service.getOriginalNetworkID().get());
- m_event_handler.inject(event, 0);
- m_event_handler.inject(empty, 1);
- eDebug("injected");
- }
+ ePtr<eServiceEvent> empty;
+ m_event_handler.inject(event, 0);
+ m_event_handler.inject(empty, 1);
}
}
-
+
if (m_is_pvr)
loadCuesheet();
RESULT eDVBServicePlay::stop()
{
+ /* add bookmark for last play position */
+ if (m_is_pvr)
+ {
+ pts_t play_position;
+ if (!getPlayPosition(play_position))
+ {
+ /* remove last position */
+ for (std::multiset<struct cueEntry>::iterator i(m_cue_entries.begin()); i != m_cue_entries.end();)
+ {
+ if (i->what == 3) /* current play position */
+ {
+ m_cue_entries.erase(i);
+ i = m_cue_entries.begin();
+ continue;
+ } else
+ ++i;
+ }
+
+ m_cue_entries.insert(cueEntry(play_position, 3)); /* last play position */
+ m_cuesheet_changed = 1;
+ }
+ }
+
stopTimeshift(); /* in case timeshift was enabled, remove buffer etc. */
m_service_handler_timeshift.free();
RESULT eDVBServicePlay::timeshift(ePtr<iTimeshiftService> &ptr)
{
ptr = 0;
- if (m_timeshift_enabled || !m_is_pvr)
+ if (m_have_video_pid && // HACK !!! FIXMEE !! temporary no timeshift on radio services !!
+ (m_timeshift_enabled || !m_is_pvr))
{
if (!m_timeshift_enabled)
{
return 0;
}
+RESULT eDVBServicePlay::audioDelay(ePtr<iAudioDelay> &ptr)
+{
+ ptr = this;
+ return 0;
+}
+
RESULT eDVBServicePlay::getName(std::string &name)
{
if (m_is_pvr)
int eDVBServicePlay::getCurrentChannel()
{
- return m_current_audio_channel == -1 ? STEREO : m_current_audio_channel;
+ return m_decoder ? m_decoder->getAudioChannel() : STEREO;
}
RESULT eDVBServicePlay::selectChannel(int i)
{
- if (i < iAudioChannelSelection::LEFT || i > iAudioChannelSelection::RIGHT)
+ if (i < LEFT || i > RIGHT || i == STEREO)
i = -1; // Stereo
- if (m_current_audio_channel != i)
- {
- if (m_dvb_service)
- m_dvb_service->setCacheEntry(eDVBService::cACHANNEL, i);
- m_current_audio_channel=i;
- if (m_decoder)
- m_decoder->setAudioChannel(i);
- }
+ if (m_dvb_service)
+ m_dvb_service->setCacheEntry(eDVBService::cACHANNEL, i);
+ if (m_decoder)
+ m_decoder->setAudioChannel(i);
return 0;
}
m_decoder = 0;
m_decode_demux = 0;
m_teletext_parser = 0;
+ m_new_subtitle_page_connection = 0;
/* free the timeshift service handler, we need the resources */
m_service_handler_timeshift.free();
m_decode_demux = 0;
m_decoder = 0;
m_teletext_parser = 0;
+ m_new_subtitle_page_connection = 0;
m_timeshift_active = 1;
void eDVBServicePlay::updateDecoder()
{
- int vpid = -1, vpidtype = -1, apid = -1, apidtype = -1, pcrpid = -1, tpid = -1, achannel = -1;
+ int vpid = -1, vpidtype = -1, apid = -1, apidtype = -1, pcrpid = -1, tpid = -1, achannel = -1, ac3_delay=-1, pcm_delay=-1;
+
eDVBServicePMTHandler &h = m_timeshift_active ? m_service_handler_timeshift : m_service_handler;
bool defaultac3=false;
pcrpid = program.pcrPid;
eDebug(", and the text pid is %04x", program.textPid);
tpid = program.textPid;
- achannel = program.audioChannel;
}
if (!m_decoder)
if (m_decoder)
{
+ if (m_dvb_service)
+ {
+ achannel = m_dvb_service->getCacheEntry(eDVBService::cACHANNEL);
+ ac3_delay = m_dvb_service->getCacheEntry(eDVBService::cAC3DELAY);
+ pcm_delay = m_dvb_service->getCacheEntry(eDVBService::cPCMDELAY);
+ }
+ else // subservice or recording
+ {
+ eServiceReferenceDVB ref;
+ m_service_handler.getServiceReference(ref);
+ eServiceReferenceDVB parent = ref.getParentServiceReference();
+ if (!parent)
+ parent = ref;
+ if (parent)
+ {
+ ePtr<eDVBResourceManager> res_mgr;
+ if (!eDVBResourceManager::getInstance(res_mgr))
+ {
+ ePtr<iDVBChannelList> db;
+ if (!res_mgr->getChannelList(db))
+ {
+ ePtr<eDVBService> origService;
+ if (!db->getService(parent, origService))
+ {
+ ac3_delay = origService->getCacheEntry(eDVBService::cAC3DELAY);
+ pcm_delay = origService->getCacheEntry(eDVBService::cPCMDELAY);
+ }
+ }
+ }
+ }
+ }
+ m_decoder->setAC3Delay(ac3_delay == -1 ? 0 : ac3_delay);
+ m_decoder->setPCMDelay(pcm_delay == -1 ? 0 : pcm_delay);
+
m_decoder->setVideoPID(vpid, vpidtype);
m_current_audio_stream = 0;
m_decoder->setAudioPID(apid, apidtype);
m_decoder->start();
- m_current_audio_channel=achannel;
+ if (vpid > 0 && vpid < 0x2000)
+ ;
+ else
+ {
+ std::string radio_pic;
+ if (!ePythonConfigQuery::getConfigValue("config.misc.radiopic", radio_pic))
+ m_decoder->setRadioPic(radio_pic);
+ }
+
m_decoder->setAudioChannel(achannel);
// how we can do this better?
m_dvb_service->setCacheEntry(eDVBService::cTPID, tpid);
}
}
+ m_have_video_pid = (vpid > 0 && vpid < 0x2000);
}
void eDVBServicePlay::loadCuesheet()
#endif
what = ntohl(what);
- if (what > 2)
+ if (what > 3)
break;
m_cue_entries.insert(cueEntry(where, what));
if (!m_cutlist_enabled)
{
m_cue->commitSpans();
- eDebug("cutlists where disabled");
+ eDebug("cutlists were disabled");
return;
}
continue;
} else if (i->what == 1) /* out */
out = i++->where;
- else /* mark */
+ else /* mark (2) or last play position (3) */
{
i++;
continue;
}
}
+int eDVBServicePlay::getAC3Delay()
+{
+ if (m_dvb_service)
+ return m_dvb_service->getCacheEntry(eDVBService::cAC3DELAY);
+ else if (m_decoder)
+ return m_decoder->getAC3Delay();
+ else
+ return 0;
+}
+
+int eDVBServicePlay::getPCMDelay()
+{
+ if (m_dvb_service)
+ return m_dvb_service->getCacheEntry(eDVBService::cPCMDELAY);
+ else if (m_decoder)
+ return m_decoder->getPCMDelay();
+ else
+ return 0;
+}
+
+void eDVBServicePlay::setAC3Delay(int delay)
+{
+ if (m_dvb_service)
+ m_dvb_service->setCacheEntry(eDVBService::cAC3DELAY, delay ? delay : -1);
+ if (m_decoder)
+ m_decoder->setAC3Delay(delay);
+}
+
+void eDVBServicePlay::setPCMDelay(int delay)
+{
+ if (m_dvb_service)
+ m_dvb_service->setCacheEntry(eDVBService::cPCMDELAY, delay ? delay : -1);
+ if (m_decoder)
+ m_decoder->setPCMDelay(delay);
+}
+
DEFINE_REF(eDVBServicePlay)
eAutoInitPtr<eServiceFactoryDVB> init_eServiceFactoryDVB(eAutoInitNumbers::service+1, "eServiceFactoryDVB");