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 "vlcmanager.hxx"
15 #include "vlcplayer.hxx"
16 #include "wrapper/Instance.hxx"
17 #include "wrapper/EventManager.hxx"
18 #include "wrapper/Media.hxx"
19 #include "wrapper/Player.hxx"
20 #include "wrapper/Common.hxx"
22 using namespace ::com::sun::star
;
29 const rtl::OUString VLC_IMPLEMENTATION_NAME
= "com.sun.star.comp.avmedia.Manager_VLC";
30 const ::rtl::OUString VLC_SERVICENAME
= "com.sun.star.media.Manager_VLC";
32 const char * const VLC_ARGS
[] = {
40 Manager::Manager( const uno::Reference
< lang::XMultiServiceFactory
>& rxMgr
)
44 using namespace wrapper
;
45 static bool success
= Instance::LoadSymbols() && EventManager::LoadSymbols()
46 && Media::LoadSymbols() && Player::LoadSymbols()
47 && Common::LoadSymbols();
49 m_is_vlc_found
= success
;
52 mInstance
.reset(new Instance( sizeof( VLC_ARGS
) / sizeof( VLC_ARGS
[0] ), VLC_ARGS
));
54 std::vector
<std::string
> verComponents
;
55 const std::string
str(Common::Version());
57 boost::split(verComponents
,
59 boost::is_any_of(". "));
60 if (verComponents
.size() < 3
61 || boost::lexical_cast
<int>(verComponents
[0]) < 2
62 || (boost::lexical_cast
<int>(verComponents
[1]) == 0
63 && boost::lexical_cast
<int>(verComponents
[2]) < 8))
65 SAL_WARN("avmedia", "VLC version '" << str
<< "' is too old");
66 m_is_vlc_found
= false;
69 SAL_INFO("avmedia", "VLC version '" << str
<< "' is acceptable");
72 SAL_WARN("avmedia", "Cannot load symbols");
76 mEventHandler
.create();
85 uno::Reference
< media::XPlayer
> SAL_CALL
Manager::createPlayer( const rtl::OUString
& rURL
)
86 throw (uno::RuntimeException
, std::exception
)
88 if ( !m_is_vlc_found
)
89 throw uno::RuntimeException("VLC not found", 0);
91 if ( !rURL
.isEmpty() )
101 VLCPlayer
* pPlayer( new VLCPlayer( mURL
,
103 mEventHandler
/*, mxMgr */ ) );
104 mPlayer
= uno::Reference
< media::XPlayer
>( pPlayer
);
109 rtl::OUString SAL_CALL
Manager::getImplementationName()
110 throw (uno::RuntimeException
, std::exception
)
112 return VLC_IMPLEMENTATION_NAME
;
115 sal_Bool SAL_CALL
Manager::supportsService( const rtl::OUString
& serviceName
)
116 throw (uno::RuntimeException
, std::exception
)
118 return cppu::supportsService(this, serviceName
);
121 uno::Sequence
< rtl::OUString
> SAL_CALL
Manager::getSupportedServiceNames()
122 throw (uno::RuntimeException
, std::exception
)
124 ::uno::Sequence
< OUString
> aRet(1);
125 aRet
[0] = VLC_SERVICENAME
;
129 } // end namespace vlc
130 } // end namespace avmedia
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */