Jump to content


Photo

EPG with GStreamer (ServiceMP3)

epg gstreamer servicemp3

  • Please log in to reply
56 replies to this topic

#1 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 24 November 2013 - 12:03

Hello,


There are many questions on the forum how you can get EPG with GStreamer (Service Reference 4097). Till now nobody succeed getting EPG, most probably because ServiceMP3 doen't contain proper implementation of iServiceInformation

On servicedvb we have the following:
                // iServiceInformation
        RESULT getName(std::string &name);
        RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
        int getInfo(int w);
        std::string getInfoString(int w);
        ePtr<iDVBTransponderData> getTransponderData();
        void getAITApplications(std::map<int, std::string> &aitlist);
        void getCaIds(std::vector<int> &caids, std::vector<int> &ecmpids);
On servicemp3 we have the following:
               // iServiceInformation
        RESULT getName(std::string &name);
        int getInfo(int w);
        std::string getInfoString(int w);
        ePtr<iServiceInfoContainer> getInfoObject(int w);
My question is if we implement getEvent on servicemp3 it would be possible to get EGP events from epg.dat?

Of course it is obvious that you need to import EGP first.

Thanks for your suggestions.



PS. Other topic mention problems with EPG and GStreamer (4097):
http://openpli.org/f...g-epg-for-iptv/
http://openpli.org/f...-4097-services/
http://openpli.org/f...tream-channels/
http://openpli.org/f...c/29916-epgdat/
Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: EPG with GStreamer (ServiceMP3) #2 pieterg

  • PLi® Core member
  • 32,766 posts

+245
Excellent

Posted 24 November 2013 - 13:03

Yes, that's at least one of the requirements, that should give you now/next in the osd, queried from the epgcache.

Re: EPG with GStreamer (ServiceMP3) #3 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 24 November 2013 - 14:11

I can give a try (although i think i'll fail).

The following are ok, or totally wrong?

1. getEvent in servicemp3.cpp
RESULT eServiceMP3::getEvent(ePtr<eServiceEvent> &evt, int nownext)
{
        return m_event_handler.getEvent(evt, nownext);
}
2. m_event_handler,m_nownext_timer,updateEpgCacheNowNext in servicemp3.h
eDVBServiceEITHandler m_event_handler;
ePtr<eTimer> m_nownext_timer;
void updateEpgCacheNowNext();
3. connect m_eit_changed on eServiceMP3 constructor
m_nownext_timer(eTimer::create(eApp))

CONNECT(m_event_handler.m_eit_changed, eServiceMP3::gotNewEvent);
CONNECT(m_nownext_timer->timeout, eServiceMP3::updateEpgCacheNowNext);
4. create getNewEvent on eServiceMP3
void eServiceMP3::gotNewEvent(int error)
{
        ePtr<eServiceEvent> event_now;
        getEvent(event_now, 0);
#if 0
                // debug only
        ePtr<eServiceEvent> event_next;
        getEvent(event_next, 1);

        if (event_now)
                eDebug("now running: %s (%d seconds :)", event_now->m_event_name.c_str(), event_now->m_duration);
        if (event_next)
                eDebug("next running: %s (%d seconds :)", event_next->m_event_name.c_str(), event_next->m_duration);
#endif
        if (!error)
        {
                m_nownext_timer->stop();
                m_event((iPlayableService*)this, evUpdatedEventInfo);
        }
        else
        {
                /* our eit reader has stopped, we have to take care of our own event updates */
                updateEpgCacheNowNext();
        }
}
5. create updateEpgCacheNowNext on eServiceMP3
void eServiceMP3::updateEpgCacheNowNext()
{
        bool update = false;
        ePtr<eServiceEvent> next = 0;
        ePtr<eServiceEvent> ptr = 0;
        eServiceReference &ref = (eServiceReference&) m_ref;
        if (eEPGCache::getInstance() && eEPGCache::getInstance()->lookupEventTime(ref, -1, ptr) >= 0)
        {
                ePtr<eServiceEvent> current = 0;
                m_event_handler.getEvent(current, 0);
                if (!current || !ptr || current->getEventId() != ptr->getEventId())
                {
                        update = true;
                        m_event_handler.inject(ptr, 0);
                        time_t next_time = ptr->getBeginTime() + ptr->getDuration();
                        if (eEPGCache::getInstance()->lookupEventTime(ref, next_time, ptr) >= 0)
                        {
                                next = ptr;
                                m_event_handler.inject(ptr, 1);
                        }
                }
        }

        int refreshtime = 60;
        if (!next)
        {
                m_event_handler.getEvent(next, 1);
        }
        if (next)
        {
                time_t now = eDVBLocalTimeHandler::getInstance()->nowTime();
                refreshtime = (int)(next->getBeginTime() - now) + 3;
                if (refreshtime <= 0 || refreshtime > 60) refreshtime = 60;
        }
        m_nownext_timer->startLongTimer(refreshtime);
        if (update) m_event((iPlayableService*)this, evUpdatedEventInfo);
}
6. Stop timer on eServiceMP3::stop
m_nownext_timer->stop();

Edited by athoik, 24 November 2013 - 14:12.

Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: EPG with GStreamer (ServiceMP3) #4 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 24 November 2013 - 16:47

Hello,


Here is the first patch using above logic. It compiles without errors, but i don't know if it is functional yet.
--- a/lib/service/servicemp3.cpp
+++ b/lib/service/servicemp3.cpp
@@ -6,6 +6,7 @@
 #include <lib/base/init.h>
 #include <lib/base/nconfig.h>
 #include <lib/base/object.h>
+#include <lib/dvb/epgcache.h>
 #include <lib/dvb/decoder.h>
 #include <lib/components/file_eraser.h>
 #include <lib/gui/esubtitle.h>
@@ -360,8 +361,10 @@ void eServiceMP3InfoContainer::setBuffer(GstBuffer *buffer)
 int eServiceMP3::ac3_delay = 0,
     eServiceMP3::pcm_delay = 0;
 
-eServiceMP3::eServiceMP3(eServiceReference ref)
-	:m_ref(ref), m_pump(eApp, 1)
+eServiceMP3::eServiceMP3(eServiceReference ref):
+	m_ref(ref),
+	m_pump(eApp, 1),
+	m_nownext_timer(eTimer::create(eApp))
 {
 	m_subtitle_sync_timer = eTimer::create(eApp);
 	m_streamingsrc_timeout = 0;
@@ -384,6 +387,8 @@ eServiceMP3::eServiceMP3(eServiceReference ref)
 
 	CONNECT(m_subtitle_sync_timer->timeout, eServiceMP3::pushSubtitles);
 	CONNECT(m_pump.recv_msg, eServiceMP3::gstPoll);
+	CONNECT(m_event_handler.m_eit_changed, eServiceMP3::gotNewEvent);
+	CONNECT(m_nownext_timer->timeout, eServiceMP3::updateEpgCacheNowNext);
 	m_aspect = m_width = m_height = m_framerate = m_progressive = -1;
 
 	m_state = stIdle;
@@ -625,6 +630,73 @@ eServiceMP3::~eServiceMP3()
 	}
 }
 
