diff options
Diffstat (limited to 'include/avmedia')
-rw-r--r-- | include/avmedia/MediaControlBase.hxx | 74 | ||||
-rw-r--r-- | include/avmedia/avmediadllapi.h | 34 | ||||
-rw-r--r-- | include/avmedia/mediaitem.hxx | 169 | ||||
-rw-r--r-- | include/avmedia/mediaplayer.hxx | 78 | ||||
-rw-r--r-- | include/avmedia/mediatoolbox.hxx | 55 | ||||
-rw-r--r-- | include/avmedia/mediawindow.hxx | 158 |
6 files changed, 568 insertions, 0 deletions
diff --git a/include/avmedia/MediaControlBase.hxx b/include/avmedia/MediaControlBase.hxx new file mode 100644 index 000000000..1379a4364 --- /dev/null +++ b/include/avmedia/MediaControlBase.hxx @@ -0,0 +1,74 @@ +/* -*- 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_MEDIACONTROLBASE_HXX +#define INCLUDED_AVMEDIA_MEDIACONTROLBASE_HXX + +#include <config_options.h> +#include <vcl/weld.hxx> + +#include <avmedia/avmediadllapi.h> + +namespace avmedia { class MediaItem; } + +#define AVMEDIA_TIME_RANGE 2048 + +#define AVMEDIA_ZOOMLEVEL_50 0 +#define AVMEDIA_ZOOMLEVEL_100 1 +#define AVMEDIA_ZOOMLEVEL_200 2 +#define AVMEDIA_ZOOMLEVEL_FIT 3 +#define AVMEDIA_ZOOMLEVEL_SCALED 4 +#define AVMEDIA_ZOOMLEVEL_INVALID 65535 + +namespace avmedia { + +enum class MediaControlStyle +{ + SingleLine = 0, + MultiLine = 1 +}; + +class UNLESS_MERGELIBS(AVMEDIA_DLLPUBLIC) MediaControlBase +{ +public: + MediaControlBase(); + virtual ~MediaControlBase(){}; + +protected: + std::unique_ptr<weld::Toolbar> mxPlayToolBox; + std::unique_ptr<weld::Scale> mxTimeSlider; + std::unique_ptr<weld::Toolbar> mxMuteToolBox; + std::unique_ptr<weld::Scale> mxVolumeSlider; + std::unique_ptr<weld::ComboBox> mxZoomListBox; + std::unique_ptr<weld::Entry> mxTimeEdit; + bool mbCurrentlySettingZoom; + + virtual void InitializeWidgets(); + virtual void UpdateToolBoxes(const MediaItem& rMediaItem); + void UpdateVolumeSlider( MediaItem const & aMediaItem ); + void UpdateTimeSlider( MediaItem const & aMediaItem ); + void UpdateTimeField( MediaItem const & aMediaItem, double fTime ); + void UpdatePlayState(const MediaItem& rMediaItem); + void SelectPlayToolBoxItem( MediaItem& aExecItem, MediaItem const & aItem, std::string_view rId); + void disposeWidgets(); +}; + +} +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/avmedia/avmediadllapi.h b/include/avmedia/avmediadllapi.h new file mode 100644 index 000000000..abe4fb48c --- /dev/null +++ b/include/avmedia/avmediadllapi.h @@ -0,0 +1,34 @@ +/* -*- 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_AVMEDIADLLAPI_H +#define INCLUDED_AVMEDIA_AVMEDIADLLAPI_H + +#include <sal/types.h> + +#if defined(AVMEDIA_DLLIMPLEMENTATION) +#define AVMEDIA_DLLPUBLIC SAL_DLLPUBLIC_EXPORT +#else +#define AVMEDIA_DLLPUBLIC SAL_DLLPUBLIC_IMPORT +#endif +#define AVMEDIA_DLLPRIVATE SAL_DLLPRIVATE + +#endif // INCLUDED_AVMEDIA_AVMEDIADLLAPI_H + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/avmedia/mediaitem.hxx b/include/avmedia/mediaitem.hxx new file mode 100644 index 000000000..bbb5e06e4 --- /dev/null +++ b/include/avmedia/mediaitem.hxx @@ -0,0 +1,169 @@ +/* -*- 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_MEDIAITEM_HXX +#define INCLUDED_AVMEDIA_MEDIAITEM_HXX + +#include <svl/poolitem.hxx> +#include <com/sun/star/media/ZoomLevel.hpp> +#include <avmedia/avmediadllapi.h> +#include <memory> +#include <string_view> + +#include <o3tl/typed_flags_set.hxx> +#include <utility> + +namespace com::sun::star::embed { class XStorage; } +namespace com::sun::star::frame { class XModel; } +namespace com::sun::star::io { class XInputStream; } +namespace com::sun::star::io { class XStream; } +namespace com::sun::star::text { struct GraphicCrop; } +class Graphic; + +enum class AVMediaSetMask +{ + NONE = 0x000, + STATE = 0x001, + DURATION = 0x002, + TIME = 0x004, + LOOP = 0x008, + MUTE = 0x010, + VOLUMEDB = 0x020, + ZOOM = 0x040, + URL = 0x080, + MIME_TYPE = 0x100, + GRAPHIC = 0x200, + CROP = 0x400, + ALL = 0x7ff, +}; +namespace o3tl +{ + template<> struct typed_flags<AVMediaSetMask> : is_typed_flags<AVMediaSetMask, 0x7ff> {}; +} + + +namespace avmedia +{ + + +enum class MediaState +{ + Stop, Play, Pause +}; + + +class AVMEDIA_DLLPUBLIC MediaItem final : public SfxPoolItem +{ +public: + static SfxPoolItem* CreateDefault(); + + explicit MediaItem( sal_uInt16 i_nWhich = 0, + AVMediaSetMask nMaskSet = AVMediaSetMask::NONE ); + MediaItem( const MediaItem& rMediaItem ); + virtual ~MediaItem() override; + + virtual bool operator==( const SfxPoolItem& ) const override; + virtual MediaItem* Clone( SfxItemPool* pPool = nullptr ) const override; + virtual bool GetPresentation( SfxItemPresentation ePres, + MapUnit eCoreUnit, + MapUnit ePresUnit, + OUString& rText, + const IntlWrapper& rIntl ) const override; + virtual bool QueryValue( css::uno::Any& rVal, sal_uInt8 nMemberId = 0 ) const override; + virtual bool PutValue( const css::uno::Any& rVal, sal_uInt8 nMemberId ) override; + + bool merge(const MediaItem& rMediaItem); + + AVMediaSetMask getMaskSet() const; + + bool setState(MediaState eState); + MediaState getState() const; + + bool setDuration(double fDuration); + double getDuration() const; + + bool setTime(double fTime); + double getTime() const; + + bool setLoop(bool bLoop); + bool isLoop() const; + + bool setMute(bool bMute); + bool isMute() const; + + bool setVolumeDB(sal_Int16 nDB); + sal_Int16 getVolumeDB() const; + + bool setZoom(css::media::ZoomLevel eZoom); + ::css::media::ZoomLevel getZoom() const; + + bool setURL(const OUString& rURL, + const OUString& rTempURL, + const OUString& rReferer); + const OUString& getURL() const; + + bool setMimeType(const OUString& rMimeType); + OUString getMimeType() const; + bool setGraphic(const Graphic& rGraphic); + const Graphic & getGraphic() const; + bool setCrop(const css::text::GraphicCrop& rCrop); + const css::text::GraphicCrop& getCrop() const; + const OUString& getTempURL() const; + + const OUString& getReferer() const; + +private: + + struct Impl; + std::unique_ptr<Impl> m_pImpl; +}; + +typedef ::avmedia::MediaItem avmedia_MediaItem; + +bool AVMEDIA_DLLPUBLIC EmbedMedia( + const ::css::uno::Reference< ::css::frame::XModel>& xModel, + const OUString& rSourceURL, + OUString & o_rEmbeddedURL, + ::css::uno::Reference<::css::io::XInputStream> const& xInputStream = + ::css::uno::Reference<::css::io::XInputStream>()); + +bool AVMEDIA_DLLPUBLIC CreateMediaTempFile( + ::css::uno::Reference<::css::io::XInputStream> const& xInStream, + OUString& o_rTempFileURL, + std::u16string_view rDesiredExtension); + +OUString GetFilename(OUString const& rSourceURL); + +::css::uno::Reference< ::css::io::XStream> CreateStream( + const ::css::uno::Reference< ::css::embed::XStorage>& xStorage, const OUString& rFilename); + +struct AVMEDIA_DLLPUBLIC MediaTempFile +{ + OUString const m_TempFileURL; + MediaTempFile(OUString aURL) + : m_TempFileURL(std::move(aURL)) + {} + ~MediaTempFile(); +}; + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/avmedia/mediaplayer.hxx b/include/avmedia/mediaplayer.hxx new file mode 100644 index 000000000..52ecd942e --- /dev/null +++ b/include/avmedia/mediaplayer.hxx @@ -0,0 +1,78 @@ +/* -*- 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_MEDIAPLAYER_HXX +#define INCLUDED_AVMEDIA_MEDIAPLAYER_HXX + +#include <sfx2/dockwin.hxx> +#include <sfx2/viewfrm.hxx> +#include <avmedia/avmediadllapi.h> +#include <memory> + +namespace avmedia +{ + +class AVMEDIA_DLLPUBLIC MediaPlayer final : public SfxChildWindow +{ +public: + MediaPlayer( vcl::Window*, sal_uInt16, SfxBindings*, SfxChildWinInfo* ); + virtual ~MediaPlayer() override; + + SFX_DECL_CHILDWINDOW_WITHID( MediaPlayer ); +}; + +class MediaWindow; + +class AVMEDIA_DLLPUBLIC MediaFloater final : public SfxDockingWindow +{ +public: + + MediaFloater( SfxBindings* pBindings, SfxChildWindow* pCW, vcl::Window* pParent ); + virtual ~MediaFloater() override; + virtual void dispose() override; + + void setURL( const OUString& rURL, const OUString& rReferer, bool bPlayImmediately ); + + void dispatchCurrentURL(); + +private: + + virtual void Resize() override; + virtual void ToggleFloatingMode() override; + + std::unique_ptr<MediaWindow> mpMediaWindow; +}; + +inline MediaFloater * getMediaFloater() { + SfxViewFrame * cur = SfxViewFrame::Current(); + if (cur != nullptr) { + SfxChildWindow * win = cur->GetChildWindow( + MediaPlayer::GetChildWindowId()); + if (win != nullptr) { + return static_cast<MediaFloater *>(win->GetWindow()); + } + } + return nullptr; +} + +} + +#endif + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/avmedia/mediatoolbox.hxx b/include/avmedia/mediatoolbox.hxx new file mode 100644 index 000000000..434d202ca --- /dev/null +++ b/include/avmedia/mediatoolbox.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/. + * + * 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_MEDIATOOLBOX_HXX +#define INCLUDED_AVMEDIA_MEDIATOOLBOX_HXX + +#include <sfx2/tbxctrl.hxx> +#include <avmedia/avmediadllapi.h> + +namespace avmedia +{ + +class MediaItem; + +class AVMEDIA_DLLPUBLIC MediaToolBoxControl final : public SfxToolBoxControl +{ + friend class MediaToolBoxControl_Impl; + +public: + + SFX_DECL_TOOLBOX_CONTROL(); + + MediaToolBoxControl( sal_uInt16 nSlotId, ToolBoxItemId nId, ToolBox& rTbX ); + virtual ~MediaToolBoxControl() override; + + virtual void StateChangedAtToolBoxControl( sal_uInt16 nSID, SfxItemState eState, const SfxPoolItem* pState ) override; + virtual VclPtr<InterimItemWindow> CreateItemWindow( vcl::Window* pParent ) override; + +private: + + AVMEDIA_DLLPRIVATE void implUpdateMediaControl(); + AVMEDIA_DLLPRIVATE void implExecuteMediaControl( const MediaItem& rItem ); +}; + +} + +#endif // INCLUDED_AVMEDIA_MEDIATOOLBOX_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/include/avmedia/mediawindow.hxx b/include/avmedia/mediawindow.hxx new file mode 100644 index 000000000..e8515d77f --- /dev/null +++ b/include/avmedia/mediawindow.hxx @@ -0,0 +1,158 @@ +/* -*- 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_MEDIAWINDOW_HXX +#define INCLUDED_AVMEDIA_MEDIAWINDOW_HXX + +#include <vector> +#include <tools/gen.hxx> +#include <com/sun/star/awt/Size.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include <com/sun/star/media/XPlayerListener.hpp> +#include <cppuhelper/compbase.hxx> +#include <cppuhelper/basemutex.hxx> +#include <vcl/vclptr.hxx> +#include <avmedia/avmediadllapi.h> + +#define AVMEDIA_FRAMEGRABBER_DEFAULTFRAME -1.0 + +namespace com::sun::star::frame { class XDispatchProvider; } +namespace com::sun::star::graphic { class XGraphic; } +namespace com::sun::star::media { + class XPlayer; + class XPlayerNotifier; +} + +namespace vcl { class Window; } +namespace weld { class Window; } +class KeyEvent; +class MouseEvent; +class CommandEvent; +struct AcceptDropEvent; +struct ExecuteDropEvent; +enum class PointerStyle; + +namespace avmedia +{ + typedef ::std::vector< ::std::pair< OUString, OUString > > FilterNameVector; + + class MediaItem; + + namespace priv { class MediaWindowImpl; } + + typedef cppu::WeakComponentImplHelper<css::media::XPlayerListener> PlayerListener_BASE; + + class AVMEDIA_DLLPUBLIC PlayerListener final : public cppu::BaseMutex, public PlayerListener_BASE + { + private: + css::uno::Reference<css::media::XPlayerNotifier> m_xNotifier; + std::function<void(const css::uno::Reference<css::media::XPlayer>&)> m_aFn; + + using WeakComponentImplHelperBase::disposing; + public: + PlayerListener(std::function<void(const css::uno::Reference<css::media::XPlayer>&)> fn); + virtual void SAL_CALL dispose() override; + virtual ~PlayerListener() override; + + virtual void SAL_CALL preferredPlayerWindowSizeAvailable(const css::lang::EventObject& rSource) override; + virtual void SAL_CALL disposing(const css::lang::EventObject& rSource) override; + + void startListening(const css::uno::Reference<css::media::XPlayerNotifier>& rNotifier); + void stopListening(); + + void callPlayerWindowSizeAvailable(const css::uno::Reference<css::media::XPlayer>& rPlayer) { m_aFn(rPlayer); } + }; + + class AVMEDIA_DLLPUBLIC MediaWindow + { + public: + MediaWindow( vcl::Window* parent, bool bInternalMediaControl ); + virtual ~MediaWindow(); + + void setURL( const OUString& rURL, const OUString& rReferer ); + const OUString& getURL() const; + + bool isValid() const; + Size getPreferredSize() const; + + vcl::Window* getWindow() const; + + void setPosSize( const tools::Rectangle& rNewRect ); + + void setPointer( PointerStyle aPointer ); + + bool start(); + + void updateMediaItem( MediaItem& rItem ) const; + void executeMediaItem( const MediaItem& rItem ); + + void show(); + void hide(); + bool isVisible() const; + + public: + + virtual void MouseMove( const MouseEvent& rMEvt ); + virtual void MouseButtonDown( const MouseEvent& rMEvt ); + virtual void MouseButtonUp( const MouseEvent& rMEvt ); + + virtual void KeyInput( const KeyEvent& rKEvt ); + virtual void KeyUp( const KeyEvent& rKEvt ); + + virtual void Command( const CommandEvent& rCEvt ); + + virtual sal_Int8 AcceptDrop( const AcceptDropEvent& rEvt ); + virtual sal_Int8 ExecuteDrop( const ExecuteDropEvent& rEvt ); + + virtual void StartDrag( sal_Int8 nAction, const Point& rPosPixel ); + + public: + + static FilterNameVector getMediaFilters(); + /// @param o_pbLink if not 0, this is an "insert" dialog: display link + /// checkbox and store its state in *o_pbLink + static bool executeMediaURLDialog(weld::Window* pParent, OUString& rURL, bool *const o_pbLink); + static void executeFormatErrorBox(weld::Window* pParent); + static bool isMediaURL(std::u16string_view rURL, const OUString& rReferer, bool bDeep = false, + rtl::Reference<PlayerListener> xPreferredPixelSizeListener = nullptr); + + static css::uno::Reference< css::media::XPlayer > createPlayer( const OUString& rURL, const OUString& rReferer, const OUString* pMimeType = nullptr ); + + static css::uno::Reference<css::graphic::XGraphic> + grabFrame(const css::uno::Reference<css::media::XPlayer>& rPlayer, + const css::uno::Reference<css::graphic::XGraphic>& rGraphic = nullptr); + + static css::uno::Reference< css::graphic::XGraphic > grabFrame(const OUString& rURL, const OUString& rReferer, + const OUString& sMimeType, rtl::Reference<PlayerListener> xPreferredPixelSizeListener); + + static void dispatchInsertAVMedia(const css::uno::Reference<css::frame::XDispatchProvider>&, + const css::awt::Size& rSize, const OUString& rURL, bool bLink); + + private: + MediaWindow(const MediaWindow&) = delete; + MediaWindow& operator =( const MediaWindow& ) = delete; + + VclPtr<priv::MediaWindowImpl> mpImpl; + }; + +} + +#endif // INCLUDED_AVMEDIA_MEDIAWINDOW_HXX + +/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |