bump product version to 6.3.0.0.beta1
[LibreOffice.git] / avmedia / source / vlc / wrapper / EventManager.cxx
blob5e7422e60dc5d60cc1a98e71ac4fb274c81d8907
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 */
10 #include <wrapper/EventManager.hxx>
11 #include "SymbolLoader.hxx"
12 #include <wrapper/EventHandler.hxx>
13 #include "Types.hxx"
15 namespace
17 libvlc_event_manager_t* ( *libvlc_media_player_event_manager ) ( libvlc_media_player_t *p_mi );
18 int ( *libvlc_event_attach ) ( libvlc_event_manager_t *p_event_manager,
19 libvlc_event_type_t i_event_type,
20 libvlc_callback_t f_callback,
21 void *user_data );
22 void ( *libvlc_event_detach ) ( libvlc_event_manager_t *p_event_manager,
23 libvlc_event_type_t i_event_type,
24 libvlc_callback_t f_callback,
25 void *p_user_data );
28 namespace avmedia
30 namespace vlc
32 namespace wrapper
34 void EventManager::Handler( const libvlc_event_t *event, void *pData )
36 EventManager *instance = static_cast<EventManager*>( pData );
37 switch ( event->type )
39 case libvlc_MediaPlayerPaused:
40 instance->mEventHandler.mCallbackQueue.push( instance->mOnPaused );
41 break;
42 case libvlc_MediaPlayerEndReached:
43 instance->mEventHandler.mCallbackQueue.push( instance->mOnEndReached );
44 break;
48 bool EventManager::LoadSymbols()
50 static ApiMap const VLC_EVENT_MANAGER_API[] =
52 SYM_MAP( libvlc_media_player_event_manager ),
53 SYM_MAP( libvlc_event_attach ),
54 SYM_MAP( libvlc_event_detach )
57 return InitApiMap( VLC_EVENT_MANAGER_API );
60 EventManager::EventManager( Player& player, EventHandler& eh )
61 : mEventHandler( eh )
62 , mManager( libvlc_media_player_event_manager( player ) )
67 void EventManager::registerSignal( int signal, const Callback& callback )
69 if ( !callback )
70 libvlc_event_detach( mManager, signal, Handler, this );
71 else
72 libvlc_event_attach( mManager, signal, Handler, this );
75 void EventManager::onPaused( const EventManager::Callback& callback )
77 mOnPaused = callback;
78 registerSignal( libvlc_MediaPlayerPaused, callback );
81 void EventManager::onEndReached( const Callback& callback )
83 mOnEndReached = callback;
84 registerSignal( libvlc_MediaPlayerEndReached, callback );
90 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */