Commit 38bef9cd authored by François Cartegnie's avatar François Cartegnie 🤞

libvlc: remove vlc_epg_Merge

parent c0774663
......@@ -266,6 +266,7 @@ libVLC:
* Add libvlc_media_player_add_slave to replace libvlc_video_set_subtitle_file,
working with MRL and supporting also audio slaves
* Add vlc_epg_event_(New|Delete|Duplicate), vlc_epg_AddEvent, vlc_epg_Duplicate
and removes vlc_epg_Merge
Logging
* Support for the SystemD Journal
......
......@@ -110,12 +110,6 @@ VLC_API bool vlc_epg_AddEvent(vlc_epg_t *p_epg, vlc_epg_event_t *p_evt);
*/
VLC_API void vlc_epg_SetCurrent(vlc_epg_t *p_epg, int64_t i_start);
/**
* It merges all the event of \p p_src and \p p_dst into \p p_dst.
*
*/
VLC_API void vlc_epg_Merge(vlc_epg_t *p_dst, const vlc_epg_t *p_src);
/**
* Returns a duplicated \p p_src and its associated events.
*
......
......@@ -678,7 +678,6 @@ vlc_epg_Delete
vlc_epg_Duplicate
vlc_epg_AddEvent
vlc_epg_SetCurrent
vlc_epg_Merge
vlc_fifo_Lock
vlc_fifo_Unlock
vlc_fifo_Signal
......
......@@ -219,83 +219,6 @@ void vlc_epg_SetCurrent( vlc_epg_t *p_epg, int64_t i_start )
}
}
static void vlc_epg_Prune( vlc_epg_t *p_dst )
{
/* 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 )
{
vlc_epg_event_Delete( p_dst->pp_event[0] );
TAB_ERASE( p_dst->i_event, p_dst->pp_event, 0 );
}
}
}
void vlc_epg_Merge( vlc_epg_t *p_dst_epg, const vlc_epg_t *p_src_epg )
{
if( p_src_epg->i_event == 0 )
return;
size_t i_dst=0;
size_t i_src=0;
for( ; i_src < p_src_epg->i_event; i_src++ )
{
bool b_current = ( p_src_epg->pp_event[i_src] == p_src_epg->p_current );
vlc_epg_event_t *p_src = vlc_epg_event_Duplicate( p_src_epg->pp_event[i_src] );
if( unlikely(!p_src) )
return;
const int64_t i_src_end = p_src->i_start + p_src->i_duration;
while( i_dst < p_dst_epg->i_event )
{
vlc_epg_event_t *p_dst = p_dst_epg->pp_event[i_dst];
const int64_t i_dst_end = p_dst->i_start + p_dst->i_duration;
/* appended is before current, no overlap */
if( p_dst->i_start >= i_src_end )
{
break;
}
/* overlap case: appended would contain current's start (or are identical) */
else if( ( p_dst->i_start >= p_src->i_start && p_dst->i_start < i_src_end ) ||
/* overlap case: appended would contain current's end */
( i_dst_end > p_src->i_start && i_dst_end <= i_src_end ) )
{
vlc_epg_event_Delete( p_dst );
if( p_dst_epg->p_current == p_dst )
{
b_current |= true;
p_dst_epg->p_current = NULL;
}
TAB_ERASE( p_dst_epg->i_event, p_dst_epg->pp_event, i_dst );
}
else
{
i_dst++;
}
}
TAB_INSERT( p_dst_epg->i_event, p_dst_epg->pp_event, p_src, i_dst );
if( b_current )
p_dst_epg->p_current = p_src;
}
/* Remaining/trailing ones */
for( ; i_src < p_src_epg->i_event; i_src++ )
{
vlc_epg_event_t *p_src = vlc_epg_event_Duplicate( p_src_epg->pp_event[i_src] );
if( unlikely(!p_src) )
return;
TAB_APPEND( p_dst_epg->i_event, p_dst_epg->pp_event, p_src );
if( p_src_epg->pp_event[i_src] == p_src_epg->p_current )
p_dst_epg->p_current = p_src;
}
vlc_epg_Prune( p_dst_epg );
}
vlc_epg_t * vlc_epg_Duplicate( const vlc_epg_t *p_src )
{
vlc_epg_t *p_epg = vlc_epg_New( p_src->i_id, p_src->i_source_id );
......
......@@ -135,87 +135,5 @@ int main( void )
assert_current( p_epg, "B" );
vlc_epg_Delete( p_epg );
/* Test epg merging */
printf("--test %d\n", i++);
p_epg = vlc_epg_New( 0, 0 );
assert(p_epg);
EPG_ADD( p_epg, 142, 20, "F" );
EPG_ADD( p_epg, 122, 20, "E" );
EPG_ADD( p_epg, 42, 20, "A" );
EPG_ADD( p_epg, 62, 20, "B" );
print_order( p_epg );
vlc_epg_t *p_epg2 = vlc_epg_New( 0, 0 );
assert(p_epg2);
EPG_ADD( p_epg2, 102, 20, "D" );
EPG_ADD( p_epg2, 82, 20, "C" );
print_order( p_epg2 );
vlc_epg_Merge( p_epg, p_epg2 );
printf("merged " );
print_order( p_epg );
assert_events( p_epg, "ABCDEF", 6 );
assert_events( p_epg2, "CD", 2 ); /* should be untouched */
vlc_epg_Delete( p_epg );
vlc_epg_Delete( p_epg2 );
/* Test event overlapping */
printf("--test %d\n", i++);
p_epg = vlc_epg_New( 0, 0 );
assert(p_epg);
EPG_ADD( p_epg, 42, 20, "A" );
EPG_ADD( p_epg, 62, 20, "B" );
EPG_ADD( p_epg, 82, 20, "C" );
EPG_ADD( p_epg, 102, 20, "D" );
print_order( p_epg );
vlc_epg_SetCurrent( p_epg, 62 );
p_epg2 = vlc_epg_New( 0, 0 );
assert(p_epg2);
EPG_ADD( p_epg2, 41, 30, "E" );
print_order( p_epg2 );
vlc_epg_Merge( p_epg, p_epg2 );
printf("merged " );
print_order( p_epg );
assert_events( p_epg, "ECD", 3 );
assert_current( p_epg, "E" );
EPG_ADD( p_epg2, 70, 42, "F" );
print_order( p_epg2 );
vlc_epg_Merge( p_epg, p_epg2 );
printf("merged " );
print_order( p_epg );
assert_events( p_epg, "F", 1 );
/* Test current overwriting */
printf("--test %d\n", i++);
vlc_epg_SetCurrent( p_epg, 70 );
assert_current( p_epg, "F" );
print_order( p_epg );
print_order( p_epg2 );
vlc_epg_Merge( p_epg, p_epg2 );
printf("merged " );
print_order( p_epg );
assert_events( p_epg, "F", 1 );
assert_current( p_epg, "F" );
printf("--test %d\n", i++);
print_order( p_epg );
EPG_ADD( p_epg2, 270, 42, "Z" );
vlc_epg_SetCurrent( p_epg2, 270 );
print_order( p_epg2 );
vlc_epg_Merge( p_epg, p_epg2 );
printf("merged " );
print_order( p_epg );
assert_current( p_epg, "Z" );
vlc_epg_Delete( p_epg );
vlc_epg_Delete( p_epg2 );
return 0;
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment