1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
10 #include <boost/algorithm/string.hpp>
11 #include <boost/lexical_cast.hpp>
12 #include <com/sun/star/uno/Exception.hpp>
13 #include <cppuhelper/supportsservice.hxx>
14 #include <cppuhelper/weak.hxx>
15 #include <sal/log.hxx>
16 #include "vlcmanager.hxx"
17 #include "vlcplayer.hxx"
18 #include <wrapper/Instance.hxx>
19 #include <wrapper/EventManager.hxx>
20 #include <wrapper/Media.hxx>
21 #include <wrapper/Player.hxx>
22 #include <wrapper/Common.hxx>
23 #include <officecfg/Office/Common.hxx>
25 using namespace ::com::sun::star
;
27 namespace avmedia::vlc
{
31 const char * const VLC_ARGS
[] = {
42 using namespace wrapper
;
43 static bool success
= Instance::LoadSymbols() && EventManager::LoadSymbols()
44 && Media::LoadSymbols() && Player::LoadSymbols()
45 && Common::LoadSymbols();
47 m_is_vlc_found
= success
;
50 mInstance
.reset(new Instance( SAL_N_ELEMENTS(VLC_ARGS
), VLC_ARGS
));
52 std::vector
<std::string
> verComponents
;
53 const std::string
str(Common::Version());
55 boost::split(verComponents
,
57 boost::is_any_of(". "));
58 if (verComponents
.size() < 3
59 || boost::lexical_cast
<int>(verComponents
[0]) < 2
60 || (boost::lexical_cast
<int>(verComponents
[1]) == 0
61 && boost::lexical_cast
<int>(verComponents
[2]) < 8))
63 SAL_WARN("avmedia", "VLC version '" << str
<< "' is too old");
64 m_is_vlc_found
= false;
67 SAL_INFO("avmedia", "VLC version '" << str
<< "' is acceptable");
70 SAL_WARN("avmedia", "Cannot load symbols");
74 mEventHandler
.create();
83 uno::Reference
< media::XPlayer
> SAL_CALL
Manager::createPlayer( const OUString
& rURL
)
85 if ( !m_is_vlc_found
)
86 throw uno::RuntimeException("VLC not found", nullptr);
88 if ( !rURL
.isEmpty() )
98 VLCPlayer
* pPlayer( new VLCPlayer( mURL
,
100 mEventHandler
/*, mxMgr */ ) );
101 mPlayer
.set( pPlayer
);
106 OUString SAL_CALL
Manager::getImplementationName()
108 return "com.sun.star.comp.avmedia.Manager_VLC";
111 sal_Bool SAL_CALL
Manager::supportsService( const OUString
& serviceName
)
113 return cppu::supportsService(this, serviceName
);
116 uno::Sequence
< OUString
> SAL_CALL
Manager::getSupportedServiceNames()
118 return { "com.sun.star.media.Manager_VLC" };
124 extern "C" SAL_DLLPUBLIC_EXPORT
css::uno::XInterface
*
125 com_sun_star_comp_media_Manager_VLC_get_implementation(
126 css::uno::XComponentContext
* context
, css::uno::Sequence
<css::uno::Any
> const&)
128 // Experimental for now - code is neither elegant nor well tested.
129 if (!officecfg::Office::Common::Misc::ExperimentalMode::get(context
))
131 return cppu::acquire(static_cast<cppu::OWeakObject
*>(new ::avmedia::vlc::Manager
));
135 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */