Instance.cpp 4.03 KB
Newer Older
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
1 2 3 4 5 6
/*****************************************************************************
 * libvlc_Instance.cpp: Instance implementation
 *****************************************************************************
 * Copyright © 2014 the VideoLAN team
 *
 * Authors: Alexey Sokolov <alexey@alexeysokolov.co.cc>
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
7
 *          Hugo Beauzée-Luyssen <hugo@beauzee.fr>
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; either version 2.1 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
 *****************************************************************************/

24
#include "vlc.hpp"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
25

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
26 27
namespace VLC
{
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
28

29
Instance::Instance(int argc, const char* const* argv)
30
    : Internal{ libvlc_new( argc, argv ), libvlc_release }
31
{
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
32 33
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
34
bool Instance::operator==( const Instance& another ) const
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
35 36 37 38
{
    return m_obj == another.m_obj;
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
39
int Instance::addIntf( const std::string& name )
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
40
{
41
    return libvlc_add_intf( get(), name.c_str() );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
42 43
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
44
void Instance::setExitHandler( void(*cb)(void *), void * opaque )
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
45
{
46
    libvlc_set_exit_handler( get(), cb, opaque );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
47 48
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
49
void Instance::setUserAgent( const std::string& name, const std::string& http )
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
50
{
51
    libvlc_set_user_agent( get(), name.c_str(), http.c_str() );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
52 53
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
54
void Instance::setAppId( const std::string& id, const std::string& version, const std::string& icon )
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
55
{
56
    libvlc_set_app_id( get(), id.c_str(), version.c_str(), icon.c_str() );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
57 58
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
59
void Instance::logUnset()
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
60
{
61
    libvlc_log_unset( get() );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
62 63
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
64
void Instance::logSet( libvlc_log_cb cb, void * data )
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
65
{
66
    libvlc_log_set(get(), cb, data);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
67 68
}

Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
69
void Instance::logSetFile( FILE * stream )
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
70
{
71
    libvlc_log_set_file( get(), stream );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
72 73
}

74 75
std::vector<ModuleDescription> Instance::audioFilterList()
{
76
    libvlc_module_description_t* result = libvlc_audio_filter_list_get(get());
77 78 79 80 81 82 83 84 85 86 87
    std::vector<ModuleDescription> res;
    if ( result == NULL )
        return res;
    libvlc_module_description_t* p = result;
    while ( p != NULL )
    {
        res.push_back( ModuleDescription( p ) );
        p = p->p_next;
    }
    libvlc_module_description_list_release( result );
    return res;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
88 89
}

90
std::vector<ModuleDescription> Instance::videoFilterList()
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
91
{
92
    libvlc_module_description_t* result = libvlc_video_filter_list_get(get());
93 94 95 96 97 98 99 100 101 102 103
    std::vector<ModuleDescription> res;
    if ( result == NULL )
        return res;
    libvlc_module_description_t* p = result;
    while ( p != NULL )
    {
        res.push_back( ModuleDescription( p ) );
        p = p->p_next;
    }
    libvlc_module_description_list_release( result );
    return res;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
104 105
}

106
std::vector<AudioOutputDescription> Instance::audioOutputList()
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
107
{
108
    libvlc_audio_output_t* result = libvlc_audio_output_list_get(get());
109 110 111 112 113 114 115 116 117 118 119
    std::vector<AudioOutputDescription> res;
    if ( result == NULL )
        return res;
    libvlc_audio_output_t* p = result;
    while ( p != NULL )
    {
        res.push_back( AudioOutputDescription( p ) );
        p = p->p_next;
    }
    libvlc_audio_output_list_release(result);
    return res;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
120 121
}

122
std::vector<AudioOutputDeviceDescription> Instance::audioOutputDeviceList(const std::string& aout)
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
123
{
124
    libvlc_audio_output_device_t* devices = libvlc_audio_output_device_list_get( get(), aout.c_str() );
125 126 127 128 129 130 131
    std::vector<AudioOutputDeviceDescription> res;
    if ( devices == NULL )
        return res;
    for ( libvlc_audio_output_device_t* p = devices; p != NULL; p = p->p_next )
        res.push_back( AudioOutputDeviceDescription( p ) );
    libvlc_audio_output_device_list_release( devices );
    return res;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
132 133 134 135
}

} // namespace VLC