summaryrefslogtreecommitdiffstats
path: root/avmedia/source/vlc/wrapper/EventManager.cxx
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-27 16:51:28 +0000
commit940b4d1848e8c70ab7642901a68594e8016caffc (patch)
treeeb72f344ee6c3d9b80a7ecc079ea79e9fba8676d /avmedia/source/vlc/wrapper/EventManager.cxx
parentInitial commit. (diff)
downloadlibreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.tar.xz
libreoffice-940b4d1848e8c70ab7642901a68594e8016caffc.zip
Adding upstream version 1:7.0.4.upstream/1%7.0.4upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'avmedia/source/vlc/wrapper/EventManager.cxx')
-rw-r--r--avmedia/source/vlc/wrapper/EventManager.cxx84
1 files changed, 84 insertions, 0 deletions
diff --git a/avmedia/source/vlc/wrapper/EventManager.cxx b/avmedia/source/vlc/wrapper/EventManager.cxx
new file mode 100644
index 000000000..27e56603e
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/EventManager.cxx
@@ -0,0 +1,84 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+#include <wrapper/EventManager.hxx>
+#include "SymbolLoader.hxx"
+#include <wrapper/EventHandler.hxx>
+#include "Types.hxx"
+
+namespace
+{
+ libvlc_event_manager_t* ( *libvlc_media_player_event_manager ) ( libvlc_media_player_t *p_mi );
+ int ( *libvlc_event_attach ) ( libvlc_event_manager_t *p_event_manager,
+ libvlc_event_type_t i_event_type,
+ libvlc_callback_t f_callback,
+ void *user_data );
+ void ( *libvlc_event_detach ) ( libvlc_event_manager_t *p_event_manager,
+ libvlc_event_type_t i_event_type,
+ libvlc_callback_t f_callback,
+ void *p_user_data );
+}
+
+namespace avmedia::vlc::wrapper
+{
+void EventManager::Handler( const libvlc_event_t *event, void *pData )
+{
+ EventManager *instance = static_cast<EventManager*>( pData );
+ switch ( event->type )
+ {
+ case libvlc_MediaPlayerPaused:
+ instance->mEventHandler.mCallbackQueue.push( instance->mOnPaused );
+ break;
+ case libvlc_MediaPlayerEndReached:
+ instance->mEventHandler.mCallbackQueue.push( instance->mOnEndReached );
+ break;
+ }
+}
+
+bool EventManager::LoadSymbols()
+{
+ static ApiMap const VLC_EVENT_MANAGER_API[] =
+ {
+ SYM_MAP( libvlc_media_player_event_manager ),
+ SYM_MAP( libvlc_event_attach ),
+ SYM_MAP( libvlc_event_detach )
+ };
+
+ return InitApiMap( VLC_EVENT_MANAGER_API );
+}
+
+EventManager::EventManager( Player& player, EventHandler& eh )
+ : mEventHandler( eh )
+ , mManager( libvlc_media_player_event_manager( player ) )
+{
+
+}
+
+void EventManager::registerSignal( int signal, const Callback& callback )
+{
+ if ( !callback )
+ libvlc_event_detach( mManager, signal, Handler, this );
+ else
+ libvlc_event_attach( mManager, signal, Handler, this );
+}
+
+void EventManager::onPaused( const EventManager::Callback& callback )
+{
+ mOnPaused = callback;
+ registerSignal( libvlc_MediaPlayerPaused, callback );
+}
+
+void EventManager::onEndReached( const Callback& callback )
+{
+ mOnEndReached = callback;
+ registerSignal( libvlc_MediaPlayerEndReached, callback );
+}
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */