MediaList.hpp 6 KB
Newer Older
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
1 2 3 4 5 6
/*****************************************************************************
 * libvlc_MediaList.hpp: MediaList API
 *****************************************************************************
 * 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 24 25 26
 *
 * 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.
 *****************************************************************************/

#ifndef LIBVLC_CXX_MEDIALIST_H
#define LIBVLC_CXX_MEDIALIST_H

27
#include "common.hpp"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
28
#include "Internal.hpp"
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
29

30
namespace VLC
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
31 32
{

33 34
class EventManager;

35
class VLCPP_API MediaList : public Internal<libvlc_media_list_t>
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
36 37 38 39 40 41 42 43 44 45 46 47 48
{
public:
    /**
     * Copy libvlc_media_list_t from another to new MediaList object.
     * \param another existing MediaList
     */
    MediaList(const MediaList& another);

    /**
     * Copy libvlc_media_list_t from another MediaList
     * to this MediaList
     * \param another existing MediaList
     */
49
    MediaList& operator=(const MediaList& another);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

    /**
     * Check if 2 MediaList objects contain the same libvlc_media_list_t.
     * \param another another MediaList
     * \return true if they contain the same libvlc_media_list_t
     */
    bool operator==(const MediaList& another) const;

    ~MediaList();

    // libvlc_media_subitems
    /**
     * Get subitems of media descriptor object. This will increment the
     * reference count of supplied media descriptor object. Use
     * MediaList::release() to decrement the reference counting.
     *
     * \param p_md  media descriptor object
     */
68
    MediaList(Media &md);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
69 70 71 72 73 74 75

    // libvlc_media_discoverer_media_list
    /**
     * Get media service discover media list.
     *
     * \param p_mdis  media service discover object
     */
76
    MediaList(MediaDiscoverer & mdis);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
77 78 79 80 81 82 83

    // libvlc_media_library_media_list
    /**
     * Get media library subitems.
     *
     * \param p_mlib  media library object
     */
84
    MediaList( MediaLibrary &mlib );
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
85 86 87 88 89 90 91

    // libvlc_media_list_new
    /**
     * Create an empty media list.
     *
     * \param p_instance  libvlc instance
     */
92
    MediaList(Instance &instance);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122

    /**
     * Associate media instance with this media list instance. If another
     * media instance was present it will be released. The
     * libvlc_media_list_lock should NOT be held upon entering this function.
     *
     * \param p_md  media instance to add
     */
    void setMedia(Media & p_md);

    /**
     * Add media instance to media list The libvlc_media_list_lock should be
     * held upon entering this function.
     *
     * \param p_md  a media instance
     *
     * \return 0 on success, -1 if the media list is read-only
     */
    int addMedia(Media & p_md);

    /**
     * Insert media instance in media list on a position The
     * libvlc_media_list_lock should be held upon entering this function.
     *
     * \param p_md  a media instance
     *
     * \param i_pos  position in array where to insert
     *
     * \return 0 on success, -1 if the media list is read-only
     */
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
123
    int insertMedia(Media & md, int pos);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164

    /**
     * Remove media instance from media list on a position The
     * libvlc_media_list_lock should be held upon entering this function.
     *
     * \param i_pos  position in array where to insert
     *
     * \return 0 on success, -1 if the list is read-only or the item was not
     * found
     */
    int removeIndex(int i_pos);

    /**
     * Get count on media list items The libvlc_media_list_lock should be
     * held upon entering this function.
     *
     * \return number of items in media list
     */
    int count();

    /**
     * List media instance in media list at a position The
     * libvlc_media_list_lock should be held upon entering this function.
     *
     * \param i_pos  position in array where to insert
     *
     * \return media instance at position i_pos, or NULL if not found. In
     * case of success, Media::retain() is called to increase the refcount on
     * the media.
     */
    Media itemAtIndex(int i_pos);

    /**
     * Find index position of List media instance in media list. Warning: the
     * function will return the first matched position. The
     * libvlc_media_list_lock should be held upon entering this function.
     *
     * \param p_md  media instance
     *
     * \return position of media instance or -1 if media not found
     */
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
165
    int indexOfItem(Media & md);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191

    /**
     * This indicates if this media list is read-only from a user point of
     * view
     *
     * \return 1 on readonly, 0 on readwrite
     */
    bool isReadonly();

    /**
     * Get lock on media list items
     */
    void lock();

    /**
     * Release lock on media list items The libvlc_media_list_lock should be
     * held upon entering this function.
     */
    void unlock();

    /**
     * Get libvlc_event_manager from this media list instance. The
     * p_event_manager is immutable, so you don't have to hold the lock
     *
     * \return libvlc_event_manager
     */
192
    VLC::EventManager& eventManager();
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
193 194

private:
195
    explicit MediaList(InternalPtr ptr);
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
196 197 198 199 200 201 202 203 204
    /**
     * Release media list created with MediaList::MediaList() .
     */
    void release();

    /**
     * Retain reference to a media list
     */
    void retain();
205 206 207

private:
    EventManager* m_eventManager;
Hugo Beauzée-Luyssen's avatar
Hugo Beauzée-Luyssen committed
208 209 210 211 212 213
};

} // namespace VLC

#endif