From 931decd0e908dae1b3780c56a58ca1f4d858729c Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 12 Oct 2017 23:35:40 +0200 Subject: Move vlc/wrapper include files to common include directory ...that are inclued from both vlc and vlc/wrapper. Change done in preparation of loplugin:inlcudeform. Change-Id: Ic7dc08b93d8a33b21dc64dfc0bfbe3952039f05b Reviewed-on: https://gerrit.libreoffice.org/43556 Tested-by: Jenkins Reviewed-by: Stephan Bergmann --- avmedia/source/vlc/inc/wrapper/Common.hxx | 31 ++++++++ avmedia/source/vlc/inc/wrapper/EventHandler.hxx | 45 ++++++++++++ avmedia/source/vlc/inc/wrapper/EventManager.hxx | 58 +++++++++++++++ avmedia/source/vlc/inc/wrapper/Instance.hxx | 43 +++++++++++ avmedia/source/vlc/inc/wrapper/Media.hxx | 49 +++++++++++++ avmedia/source/vlc/inc/wrapper/Player.hxx | 81 +++++++++++++++++++++ avmedia/source/vlc/inc/wrapper/ThreadsafeQueue.hxx | 83 ++++++++++++++++++++++ avmedia/source/vlc/inc/wrapper/Wrapper.hxx | 22 ++++++ 8 files changed, 412 insertions(+) create mode 100644 avmedia/source/vlc/inc/wrapper/Common.hxx create mode 100644 avmedia/source/vlc/inc/wrapper/EventHandler.hxx create mode 100644 avmedia/source/vlc/inc/wrapper/EventManager.hxx create mode 100644 avmedia/source/vlc/inc/wrapper/Instance.hxx create mode 100644 avmedia/source/vlc/inc/wrapper/Media.hxx create mode 100644 avmedia/source/vlc/inc/wrapper/Player.hxx create mode 100644 avmedia/source/vlc/inc/wrapper/ThreadsafeQueue.hxx create mode 100644 avmedia/source/vlc/inc/wrapper/Wrapper.hxx (limited to 'avmedia/source/vlc/inc') diff --git a/avmedia/source/vlc/inc/wrapper/Common.hxx b/avmedia/source/vlc/inc/wrapper/Common.hxx new file mode 100644 index 000000000000..6935eca96bc7 --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/Common.hxx @@ -0,0 +1,31 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_COMMON_HXX +#define INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_COMMON_HXX + +namespace avmedia +{ +namespace vlc +{ +namespace wrapper +{ + class Common + { + public: + static bool LoadSymbols(); + static const char* Version(); + static const char* LastErrorMessage(); + }; +} +} +} + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ \ No newline at end of file diff --git a/avmedia/source/vlc/inc/wrapper/EventHandler.hxx b/avmedia/source/vlc/inc/wrapper/EventHandler.hxx new file mode 100644 index 000000000000..0315b809507d --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/EventHandler.hxx @@ -0,0 +1,45 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_EVENTHANDLER_HXX +#define INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_EVENTHANDLER_HXX + +#include +#include +#include "wrapper/ThreadsafeQueue.hxx" + +namespace avmedia +{ +namespace vlc +{ +namespace wrapper +{ + class EventHandler : public ::osl::Thread + { + public: + EventHandler(const EventHandler&) = delete; + const EventHandler& operator=(const EventHandler&) = delete; + + EventHandler(); + void stop(); + + protected: + virtual void SAL_CALL run() override; + + public: + typedef std::function< void() > TCallback; + ThreadsafeQueue< TCallback > mCallbackQueue; + }; +} +} +} + +#endif // INCLUDED_AVMEDIA_SOURCE_VLC_WRAPPER_EVENTHANDLER_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/avmedia/source/vlc/inc/wrapper/EventManager.hxx b/avmedia/source/vlc/inc/wrapper/EventManager.hxx new file mode 100644 index 000000000000..eb4f2980284a --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/EventManager.hxx @@ -0,0 +1,58 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_EVENTMANAGER_HXX +#define INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_EVENTMANAGER_HXX + +#include +#include "wrapper/Player.hxx" + +struct libvlc_event_manager_t; +struct libvlc_event_t; + +namespace avmedia +{ +namespace vlc +{ +namespace wrapper +{ + class EventHandler; + class EventManager + { + + public: + EventManager(const EventManager&) = delete; + const EventManager& operator=(const EventManager&) = delete; + + static bool LoadSymbols(); + typedef std::function Callback; + + EventManager( Player& player, EventHandler& eh ); + + void onPaused( const Callback& callback = Callback() ); + void onEndReached( const Callback& callback = Callback() ); + + private: + EventHandler& mEventHandler; + typedef std::function< void() > TCallback; + libvlc_event_manager_t *mManager; + TCallback mOnPaused; + TCallback mOnEndReached; + + void registerSignal( int signal, const Callback& callback ); + + static void Handler( const libvlc_event_t *event, void *pData ); + }; +} +} +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/avmedia/source/vlc/inc/wrapper/Instance.hxx b/avmedia/source/vlc/inc/wrapper/Instance.hxx new file mode 100644 index 000000000000..f2e8c9c8ef0e --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/Instance.hxx @@ -0,0 +1,43 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_INSTANCE_HXX +#define INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_INSTANCE_HXX + +struct libvlc_instance_t; + +namespace avmedia +{ +namespace vlc +{ +namespace wrapper +{ + class Instance + { + public: + static bool LoadSymbols(); + Instance( int argc, const char * const argv[] ); + Instance( const Instance& other ); + Instance& operator=( const Instance& other ); + virtual ~Instance(); + + operator libvlc_instance_t*() + { + return mInstance; + } + + private: + libvlc_instance_t *mInstance; + }; +} +} +} + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/avmedia/source/vlc/inc/wrapper/Media.hxx b/avmedia/source/vlc/inc/wrapper/Media.hxx new file mode 100644 index 000000000000..77d17118f2f7 --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/Media.hxx @@ -0,0 +1,49 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_MEDIA_HXX +#define INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_MEDIA_HXX + +struct libvlc_media_t; + +namespace rtl { class OUString; } + +namespace avmedia +{ +namespace vlc +{ +namespace wrapper +{ + class Instance; + class Media + { + public: + static bool LoadSymbols(); + Media( const rtl::OUString& url, Instance& instance ); + Media( const Media& other ); + Media& operator=( const Media& other ); + + int getDuration() const; + + virtual ~Media(); + + operator libvlc_media_t*() + { + return mMedia; + } + + private: + libvlc_media_t *mMedia; + }; +} +} +} + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/avmedia/source/vlc/inc/wrapper/Player.hxx b/avmedia/source/vlc/inc/wrapper/Player.hxx new file mode 100644 index 000000000000..2e2921682260 --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/Player.hxx @@ -0,0 +1,81 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_PLAYER_HXX +#define INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_PLAYER_HXX +#if defined UNX +# include +#endif + +struct libvlc_media_player_t; + +namespace rtl +{ + class OUString; +} + +namespace avmedia +{ +namespace vlc +{ +namespace wrapper +{ + class Media; + class Player + { + public: + static bool LoadSymbols(); + explicit Player( Media& media ); + Player( const Player& other ); + Player& operator=( const Player& other ); + virtual ~Player(); + + bool play(); + void pause(); + void stop(); + void setTime( int time ); + int getTime() const; + bool isPlaying() const; + + float getRate() const; + + void setVolume( int volume ); + int getVolume() const; + + void setMute( bool mute); + bool getMute() const; + + void setWindow( intptr_t id ); + + bool takeSnapshot(const rtl::OUString& file); + + bool hasVout() const; + + void setScale( float factor ); + void setVideoSize( unsigned width, unsigned height ); + + unsigned getWidth() const; + unsigned getHeight() const; + + operator libvlc_media_player_t*() + { + return mPlayer; + } + + void setMouseHandling(bool flag); + private: + libvlc_media_player_t *mPlayer; + }; +} +} +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/avmedia/source/vlc/inc/wrapper/ThreadsafeQueue.hxx b/avmedia/source/vlc/inc/wrapper/ThreadsafeQueue.hxx new file mode 100644 index 000000000000..f76a08fda276 --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/ThreadsafeQueue.hxx @@ -0,0 +1,83 @@ +/* -*- 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 INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_THREADSAFEQUEUE_HXX +#define INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_THREADSAFEQUEUE_HXX +#include +#include +#include +#include + +namespace avmedia +{ +namespace vlc +{ +namespace wrapper +{ +template +class ThreadsafeQueue +{ +public: + ThreadsafeQueue(const ThreadsafeQueue&) = delete; + const ThreadsafeQueue& operator=(const ThreadsafeQueue&) = delete; + + ThreadsafeQueue(); + + void push( const T& data ); + void pop( T& data ); + +private: + std::queue< T > mQueue; + mutable ::osl::Mutex mMutex; + ::osl::Condition mCondition; +}; + +template +ThreadsafeQueue::ThreadsafeQueue() +{ +} + +template +void ThreadsafeQueue::push( const T& data ) +{ + ::osl::MutexGuard guard( mMutex ); + mQueue.push( data ); + mMutex.release(); + mCondition.set(); +} + +template +void ThreadsafeQueue::pop( T& data ) +{ + mCondition.wait(); + ::osl::MutexGuard guard( mMutex ); + while ( mQueue.empty() ) + { + mMutex.release(); + mCondition.wait(); + mMutex.acquire(); + } + data = mQueue.front(); + mQueue.pop(); +} +} +} +} + +#endif +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/avmedia/source/vlc/inc/wrapper/Wrapper.hxx b/avmedia/source/vlc/inc/wrapper/Wrapper.hxx new file mode 100644 index 000000000000..a2c6a0c5eebc --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/Wrapper.hxx @@ -0,0 +1,22 @@ +/* -*- 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/. + */ + +#ifndef INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_WRAPPER_HXX +#define INCLUDED_AVMEDIA_SOURCE_VLC_INC_WRAPPER_WRAPPER_HXX + +#include "wrapper/Common.hxx" +#include "wrapper/EventHandler.hxx" +#include "wrapper/EventManager.hxx" +#include "wrapper/Instance.hxx" +#include "wrapper/Media.hxx" +#include "wrapper/Player.hxx" + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit