<div dir="ltr"><div><div>Hi,<br><br></div>This is not the correct way to write this code but this is what works for me. After saving to a file I parse it for XMLTV.dtd.<br><br></div>This is for those who really need this and might need some ideas.<br>
<br>Index: demux.c<br>===================================================================<br>RCS file: /var/dvblast-2.2/Attic/demux.c,v<br>retrieving revision 1.1.2.1.24.2<br>retrieving revision 1.1.2.1.24.2.46.3<br>diff -u -r1.1.2.1.24.2 -r1.1.2.1.24.2.46.3<br>
--- demux.c 8 Mar 2013 12:40:18 -0000 1.1.2.1.24.2<br>+++ demux.c 27 Sep 2013 17:18:40 -0000 1.1.2.1.24.2.46.3<br>@@ -1036,6 +1036,18 @@<br> bool b_epg = i_table_id >= EIT_TABLE_ID_SCHED_ACTUAL_FIRST &&<br>
i_table_id <= EIT_TABLE_ID_SCHED_ACTUAL_LAST;<br> int i;<br>+ uint8_t *p_event;<br>+ uint16_t current_event_id;<br>+<br>+ // Persistent values<br>+ static uint16_t this_event_id = 0;<br>
+ static time_t wait_time = 0;<br>+ static time_t end_time = 0;<br>+<br>+ if ( wait_time == 0 )<br>+ {<br>+ wait_time = time(NULL);<br>+ }<br> <br> for ( i = 0; i < i_nb_outputs; i++ )<br> {<br>
@@ -1052,6 +1064,47 @@<br> psi_set_crc( p_eit );<br> }<br> <br>+ /*<br>+ * Checking if there are any events at all for this EIT.<br>+ * If not don't even print the empty EIT table<br>
+ */<br>+ if ((p_event = eit_get_event(p_eit, 0)) == NULL)<br>+ {<br>+ return;<br>+ }<br>+ else if ( wait_time < time(NULL) )<br>+ {<br>
+ current_event_id = eitn_get_event_id(p_event);<br>+<br>+ if ( this_event_id == 0 )<br>+ {<br>+ // Make sure we start with an actual PF as it occurs more often<br>
+ if (psi_get_tableid(p_eit) != EIT_TABLE_ID_PF_ACTUAL)<br>+ return;<br>+<br>+ this_event_id = current_event_id;<br>+ end_time = time(NULL) + EPG_TIMEOUT;<br>
+<br>+ msg_Dbg( NULL, "Starting EIT parser with event id : %d", this_event_id);<br>+ }<br>+ else if ( (this_event_id == current_event_id && psi_get_tableid(p_eit) == EIT_TABLE_ID_PF_ACTUAL)<br>
+ || end_time < time(NULL) )<br>+ {<br>+ msg_Dbg( NULL, "Stopping EIT parser");<br>+<br>+ // Resetting event id<br>+ this_event_id = 0;<br>
+ // Scheduling next EPG grab<br>+ wait_time = time(NULL) + EPG_INTERVAL;<br>+ // Rename to final XML<br>+ rename (epg_file_tmp, epg_file);<br>+<br>
+ return;<br>+ }<br>+<br>+ eit_print( p_eit, msg_Epg, NULL, demux_Iconv, NULL, PRINT_XML );<br>+ }<br>+<br> OutputPSISection( p_output, p_eit, EIT_PID, &p_output->i_eit_cc,<br>
i_dts, &p_output->p_eit_ts_buffer,<br> &p_output->i_eit_ts_buffer_offset );<br>Index: dvblast.c<br>===================================================================<br>
RCS file: /var/dvblast-2.2/Attic/dvblast.c,v<br>retrieving revision 1.1.2.1.24.2<br>retrieving revision 1.1.2.1.24.2.46.1<br>diff -u -r1.1.2.1.24.2 -r1.1.2.1.24.2.46.1<br>--- dvblast.c 8 Mar 2013 12:40:18 -0000 1.1.2.1.24.2<br>
+++ dvblast.c 26 Sep 2013 16:09:46 -0000 1.1.2.1.24.2.46.1<br>@@ -119,6 +119,10 @@<br> int (*pf_SetFilter)( uint16_t i_pid ) = NULL;<br> void (*pf_UnsetFilter)( int i_fd, uint16_t i_pid ) = NULL;<br> <br>+/* EPG default */<br>
+char epg_file_tmp[EPG_NAME];<br>+char epg_file[EPG_NAME];<br>+<br> /*****************************************************************************<br> * Configuration files<br> *****************************************************************************/<br>
@@ -879,6 +883,13 @@<br> b_dvb_global = true;<br> }<br> <br>+ if ( b_epg_global )<br>+ {<br>+ // Create EPG file string<br>+ sprintf (epg_file_tmp, "/tmp/epg_adapter%d.tmp", i_adapter);<br>
+ sprintf (epg_file, "/tmp/epg_adapter%d.xml", i_adapter);<br>+ }<br>+<br> memset( &output_dup, 0, sizeof(output_dup) );<br> if ( psz_dup_config != NULL )<br> {<br>Index: dvblast.h<br>===================================================================<br>
RCS file: /var/dvblast-2.2/Attic/dvblast.h,v<br>retrieving revision 1.1.2.1.24.3<br>retrieving revision 1.1.2.1.24.3.44.4<br>diff -u -r1.1.2.1.24.3 -r1.1.2.1.24.3.44.4<br>--- dvblast.h 2 Apr 2013 14:52:29 -0000 1.1.2.1.24.3<br>
+++ dvblast.h 1 Oct 2013 14:22:09 -0000 1.1.2.1.24.3.44.4<br>@@ -43,6 +43,10 @@<br> #define DEFAULT_FRONTEND_TIMEOUT 30000000 /* 30 s */<br> #define EXIT_STATUS_FRONTEND_TIMEOUT 100<br> <br>+#define EPG_NAME 50<br>+#define EPG_TIMEOUT 60<br>
+#define EPG_INTERVAL 600<br>+<br> /*****************************************************************************<br> * Output configuration flags (for output_t -> i_config) - bit values<br> * Bit 0 : Set for watch mode<br>
@@ -193,6 +197,9 @@<br> extern int (*pf_SetFilter)( uint16_t i_pid );<br> extern void (*pf_UnsetFilter)( int i_fd, uint16_t i_pid );<br> <br>+extern char epg_file_tmp[];<br>+extern char epg_file[];<br>+<br> /*****************************************************************************<br>
* Prototypes<br> *****************************************************************************/<br>@@ -212,6 +219,7 @@<br> __attribute__ ((format(printf, 2, 3))) void msg_Dbg( void *_unused, const char *psz_format, ... );<br>
__attribute__ ((format(printf, 2, 3))) void msg_Raw( void *_unused, const char *psz_format, ... );<br> __attribute__ ((format(printf, 2, 3))) void msg_Crit( void *_unused, const char *psz_format, ... );<br>+__attribute__ ((format(printf, 2, 3))) void msg_Epg( void *_unused, const char *psz_format, ... );<br>
<br> /* */<br> bool streq(char *a, char *b);<br>Index: dvblastctl.c<br>===================================================================<br>RCS file: /var/dvblast-2.2/Attic/dvblastctl.c,v<br>retrieving revision 1.1.2.1.24.2<br>
retrieving revision 1.1.2.1.24.2.46.1<br>diff -u -r1.1.2.1.24.2 -r1.1.2.1.24.2.46.1<br>--- dvblastctl.c 8 Mar 2013 12:40:18 -0000 1.1.2.1.24.2<br>+++ dvblastctl.c 26 Sep 2013 16:09:46 -0000 1.1.2.1.24.2.46.1<br>
@@ -56,6 +56,9 @@<br> int i_fd = -1;<br> char psz_client_socket[PATH_MAX] = {0};<br> <br>+/* Never used here. For compilation reasons only */<br>+char epg_file_tmp[EPG_NAME];<br>+<br> static void clean_client_socket() {<br>
if ( i_fd > -1 )<br> {<br>Index: util.c<br>===================================================================<br>RCS file: /var/dvblast-2.2/Attic/util.c,v<br>retrieving revision 1.1.2.1.24.2<br>retrieving revision 1.1.2.1.24.1.44.2<br>
diff -u -r1.1.2.1.24.2 -r1.1.2.1.24.1.44.2<br>--- util.c 26 Sep 2013 16:16:13 -0000 1.1.2.1.24.2<br>+++ util.c 26 Sep 2013 16:18:06 -0000 1.1.2.1.24.1.44.2<br>@@ -65,6 +65,8 @@<br> {<br> i_syslog = 0;<br> closelog();<br>
+<br>+ unlink (epg_file_tmp);<br> }<br> <br> /*****************************************************************************<br>@@ -176,6 +178,23 @@<br> }<br> <br> /*****************************************************************************<br>
+ * msg_Epg<br>+ *****************************************************************************/<br>+void msg_Epg( void *_unused, const char *psz_format, ... )<br>+{<br>+ FILE * pFile;<br>+ va_list args;<br>+<br>+ pFile = fopen (epg_file_tmp,"a");<br>
+<br>+ va_start( args, psz_format );<br>+ vfprintf( pFile, psz_format, args );<br>+<br>+ fclose (pFile);<br>+<br>+}<br>+<br>+/*****************************************************************************<br> * streq<br>
*****************************************************************************/<br> inline bool streq(char *a, char *b) {<br><br></div>