[vlc-devel] [PATCH 2/2] libvlc: add event libvlc_MediaPlayerESChanged

Felix Abecassis felix.abecassis at gmail.com
Wed Jul 16 14:11:34 CEST 2014


2014-07-16 13:43 GMT+02:00 Rémi Denis-Courmont <remi at remlab.net>:
> Le 2014-07-16 14:06, Felix Abecassis a écrit :
>
>> ---
>>  include/vlc/libvlc_events.h |  6 ++++++
>>  lib/event.c                 |  1 +
>>  lib/media_player.c          | 21 +++++++++++++++++++++
>>  3 files changed, 28 insertions(+)
>>
>> diff --git a/include/vlc/libvlc_events.h b/include/vlc/libvlc_events.h
>> index f268fb5..1d4f781 100644
>> --- a/include/vlc/libvlc_events.h
>> +++ b/include/vlc/libvlc_events.h
>> @@ -74,6 +74,7 @@ enum libvlc_event_e {
>>      libvlc_MediaPlayerLengthChanged,
>>      libvlc_MediaPlayerVout,
>>      libvlc_MediaPlayerScrambledChanged,
>> +    libvlc_MediaPlayerESChanged,
>>
>>      libvlc_MediaListItemAdded=0x200,
>>      libvlc_MediaListWillAddItem,
>> @@ -230,6 +231,11 @@ typedef struct libvlc_event_t
>>          {
>>              libvlc_media_t * new_media;
>>          } media_player_media_changed;
>> +
>> +        struct
>> +        {
>> +            libvlc_track_type_t i_type;
>> +        } media_player_es_changed;
>
>
> That does not seem very useful. The callback would almost certainly need to
> know if the ES was added, changed  or removed, and since there may be more
> than one ES of a given type, the unique ID.
>

If we want to provide only one additional piece of information for
this event, I think we should provide the ES type instead of the ID.
This way we immediately know which list we have to fetch again. But
this is open to discussion.
If we want to provide ES type, ID and operation type, it would be
awkward to add more variables; I've suggested different options when
discussing the previous submitted patch for the new libVLC event.

>
>>      } u; /**< Type-dependent event description */
>>  } libvlc_event_t;
>>
>> diff --git a/lib/event.c b/lib/event.c
>> index aa285f9..67c0f15 100644
>> --- a/lib/event.c
>> +++ b/lib/event.c
>> @@ -281,6 +281,7 @@ static const event_name_t event_list[] = {
>>      DEF(MediaPlayerLengthChanged)
>>      DEF(MediaPlayerVout)
>>      DEF(MediaPlayerScrambledChanged)
>> +    DEF(MediaPlayerESChanged)
>>
>>      DEF(MediaListItemAdded)
>>      DEF(MediaListWillAddItem)
>> diff --git a/lib/media_player.c b/lib/media_player.c
>> index b31a832..a3c5ede 100644
>> --- a/lib/media_player.c
>> +++ b/lib/media_player.c
>> @@ -343,6 +343,26 @@ input_event_changed( vlc_object_t * p_this, char
>> const * psz_cmd,
>>          event.u.media_player_vout.new_count = i_vout;
>>          libvlc_event_send( p_mi->p_event_manager, &event );
>>      }
>> +    else if( newval.i_int == INPUT_EVENT_ES )
>> +    {
>> +        event.type = libvlc_MediaPlayerESChanged;
>> +        switch ( var_GetInteger( p_input, "es-type" ) )
>
>
> What warrants that the es-type variable wwas not overriden by another
> pending ES change?
>

Is this possible? If this is the case, we might have a similar issue
with INPUT_EVENT_STATE and the "state" variable.

>
>> +        {
>> +        case VIDEO_ES:
>> +            event.u.media_player_es_changed.i_type = libvlc_track_video;
>> +            break;
>> +        case AUDIO_ES:
>> +            event.u.media_player_es_changed.i_type = libvlc_track_audio;
>> +            break;
>> +        case SPU_ES:
>> +            event.u.media_player_es_changed.i_type = libvlc_track_text;
>> +            break;
>> +        default:
>> +            event.u.media_player_es_changed.i_type =
>> libvlc_track_unknown;
>> +            break;
>> +        }
>> +        libvlc_event_send( p_mi->p_event_manager, &event );
>> +    }
>>
>>      return VLC_SUCCESS;
>>  }
>> @@ -538,6 +558,7 @@ libvlc_media_player_new( libvlc_instance_t *instance )
>>
>>      register_event(mp, Vout);
>>      register_event(mp, ScrambledChanged);
>> +    register_event(mp, ESChanged);
>>
>>      /* Snapshot initialization */
>>      register_event(mp, SnapshotTaken);
>
>
> --
> Rémi Denis-Courmont
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel



-- 
Félix Abecassis
http://felix.abecassis.me



More information about the vlc-devel mailing list