+ if( b_add )
+ {
+ vlc_epg_event_t *p_copy = malloc( sizeof(vlc_epg_event_t) );
+ if( !p_copy )
+ break;
+ memset( p_copy, 0, sizeof(vlc_epg_event_t) );
+ p_copy->i_start = p_evt->i_start;
+ p_copy->i_duration = p_evt->i_duration;
+ p_copy->psz_name = p_evt->psz_name ? strdup( p_evt->psz_name ) : NULL;
+ p_copy->psz_short_description = p_evt->psz_short_description ? strdup( p_evt->psz_short_description ) : NULL;
+ p_copy->psz_description = p_evt->psz_description ? strdup( p_evt->psz_description ) : NULL;
+ TAB_INSERT( p_dst->i_event, p_dst->pp_event, p_copy, j );
+ }
+ }
+ /* Update current */
+ vlc_epg_SetCurrent( p_dst, p_src->p_current ? p_src->p_current->i_start : -1 );
+
+ /* Keep only 1 old event */
+ if( p_dst->p_current )
+ {
+ while( p_dst->i_event > 1 && p_dst->pp_event[0] != p_dst->p_current && p_dst->pp_event[1] != p_dst->p_current )
+ TAB_REMOVE( p_dst->i_event, p_dst->pp_event, p_dst->pp_event[0] );
+ }
+}
+
+static void EsOutProgramEpg( es_out_t *out, int i_group, vlc_epg_t *p_epg )
+{
+ es_out_sys_t *p_sys = out->p_sys;
+ input_thread_t *p_input = p_sys->p_input;
+ es_out_pgrm_t *p_pgrm = NULL;
+ char *psz_cat;
+ int i;
+
+ /* Find program */
+ for( i = 0; i < p_sys->i_pgrm; i++ )
+ {
+ if( p_sys->pgrm[i]->i_id == i_group )
+ {
+ p_pgrm = p_sys->pgrm[i];
+ break;
+ }
+ }
+ if( p_pgrm == NULL )
+ p_pgrm = EsOutProgramAdd( out, i_group ); /* Create it */
+
+ /* Merge EPG */
+ if( !p_pgrm->p_epg )
+ p_pgrm->p_epg = vlc_epg_New( p_pgrm->psz_name );
+ vlc_epg_Merge( p_pgrm->p_epg, p_epg );
+
+ /* Update info */
+ psz_cat = EsOutProgramGetMetaName( p_pgrm );
+#ifdef HAVE_LOCALTIME_R
+ char *psz_epg;
+ if( asprintf( &psz_epg, "EPG %s", psz_cat ) == -1 )
+ psz_epg = NULL;
+ input_Control( p_input, INPUT_DEL_INFO, psz_epg, NULL );
+ msg_Dbg( p_input, "EsOutProgramEpg: number=%d name=%s", i_group, p_pgrm->p_epg->psz_name );
+ for( i = 0; i < p_pgrm->p_epg->i_event; i++ )
+ {
+ const vlc_epg_event_t *p_evt = p_pgrm->p_epg->pp_event[i];
+ time_t t_start = (time_t)p_evt->i_start;
+ struct tm tm_start;
+ char psz_start[128];
+
+ localtime_r( &t_start, &tm_start );
+
+ snprintf( psz_start, sizeof(psz_start), "%2.2d:%2.2d:%2.2d", tm_start.tm_hour, tm_start.tm_min, tm_start.tm_sec );
+ if( p_evt->psz_short_description || p_evt->psz_description )
+ input_Control( p_input, INPUT_ADD_INFO, psz_epg, psz_start, "%s (%2.2d:%2.2d) - %s",
+ p_evt->psz_name,
+ p_evt->i_duration/60/60, (p_evt->i_duration/60)%60,
+ p_evt->psz_short_description ? p_evt->psz_short_description : p_evt->psz_description );
+ else
+ input_Control( p_input, INPUT_ADD_INFO, psz_epg, psz_start, "%s (%2.2d:%2.2d)",
+ p_evt->psz_name,
+ p_evt->i_duration/60/60, (p_evt->i_duration/60)%60 );