Commit 6f944e28 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Add missing media discoverers listing

parent 2ebcc98b
......@@ -36,6 +36,10 @@ int main(int ac, char** av)
const char* vlcArgs = "-vv";
auto instance = VLC::Instance(1, &vlcArgs);
auto sds = instance.mediaDiscoverers( VLC::MediaDiscoverer::Category::Lan );
for ( const auto& sd : sds )
std::cout << "Found SD: " << sd.name() << "(" << sd.longName() << ")" << std::endl;
instance.setExitHandler([] {
std::cout << "Libvlc is exiting" << std::endl;
});
......
......@@ -29,6 +29,7 @@
#include "Internal.hpp"
#include "structures.hpp"
#include "Dialog.hpp"
#include "MediaDiscoverer.hpp"
#include <string>
#include <vector>
......@@ -490,6 +491,34 @@ public:
std::fill(m_callbacks->begin() + 2, m_callbacks->end(), nullptr);
libvlc_dialog_set_callbacks(*this, nullptr, nullptr);
}
/**
* Get media discoverer services by category
*
* \version LibVLC 3.0.0 and later.
*
* \param category The category of services to fetch
*
* \return A vector containing the available media discoverers
*/
std::vector<MediaDiscoverer::Description> mediaDiscoverers(MediaDiscoverer::Category category)
{
libvlc_media_discoverer_description** pp_descs;
auto nbSd = libvlc_media_discoverer_list_get( *this, static_cast<libvlc_media_discoverer_category>( category ),
&pp_descs );
if ( nbSd == 0 )
return {};
auto releaser = [nbSd](libvlc_media_discoverer_description** ptr) {
libvlc_media_discoverer_list_release( ptr, nbSd );
};
std::unique_ptr<libvlc_media_discoverer_description*, decltype(releaser)> descPtr( pp_descs, releaser );
std::vector<MediaDiscoverer::Description> res;
res.reserve( nbSd );
for ( auto i = 0u; i < nbSd; ++i )
res.emplace_back( pp_descs[i]->psz_name, pp_descs[i]->psz_longname, pp_descs[i]->i_cat );
return res;
}
#endif
};
......
......@@ -39,6 +39,45 @@ class MediaList;
class MediaDiscoverer : public Internal<libvlc_media_discoverer_t>
{
public:
enum class Category
{
Devices = libvlc_media_discoverer_devices,
Lan = libvlc_media_discoverer_lan,
Podcasts = libvlc_media_discoverer_podcasts,
Localdirs = libvlc_media_discoverer_localdirs,
};
class Description
{
public:
explicit Description( const std::string& name, const std::string& longName, libvlc_media_discoverer_category cat )
: m_name( name )
, m_longName( longName )
, m_category( static_cast<Category>( cat ) )
{
}
const std::string& name() const
{
return m_name;
}
const std::string& longName() const
{
return m_longName;
}
Category category() const
{
return m_category;
}
private:
std::string m_name;
std::string m_longName;
Category m_category;
};
/**
* Discover media service by name.
*
......
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