+void eServiceMP3::gotNewEvent(int error)
+{
+	ePtr<eServiceEvent> event_now;
+	getEvent(event_now, 0);
+#if 0
+		// debug only
+	ePtr<eServiceEvent> event_next;
+	getEvent(event_next, 1);
+
+	if (event_now)
+		eDebug("now running: %s (%d seconds :)", event_now->m_event_name.c_str(), event_now->m_duration);
+	if (event_next)
+		eDebug("next running: %s (%d seconds :)", event_next->m_event_name.c_str(), event_next->m_duration);
+#endif
+	if (!error)
+	{
+		m_nownext_timer->stop();
+		m_event((iPlayableService*)this, evUpdatedEventInfo);
+	}
+	else
+	{
+		/* our eit reader has stopped, we have to take care of our own event updates */
+		updateEpgCacheNowNext();
+	}
+}
+
+void eServiceMP3::updateEpgCacheNowNext()
+{
+	bool update = false;
+	ePtr<eServiceEvent> next = 0;
+	ePtr<eServiceEvent> ptr = 0;
+	//eServiceReference &ref = (eServiceReference&) m_ref;
+	eServiceReference ref(m_ref);
+	ref.type = eServiceFactoryMP3::id;
+	ref.path.clear();
+	if (eEPGCache::getInstance() && eEPGCache::getInstance()->lookupEventTime(ref, -1, ptr) >= 0)
+	{
+		ePtr<eServiceEvent> current = 0;
+		m_event_handler.getEvent(current, 0);
+		if (!current || !ptr || current->getEventId() != ptr->getEventId())
+		{
+			update = true;
+			m_event_handler.inject(ptr, 0);
+			time_t next_time = ptr->getBeginTime() + ptr->getDuration();
+			if (eEPGCache::getInstance()->lookupEventTime(ref, next_time, ptr) >= 0)
+			{
+				next = ptr;
+				m_event_handler.inject(ptr, 1);
+			}
+		}
+	}
+
+	int refreshtime = 60;
+	if (!next)
+	{
+		m_event_handler.getEvent(next, 1);
+	}
+	if (next)
+	{
+		time_t now = eDVBLocalTimeHandler::getInstance()->nowTime();
+		refreshtime = (int)(next->getBeginTime() - now) + 3;
+		if (refreshtime <= 0 || refreshtime > 60) refreshtime = 60;
+	}
+	m_nownext_timer->startLongTimer(refreshtime);
+	if (update) m_event((iPlayableService*)this, evUpdatedEventInfo);
+}
+
 DEFINE_REF(eServiceMP3);
 
 DEFINE_REF(eServiceMP3::GstMessageContainer);
@@ -668,6 +740,8 @@ RESULT eServiceMP3::stop()
 	gst_element_set_state(m_gst_playbin, GST_STATE_NULL);
 	m_state = stStopped;
 
+	m_nownext_timer->stop();
+
 	return 0;
 }
 
@@ -909,6 +983,11 @@ RESULT eServiceMP3::getName(std::string &name)
 	return 0;
 }
 
+RESULT eServiceMP3::getEvent(ePtr<eServiceEvent> &evt, int nownext)
+{
+	return m_event_handler.getEvent(evt, nownext);
+}
+
 int eServiceMP3::getInfo(int w)
 {
 	const gchar *tag = 0;
diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h
index a118a5b..cafde9c 100644
--- a/lib/service/servicemp3.h
+++ b/lib/service/servicemp3.h
@@ -142,6 +142,7 @@ public:
 
 		// iServiceInformation
 	RESULT getName(std::string &name);
+	RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
 	int getInfo(int w);
 	std::string getInfoString(int w);
 	ePtr<iServiceInfoContainer> getInfoObject(int w);
@@ -222,6 +223,14 @@ public:
 		std::string missing_codec;
 	};
 
+protected:
+	eDVBServiceEITHandler m_event_handler;
+	ePtr<eTimer> m_nownext_timer;
+	void updateEpgCacheNowNext();
+
+		/* events */
+	void gotNewEvent(int error);
+
 private:
 	static int pcm_delay;
 	static int ac3_delay;

Attached Files


Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: EPG with GStreamer (ServiceMP3) #5 malakudi

  • Senior Member
  • 1,449 posts

+69
Good

Posted 24 November 2013 - 17:13

@athoik: I had EPG on 4097 serviceref with a quick "hack" in epgcache.cpp, but I didn't experiment with it more.

I was changing reftype from 0x1001 to 0x1 only inside the scope of epgcache.cpp. It was something as shown next.

Weekly EPG was displayed but not now/next in Infobar (although events were available).

I will test your patches.

 

 

                        eServiceReference ref(handleGroup(eServiceReference(PyString_AS_STRING(service))));
                        if (ref.type != eServiceReference::idDVB)
                        {
                                if (ref.type == 0x1001)
                                        ref.type = 0x1;
                                else
                                {
                                        eDebug("service reference for epg query is not valid");
                                        continue;
                                }
                        }

Edited by malakudi, 24 November 2013 - 17:13.


Re: EPG with GStreamer (ServiceMP3) #6 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 24 November 2013 - 17:25

@malakudi,

getEvent, was missing that's certenly one reason.

Edited by athoik, 24 November 2013 - 17:26.

Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: EPG with GStreamer (ServiceMP3) #7 pieterg

  • PLi® Core member
  • 32,766 posts

+245
Excellent

Posted 24 November 2013 - 19:24

You don't need the nownext_timer stuff, as you'll have no eit reader running. Just get the now/next events from the epgcache right away.

Re: EPG with GStreamer (ServiceMP3) #8 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 24 November 2013 - 20:17

So there that means we only need to implement getEvent!

Something like this seems ok?
RESULT eServiceMP3::getEvent(ePtr<eServiceEvent> &evt, int nownext)
{
	//bool update = false;
	//eServiceReference &ref = (eServiceReference&) m_ref;
	eServiceReference ref(m_ref);
	ref.type = eServiceFactoryMP3::id;
	ref.path.clear();
	if (eEPGCache::getInstance() && eEPGCache::getInstance()->lookupEventTime(ref, -1, evt) >= 0)
	{
		if(!evt)
		{
			return -1;
		}
		if(!nownext)
		{
			return 0;
		}
		time_t next_time = ptr->getBeginTime() + ptr->getDuration();
		if (eEPGCache::getInstance()->lookupEventTime(ref, next_time, ptr) >= 0)
		{
			if(!evt)
			{
				return -1;
			}
			return 0;
		}
	}
	return -1;
	//if (update) m_event((iPlayableService*)this, evUpdatedEventInfo);
}
Do we need to raise evUpdatedEventInfo?

Edited by athoik, 24 November 2013 - 20:20.

Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: EPG with GStreamer (ServiceMP3) #9 pieterg

  • PLi® Core member
  • 32,766 posts

+245
Excellent

Posted 24 November 2013 - 20:31

Yes I think so (unless there is a more 'finegrained' event to signal just now/next change).

On the other hand, getEvent is called by the osd. So it already knows there is information to be queried.
I think we will need that nownext timer after all, to poll the epgcache, and emit an event when something changed.
You should be able to copy existing code, as I already implemented this as a backup on systems where no EIT exists.

Re: EPG with GStreamer (ServiceMP3) #10 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 25 November 2013 - 18:14

I just tested the latest patch and it is working ;) but there are more steps and discussion here.
diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp
index b12bf0a..5ff0909 100644
--- a/lib/service/servicemp3.cpp
+++ b/lib/service/servicemp3.cpp
@@ -6,6 +6,7 @@
 #include <lib/base/init.h>
 #include <lib/base/nconfig.h>
 #include <lib/base/object.h>
+#include <lib/dvb/epgcache.h>
 #include <lib/dvb/decoder.h>
 #include <lib/components/file_eraser.h>
 #include <lib/gui/esubtitle.h>
@@ -909,6 +910,37 @@ RESULT eServiceMP3::getName(std::string &name)
 	return 0;
 }
 
+RESULT eServiceMP3::getEvent(ePtr<eServiceEvent> &evt, int nownext)
+{
+	//bool update = false;
+	//eServiceReference &ref = (eServiceReference&) m_ref;
+	eServiceReference ref(m_ref);
+	ref.type = 0x1; //eServiceFactoryDVB::id; //eServiceFactoryMP3::id;
+	ref.path.clear();
+	if (eEPGCache::getInstance() && eEPGCache::getInstance()->lookupEventTime(ref, -1, evt) >= 0)
+	{
+		if(!evt)
+		{
+			return -1;
+		}
+		if(!nownext)
+		{
+			return 0;
+		}
+		time_t next_time = evt->getBeginTime() + evt->getDuration();
+		if (eEPGCache::getInstance()->lookupEventTime(ref, next_time, evt) >= 0)
+		{
+			if(!evt)
+			{
+				return -1;
+			}
+			return 0;
+		}
+	}
+	return -1;
+	//if (update) m_event((iPlayableService*)this, evUpdatedEventInfo);
+}
+
 int eServiceMP3::getInfo(int w)
 {
 	const gchar *tag = 0;
diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h
index a118a5b..29e5dc5 100644
--- a/lib/service/servicemp3.h
+++ b/lib/service/servicemp3.h
@@ -142,6 +142,7 @@ public:
 
 		// iServiceInformation
 	RESULT getName(std::string &name);
+	RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
 	int getInfo(int w);
 	std::string getInfoString(int w);
 	ePtr<iServiceInfoContainer> getInfoObject(int w);
Above i changed the service type to 0x1 in order to be able to use service reference existing in epg.dat. But i don't know if this is good. We need to discuss about this (Eg we can have a feature in order to change type to 0x1 by a flag in service reference)

So i used 4097:0:1:13F:157C:13E:820000:0:0:0 and it was translated into 1:0:1:13F:157C:13E:820000:0:0:0. 1:0:1:13F:157C:13E:820000:0:0:0 was already inserted in epg.dat using offline rytec method.


@pieterg, can you point to the code you already implemented to have a look?

@All, what do you think about the 4097 to 1 feature? Should we enable the 4097 -> 1 mapping? (In order to use existing service references).

Attached Files


Edited by athoik, 25 November 2013 - 18:16.

Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: EPG with GStreamer (ServiceMP3) #11 pieterg

  • PLi® Core member
  • 32,766 posts

+245
Excellent

Posted 25 November 2013 - 18:54

With this patch, you won't get an OSD update when the next event starts.

I think you were pretty close with your first attempt after all, the code I mean is in servicedvb.cpp, see eDVBServicePlay::updateEpgCacheNowNext()

Re: EPG with GStreamer (ServiceMP3) #12 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 25 November 2013 - 19:17

Do we need a class eServiceMP3Handler like eDVBServiceEITHandler only with functions inject, getEvent?

Or it's ok to use two private variables (ePtr<eServiceEvent>) on eServiceMP3?
Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: EPG with GStreamer (ServiceMP3) #13 pieterg

  • PLi® Core member
  • 32,766 posts

+245
Excellent

Posted 25 November 2013 - 19:19

no, that's the EIT reader, which we don't have for non-ts streams.
I think we can indeed store both events in the eServiceMP3 object itself, and pass them back when the getEvent call requests them.

Re: EPG with GStreamer (ServiceMP3) #14 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 25 November 2013 - 20:36

One step closer.
diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp
index b12bf0a..c7fbe17 100644
--- a/lib/service/servicemp3.cpp
+++ b/lib/service/servicemp3.cpp
@@ -6,6 +6,7 @@
 #include <lib/base/init.h>
 #include <lib/base/nconfig.h>
 #include <lib/base/object.h>
+#include <lib/dvb/epgcache.h>
 #include <lib/dvb/decoder.h>
 #include <lib/components/file_eraser.h>
 #include <lib/gui/esubtitle.h>
@@ -360,8 +361,10 @@ void eServiceMP3InfoContainer::setBuffer(GstBuffer *buffer)
 int eServiceMP3::ac3_delay = 0,
     eServiceMP3::pcm_delay = 0;
 
-eServiceMP3::eServiceMP3(eServiceReference ref)
-	:m_ref(ref), m_pump(eApp, 1)
+eServiceMP3::eServiceMP3(eServiceReference ref):
+	m_ref(ref),
+	m_pump(eApp, 1),
+	m_nownext_timer(eTimer::create(eApp))
 {
 	m_subtitle_sync_timer = eTimer::create(eApp);
 	m_streamingsrc_timeout = 0;
@@ -384,6 +387,7 @@ eServiceMP3::eServiceMP3(eServiceReference ref)
 
 	CONNECT(m_subtitle_sync_timer->timeout, eServiceMP3::pushSubtitles);
 	CONNECT(m_pump.recv_msg, eServiceMP3::gstPoll);
+	CONNECT(m_nownext_timer->timeout, eServiceMP3::updateEpgCacheNowNext);
 	m_aspect = m_width = m_height = m_framerate = m_progressive = -1;
 
 	m_state = stIdle;
@@ -625,6 +629,53 @@ eServiceMP3::~eServiceMP3()
 	}
 }
 
+void eServiceMP3::updateEpgCacheNowNext()
+{
+	bool update = false;
+	ePtr<eServiceEvent> next = 0;
+	ePtr<eServiceEvent> ptr = 0;
+	eServiceReference ref(m_ref);
+	/** FIXME **/
+	ref.type = 0x1; //eServiceFactoryMP3::id;
+	ref.path.clear();
+	if (eEPGCache::getInstance() && eEPGCache::getInstance()->lookupEventTime(ref, -1, ptr) >= 0)
+	{
+		ePtr<eServiceEvent> current = 0;
+		getEvent(current, 0);
+		if (!current || !ptr || current->getEventId() != ptr->getEventId())
+		{
+			update = true;
+			m_event_now = ptr;
+			time_t next_time = ptr->getBeginTime() + ptr->getDuration();
+			if (eEPGCache::getInstance()->lookupEventTime(ref, next_time, ptr) >= 0)
+			{
+				next = ptr;
+				m_event_next = ptr;
+			}
+		}
+	}
+
+	int refreshtime = 60;
+	if (!next)
+	{
+		getEvent(next, 1);
+	}
+	if (next)
+	{
+		time_t now = eDVBLocalTimeHandler::getInstance()->nowTime();
+		refreshtime = (int)(next->getBeginTime() - now) + 3;
+		if (refreshtime <= 0 || refreshtime > 60)
+		{
+			refreshtime = 60;
+		}
+	}
+	m_nownext_timer->startLongTimer(refreshtime);
+	if (update)
+	{
+		m_event((iPlayableService*)this, evUpdatedEventInfo);
+	}
+}
+
 DEFINE_REF(eServiceMP3);
 
 DEFINE_REF(eServiceMP3::GstMessageContainer);
@@ -644,6 +695,7 @@ RESULT eServiceMP3::start()
 	{
 		eDebug("eServiceMP3::starting pipeline");
 		gst_element_set_state (m_gst_playbin, GST_STATE_PLAYING);
+		updateEpgCacheNowNext();
 	}
 
 	m_event(this, evStart);
@@ -667,6 +719,7 @@ RESULT eServiceMP3::stop()
 	eDebug("eServiceMP3::stop %s", m_ref.path.c_str());
 	gst_element_set_state(m_gst_playbin, GST_STATE_NULL);
 	m_state = stStopped;
+	m_nownext_timer->stop();
 
 	return 0;
 }
@@ -909,6 +962,14 @@ RESULT eServiceMP3::getName(std::string &name)
 	return 0;
 }
 
+RESULT eServiceMP3::getEvent(ePtr<eServiceEvent> &evt, int nownext)
+{
+	evt = nownext ? m_event_next : m_event_now;
+	if (!evt)
+		return -1;
+	return 0;
+}
+
 int eServiceMP3::getInfo(int w)
 {
 	const gchar *tag = 0;
diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h
index a118a5b..3bbf97e 100644
--- a/lib/service/servicemp3.h
+++ b/lib/service/servicemp3.h
@@ -142,6 +142,7 @@ public:
 
 		// iServiceInformation
 	RESULT getName(std::string &name);
+	RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
 	int getInfo(int w);
 	std::string getInfoString(int w);
 	ePtr<iServiceInfoContainer> getInfoObject(int w);
@@ -222,6 +223,11 @@ public:
 		std::string missing_codec;
 	};
 
+protected:
+	ePtr<eTimer> m_nownext_timer;
+	ePtr<eServiceEvent> m_event_now, m_event_next;	
+	void updateEpgCacheNowNext();
+
 private:
 	static int pcm_delay;
 	static int ac3_delay;
Changing type 4097 to 1 should be a feature or by default (just like @malakudi did)?
Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: EPG with GStreamer (ServiceMP3) #15 malakudi

  • Senior Member
  • 1,449 posts

+69
Good

Posted 25 November 2013 - 21:40

My "change" of serviceref was just a dirty hack, don't go that route. In order to match already stored EPG entries for 1 and 4097 servicerefs, you should find where this matching is happening and match both 0x1001 and 0x0001. I was going to do that but postponed the whole work due to lack of free time.



Re: EPG with GStreamer (ServiceMP3) #16 pieterg

  • PLi® Core member
  • 32,766 posts

+245
Excellent

Posted 25 November 2013 - 23:11

why are you calling getEvent in updateEpgCacheNowNext?

Re: EPG with GStreamer (ServiceMP3) #17 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 26 November 2013 - 02:32

I will change it to m_event_now,m_event_next. :)

(I just did minimal changes in order to be sure i wont break existing logic)

If above is ready, its time for epgcache changes..
Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: EPG with GStreamer (ServiceMP3) #18 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 26 November 2013 - 17:49

Hello,


I think patch is complete!

updateEpgCacheNowNext was modified to use m_event_now,m_event_next insted of getEvent. Also idServiceMP3 (4097) was added into eServiceReference in order to check service reference type on epgcache.

Using above patch i was able to get EPG and now,next information (most probably is enouph to use valid sid, onid and tsid).
diff --git a/lib/dvb/epgcache.cpp b/lib/dvb/epgcache.cpp
index d420419..6834cf5 100644
--- a/lib/dvb/epgcache.cpp
+++ b/lib/dvb/epgcache.cpp
@@ -2468,7 +2468,7 @@ PyObject *eEPGCache::lookupEvent(ePyObject list, ePyObject convertFunc)
 				stime = ::time(0);
 
 			eServiceReference ref(handleGroup(eServiceReference(PyString_AS_STRING(service))));
-			if (ref.type != eServiceReference::idDVB)
+			if (ref.type != eServiceReference::idDVB && ref.type != eServiceReference::idServiceMP3)
 			{
 				eDebug("service reference for epg query is not valid");
 				continue;
diff --git a/lib/service/iservice.h b/lib/service/iservice.h
index a61751d..71eee58 100644
--- a/lib/service/iservice.h
+++ b/lib/service/iservice.h
@@ -20,7 +20,8 @@ public:
 		idStructure,	// service_id == 0 is root
 		idDVB,
 		idFile,
-		idUser=0x1000
+		idUser=0x1000,
+		idServiceMP3=0x1001
 	};
 	int type;
 
diff --git a/lib/service/servicemp3.cpp b/lib/service/servicemp3.cpp
index b12bf0a..b157a61 100644
--- a/lib/service/servicemp3.cpp
+++ b/lib/service/servicemp3.cpp
@@ -6,6 +6,7 @@
 #include <lib/base/init.h>
 #include <lib/base/nconfig.h>
 #include <lib/base/object.h>
+#include <lib/dvb/epgcache.h>
 #include <lib/dvb/decoder.h>
 #include <lib/components/file_eraser.h>
 #include <lib/gui/esubtitle.h>
@@ -360,8 +361,10 @@ void eServiceMP3InfoContainer::setBuffer(GstBuffer *buffer)
 int eServiceMP3::ac3_delay = 0,
     eServiceMP3::pcm_delay = 0;
 
-eServiceMP3::eServiceMP3(eServiceReference ref)
-	:m_ref(ref), m_pump(eApp, 1)
+eServiceMP3::eServiceMP3(eServiceReference ref):
+	m_ref(ref),
+	m_pump(eApp, 1),
+	m_nownext_timer(eTimer::create(eApp))
 {
 	m_subtitle_sync_timer = eTimer::create(eApp);
 	m_streamingsrc_timeout = 0;
@@ -384,6 +387,7 @@ eServiceMP3::eServiceMP3(eServiceReference ref)
 
 	CONNECT(m_subtitle_sync_timer->timeout, eServiceMP3::pushSubtitles);
 	CONNECT(m_pump.recv_msg, eServiceMP3::gstPoll);
+	CONNECT(m_nownext_timer->timeout, eServiceMP3::updateEpgCacheNowNext);
 	m_aspect = m_width = m_height = m_framerate = m_progressive = -1;
 
 	m_state = stIdle;
@@ -625,6 +629,51 @@ eServiceMP3::~eServiceMP3()
 	}
 }
 
+void eServiceMP3::updateEpgCacheNowNext()
+{
+	bool update = false;
+	ePtr<eServiceEvent> next = 0;
+	ePtr<eServiceEvent> ptr = 0;
+	eServiceReference ref(m_ref);
+	ref.type = eServiceFactoryMP3::id;
+	ref.path.clear();
+	if (eEPGCache::getInstance() && eEPGCache::getInstance()->lookupEventTime(ref, -1, ptr) >= 0)
+	{
+		ePtr<eServiceEvent> current = m_event_now;
+		if (!current || !ptr || current->getEventId() != ptr->getEventId())
+		{
+			update = true;
+			m_event_now = ptr;
+			time_t next_time = ptr->getBeginTime() + ptr->getDuration();
+			if (eEPGCache::getInstance()->lookupEventTime(ref, next_time, ptr) >= 0)
+			{
+				next = ptr;
+				m_event_next = ptr;
+			}
+		}
+	}
+
+	int refreshtime = 60;
+	if (!next)
+	{
+		next = m_event_next;
+	}
+	if (next)
+	{
+		time_t now = eDVBLocalTimeHandler::getInstance()->nowTime();
+		refreshtime = (int)(next->getBeginTime() - now) + 3;
+		if (refreshtime <= 0 || refreshtime > 60)
+		{
+			refreshtime = 60;
+		}
+	}
+	m_nownext_timer->startLongTimer(refreshtime);
+	if (update)
+	{
+		m_event((iPlayableService*)this, evUpdatedEventInfo);
+	}
+}
+
 DEFINE_REF(eServiceMP3);
 
 DEFINE_REF(eServiceMP3::GstMessageContainer);
@@ -644,6 +693,7 @@ RESULT eServiceMP3::start()
 	{
 		eDebug("eServiceMP3::starting pipeline");
 		gst_element_set_state (m_gst_playbin, GST_STATE_PLAYING);
+		updateEpgCacheNowNext();
 	}
 
 	m_event(this, evStart);
@@ -667,6 +717,7 @@ RESULT eServiceMP3::stop()
 	eDebug("eServiceMP3::stop %s", m_ref.path.c_str());
 	gst_element_set_state(m_gst_playbin, GST_STATE_NULL);
 	m_state = stStopped;
+	m_nownext_timer->stop();
 
 	return 0;
 }
@@ -909,6 +960,14 @@ RESULT eServiceMP3::getName(std::string &name)
 	return 0;
 }
 
+RESULT eServiceMP3::getEvent(ePtr<eServiceEvent> &evt, int nownext)
+{
+	evt = nownext ? m_event_next : m_event_now;
+	if (!evt)
+		return -1;
+	return 0;
+}
+
 int eServiceMP3::getInfo(int w)
 {
 	const gchar *tag = 0;
diff --git a/lib/service/servicemp3.h b/lib/service/servicemp3.h
index a118a5b..3bbf97e 100644
--- a/lib/service/servicemp3.h
+++ b/lib/service/servicemp3.h
@@ -142,6 +142,7 @@ public:
 
 		// iServiceInformation
 	RESULT getName(std::string &name);
+	RESULT getEvent(ePtr<eServiceEvent> &evt, int nownext);
 	int getInfo(int w);
 	std::string getInfoString(int w);
 	ePtr<iServiceInfoContainer> getInfoObject(int w);
@@ -222,6 +223,11 @@ public:
 		std::string missing_codec;
 	};
 
+protected:
+	ePtr<eTimer> m_nownext_timer;
+	ePtr<eServiceEvent> m_event_now, m_event_next;	
+	void updateEpgCacheNowNext();
+
 private:
 	static int pcm_delay;
 	static int ac3_delay;
Thanks/Ευχαριστώ

Attached Files


Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: EPG with GStreamer (ServiceMP3) #19 athoik

  • PLi® Core member
  • 8,458 posts

+327
Excellent

Posted 27 November 2013 - 20:05

Hello,

@pieterg, did you take a look on the patch?

Thanks
Wavefield T90: 0.8W - 1.9E - 4.8E - 13E - 16E - 19.2E - 23.5E - 26E - 33E - 39E - 42E - 45E on EMP Centauri DiseqC 16/1
Unamed: 13E Quattro - 9E Quattro on IKUSI MS-0916

Re: EPG with GStreamer (ServiceMP3) #20 pieterg

  • PLi® Core member
  • 32,766 posts

+245
Excellent

Posted 27 November 2013 - 22:12

applied



Also tagged with one or more of these keywords: epg, gstreamer, servicemp3

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users