summaryrefslogtreecommitdiffstats
path: root/include/avmedia
diff options
context:
space:
mode:
Diffstat (limited to 'include/avmedia')
-rw-r--r--include/avmedia/MediaControlBase.hxx85
-rw-r--r--include/avmedia/avmediadllapi.h34
-rw-r--r--include/avmedia/mediaitem.hxx158
-rw-r--r--include/avmedia/mediaplayer.hxx79
-rw-r--r--include/avmedia/mediatoolbox.hxx55
-rw-r--r--include/avmedia/mediawindow.hxx118
6 files changed, 529 insertions, 0 deletions
diff --git a/include/avmedia/MediaControlBase.hxx b/include/avmedia/MediaControlBase.hxx
new file mode 100644
index 000000000..7c5530019
--- /dev/null
+++ b/include/avmedia/MediaControlBase.hxx
@@ -0,0 +1,85 @@
+/* -*- 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_DB_RANGE -40
+#define AVMEDIA_LINEINCREMENT 1.0
+#define AVMEDIA_PAGEINCREMENT 10.0
+
+#define AVMEDIA_TOOLBOXITEM_PLAY 0x0001
+#define AVMEDIA_TOOLBOXITEM_PAUSE 0x0004
+#define AVMEDIA_TOOLBOXITEM_STOP 0x0008
+#define AVMEDIA_TOOLBOXITEM_MUTE 0x0010
+#define AVMEDIA_TOOLBOXITEM_LOOP 0x0011
+#define AVMEDIA_TOOLBOXITEM_ZOOM 0x0012
+#define AVMEDIA_TOOLBOXITEM_OPEN 0x0014
+#define AVMEDIA_TOOLBOXITEM_INSERT 0x0018
+
+#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 MediaControlStyle
+{
+ MEDIACONTROLSTYLE_SINGLELINE = 0,
+ MEDIACONTROLSTYLE_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 SelectPlayToolBoxItem( MediaItem& aExecItem, MediaItem const & aItem, const OString& 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..cca250a6e
--- /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..b30689c6f
--- /dev/null
+++ b/include/avmedia/mediaitem.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_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 <o3tl/typed_flags_set.hxx>
+
+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; }
+
+enum class AVMediaSetMask
+{
+ NONE = 0x000,
+ STATE = 0x001,
+ DURATION = 0x002,
+ TIME = 0x004,
+ LOOP = 0x008,
+ MUTE = 0x010,
+ VOLUMEDB = 0x020,
+ ZOOM = 0x040,
+ URL = 0x080,
+ MIME_TYPE = 0x100,
+ ALL = 0x1ff,
+};
+namespace o3tl
+{
+ template<> struct typed_flags<AVMediaSetMask> : is_typed_flags<AVMediaSetMask, 0x1ff> {};
+}
+
+
+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;
+
+ void merge( const MediaItem& rMediaItem );
+
+ AVMediaSetMask getMaskSet() const;
+
+ void setState( MediaState eState );
+ MediaState getState() const;
+
+ void setDuration( double fDuration );
+ double getDuration() const;
+
+ void setTime( double fTime );
+ double getTime() const;
+
+ void setLoop( bool bLoop );
+ bool isLoop() const;
+
+ void setMute( bool bMute );
+ bool isMute() const;
+
+ void setVolumeDB( sal_Int16 nDB );
+ sal_Int16 getVolumeDB() const;
+
+ void setZoom( ::css::media::ZoomLevel eZoom );
+ ::css::media::ZoomLevel getZoom() const;
+
+ void setURL( const OUString& rURL,
+ const OUString& rTempURL,
+ const OUString& rReferer);
+ const OUString& getURL() const;
+
+ void setMimeType( const OUString& rMimeType );
+ OUString getMimeType() 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,
+ const OUString& 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 const& rURL)
+ : m_TempFileURL(rURL)
+ {}
+ ~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..d00fcc55a
--- /dev/null
+++ b/include/avmedia/mediaplayer.hxx
@@ -0,0 +1,79 @@
+/* -*- 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 <config_options.h>
+#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 UNLESS_MERGELIBS(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..23a766d78
--- /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, sal_uInt16 nId, ToolBox& rTbX );
+ virtual ~MediaToolBoxControl() override;
+
+ virtual void StateChanged( 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..78e0b1a29
--- /dev/null
+++ b/include/avmedia/mediawindow.hxx
@@ -0,0 +1,118 @@
+/* -*- 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/uno/Reference.hxx>
+#include <vcl/vclptr.hxx>
+#include <avmedia/avmediadllapi.h>
+
+#define AVMEDIA_FRAMEGRABBER_DEFAULTFRAME -1.0
+
+namespace com::sun::star::graphic { class XGraphic; }
+namespace com::sun::star::media { class XPlayer; }
+
+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; }
+
+ 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();
+
+ 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( const OUString& rURL, const OUString& rReferer, bool bDeep = false, Size* pPreferredSizePixel = 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 OUString& rURL, const OUString& rReferer,
+ const OUString& sMimeType );
+
+ 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: */