summaryrefslogtreecommitdiff
path: root/avmedia
diff options
context:
space:
mode:
authorMinh Ngo <nlminhtl@gmail.com>2013-08-06 16:32:59 +0300
committerMichael Meeks <michael.meeks@suse.com>2013-08-21 10:54:52 +0100
commitfb89c0c579f70734cd5c0f72316a77ce1b0b3cad (patch)
treec8965c67e038e607d08a3fe6c56f3f8d8523f308 /avmedia
parentd160838b234c75455e26a91c65135cf1381e507a (diff)
Porting all VLC API for loading by wrappers
Change-Id: Idafdf7a43675efd74b6a198178c79342fbcee3d0
Diffstat (limited to 'avmedia')
-rw-r--r--avmedia/Library_avmediavlc.mk1
-rw-r--r--avmedia/source/vlc/vlccommon.hxx3
-rw-r--r--avmedia/source/vlc/vlcframegrabber.cxx26
-rw-r--r--avmedia/source/vlc/vlcplayer.cxx25
-rw-r--r--avmedia/source/vlc/vlcplayer.hxx5
-rw-r--r--avmedia/source/vlc/wrapper/EventManager.cxx144
-rw-r--r--avmedia/source/vlc/wrapper/EventManager.hxx50
7 files changed, 215 insertions, 39 deletions
diff --git a/avmedia/Library_avmediavlc.mk b/avmedia/Library_avmediavlc.mk
index 0f8b0390bef9..5ab91d98759a 100644
--- a/avmedia/Library_avmediavlc.mk
+++ b/avmedia/Library_avmediavlc.mk
@@ -48,6 +48,7 @@ $(eval $(call gb_Library_add_exception_objects,avmediavlc,\
avmedia/source/vlc/wrapper/Instance \
avmedia/source/vlc/wrapper/Media \
avmedia/source/vlc/wrapper/Player \
+ avmedia/source/vlc/wrapper/EventManager \
))
# vim: set noet sw=4 ts=4:
diff --git a/avmedia/source/vlc/vlccommon.hxx b/avmedia/source/vlc/vlccommon.hxx
index 6b8e2caa487f..1bc9fa169b10 100644
--- a/avmedia/source/vlc/vlccommon.hxx
+++ b/avmedia/source/vlc/vlccommon.hxx
@@ -20,9 +20,6 @@
#ifndef _VLCCOMMON_HXX
#define _VLCCOMMON_HXX
-#include <vlc/libvlc.h>
-#include <vlc/libvlc_media.h>
-
#include <osl/mutex.hxx>
#include <tools/stream.hxx>
#include <tools/urlobj.hxx>
diff --git a/avmedia/source/vlc/vlcframegrabber.cxx b/avmedia/source/vlc/vlcframegrabber.cxx
index 4e0eaf92b0f5..4ca6addefd72 100644
--- a/avmedia/source/vlc/vlcframegrabber.cxx
+++ b/avmedia/source/vlc/vlcframegrabber.cxx
@@ -1,3 +1,4 @@
+#include <boost/bind.hpp>
#include <osl/conditn.hxx>
#include <vcl/graph.hxx>
#include <vcl/bmpacc.hxx>
@@ -11,8 +12,7 @@
#include "vlcframegrabber.hxx"
#include "vlcplayer.hxx"
#include "wrapper/Player.hxx"
-
-#include <vlc/libvlc_events.h>
+#include "wrapper/EventManager.hxx"
using namespace ::com::sun::star;
@@ -30,26 +30,12 @@ SAL_CALL VLCFrameGrabber::VLCFrameGrabber( VLC::Player& player, const rtl::OUStr
{
}
-namespace
-{
- void EventHandler( const libvlc_event_t *evemt, void *pData )
- {
- switch ( evemt->type )
- {
- case libvlc_MediaPlayerPaused:
- osl::Condition *condition = static_cast<osl::Condition*>( pData );
- condition->set();
- break;
- }
- }
-}
-
::uno::Reference< css::graphic::XGraphic > SAL_CALL VLCFrameGrabber::grabFrame( double fMediaTime )
{
osl::Condition condition;
- libvlc_event_manager_t *manager = libvlc_media_player_event_manager( mPlayer );
- libvlc_event_attach( manager, libvlc_MediaPlayerPaused, EventHandler, &condition );
+ VLC::EventManager manager( mPlayer );
+ manager.onPaused(boost::bind(&osl::Condition::set, &condition));
mPlayer.setMute( true );
@@ -69,7 +55,7 @@ namespace
std::cerr << "Couldn't grab frame" << std::endl;
mPlayer.setMute( false );
- libvlc_event_detach( manager, libvlc_MediaPlayerPaused, EventHandler, &condition );
+ manager.onPaused();
return ::uno::Reference< css::graphic::XGraphic >();
}
@@ -80,7 +66,7 @@ namespace
mPlayer.setMute( false );
mPlayer.stop();
- libvlc_event_detach( manager, libvlc_MediaPlayerPaused, EventHandler, &condition );
+ manager.onPaused();
rtl::OUString url;
utl::LocalFileHelper::ConvertPhysicalNameToURL( fileName, url );
diff --git a/avmedia/source/vlc/vlcplayer.cxx b/avmedia/source/vlc/vlcplayer.cxx
index 2bf15fbd4321..ba304f748a0e 100644
--- a/avmedia/source/vlc/vlcplayer.cxx
+++ b/avmedia/source/vlc/vlcplayer.cxx
@@ -1,3 +1,4 @@
+#include <boost/bind.hpp>
#include <vcl/syschild.hxx>
#include <vcl/sysdata.hxx>
@@ -28,6 +29,7 @@ VLCPlayer::VLCPlayer( const rtl::OUString& url )
, mInstance( VLC_ARGS )
, mMedia( url, mInstance )
, mPlayer( mMedia )
+ , mEventManager( mPlayer )
, mUrl( url )
, mPlaybackLoop( false )
{
@@ -86,20 +88,10 @@ double SAL_CALL VLCPlayer::getRate()
return mPlayer.getRate();
}
-namespace
+void VLCPlayer::replay()
{
- void EventHandler( const libvlc_event_t *evemt, void *pData )
- {
- switch (evemt->type)
- {
- case libvlc_MediaPlayerEndReached:
- VLC::Player& player = *static_cast< VLC::Player* >( pData );
-
- player.stop();
- player.play();
- break;
- }
- }
+ mPlayer.stop();
+ mPlayer.play();
}
void SAL_CALL VLCPlayer::setPlaybackLoop( ::sal_Bool bSet )
@@ -107,12 +99,13 @@ void SAL_CALL VLCPlayer::setPlaybackLoop( ::sal_Bool bSet )
::osl::MutexGuard aGuard(m_aMutex);
mPlaybackLoop = bSet;
- libvlc_event_manager_t *manager = libvlc_media_player_event_manager( mPlayer );
+ //TODO: Fix it
+ return;
if ( bSet )
- libvlc_event_attach( manager, libvlc_MediaPlayerEndReached, EventHandler, &mPlayer );
+ mEventManager.onEndReached(boost::bind(&VLCPlayer::replay, this));
else
- libvlc_event_detach( manager, libvlc_MediaPlayerEndReached, EventHandler, &mPlayer );
+ mEventManager.onEndReached();
}
::sal_Bool SAL_CALL VLCPlayer::isPlaybackLoop()
diff --git a/avmedia/source/vlc/vlcplayer.hxx b/avmedia/source/vlc/vlcplayer.hxx
index 230b21906781..3723f16c3e9b 100644
--- a/avmedia/source/vlc/vlcplayer.hxx
+++ b/avmedia/source/vlc/vlcplayer.hxx
@@ -30,6 +30,7 @@
#include "wrapper/Instance.hxx"
#include "wrapper/Media.hxx"
#include "wrapper/Player.hxx"
+#include "wrapper/EventManager.hxx"
namespace avmedia {
namespace vlc {
@@ -43,6 +44,7 @@ class VLCPlayer : public ::cppu::BaseMutex,
VLC::Instance mInstance;
VLC::Media mMedia;
VLC::Player mPlayer;
+ VLC::EventManager mEventManager;
const rtl::OUString mUrl;
bool mPlaybackLoop;
public:
@@ -70,6 +72,9 @@ public:
::rtl::OUString SAL_CALL getImplementationName();
::sal_Bool SAL_CALL supportsService( const ::rtl::OUString& serviceName );
::com::sun::star::uno::Sequence< ::rtl::OUString > SAL_CALL getSupportedServiceNames();
+
+private:
+ void replay();
};
}
diff --git a/avmedia/source/vlc/wrapper/EventManager.cxx b/avmedia/source/vlc/wrapper/EventManager.cxx
new file mode 100644
index 000000000000..6ae5bc990196
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/EventManager.cxx
@@ -0,0 +1,144 @@
+#include "EventManager.hxx"
+#include "SymbolLoader.hxx"
+
+typedef struct libvlc_event_t
+{
+ int type;
+ void *p_obj;
+ union
+ {
+ struct
+ {
+ void *p;
+ } media_meta_changed;
+ } u;
+} libvlc_event_t;
+
+typedef int libvlc_event_type_t;
+typedef void ( *libvlc_callback_t ) ( const struct libvlc_event_t *, void * );
+
+namespace VLC
+{
+ namespace
+ {
+ enum libvlc_event_e {
+ libvlc_MediaMetaChanged=0,
+ libvlc_MediaSubItemAdded,
+ libvlc_MediaDurationChanged,
+ libvlc_MediaParsedChanged,
+ libvlc_MediaFreed,
+ libvlc_MediaStateChanged,
+
+ libvlc_MediaPlayerMediaChanged=0x100,
+ libvlc_MediaPlayerNothingSpecial,
+ libvlc_MediaPlayerOpening,
+ libvlc_MediaPlayerBuffering,
+ libvlc_MediaPlayerPlaying,
+ libvlc_MediaPlayerPaused,
+ libvlc_MediaPlayerStopped,
+ libvlc_MediaPlayerForward,
+ libvlc_MediaPlayerBackward,
+ libvlc_MediaPlayerEndReached,
+ libvlc_MediaPlayerEncounteredError,
+ libvlc_MediaPlayerTimeChanged,
+ libvlc_MediaPlayerPositionChanged,
+ libvlc_MediaPlayerSeekableChanged,
+ libvlc_MediaPlayerPausableChanged,
+ libvlc_MediaPlayerTitleChanged,
+ libvlc_MediaPlayerSnapshotTaken,
+ libvlc_MediaPlayerLengthChanged,
+ libvlc_MediaPlayerVout,
+
+ libvlc_MediaListItemAdded=0x200,
+ libvlc_MediaListWillAddItem,
+ libvlc_MediaListItemDeleted,
+ libvlc_MediaListWillDeleteItem,
+
+ libvlc_MediaListViewItemAdded=0x300,
+ libvlc_MediaListViewWillAddItem,
+ libvlc_MediaListViewItemDeleted,
+ libvlc_MediaListViewWillDeleteItem,
+
+ libvlc_MediaListPlayerPlayed=0x400,
+ libvlc_MediaListPlayerNextItemSet,
+ libvlc_MediaListPlayerStopped,
+
+ libvlc_MediaDiscovererStarted=0x500,
+ libvlc_MediaDiscovererEnded,
+
+ libvlc_VlmMediaAdded=0x600,
+ libvlc_VlmMediaRemoved,
+ libvlc_VlmMediaChanged,
+ libvlc_VlmMediaInstanceStarted,
+ libvlc_VlmMediaInstanceStopped,
+ libvlc_VlmMediaInstanceStatusInit,
+ libvlc_VlmMediaInstanceStatusOpening,
+ libvlc_VlmMediaInstanceStatusPlaying,
+ libvlc_VlmMediaInstanceStatusPause,
+ libvlc_VlmMediaInstanceStatusEnd,
+ libvlc_VlmMediaInstanceStatusError
+ };
+
+ 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 );
+
+ ApiMap VLC_EVENT_MANAGER_API[] =
+ {
+ SYM_MAP( libvlc_media_player_event_manager ),
+ SYM_MAP( libvlc_event_attach ),
+ SYM_MAP( libvlc_event_detach )
+ };
+ }
+
+void EventManagerEventHandler( const libvlc_event_t *event, void *pData )
+{
+ EventManager *instance = static_cast<EventManager*>( pData );
+ switch ( event->type )
+ {
+ case libvlc_MediaPlayerPaused:
+ instance->mOnPaused();
+ break;
+ case libvlc_MediaPlayerEndReached:
+ instance->mOnEndReached();
+ break;
+ }
+}
+
+EventManager::EventManager(VLC::Player& player)
+{
+ InitApiMap( VLC_EVENT_MANAGER_API );
+ mManager = libvlc_media_player_event_manager( player );
+}
+
+EventManager::~EventManager()
+{
+}
+
+void EventManager::registerSignal(int signal, const Callback& callback)
+{
+ if (callback.empty())
+ libvlc_event_detach( mManager, signal, EventManagerEventHandler, this );
+ else
+ libvlc_event_attach( mManager, signal, EventManagerEventHandler, 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);
+}
+
+} \ No newline at end of file
diff --git a/avmedia/source/vlc/wrapper/EventManager.hxx b/avmedia/source/vlc/wrapper/EventManager.hxx
new file mode 100644
index 000000000000..9143b5551c17
--- /dev/null
+++ b/avmedia/source/vlc/wrapper/EventManager.hxx
@@ -0,0 +1,50 @@
+/* -*- 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/.
+ *
+ * This file incorporates work covered by the following license notice:
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed
+ * with this work for additional information regarding copyright
+ * ownership. The ASF licenses this file to you under the Apache
+ * License, Version 2.0 (the "License"); you may not use this file
+ * except in compliance with the License. You may obtain a copy of
+ * the License at http://www.apache.org/licenses/LICENSE-2.0 .
+ */
+#ifndef _WRAPPER_EVENT_MANAGER_HXX
+#define _WRAPPER_EVENT_MANAGER_HXX
+#include <boost/function.hpp>
+#include "Player.hxx"
+
+struct libvlc_event_manager_t;
+struct libvlc_event_t;
+namespace VLC
+{
+ class EventManager
+ {
+ friend void EventManagerEventHandler( const libvlc_event_t *event, void *pData );
+ public:
+ typedef boost::function<void()> Callback;
+
+ EventManager(VLC::Player& player);
+ virtual ~EventManager();
+
+ void onPaused(const Callback& callback = Callback());
+ void onEndReached(const Callback& callback = Callback());
+
+ private:
+ libvlc_event_manager_t *mManager;
+ boost::function<void()> mOnPaused;
+ boost::function<void()> mOnEndReached;
+
+ void registerSignal(int signal, const Callback& callback);
+ };
+}
+
+#endif
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file