fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / avmedia / source / vlc / vlcmanager.cxx
blob296c35011a427f28c60e4788feaff556068211c0
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
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/.
8 */
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;
24 namespace avmedia {
25 namespace vlc {
27 namespace
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[] = {
33 "--demux",
34 "ffmpeg",
35 "--no-mouse-events",
36 "--verbose=-1"
40 Manager::Manager( const uno::Reference< lang::XMultiServiceFactory >& rxMgr )
41 : mEventHandler()
42 , mxMgr( 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;
50 if (m_is_vlc_found)
52 mInstance.reset(new Instance( sizeof( VLC_ARGS ) / sizeof( VLC_ARGS[0] ), VLC_ARGS ));
53 //Check VLC version
54 std::vector<std::string> verComponents;
55 const std::string str(Common::Version());
57 boost::split(verComponents,
58 str,
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;
68 else
69 SAL_INFO("avmedia", "VLC version '" << str << "' is acceptable");
71 else
72 SAL_WARN("avmedia", "Cannot load symbols");
74 if (m_is_vlc_found)
76 mEventHandler.create();
80 Manager::~Manager()
82 mEventHandler.stop();
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() )
93 if (mURL == rURL)
94 return mPlayer;
96 mURL = rURL;
98 else
99 return mPlayer;
101 VLCPlayer* pPlayer( new VLCPlayer( mURL,
102 *mInstance,
103 mEventHandler /*, mxMgr */ ) );
104 mPlayer = uno::Reference< media::XPlayer >( pPlayer );
106 return mPlayer;
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;
126 return aRet;
129 } // end namespace vlc
130 } // end namespace avmedia
132 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */