MediaLibrary.cpp 2.18 KB
Newer Older
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
1 2 3 4 5 6
/*****************************************************************************
 * libvlc_MediaLibrary.cpp: MediaLibrary implementation
 *****************************************************************************
 * Copyright © 2014 the VideoLAN team
 *
 * Authors: Alexey Sokolov <alexey@alexeysokolov.co.cc>
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

26 27
#include <stdexcept>

28 29
namespace VLC
{
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
30

31
MediaLibrary::MediaLibrary(Instance& instance)
32
{
33 34 35
    m_obj = libvlc_media_library_new( instance );
    if (m_obj == NULL)
        throw std::runtime_error("Failed to construct a media library");
36 37 38
}

MediaLibrary::MediaLibrary(const MediaLibrary& another)
39
    : Internal( another )
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
40 41 42 43
{
    retain();
}

44
MediaLibrary& MediaLibrary::operator=(const MediaLibrary& another)
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
45
{
46
    if (this == &another)
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
47 48 49 50 51 52 53 54 55
    {
        return *this;
    }
    release();
    m_obj = another.m_obj;
    retain();
    return *this;
}

56
bool MediaLibrary::operator==(const MediaLibrary& another) const
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
57 58 59 60
{
    return m_obj == another.m_obj;
}

61
MediaLibrary::~MediaLibrary()
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
62 63 64 65
{
    release();
}

66
int MediaLibrary::load()
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
67
{
68
    return libvlc_media_library_load(m_obj);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
69 70
}

71 72 73 74 75
MediaLibrary::MediaLibrary(Internal::InternalPtr ptr)
    : Internal( ptr )
{
}

76
void MediaLibrary::release()
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
77 78 79 80
{
    libvlc_media_library_release(m_obj);
}

81
void MediaLibrary::retain()
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
82 83 84 85 86 87
{
    libvlc_media_library_retain(m_obj);
}

} // namespace VLC