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

Remove C++/CX bindings

Those belong in the WinRT app
parent dc88b216
/*****************************************************************************
* DialogCX.cpp: libvlcpp dialog API
*****************************************************************************
* Copyright © 2016 VLC authors and VideoLAN
*
* Authors: 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.
*****************************************************************************/
#include "InstanceCX.hpp"
libVLCX::Dialog::Dialog(VLC::Dialog &&other) : _dialog(std::move(other))
{
}
bool libVLCX::Dialog::postLogin(Platform::String^ username, Platform::String^ password, bool store)
{
return _dialog.postLogin(FromPlatformString(username), FromPlatformString(password), store);
}
bool libVLCX::Dialog::postAction(int actionIndex)
{
return _dialog.postAction(actionIndex);
}
bool libVLCX::Dialog::dismiss()
{
return _dialog.dismiss();
}
\ No newline at end of file
/*****************************************************************************
* DialogCX.hpp: libvlcpp dialog API
*****************************************************************************
* Copyright © 2016 VLC authors and VideoLAN
*
* Authors: 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
namespace libVLCX
{
public ref class Dialog sealed
{
VLC::Dialog _dialog;
friend ref class Instance;
/**
* The standard constructor.
*
* Used only by setDialogHandlers in Instance.hpp.
* \param other native C++ instance of Dialog
*/
Dialog(VLC::Dialog &&other);
public:
/**
* Post a login answer.
*
* After this call, the instance won't be valid anymore
*
* \param username valid non-empty string
* \param password valid string
* \param store if true stores the credentials
* \return true if success, false otherwise
*/
bool postLogin(Platform::String^ username, Platform::String^ password, bool store);
/**
* Post a question answer.
*
* After this call, this instance won't be valid anymore
*
* \see QuestionCb
* \param actionIndex 1 for action1, 2 for action2
* \return true on success, false otherwise
*/
bool postAction(int actionIndex);
/**
* Dismiss a dialog.
*
* After this call, this instance won't be valid anymore
*
* \see CancelCb
*/
bool dismiss();
};
}
\ No newline at end of file
/*****************************************************************************
* EqualizerCX.cpp: Equalizer API
*****************************************************************************
* Copyright © 2015 libvlcpp authors & VideoLAN
*
* Authors: Hugo Beauzée-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.
*****************************************************************************/
#include "EqualizerCX.hpp"
#include "Helpers.h"
namespace libVLCX
{
Equalizer::Equalizer()
{
}
Equalizer::Equalizer(unsigned int index)
: m_eq(index)
{
}
int Equalizer::setPreamp(float preamp)
{
return m_eq.setPreamp(preamp);
}
float Equalizer::preamp()
{
return m_eq.preamp();
}
int Equalizer::setAmp(float amp, unsigned int band)
{
return m_eq.setAmp(amp, band);
}
float Equalizer::amp(unsigned int band)
{
return m_eq.amp(band);
}
unsigned int Equalizer::presetCount()
{
return VLC::Equalizer::presetCount();
}
Platform::String^ Equalizer::presetName(unsigned index)
{
return ToPlatformString(VLC::Equalizer::presetName(index));
}
unsigned int Equalizer::bandCount()
{
return VLC::Equalizer::bandCount();
}
float Equalizer::bandFrequency(unsigned int index)
{
return VLC::Equalizer::bandFrequency(index);
}
}
/*****************************************************************************
* EqualizerCX.hpp: Equalizer API
*****************************************************************************
* Copyright © 2015 libvlcpp authors & VideoLAN
*
* Authors: Hugo Beauzée-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\Equalizer.hpp"
namespace libVLCX
{
public ref class Equalizer sealed
{
internal:
VLC::Equalizer m_eq;
public:
/**
* Create a new default equalizer, with all frequency values zeroed.
*
* The new equalizer can subsequently be applied to a media player by invoking
* libvlc_media_player_set_equalizer().
*
* \throw std::runtime_error when equalizer creation fails
*
* \version LibVLC 2.2.0 or later
*/
Equalizer();
/**
* Create a new equalizer, with initial frequency values copied from an existing
* preset.
*
* The new equalizer can subsequently be applied to a media player by invoking
* libvlc_media_player_set_equalizer().
*
* \param index index of the preset, counting from zero
*
* \throw std::runtime_error when equalizer creation fails
*
* \version LibVLC 2.2.0 or later
*/
Equalizer(unsigned int index);
/**
* Set a new pre-amplification value for an equalizer.
*
* The new equalizer settings are subsequently applied to a media player by invoking
* MediaPlayer::setEqualizer().
*
* The supplied amplification value will be clamped to the -20.0 to +20.0 range.
*
* \param preamp preamp value (-20.0 to 20.0 Hz)
* \return zero on success, -1 on error
* \version LibVLC 2.2.0 or later
*/
int setPreamp(float preamp);
/**
* Get the current pre-amplification value from an equalizer.
*
* \return preamp value (Hz)
* \version LibVLC 2.2.0 or later
*/
float preamp();
/**
* Set a new amplification value for a particular equalizer frequency band.
*
* The new equalizer settings are subsequently applied to a media player by invoking
* MediaPlayer::setEqualizer().
*
* The supplied amplification value will be clamped to the -20.0 to +20.0 range.
*
* \param amp amplification value (-20.0 to 20.0 Hz)
* \param band index, counting from zero, of the frequency band to set
* \return zero on success, -1 on error
* \version LibVLC 2.2.0 or later
*/
int setAmp(float amp, unsigned int band);
/**
* Get the amplification value for a particular equalizer frequency band.
*
* \param u_band index, counting from zero, of the frequency band to get
* \return amplification value (Hz); NaN if there is no such frequency band
* \version LibVLC 2.2.0 or later
*/
float amp(unsigned int band);
/**
* Get the number of equalizer presets.
*
* \return number of presets
* \version LibVLC 2.2.0 or later
*/
static unsigned int presetCount();
/**
* Get the name of a particular equalizer preset.
*
* This name can be used, for example, to prepare a preset label or menu in a user
* interface.
*
* \param index index of the preset, counting from zero
* \return preset name, or empty string if there is no such preset
* \version LibVLC 2.2.0 or later
*/
static Platform::String^ presetName(unsigned index);
/**
* Get the number of distinct frequency bands for an equalizer.
*
* \return number of frequency bands
* \version LibVLC 2.2.0 or later
*/
static unsigned int bandCount();
/**
* Get a particular equalizer band frequency.
*
* This value can be used, for example, to create a label for an equalizer band control
* in a user interface.
*
* \param index index of the band, counting from zero
* \return equalizer band frequency (Hz), or -1 if there is no such band
* \version LibVLC 2.2.0 or later
*/
static float bandFrequency(unsigned int index);
};
}
/*****************************************************************************
* EventManagerCX.cpp: EventManager API
*****************************************************************************
* Copyright © 2014 the VideoLAN team
*
* Authors: Hugo Beauzée-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 "EventManagerCX.hpp"
#include "MediaCX.hpp"
#include <vlcpp/vlc.hpp>
namespace libVLCX
{
MediaPlayerEventManager::MediaPlayerEventManager(VLC::MediaPlayerEventManager& em)
: m_em(em)
{
}
MediaEventManager::MediaEventManager(VLC::MediaEventManager& em)
: m_em(em)
{
}
MediaListEventManager::MediaListEventManager(VLC::MediaListEventManager& em)
: m_em(em)
{
}
void EventRemover::removeToken(std::vector<VLC::EventManager::RegisteredEvent>& events, Windows::Foundation::EventRegistrationToken token)
{
auto h = (VLC::EventManager::RegisteredEvent)token.Value;
auto it = std::find(begin(events), end(events), h);
assert(it != end(events));
(*it)->unregister();
events.erase(it);
}
}
This diff is collapsed.
/*****************************************************************************
* InstanceCX.cpp: Instance API
*****************************************************************************
* Copyright © 2014 the VideoLAN team
*
* Authors: Hugo Beauzée-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 "Helpers.h"
#include <collection.h>
//HACK HACK HACK
using namespace Windows::Graphics::Display;
namespace libVLCX
{
Instance::Instance(Windows::Foundation::Collections::IVector<Platform::String^>^ argv, SwapChainPanel^ panel)
: m_chainPanel(panel)
{
int extraArgs = 2;
auto c_argv = new char*[argv->Size + extraArgs];
unsigned int i = 0;
for (auto arg : argv)
{
c_argv[i++] = _strdup((const char*) VLCString(arg));
}
InitializeHack(c_argv, i);
m_instance = VLC::Instance(i, c_argv);
for (unsigned j = 0; j < i; ++j)
free(c_argv[j]);
delete [] c_argv;
}
void Instance::Trim()
{
m_dxManager->Trim();
}
void Instance::InitializeHack(char** argv, unsigned int & nbArgs)
{
m_dxManager.reset(new DirectXManager);
m_dxManager->CreateSwapPanel(m_chainPanel);
UpdateSize(m_chainPanel->ActualWidth * m_chainPanel->CompositionScaleX,
m_chainPanel->ActualHeight * m_chainPanel->CompositionScaleY);
char ptr_d3dcstring[64];
sprintf_s(ptr_d3dcstring, "--winrt-d3dcontext=0x%p", m_dxManager->cp_d3dContext);
argv[nbArgs++] = _strdup(ptr_d3dcstring);
char ptr_scstring[64];
sprintf_s(ptr_scstring, "--winrt-swapchain=0x%p", m_dxManager->cp_swapChain);
argv[nbArgs++] = _strdup(ptr_scstring);
}
static const GUID SWAPCHAIN_WIDTH = { 0xf1b59347, 0x1643, 0x411a,{ 0xad, 0x6b, 0xc7, 0x80, 0x17, 0x7a, 0x6, 0xb6 } };
static const GUID SWAPCHAIN_HEIGHT = { 0x6ea976a0, 0x9d60, 0x4bb7,{ 0xa5, 0xa9, 0x7d, 0xd1, 0x18, 0x7f, 0xc9, 0xbd } };
void Instance::UpdateSize(float x, float y)
{
m_width = (uint32_t)x;
m_height = (uint32_t)y;
m_dxManager->cp_swapChain->SetPrivateData(SWAPCHAIN_WIDTH, sizeof(uint32_t), &m_width);
m_dxManager->cp_swapChain->SetPrivateData(SWAPCHAIN_HEIGHT, sizeof(uint32_t), &m_height);
}
int Instance::addIntf(Platform::String^ name)
{
return m_instance.addIntf(VLCString(name));
}
void Instance::setUserAgent(Platform::String^ name, Platform::String^ http)
{
m_instance.setUserAgent(VLCString(name), VLCString(http));
}
void Instance::setAppId(Platform::String^ id, Platform::String^ version, Platform::String^ icon)
{
m_instance.setAppId(VLCString(id), VLCString(version), VLCString(icon));
}
void Instance::logUnset()
{
m_instance.logUnset();
}
void Instance::logSet(LogCallback^ logCb)
{
m_instance.logSet([logCb](int logLevel, const libvlc_log_t* Log, std::string msgStr)
{
logCb(logLevel, ToPlatformString(msgStr));
});
}
void Instance::setDialogHandlers(DialogCallback::Error ^ error, DialogCallback::Login ^ login, DialogCallback::Question ^ question, DialogCallback::DisplayProgress ^ dspProgress, DialogCallback::Cancel ^ cancel, DialogCallback::UpdateProgress ^ updtProgress)
{
m_instance.setDialogHandlers(
[error](std::string &&title, std::string &&txt) {
if (error)
error(ToPlatformString(title), ToPlatformString(txt));
},
[login](VLC::Dialog&& dialog, std::string &&title, std::string &&text, std::string &&defaultUserName, bool askToStore) {
if (login)
login(ref new Dialog(std::move(dialog)), ToPlatformString(std::move(title)), ToPlatformString(std::move(text)), ToPlatformString(std::move(defaultUserName)), askToStore);
},
[question](VLC::Dialog &&dialog, std::string &&title, std::string &&text, VLC::Question qType, std::string &&cancel, std::string &&action1, std::string &&action2) {
if (question)
question(ref new Dialog(std::move(dialog)), ToPlatformString(std::move(title)), ToPlatformString(std::move(text)), (libVLCX::Question)qType, ToPlatformString(std::move(cancel)), ToPlatformString(std::move(action1)), ToPlatformString(std::move(action2)));
},
[dspProgress](VLC::Dialog &&dialog, std::string &&title, std::string &&text, bool intermediate, float position, std::string &&cancel) {
if (dspProgress)
dspProgress(ref new Dialog(std::move(dialog)), ToPlatformString(std::move(title)), ToPlatformString(std::move(text)), intermediate, position, ToPlatformString(std::move(cancel)));
},
[cancel](VLC::Dialog &&dialog) {
if (cancel)
cancel(ref new Dialog(std::move(dialog)));
},
[updtProgress](VLC::Dialog &&dialog, float position, std::string &&text) {
if (updtProgress)
updtProgress(ref new Dialog(std::move(dialog)), position, ToPlatformString(std::move(text)));
});
}
void Instance::unsetDialogHandlers()
{
m_instance.unsetDialogHandlers();
}
Windows::Foundation::Collections::IVector<ModuleDescription^>^ Instance::audioFilterList()
{
return MarshallVector<ModuleDescription, VLC::ModuleDescription>(m_instance.audioFilterList());
}
Windows::Foundation::Collections::IVector<ModuleDescription^>^ Instance::videoFilterList()
{
return MarshallVector<ModuleDescription, VLC::ModuleDescription>(m_instance.videoFilterList());
}
Windows::Foundation::Collections::IVector<AudioOutputDescription^>^ Instance::audioOutputList()
{
return MarshallVector<AudioOutputDescription, VLC::AudioOutputDescription>(m_instance.audioOutputList());
}
Windows::Foundation::Collections::IVector<AudioOutputDeviceDescription^>^ Instance::audioOutputDeviceList(Platform::String^ aout)
{
return MarshallVector<AudioOutputDeviceDescription, VLC::AudioOutputDeviceDescription>(m_instance.audioOutputDeviceList(VLCString(aout)));
}
Windows::Foundation::Collections::IVector<MediaDiscovererDescription^>^ Instance::mediaDiscoverers(MediaDiscovererCategory category)
{
return MarshallVector<MediaDiscovererDescription, VLC::MediaDiscoverer::Description>(m_instance.mediaDiscoverers(static_cast<VLC::MediaDiscoverer::Category>(category)));
}
Instance::~Instance()
{
}
} // namespace VLC
This diff is collapsed.
/*****************************************************************************
* MediaCX.hpp: Media API
*****************************************************************************
* Copyright © 2014 the VideoLAN team
*
* Authors: Hugo Beauzée-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 "structuresCX.hpp"
#include "InstanceCX.hpp"
#include "EventManagerCX.hpp"
#include "MediaCX.hpp"
#include "MediaListCX.hpp"
#include <collection.h>
namespace libVLCX
{
Media::Media(Instance^ instance, Platform::String^ location, FromType from_type)
: m_media(VLC::Media( instance->m_instance, VLCString(location), (VLC::Media::FromType)from_type ))
{
}
void Media::addOption(Platform::String^ options)
{
m_media.addOption(VLCString(options));
}
void Media::addOptionFlag(Platform::String^ options, unsigned i_flags)
{
m_media.addOptionFlag(VLCString(options), i_flags);
}
Platform::String^ Media::mrl()
{
return ToPlatformString(m_media.mrl());
}
Media^ Media::duplicate()
{
return ref new Media(m_media.duplicate());
}
Platform::String^ Media::meta(MediaMeta e_meta)
{
return ToPlatformString(m_media.meta((libvlc_meta_t)e_meta));
}
void Media::setMeta(MediaMeta e_meta, Platform::String^ psz_value)
{
m_media.setMeta((libvlc_meta_t)e_meta, VLCString(psz_value));
}
int Media::saveMeta()
{
return m_media.saveMeta();
}
MediaState Media::state()
{
return (MediaState)m_media.state();
}
//bool Media::stats(libvlc_media_stats_t * p_stats);
MediaEventManager^ Media::eventManager()
{
if (m_eventManager == nullptr)
m_eventManager = ref new MediaEventManager(m_media.eventManager());
return m_eventManager;
}
libvlc_time_t Media::duration()
{
return m_media.duration();
}
void Media::parseWithOptions(ParseFlags flags, int timeoutMs)
{
m_media.parseWithOptions(static_cast<VLC::Media::ParseFlags>( flags ), timeoutMs);
}
IAsyncOperation<ParsedStatus>^ Media::parseWithOptionsAsync(ParseFlags flags, int timeoutMs)
{
return concurrency::create_async([=](concurrency::cancellation_token ct) {
auto res = std::make_shared<Concurrency::task_completion_event<ParsedStatus>>();
m_media.eventManager().onParsedChanged([res](VLC::Media::ParsedStatus status) {
res->set(static_cast<ParsedStatus>(status));
});
if (m_media.parseWithOptions(static_cast<VLC::Media::ParseFlags>(flags), timeoutMs) == false)
res->set(ParsedStatus::Failed);
return concurrency::create_task(*res, ct);
});
}
ParsedStatus Media::parsedStatus()
{
return (ParsedStatus)m_media.parsedStatus();
}
Windows::Foundation::Collections::IVector<MediaTrack^>^ Media::tracks()
{
return MarshallVector<MediaTrack, VLC::MediaTrack>(m_media.tracks());
}
MediaList^ Media::subItems()
{
return ref new MediaList(*m_media.subitems());
}
MediaType Media::type()
{
return static_cast<MediaType>(m_media.type());
}
Media::Media(const VLC::Media& media)
: m_media(media)
{
}
Media::Media(VLC::Media&& media)
: m_media( std::move( media ) )
{
}
bool Media::addSlave(SlaveType type, unsigned priority, Platform::String^ uri)
{
return m_media.addSlave((VLC::MediaSlave::Type)type, priority, FromPlatformString(uri));
}
void Media::slavesClear()
{
m_media.slavesClear();
}
Windows::Foundation::Collections::IVector<MediaSlave^>^ Media::slaves()
{
return MarshallVector<MediaSlave, VLC::MediaSlave>(m_media.slaves());
}
} // namespace VLC