[vlc-devel] [PATCH] Add mappings for some new libvlc events

Hugo Beauzée-Luyssen hugo at beauzee.fr
Tue Dec 15 10:49:31 CET 2015


On 12/14/2015 11:43 PM, Daniel Amm wrote:
>>> On Mon, Dec 14, 2015, at 08:03 PM, Daniel Amm wrote:
>>>> On 12/14/2015 05:59 PM, Daniel Amm wrote:
>>>>> ---
>>>>>    vlcpp/EventManager.hpp | 72
>>> ++++++++++++++++++++++++++++++++++++++++++++++++++
>>>>>    1 file changed, 72 insertions(+)
>>>>>
>>>>> diff --git a/vlcpp/EventManager.hpp b/vlcpp/EventManager.hpp
>>>>> index f15ea46..15ff377 100644
>>>>> --- a/vlcpp/EventManager.hpp
>>>>> +++ b/vlcpp/EventManager.hpp
>>>>> @@ -700,6 +700,78 @@ class MediaPlayerEventManager : public
> EventManager
>>>>>                    (*callback)( e->u.media_player_es_changed.i_type,
>>> e->u.media_player_es_changed.i_id );
>>>>>                });
>>>>>            }
>>>>> +
>>>>> +        /**
>>>>> +         * \brief onCorked Registers an event called when the
> playback
>>> is paused automatically for a higher priority audio stream
>>>>> +         * \param f A std::function<void(void)> (or an equivalent
>>> Callable type)
>>>>> +         */
>>>>> +        template <typename Func>
>>>>> +        RegisteredEvent onCorked( Func&& f )
>>>>> +        {
>>>>> +            return handle( libvlc_MediaPlayerCorked,
>>> std::forward<Func>( f ) );
>>>>> +        }
>>>>> +
>>>>> +        /**
>>>>> +         * \brief onUncorked Registers an event called when the
>>> playback is unpaused automatically after a higher priority audio stream
>>> ends
>>>>> +         * \param f A std::function<void(void)> (or an equivalent
>>> Callable type)
>>>>> +         */
>>>>> +        template <typename Func>
>>>>> +        RegisteredEvent onUncorked( Func&& f )
>>>>> +        {
>>>>> +            return handle( libvlc_MediaPlayerUncorked,
>>> std::forward<Func>( f ) );
>>>>> +        }
>>>>> +
>>>>> +        /**
>>>>> +         * \brief onMuted Registers an event called when the audio
> is
>>> muted
>>>>> +         * \param f A std::function<void(void)> (or an equivalent
>>> Callable type)
>>>>> +         */
>>>>> +        template <typename Func>
>>>>> +        RegisteredEvent onMuted( Func&& f )
>>>>> +        {
>>>>> +            return handle( libvlc_MediaPlayerMuted,
> std::forward<Func>(
>>> f ) );
>>>>> +        }
>>>>> +
>>>>> +        /**
>>>>> +         * \brief onUnmuted Registers an event called when the
> audio is
>>> unmuted
>>>>> +         * \param f A std::function<void(void)> (or an equivalent
>>> Callable type)
>>>>> +         */
>>>>> +        template <typename Func>
>>>>> +        RegisteredEvent onUnmuted( Func&& f )
>>>>> +        {
>>>>> +            return handle( libvlc_MediaPlayerUnmuted,
>>> std::forward<Func>( f ) );
>>>>> +        }
>>>>> +
>>>>> +        /**
>>>>> +         * \brief onAudioVolume Registers an event called when the
>>> current audio volume changes
>>>>> +         * \param f A std::function<void(float)> (or an equivalent
>>> Callable type)
>>>>> +         *          The provided float is the new current audio
> volume
>>> percentage.
>>>>> +         */
>>>>> +        template <typename Func>
>>>>> +        RegisteredEvent onAudioVolume( Func&& f )
>>>>> +        {
>>>>> +            EXPECT_SIGNATURE(void(float));
>>>>> +            return handle( libvlc_MediaPlayerAudioVolume,
>>> std::forward<Func>( f ), [](const libvlc_event_t* e, void* data)
>>>>> +            {
>>>>> +                auto callback = static_cast<DecayPtr<Func>>( data
> );
>>>>> +                (*callback)( e->u.media_player_audio_volume.volume
> );
>>>>> +            });
>>>>> +        }
>>>>> +
>>>>> +        /**
>>>>> +         * \brief onAudioDevice Registers an event called when the
>>> current audio output device changes
>>>>> +         * \param f A std::function<void(std::string)> (or an
>>> equivalent Callable type)
>>>>> +         *          The provided string is the new current volume.
>>>>> +         */
>>>>> +        template <typename Func>
>>>>> +        RegisteredEvent onAudioDevice( Func&& f )
>>>>> +        {
>>>>> +            EXPECT_SIGNATURE(void(std::string));
>>>>> +            return handle( libvlc_MediaPlayerAudioDevice,
>>> std::forward<Func>( f ), [](const libvlc_event_t* e, void* data)
>>>>> +            {
>>>>> +                auto callback = static_cast<DecayPtr<Func>>( data
> );
>>>>> +                (*callback)( e->u.media_player_audio_device.device
> );
>>>>> +            });
>>>>> +        }
>>>>>    #endif
>>>>>    };
>>>>>
>>>>>
>>>> Hi,
>>>>
>>>> If I'm not mistaking, libvlc 2.2 also has corked/uncorked, mute/unmute
> &
>>>> volume changed events.
>>>> You should move the wrappers for those out of the #if
>>>> LIBVLC_VERSION_INT... scope.
>>>> Audio device is 3.0 only indeed.
>>>>
>>>> LGTM otherwise :)
>>>>
>>>> Regards,
>>>
>>> Ooops, you're right. I was thinking that these events were only added in
>>> libvlc 3.
>>> Do we need a check for libvlc 2.2.2 instead?
>>>
>>
>> libvlcpp assumes a libvlc version >= 2.2, so there's no need for a check
>> here.
>>
>> Regards,
>
> Ok, I have sent the corrected patch. But now, libvlcpp assumes libvlc
> version >= 2.2.2, because the events were added in libvlc version 2.2.2,
> right?
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> https://mailman.videolan.org/listinfo/vlc-devel
>
Hm, yeah good point.
Well then I guess I was wrong and this needs a version check... sorry. 
I'll apply your patch and add the check later today, though feel free to 
send an updated version :)

Regards,


More information about the vlc-devel mailing list