Kaydet (Commit) 5ae5a11f authored tarafından Minh Ngo's avatar Minh Ngo Kaydeden (comit) Michael Meeks

VLC::Instance Wrapper class for libvlc_instance_t

Change-Id: I46beb65c13ed349b0faadfab1be888d6cbd10ff9
üst 3e51dc6f
......@@ -45,6 +45,7 @@ $(eval $(call gb_Library_add_exception_objects,avmediavlc,\
avmedia/source/vlc/vlcuno \
avmedia/source/vlc/vlcwindow \
avmedia/source/vlc/vlcframegrabber \
avmedia/source/vlc/wrapper/Instance \
))
# vim: set noet sw=4 ts=4:
......@@ -4,6 +4,7 @@
#include "vlcplayer.hxx"
#include "vlcwindow.hxx"
#include "vlcframegrabber.hxx"
#include "wrapper/Instance.hxx"
using namespace ::com::sun::star;
......@@ -14,31 +15,28 @@ const ::rtl::OUString AVMEDIA_VLC_PLAYER_IMPLEMENTATIONNAME = "com.sun.star.comp
const ::rtl::OUString AVMEDIA_VLC_PLAYER_SERVICENAME = "com.sun.star.media.Player_VLC";
const char * const VLC_ARGS[] = {
// "-I",
"-Vdummy",
"--snapshot-format=png",
// "--ignore-config",
"--ffmpeg-threads",
"--verbose=-1",
// "--quiet"
};
const int MS_IN_SEC = 1000; // Millisec in sec
namespace
{
libvlc_media_t* InitMedia( const rtl::OUString& url, boost::shared_ptr<libvlc_instance_t>& instance )
libvlc_media_t* InitMedia( const rtl::OUString& url, VLC::Instance& instance )
{
rtl::OString dest;
url.convertToString(&dest, RTL_TEXTENCODING_UTF8, 0);
return libvlc_media_new_path(instance.get(), dest.getStr());
return libvlc_media_new_path(instance, dest.getStr());
}
}
VLCPlayer::VLCPlayer( const rtl::OUString& url )
: VLC_Base(m_aMutex)
, mInstance( libvlc_new( sizeof( VLC_ARGS ) / sizeof( VLC_ARGS[0] ), VLC_ARGS ), libvlc_release )
, mInstance( sizeof( VLC_ARGS ) / sizeof( VLC_ARGS[0] ), VLC_ARGS )
, mMedia( InitMedia( url, mInstance ), libvlc_media_release )
, mPlayer( libvlc_media_player_new_from_media( mMedia.get() ), libvlc_media_player_release )
, mUrl( url )
......@@ -108,7 +106,7 @@ namespace
case libvlc_MediaPlayerEndReached:
boost::shared_ptr<libvlc_media_player_t> player = *static_cast< boost::shared_ptr<libvlc_media_player_t>* >( pData );
libvlc_media_player_stop( player.get() );
libvlc_media_player_play( player.get() )
libvlc_media_player_play( player.get() );
break;
}
}
......
......@@ -27,6 +27,7 @@
#include <com/sun/star/media/XPlayer.hpp>
#include <cppuhelper/basemutex.hxx>
#include "wrapper/Instance.hxx"
namespace avmedia {
namespace vlc {
......@@ -37,7 +38,7 @@ typedef ::cppu::WeakComponentImplHelper2< ::com::sun::star::media::XPlayer,
class VLCPlayer : public ::cppu::BaseMutex,
public VLC_Base
{
boost::shared_ptr<libvlc_instance_t> mInstance;
VLC::Instance mInstance;
boost::shared_ptr<libvlc_media_t> mMedia;
boost::shared_ptr<libvlc_media_player_t> mPlayer;
const rtl::OUString mUrl;
......@@ -74,4 +75,4 @@ public:
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
\ No newline at end of file
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#include <rtl/ustring.hxx>
#include "Instance.hxx"
#include "SymbolLoader.hxx"
namespace VLC
{
namespace
{
libvlc_instance_t *(*libvlc_new) (int argc, const char * const *argv);
void (*libvlc_release) (libvlc_instance_t *p_instance);
ApiMap VLC_INSTANCE_API[] =
{
SYM_MAP( libvlc_new ),
SYM_MAP( libvlc_release )
};
}
Instance::Instance( int argc, const char * const *argv )
{
InitApiMap( VLC_INSTANCE_API );
mInstance = libvlc_new( argc, argv );
}
Instance::~Instance()
{
libvlc_release( mInstance );
}
}
/* -*- 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 .
*/
#ifndef _WRAPPER_INSTANCE_HXX
#define _WRAPPER_INSTANCE_HXX
struct libvlc_instance_t;
namespace VLC
{
class Instance
{
public:
Instance( int argc, const char * const *argv );
virtual ~Instance();
inline operator libvlc_instance_t*()
{
return mInstance;
}
private:
libvlc_instance_t *mInstance;
};
}
#endif
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment