Commit 50e21070 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Rework MediaList

Remove exceptions & c_object references
parent fa09e7b4
......@@ -34,6 +34,8 @@
namespace VLC
{
class MediaList;
class MediaPlayer;
class Media : public Internal<libvlc_media_t>
{
......@@ -353,6 +355,9 @@ private:
* not be used again.
*/
void release();
friend class MediaList;
friend class MediaPlayer;
};
} // namespace VLC
......
......@@ -55,58 +55,53 @@ MediaList::~MediaList()
release();
}
MediaList::MediaList(Media & p_md)
MediaList*MediaList::fromMedia(Media& md)
{
m_obj = libvlc_media_subitems(p_md.get_c_object());
if (!m_obj)
{
throw Exception("Can't construct MediaList");
}
InternalPtr ptr = libvlc_media_subitems( md );
if ( ptr == NULL )
return NULL;
return new MediaList( ptr );
}
MediaList::MediaList(MediaDiscoverer & p_mdis)
MediaList* MediaList::fromMediaDiscoverer( MediaDiscoverer& mdis )
{
m_obj = libvlc_media_discoverer_media_list(p_mdis.get_c_object());
if (!m_obj)
{
throw Exception("Can't construct MediaList");
}
InternalPtr ptr = libvlc_media_discoverer_media_list( mdis );
if ( ptr == NULL )
return NULL;
return new MediaList( ptr );
}
MediaList::MediaList(MediaLibrary & p_mlib)
MediaList*MediaList::fromMediaLibrary(MediaLibrary& mlib)
{
m_obj = libvlc_media_library_media_list(p_mlib.get_c_object());
if (!m_obj)
{
throw Exception("Can't construct MediaList");
}
InternalPtr ptr = libvlc_media_library_media_list( mlib );
if ( ptr == NULL )
return NULL;
return new MediaList( ptr );
}
MediaList::MediaList(Instance & p_instance)
MediaList*MediaList::create( Instance& instance )
{
m_obj = libvlc_media_list_new(p_instance.get_c_object());
if (!m_obj)
{
throw Exception("Can't construct MediaList");
}
InternalPtr ptr = libvlc_media_list_new( instance );
if ( ptr == NULL )
return NULL;
return new MediaList( ptr );
}
void MediaList::setMedia(Media & p_md)
void MediaList::setMedia( Media &md )
{
libvlc_media_list_set_media(m_obj, p_md.get_c_object());
libvlc_media_list_set_media( m_obj, md );
}
int MediaList::addMedia(Media & p_md)
int MediaList::addMedia(Media& p_md)
{
int c_result = libvlc_media_list_add_media(m_obj, p_md.get_c_object());
int c_result = libvlc_media_list_add_media( m_obj, p_md );
int result = c_result;
return result;
}
int MediaList::insertMedia(Media & p_md, int i_pos)
int MediaList::insertMedia( Media& md, int pos )
{
int c_result = libvlc_media_list_insert_media(m_obj, p_md.get_c_object(), i_pos);
int c_result = libvlc_media_list_insert_media( m_obj, md, pos );
int result = c_result;
return result;
}
......@@ -132,9 +127,9 @@ Media MediaList::itemAtIndex(int i_pos)
return result;
}
int MediaList::indexOfItem(Media & p_md)
int MediaList::indexOfItem( Media &md )
{
int c_result = libvlc_media_list_index_of_item(m_obj, p_md.get_c_object());
int c_result = libvlc_media_list_index_of_item( m_obj, md );
int result = c_result;
return result;
}
......@@ -163,6 +158,11 @@ libvlc_event_manager_t * MediaList::eventManager()
return result;
}
MediaList::MediaList( Internal::InternalPtr ptr )
: Internal( ptr )
{
}
void MediaList::release()
{
libvlc_media_list_release(m_obj);
......
......@@ -67,7 +67,7 @@ public:
*
* \param p_md media descriptor object
*/
MediaList(Media & p_md);
static MediaList* fromMedia(Media &md);
// libvlc_media_discoverer_media_list
/**
......@@ -75,7 +75,7 @@ public:
*
* \param p_mdis media service discover object
*/
MediaList(MediaDiscoverer & p_mdis);
static MediaList* fromMediaDiscoverer(MediaDiscoverer & mdis);
// libvlc_media_library_media_list
/**
......@@ -83,7 +83,7 @@ public:
*
* \param p_mlib media library object
*/
MediaList(MediaLibrary & p_mlib);
static MediaList* fromMediaLibrary( MediaLibrary &mlib );
// libvlc_media_list_new
/**
......@@ -91,7 +91,7 @@ public:
*
* \param p_instance libvlc instance
*/
MediaList(Instance & p_instance);
static MediaList* create(Instance &instance);
/**
* Associate media instance with this media list instance. If another
......@@ -122,7 +122,7 @@ public:
*
* \return 0 on success, -1 if the media list is read-only
*/
int insertMedia(Media & p_md, int i_pos);
int insertMedia(Media & md, int pos);
/**
* Remove media instance from media list on a position The
......@@ -164,7 +164,7 @@ public:
*
* \return position of media instance or -1 if media not found
*/
int indexOfItem(Media & p_md);
int indexOfItem(Media & md);
/**
* This indicates if this media list is read-only from a user point of
......@@ -194,6 +194,7 @@ public:
libvlc_event_manager_t * eventManager();
private:
MediaList(InternalPtr ptr);
/**
* Release media list created with MediaList::MediaList() .
*/
......
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