Commit 41afbf47 authored by Martin Finkel's avatar Martin Finkel

Add RendererDiscoverer C++/CX bindings

parent 3280f870
......@@ -251,6 +251,7 @@
<ClInclude Include="..\libvlcppcx\MediaListCX.hpp" />
<ClInclude Include="..\libvlcppcx\MediaPlayerCX.hpp" />
<ClInclude Include="..\libvlcppcx\PlatformHelpers.hpp" />
<ClInclude Include="..\libvlcppcx\RendererDiscovererCX.hpp" />
<ClInclude Include="..\libvlcppcx\StructuresCX.hpp" />
<ClInclude Include="..\libvlcpp\vlcpp\common.hpp" />
<ClInclude Include="..\libvlcpp\vlcpp\Dialog.hpp" />
......@@ -264,6 +265,7 @@
<ClInclude Include="..\libvlcpp\vlcpp\MediaList.hpp" />
<ClInclude Include="..\libvlcpp\vlcpp\MediaListPlayer.hpp" />
<ClInclude Include="..\libvlcpp\vlcpp\MediaPlayer.hpp" />
<ClInclude Include="..\libvlcpp\vlcpp\RendererDiscoverer.hpp" />
<ClInclude Include="..\libvlcpp\vlcpp\structures.hpp" />
<ClInclude Include="..\libvlcpp\vlcpp\vlc.hpp" />
<ClInclude Include="..\libVLCX\DirectXManager.h" />
......@@ -280,6 +282,7 @@
<ClCompile Include="..\libvlcppcx\MediaListCX.cpp" />
<ClCompile Include="..\libvlcppcx\MediaPlayerCX.cpp" />
<ClCompile Include="..\libvlcppcx\PlatformHelpers.cpp" />
<ClCompile Include="..\libvlcppcx\RendererDiscovererCX.cpp" />
<ClCompile Include="..\libvlcppcx\StructuresCX.cpp" />
<ClCompile Include="..\libVLCX\DirectXManager.cpp" />
<ClCompile Include="..\libVLCX\Thumbnailer.cpp" />
......
......@@ -46,6 +46,9 @@
<ClCompile Include="..\libvlcppcx\PlatformHelpers.cpp">
<Filter>libvlcppcx</Filter>
</ClCompile>
<ClCompile Include="..\libvlcppcx\RendererDiscovererCX.cpp">
<Filter>libvlcppcx</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="pch.h" />
......@@ -123,5 +126,11 @@
<ClInclude Include="..\libvlcppcx\PlatformHelpers.hpp">
<Filter>libvlcppcx</Filter>
</ClInclude>
<ClInclude Include="..\libvlcpp\vlcpp\RendererDiscoverer.hpp">
<Filter>libvlcpp</Filter>
</ClInclude>
<ClInclude Include="..\libvlcppcx\RendererDiscovererCX.hpp">
<Filter>libvlcppcx</Filter>
</ClInclude>
</ItemGroup>
</Project>
\ No newline at end of file
......@@ -42,6 +42,11 @@ namespace libVLCX
{
}
RendererDiscovererEventManager::RendererDiscovererEventManager(VLC::RendererDiscovererEventManager& em)
: m_em(em)
{
}
void EventRemover::removeToken(std::vector<VLC::EventManager::RegisteredEvent>& events, Windows::Foundation::EventRegistrationToken token)
{
auto h = (VLC::EventManager::RegisteredEvent)token.Value;
......
......@@ -25,12 +25,14 @@
#include <vlcpp/vlc.hpp>
#include "StructuresCX.hpp"
#include "MediaCX.hpp"
#include "RendererDiscovererCX.hpp"
#include <memory>
namespace libVLCX
{
ref class Media;
ref class RendererItem;
public delegate void MediaChanged(Media^);
public delegate void NothingSpecial();
......@@ -62,6 +64,10 @@ namespace libVLCX
public delegate void MediaListWillDeleteItem(Media^, int);
public delegate void ParsedChanged(ParsedStatus);
public delegate void RendererItemAdded(RendererItem^);
public delegate void RendererItemDeleted(RendererItem^);
ref class EventManager;
private ref class EventRemover sealed
......@@ -70,7 +76,6 @@ namespace libVLCX
static void removeToken(std::vector<VLC::EventManager::RegisteredEvent>& events, Windows::Foundation::EventRegistrationToken token);
};
public ref class MediaPlayerEventManager sealed
{
private:
......@@ -563,4 +568,45 @@ namespace libVLCX
}
}
};
public ref class RendererDiscovererEventManager sealed
{
private:
std::vector<VLC::EventManager::RegisteredEvent> m_events;
internal:
RendererDiscovererEventManager(VLC::RendererDiscovererEventManager& em);
private:
VLC::RendererDiscovererEventManager& m_em;
public:
event RendererItemAdded^ OnItemAdded
{
Windows::Foundation::EventRegistrationToken add(RendererItemAdded^ handler)
{
auto h = m_em.onItemAdded([handler](VLC::RendererDiscoverer::Item i) {
handler(ref new RendererItem(i));
});
m_events.push_back(h);
return Windows::Foundation::EventRegistrationToken{ (int64)h };
}
void remove(Windows::Foundation::EventRegistrationToken token) {
EventRemover::removeToken(m_events, token);
}
}
event RendererItemDeleted^ OnRendererItemDeleted
{
Windows::Foundation::EventRegistrationToken add(RendererItemDeleted^ handler)
{
auto h = m_em.onItemDeleted([handler](VLC::RendererDiscoverer::Item i) {
handler(ref new RendererItem(i));
});
m_events.push_back(h);
return Windows::Foundation::EventRegistrationToken{ (int64)h };
}
void remove(Windows::Foundation::EventRegistrationToken token) {
EventRemover::removeToken(m_events, token);
}
}
};
}
......@@ -170,6 +170,11 @@ namespace libVLCX
return MarshallVector<MediaDiscovererDescription, VLC::MediaDiscoverer::Description>(m_instance.mediaDiscoverers(static_cast<VLC::MediaDiscoverer::Category>(category)));
}
Windows::Foundation::Collections::IVector<RendererDiscovererDescription^>^ Instance::rendererDiscoverers()
{
return MarshallVector<RendererDiscovererDescription, VLC::RendererDiscovererDescription>(m_instance.rendererDiscoverers());
}
Instance::~Instance()
{
}
......
......@@ -305,6 +305,8 @@ namespace libVLCX
Windows::Foundation::Collections::IVector<MediaDiscovererDescription^>^ mediaDiscoverers(MediaDiscovererCategory category);
Windows::Foundation::Collections::IVector<RendererDiscovererDescription^>^ rendererDiscoverers();
void UpdateScale(float x, float y);
private:
void InitializeHack(char** argv, unsigned int & nbArgs);
......
......@@ -25,6 +25,7 @@
#include "InstanceCX.hpp"
#include "EventManagerCX.hpp"
#include "EqualizerCX.hpp"
#include "RendererDiscovererCX.hpp"
#include "Helpers.h"
......@@ -544,5 +545,10 @@ namespace libVLCX
m_mp.setAdjustFloat(option, value);
}
bool MediaPlayer::setRenderer(RendererItem^ item)
{
return m_mp.setRenderer(item->m_item);
}
} // namespace VLC
......@@ -25,6 +25,7 @@
#include <collection.h>
#include "StructuresCX.hpp"
#include "MediaCX.hpp"
#include "RendererDiscovererCX.hpp"
#include <vlcpp/vlc.hpp>
namespace libVLCX
......@@ -1111,6 +1112,8 @@ namespace libVLCX
*/
void setAdjustFloat(unsigned option, float value);
bool setRenderer(RendererItem^ item);
private:
~MediaPlayer(){}
......
/*****************************************************************************
* RendererDiscoverer.cpp: RendererDiscoverer API
*****************************************************************************
* Copyright 2018 libvlcpp authors & VideoLAN
*
* Authors: Alexey Sokolov <alexey+vlc@asokolov.org>
* Hugo Beauze-Luyssen <hugo@beauzee.fr>
*
* 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.
*****************************************************************************/
#include "InstanceCX.hpp"
#include "RendererDiscovererCX.hpp"
#include "EventManagerCX.hpp"
namespace libVLCX
{
RendererItem::RendererItem(const VLC::RendererDiscoverer::Item& item)
: m_item(item)
{
}
Platform::String^ RendererItem::name()
{
return ToPlatformString(m_item.name());
}
Platform::String^ RendererItem::type()
{
return ToPlatformString(m_item.type());
}
Platform::String^ RendererItem::iconUri()
{
return ToPlatformString(m_item.iconUri());
}
bool RendererItem::canRenderVideo()
{
return m_item.canRenderVideo();
}
bool RendererItem::canRenderAudio()
{
return m_item.canRenderAudio();
}
RendererDiscoverer::RendererDiscoverer(Instance^ inst, Platform::String^ name) :
m_discoverer(inst->m_instance, FromPlatformString(name))
{
}
bool RendererDiscoverer::start()
{
return m_discoverer.start();
}
void RendererDiscoverer::stop()
{
m_discoverer.stop();
}
RendererDiscovererEventManager^ RendererDiscoverer::eventManager()
{
if (m_eventManager == nullptr)
m_eventManager = ref new RendererDiscovererEventManager(m_discoverer.eventManager());
return m_eventManager;
}
}
\ No newline at end of file
/*****************************************************************************
* RendererDiscoverer.hpp: RendererDiscoverer API
*****************************************************************************
* Copyright 2015 libvlcpp authors & VideoLAN
*
* Authors: Alexey Sokolov <alexey+vlc@asokolov.org>
* Hugo Beauze-Luyssen <hugo@beauzee.fr>
* Bastien Penavayre <bastienPenava@gmail.com>
*
* 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.
*****************************************************************************/
#pragma once
#include "vlcpp\RendererDiscoverer.hpp"
namespace libVLCX
{
ref class RendererDiscovererEventManager;
ref class Instance;
public ref class RendererItem sealed
{
internal:
VLC::RendererDiscoverer::Item m_item;
RendererItem(const VLC::RendererDiscoverer::Item& item);
public:
Platform::String^ name();
Platform::String^ type();
Platform::String^ iconUri();
bool canRenderVideo();
bool canRenderAudio();
};
public ref class RendererDiscoverer sealed
{
VLC::RendererDiscoverer m_discoverer;
public:
RendererDiscoverer(Instance^ inst, Platform::String^ name);
bool start();
void stop();
RendererDiscovererEventManager^ eventManager();
private:
RendererDiscovererEventManager ^ m_eventManager;
};
}
\ No newline at end of file
......@@ -330,4 +330,20 @@ namespace libVLCX
, m_category(static_cast<MediaDiscovererCategory>(desc.category()))
{
}
}
Platform::String^ RendererDiscovererDescription::name()
{
return m_name;
}
Platform::String^ RendererDiscovererDescription::longName()
{
return m_longName;
}
RendererDiscovererDescription::RendererDiscovererDescription(const VLC::RendererDiscovererDescription& desc)
: m_name(ToPlatformString(desc.name().c_str()))
, m_longName(ToPlatformString(desc.longName().c_str()))
{
}
}
\ No newline at end of file
......@@ -268,4 +268,17 @@ namespace libVLCX
Platform::String^ m_longName;
MediaDiscovererCategory m_category;
};
public ref class RendererDiscovererDescription sealed
{
public:
Platform::String^ name();
Platform::String^ longName();
internal:
explicit RendererDiscovererDescription(const VLC::RendererDiscovererDescription& desc);
private:
Platform::String^ m_name;
Platform::String^ m_longName;
};
}
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