summaryrefslogtreecommitdiff
path: root/avmedia
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2020-07-03 20:35:15 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2020-07-04 08:33:02 +0200
commit43d2f3d5f1ab360cb40de7ccb45c2c0dd6b33ccb (patch)
treed226593fcbd41cfb3d3ca7651e7c266f08ce823d /avmedia
parent78639945dab254e2de5315c49e82c333e1056170 (diff)
avmedia/mac: create instances with uno constructors
See tdf#74608 for motivation. Change-Id: I7dfb9933c1625b4e0b68cf8ab459eebcd3db9d44 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97893 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'avmedia')
-rw-r--r--avmedia/Library_avmediaMacAVF.mk1
-rw-r--r--avmedia/source/macavf/avmediaMacAVF.component5
-rw-r--r--avmedia/source/macavf/framegrabber.hxx4
-rw-r--r--avmedia/source/macavf/framegrabber.mm2
-rw-r--r--avmedia/source/macavf/macavfcommon.hxx3
-rw-r--r--avmedia/source/macavf/macavfuno.mm55
-rw-r--r--avmedia/source/macavf/manager.hxx5
-rw-r--r--avmedia/source/macavf/manager.mm26
-rw-r--r--avmedia/source/macavf/player.hxx3
-rw-r--r--avmedia/source/macavf/player.mm23
-rw-r--r--avmedia/source/macavf/window.hxx5
-rw-r--r--avmedia/source/macavf/window.mm5
12 files changed, 35 insertions, 102 deletions
diff --git a/avmedia/Library_avmediaMacAVF.mk b/avmedia/Library_avmediaMacAVF.mk
index 877efd97ac36..de6373632df7 100644
--- a/avmedia/Library_avmediaMacAVF.mk
+++ b/avmedia/Library_avmediaMacAVF.mk
@@ -37,7 +37,6 @@ $(eval $(call gb_Library_use_system_darwin_frameworks,avmediaMacAVF,\
$(eval $(call gb_Library_add_objcxxobjects,avmediaMacAVF,\
avmedia/source/macavf/framegrabber \
- avmedia/source/macavf/macavfuno \
avmedia/source/macavf/manager \
avmedia/source/macavf/player \
avmedia/source/macavf/window \
diff --git a/avmedia/source/macavf/avmediaMacAVF.component b/avmedia/source/macavf/avmediaMacAVF.component
index 376576ff5d2d..3cb9966c1287 100644
--- a/avmedia/source/macavf/avmediaMacAVF.component
+++ b/avmedia/source/macavf/avmediaMacAVF.component
@@ -18,8 +18,9 @@
-->
<component loader="com.sun.star.loader.SharedLibrary" environment="@CPPU_ENV@"
- prefix="avmediaMacAVF" xmlns="http://openoffice.org/2010/uno-components">
- <implementation name="com.sun.star.comp.avmedia.Manager_MacAVF">
+ xmlns="http://openoffice.org/2010/uno-components">
+ <implementation name="com.sun.star.comp.avmedia.Manager_MacAVF"
+ constructor="com_sun_star_comp_avmedia_Manager_MacAVF_get_implementation">
<service name="com.sun.star.media.Manager_MacAVF"/>
</implementation>
</component>
diff --git a/avmedia/source/macavf/framegrabber.hxx b/avmedia/source/macavf/framegrabber.hxx
index 0b199991edaa..5e0c749d944b 100644
--- a/avmedia/source/macavf/framegrabber.hxx
+++ b/avmedia/source/macavf/framegrabber.hxx
@@ -31,7 +31,7 @@ class FrameGrabber : public ::cppu::WeakImplHelper< css::media::XFrameGrabber,
{
public:
- explicit FrameGrabber( const css::uno::Reference< css::lang::XMultiServiceFactory >& );
+ explicit FrameGrabber();
virtual ~FrameGrabber() override;
bool create( AVAsset* pMovie );
@@ -46,8 +46,6 @@ public:
private:
- css::uno::Reference< css::lang::XMultiServiceFactory > mxMgr;
-
AVAssetImageGenerator* mpImageGen;
};
diff --git a/avmedia/source/macavf/framegrabber.mm b/avmedia/source/macavf/framegrabber.mm
index 71180010305b..31566bef3876 100644
--- a/avmedia/source/macavf/framegrabber.mm
+++ b/avmedia/source/macavf/framegrabber.mm
@@ -30,7 +30,7 @@ using namespace ::com::sun::star;
namespace avmedia::macavf {
-FrameGrabber::FrameGrabber( const uno::Reference< lang::XMultiServiceFactory >& /*rxMgr*/ )
+FrameGrabber::FrameGrabber()
: mpImageGen( nullptr )
{}
diff --git a/avmedia/source/macavf/macavfcommon.hxx b/avmedia/source/macavf/macavfcommon.hxx
index 699f495a0ddf..b031f1ecc51f 100644
--- a/avmedia/source/macavf/macavfcommon.hxx
+++ b/avmedia/source/macavf/macavfcommon.hxx
@@ -45,9 +45,6 @@
#include <com/sun/star/media/XManager.hpp>
-#define AVMEDIA_MACAVF_MANAGER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Manager_MacAVF"
-#define AVMEDIA_MACAVF_MANAGER_SERVICENAME "com.sun.star.media.Manager_MacAVF"
-
#define AVMEDIA_MACAVF_PLAYER_IMPLEMENTATIONNAME "com.sun.star.comp.avmedia.Player_MacAVF"
#define AVMEDIA_MACAVF_PLAYER_SERVICENAME "com.sun.star.media.Player_MacAVF"
diff --git a/avmedia/source/macavf/macavfuno.mm b/avmedia/source/macavf/macavfuno.mm
deleted file mode 100644
index dbee2e8cea49..000000000000
--- a/avmedia/source/macavf/macavfuno.mm
+++ /dev/null
@@ -1,55 +0,0 @@
-/* -*- 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 .
- */
-
-#include "macavfcommon.hxx"
-#include "manager.hxx"
-#include <com/sun/star/lang/XSingleServiceFactory.hpp>
-
-using namespace ::com::sun::star;
-
-static uno::Reference< uno::XInterface > create_MediaPlayer( const uno::Reference< lang::XMultiServiceFactory >& rxFact )
-{
- return uno::Reference< uno::XInterface >( *new ::avmedia::macavf::Manager( rxFact ) );
-}
-
-extern "C" SAL_DLLPUBLIC_EXPORT void* avmediaMacAVF_component_getFactory( const char* pImplName, void* pServiceManager, void* /* pRegistryKey */ )
-{
- uno::Reference< lang::XSingleServiceFactory > xFactory;
- void* pRet = nullptr;
-
- if( rtl_str_compare( pImplName, AVMEDIA_MACAVF_MANAGER_IMPLEMENTATIONNAME ) == 0 )
- {
- const OUString aServiceName( AVMEDIA_MACAVF_MANAGER_SERVICENAME );
-
- xFactory.set( ::cppu::createSingleFactory(
- static_cast< lang::XMultiServiceFactory* >( pServiceManager ),
- AVMEDIA_MACAVF_MANAGER_IMPLEMENTATIONNAME,
- create_MediaPlayer, uno::Sequence< OUString >( &aServiceName, 1 ) ) );
- }
-
- if( xFactory.is() )
- {
- xFactory->acquire();
- pRet = xFactory.get();
- }
-
- return pRet;
-}
-
-/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/macavf/manager.hxx b/avmedia/source/macavf/manager.hxx
index fbdcb61b3caf..9072b3800680 100644
--- a/avmedia/source/macavf/manager.hxx
+++ b/avmedia/source/macavf/manager.hxx
@@ -32,7 +32,7 @@ class Manager : public ::cppu::WeakImplHelper< css::media::XManager,
{
public:
- Manager( const css::uno::Reference< css::lang::XMultiServiceFactory >& rxMgr );
+ Manager();
virtual ~Manager() override;
// XManager
@@ -42,9 +42,6 @@ public:
virtual OUString SAL_CALL getImplementationName( ) override;
virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
-private:
-
- css::uno::Reference< css::lang::XMultiServiceFactory > mxMgr;
};
} // namespace avmedia::macavf
diff --git a/avmedia/source/macavf/manager.mm b/avmedia/source/macavf/manager.mm
index 7f3036c86faf..44768b54c4e3 100644
--- a/avmedia/source/macavf/manager.mm
+++ b/avmedia/source/macavf/manager.mm
@@ -21,13 +21,13 @@
#include "player.hxx"
#include <tools/urlobj.hxx>
#include <osl/diagnose.h>
+#include <rtl/ref.hxx>
using namespace ::com::sun::star;
namespace avmedia::macavf {
-Manager::Manager( const uno::Reference< lang::XMultiServiceFactory >& rxMgr ) :
- mxMgr( rxMgr )
+Manager::Manager()
{
}
@@ -38,34 +38,40 @@ Manager::~Manager()
uno::Reference< media::XPlayer > SAL_CALL Manager::createPlayer( const OUString& rURL )
{
- Player* pPlayer( new Player( mxMgr ) );
- uno::Reference< media::XPlayer > xRet( pPlayer );
+ rtl::Reference<Player> xPlayer( new Player() );
INetURLObject aURL( rURL );
- if( !pPlayer->create( aURL.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ) ) )
- xRet.clear();
+ if( !xPlayer->create( aURL.GetMainURL( INetURLObject::DecodeMechanism::Unambiguous ) ) )
+ return {};
- return xRet;
+ return uno::Reference<media::XPlayer>(xPlayer.get());
}
OUString SAL_CALL Manager::getImplementationName( )
{
- return AVMEDIA_MACAVF_MANAGER_IMPLEMENTATIONNAME;
+ return "com.sun.star.comp.avmedia.Manager_MacAVF";
}
sal_Bool SAL_CALL Manager::supportsService( const OUString& ServiceName )
{
- return ServiceName == AVMEDIA_MACAVF_MANAGER_SERVICENAME;
+ return ServiceName == "com.sun.star.media.Manager_MacAVF";
}
uno::Sequence< OUString > SAL_CALL Manager::getSupportedServiceNames( )
{
- return { AVMEDIA_MACAVF_MANAGER_SERVICENAME };
+ return { "com.sun.star.media.Manager_MacAVF" };
}
} // namespace avmedia::macavf
+extern "C" SAL_DLLPUBLIC_EXPORT css::uno::XInterface*
+com_sun_star_comp_avmedia_Manager_MacAVF_get_implementation(
+ css::uno::XComponentContext* , css::uno::Sequence<css::uno::Any> const&)
+{
+ return cppu::acquire(new ::avmedia::macavf::Manager());
+}
+
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/avmedia/source/macavf/player.hxx b/avmedia/source/macavf/player.hxx
index b9b49cc8cdac..3dc41b347d30 100644
--- a/avmedia/source/macavf/player.hxx
+++ b/avmedia/source/macavf/player.hxx
@@ -33,7 +33,7 @@ class Player
css::lang::XServiceInfo >
{
public:
- explicit Player( const css::uno::Reference< css::lang::XMultiServiceFactory >& );
+ explicit Player();
virtual ~Player() override;
bool create( const OUString& rURL );
@@ -68,7 +68,6 @@ public:
virtual bool handleObservation( NSString* pKeyPath ) override;
private:
- css::uno::Reference< css::lang::XMultiServiceFactory > mxMgr;
AVPlayer* mpPlayer;
diff --git a/avmedia/source/macavf/player.mm b/avmedia/source/macavf/player.mm
index dfe558524073..7fdc58247f50 100644
--- a/avmedia/source/macavf/player.mm
+++ b/avmedia/source/macavf/player.mm
@@ -20,6 +20,7 @@
#include "player.hxx"
#include "framegrabber.hxx"
#include "window.hxx"
+#include <rtl/ref.hxx>
#include <cmath> // for log10()
@@ -71,9 +72,8 @@ MacAVObserverObject* MacAVObserverHandler::getObserver()
}
-Player::Player( const uno::Reference< lang::XMultiServiceFactory >& rxMgr )
-: mxMgr( rxMgr )
-, mpPlayer( nullptr )
+Player::Player()
+: mpPlayer( nullptr )
, mfUnmutedVolume( 0 )
, mfStopTime( DBL_MAX )
, mbMuted( false )
@@ -318,27 +318,22 @@ uno::Reference< ::media::XPlayerWindow > SAL_CALL Player::createPlayerWindow( co
NSView* pParentView = reinterpret_cast<NSView*>(nNSViewPtr);
// check the window parameters
- uno::Reference< ::media::XPlayerWindow > xRet;
if( (aSize.Width <= 0) || (aSize.Height <= 0) || (pParentView == nullptr) )
- return xRet;
+ return {};
// create the window
- ::avmedia::macavf::Window* pWindow = new ::avmedia::macavf::Window( mxMgr, *this, pParentView );
- xRet = pWindow;
- return xRet;
+ return new ::avmedia::macavf::Window( *this, pParentView );
}
uno::Reference< media::XFrameGrabber > SAL_CALL Player::createFrameGrabber()
{
- uno::Reference< media::XFrameGrabber > xRet;
-
- FrameGrabber* pGrabber = new FrameGrabber( mxMgr );
+ rtl::Reference<FrameGrabber> pGrabber = new FrameGrabber();
AVAsset* pMovie = [[mpPlayer currentItem] asset];
- if( pGrabber->create( pMovie ) )
- xRet = pGrabber;
+ if( !pGrabber->create( pMovie ) )
+ return {};
- return xRet;
+ return pGrabber.get();
}
diff --git a/avmedia/source/macavf/window.hxx b/avmedia/source/macavf/window.hxx
index c494b6deffd4..cfaae6f47d3b 100644
--- a/avmedia/source/macavf/window.hxx
+++ b/avmedia/source/macavf/window.hxx
@@ -44,8 +44,7 @@ class Window
{
public:
- Window( const css::uno::Reference< css::lang::XMultiServiceFactory >& i_rxMgr,
- Player& i_rPlayer,
+ Window( Player& i_rPlayer,
NSView* i_pParentView
);
virtual ~Window() override;
@@ -92,8 +91,6 @@ public:
private:
- css::uno::Reference< css::lang::XMultiServiceFactory > mxMgr;
-
::osl::Mutex maMutex;
::cppu::OMultiTypeInterfaceContainerHelper maListeners;
css::media::ZoomLevel meZoomLevel;
diff --git a/avmedia/source/macavf/window.mm b/avmedia/source/macavf/window.mm
index 3c39a0725277..fdb2e50655e8 100644
--- a/avmedia/source/macavf/window.mm
+++ b/avmedia/source/macavf/window.mm
@@ -28,9 +28,8 @@ using namespace ::com::sun::star;
namespace avmedia::macavf {
-Window::Window( const uno::Reference< lang::XMultiServiceFactory >& i_rxMgr, Player& i_rPlayer, NSView* i_pParentView )
-: mxMgr( i_rxMgr )
-, maListeners( maMutex )
+Window::Window( Player& i_rPlayer, NSView* i_pParentView )
+: maListeners( maMutex )
, meZoomLevel( media::ZoomLevel_NOT_AVAILABLE )
, mrPlayer( i_rPlayer )
, mnPointerType( awt::SystemPointer::ARROW )