diff options
Diffstat (limited to '')
-rw-r--r-- | avmedia/source/vlc/inc/wrapper/Common.hxx | 29 | ||||
-rw-r--r-- | avmedia/source/vlc/inc/wrapper/EventHandler.hxx | 42 | ||||
-rw-r--r-- | avmedia/source/vlc/inc/wrapper/EventManager.hxx | 55 | ||||
-rw-r--r-- | avmedia/source/vlc/inc/wrapper/Instance.hxx | 41 | ||||
-rw-r--r-- | avmedia/source/vlc/inc/wrapper/Media.hxx | 47 | ||||
-rw-r--r-- | avmedia/source/vlc/inc/wrapper/Player.hxx | 73 | ||||
-rw-r--r-- | avmedia/source/vlc/inc/wrapper/ThreadsafeQueue.hxx | 81 | ||||
-rw-r--r-- | avmedia/source/vlc/inc/wrapper/Wrapper.hxx | 19 |
8 files changed, 387 insertions, 0 deletions
diff --git a/avmedia/source/vlc/inc/wrapper/Common.hxx b/avmedia/source/vlc/inc/wrapper/Common.hxx new file mode 100644 index 000000000..c9b7f9682 --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/Common.hxx @@ -0,0 +1,29 @@ +/* -*- 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/. + */ + +#pragma once + +namespace avmedia +{ +namespace vlc +{ +namespace wrapper +{ + class Common + { + public: + static bool LoadSymbols(); + static const char* Version(); + static const char* LastErrorMessage(); + }; +} +} +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/avmedia/source/vlc/inc/wrapper/EventHandler.hxx b/avmedia/source/vlc/inc/wrapper/EventHandler.hxx new file mode 100644 index 000000000..955c83478 --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/EventHandler.hxx @@ -0,0 +1,42 @@ +/* -*- 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/. + */ + +#pragma once + +#include <functional> +#include <salhelper/thread.hxx> +#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; + }; +} +} +} + +/* 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 000000000..9a8515483 --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/EventManager.hxx @@ -0,0 +1,55 @@ +/* -*- 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/. + */ + +#pragma once + +#include <functional> +#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<void()> 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 ); + }; +} +} +} + +/* 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 000000000..7e4ba7741 --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/Instance.hxx @@ -0,0 +1,41 @@ +/* -*- 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/. + */ + +#pragma once + +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 ); + ~Instance(); + + operator libvlc_instance_t*() + { + return mInstance; + } + + private: + libvlc_instance_t *mInstance; + }; +} +} +} + +/* 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 000000000..288bb0d43 --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/Media.hxx @@ -0,0 +1,47 @@ +/* -*- 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/. + */ + +#pragma once + +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; + + ~Media(); + + operator libvlc_media_t*() + { + return mMedia; + } + + private: + libvlc_media_t *mMedia; + }; +} +} +} + +/* 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 000000000..a41e01b10 --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/Player.hxx @@ -0,0 +1,73 @@ +/* -*- 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/. + */ + +#pragma once +#if defined UNX +# include <stdint.h> +#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 ); + ~Player(); + + bool play(); + void pause(); + void stop(); + void setTime( int time ); + int getTime() const; + bool isPlaying() const; + + void setVolume( int volume ); + int getVolume() const; + + void setMute( bool mute); + bool getMute() const; + + void setWindow( intptr_t id ); + + void takeSnapshot(const rtl::OUString& file); + + bool hasVout() const; + + void setScale( float factor ); + void setVideoSize( unsigned width, unsigned height ); + + operator libvlc_media_player_t*() + { + return mPlayer; + } + + void setMouseHandling(bool flag); + private: + libvlc_media_player_t *mPlayer; + }; +} +} +} + +/* 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 000000000..f8eb480dd --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/ThreadsafeQueue.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/. + * + * 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 . + */ +#pragma once +#include <queue> +#include <iostream> +#include <osl/mutex.hxx> +#include <osl/conditn.hxx> + +namespace avmedia +{ +namespace vlc +{ +namespace wrapper +{ +template<class T> +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<class T> +ThreadsafeQueue<T>::ThreadsafeQueue() +{ +} + +template<class T> +void ThreadsafeQueue<T>::push( const T& data ) +{ + ::osl::MutexGuard guard( mMutex ); + mQueue.push( data ); + mMutex.release(); + mCondition.set(); +} + +template<class T> +void ThreadsafeQueue<T>::pop( T& data ) +{ + mCondition.wait(); + ::osl::MutexGuard guard( mMutex ); + while ( mQueue.empty() ) + { + mMutex.release(); + mCondition.wait(); + mMutex.acquire(); + } + data = mQueue.front(); + mQueue.pop(); +} +} +} +} + +/* 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 000000000..c381ea8db --- /dev/null +++ b/avmedia/source/vlc/inc/wrapper/Wrapper.hxx @@ -0,0 +1,19 @@ +/* -*- 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/. + */ + +#pragma once + +#include <wrapper/Common.hxx> +#include <wrapper/EventHandler.hxx> +#include <wrapper/EventManager.hxx> +#include <wrapper/Instance.hxx> +#include <wrapper/Media.hxx> +#include <wrapper/Player.hxx> + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |