bump product version to 6.3.0.0.beta1
[LibreOffice.git] / avmedia / source / vlc / vlcmanager.cxx
blobe82e88b604aa3a4d45f7bada264f64fb4872d344
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 <sal/log.hxx>
15 #include "vlcmanager.hxx"
16 #include "vlcplayer.hxx"
17 #include <wrapper/Instance.hxx>
18 #include <wrapper/EventManager.hxx>
19 #include <wrapper/Media.hxx>
20 #include <wrapper/Player.hxx>
21 #include <wrapper/Common.hxx>
23 using namespace ::com::sun::star;
25 namespace avmedia {
26 namespace vlc {
28 namespace
30 const OUString VLC_IMPLEMENTATION_NAME = "com.sun.star.comp.avmedia.Manager_VLC";
31 const OUString VLC_SERVICENAME = "com.sun.star.media.Manager_VLC";
33 const char * const VLC_ARGS[] = {
34 "--demux",
35 "ffmpeg",
36 "--no-mouse-events",
37 "--verbose=-1"
41 Manager::Manager()
42 : mEventHandler()
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( SAL_N_ELEMENTS(VLC_ARGS), 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 OUString& rURL )
87 if ( !m_is_vlc_found )
88 throw uno::RuntimeException("VLC not found", nullptr);
90 if ( !rURL.isEmpty() )
92 if (mURL == rURL)
93 return mPlayer;
95 mURL = rURL;
97 else
98 return mPlayer;
100 VLCPlayer* pPlayer( new VLCPlayer( mURL,
101 *mInstance,
102 mEventHandler /*, mxMgr */ ) );
103 mPlayer.set( pPlayer );
105 return mPlayer;
108 OUString SAL_CALL Manager::getImplementationName()
110 return VLC_IMPLEMENTATION_NAME;
113 sal_Bool SAL_CALL Manager::supportsService( const OUString& serviceName )
115 return cppu::supportsService(this, serviceName);
118 uno::Sequence< OUString > SAL_CALL Manager::getSupportedServiceNames()
120 return { VLC_SERVICENAME };
123 } // end namespace vlc
124 } // end namespace avmedia
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */