Commit 8ab2b208 authored by Matthieu Gallien's avatar Matthieu Gallien 🎵
Browse files

start working on libVLC backend

parent 1082eb2c
......@@ -128,6 +128,23 @@ if (UPNPQT_FOUND)
message(WARNING "UPnP support is experimental and may not work.")
endif()
find_package(PkgConfig)
pkg_check_modules(PC_LIBVLC libvlc>=3.0)
find_path(LIBVLC_INCLUDE_DIRS libvlc.h
HINTS
${PC_LIBVLC_INCLUDEDIR}
${PC_LIBVLC_INCLUDE_DIRS}
PATH_SUFFIXES
vlc
)
find_library(LIBVLC_LIBRARIES NAMES vlc
HINTS
${PC_LIBVLC_LIBDIR}
${PC_LIBVLC_LIBRARY_DIRS}
)
include(FeatureSummary)
include(GenerateExportHeader)
include(ECMSetupVersion)
......
......@@ -14,7 +14,7 @@ set(elisaLib_SOURCES
manageaudioplayer.cpp
trackslistener.cpp
elisaapplication.cpp
audiowrapper.cpp
audiowrapper_libvlc.cpp
notificationitem.cpp
topnotificationmanager.cpp
elisautils.cpp
......@@ -189,6 +189,16 @@ endif()
generate_export_header(elisaLib BASE_NAME ElisaLib EXPORT_FILE_NAME elisaLib_export.h)
target_include_directories(elisaLib
PRIVATE
${LIBVLC_INCLUDE_DIRS}
)
target_link_libraries(elisaLib
LINK_PRIVATE
${LIBVLC_LIBRARIES}
)
set_target_properties(elisaLib PROPERTIES
VERSION 0.1
SOVERSION 0
......
/*
* Copyright 2017 Matthieu Gallien <matthieu_gallien@yahoo.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 3 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, see <https://www.gnu.org/licenses/>.
*/
#include "audiowrapper.h"
#include <QTimer>
#include <QAudio>
#include <vlc.h>
#include "config-upnp-qt.h"
class AudioWrapperPrivate
{
public:
libvlc_instance_t *mVlcInstance = nullptr;
libvlc_media_player_t *mp = nullptr;
libvlc_media_t *m = nullptr;
};
AudioWrapper::AudioWrapper(QObject *parent) : QObject(parent), d(std::make_unique<AudioWrapperPrivate>())
{
d->mVlcInstance = libvlc_new(0, nullptr);
}
AudioWrapper::~AudioWrapper()
= default;
bool AudioWrapper::muted() const
{
return false/*d->mPlayer.isMuted()*/;
}
qreal AudioWrapper::volume() const
{
auto realVolume = static_cast<qreal>(100/*d->mPlayer.volume()*/ / 100.0);
auto userVolume = static_cast<qreal>(QAudio::convertVolume(realVolume, QAudio::LinearVolumeScale, QAudio::LogarithmicVolumeScale));
return userVolume * 100.0;
}
QUrl AudioWrapper::source() const
{
return {}/*d->mPlayer.media().canonicalUrl()*/;
}
QMediaPlayer::Error AudioWrapper::error() const
{
#if 0
if (d->mPlayer.error() != QMediaPlayer::NoError) {
qDebug() << "AudioWrapper::error" << d->mPlayer.errorString();
}
#endif
return {}/*d->mPlayer.error()*/;
}
qint64 AudioWrapper::duration() const
{
return {}/*d->mPlayer.duration()*/;
}
qint64 AudioWrapper::position() const
{
return {}/*d->mPlayer.position()*/;
}
bool AudioWrapper::seekable() const
{
return {}/*d->mPlayer.isSeekable()*/;
}
QAudio::Role AudioWrapper::audioRole() const
{
return {}/*d->mPlayer.audioRole()*/;
}
QMediaPlayer::State AudioWrapper::playbackState() const
{
return {}/*d->mPlayer.state()*/;
}
QMediaPlayer::MediaStatus AudioWrapper::status() const
{
return {}/*d->mPlayer.mediaStatus()*/;
}
void AudioWrapper::setMuted(bool muted)
{
// d->mPlayer.setMuted(muted);
}
void AudioWrapper::setVolume(qreal volume)
{
auto realVolume = static_cast<qreal>(QAudio::convertVolume(volume / 100.0, QAudio::LogarithmicVolumeScale, QAudio::LinearVolumeScale));
// d->mPlayer.setVolume(qRound(realVolume * 100));
}
void AudioWrapper::setSource(const QUrl &source)
{
// d->mPlayer.setMedia({source});
}
void AudioWrapper::setPosition(qint64 position)
{
// d->mPlayer.setPosition(position);
}
void AudioWrapper::play()
{
// d->mPlayer.play();
}
void AudioWrapper::pause()
{
// d->mPlayer.pause();
}
void AudioWrapper::stop()
{
// d->mPlayer.stop();
}
void AudioWrapper::seek(int position)
{
// d->mPlayer.setPosition(position);
}
void AudioWrapper::setAudioRole(QAudio::Role audioRole)
{
// d->mPlayer.setAudioRole(audioRole);
}
void AudioWrapper::playerStateChanged()
{
switch(d->mPlayer.state())
{
case QMediaPlayer::State::StoppedState:
Q_EMIT stopped();
break;
case QMediaPlayer::State::PlayingState:
Q_EMIT playing();
break;
case QMediaPlayer::State::PausedState:
Q_EMIT paused();
break;
}
}
void AudioWrapper::playerVolumeChanged()
{
QTimer::singleShot(0, [this]() {Q_EMIT volumeChanged();});
}
void AudioWrapper::playerMutedChanged()
{
QTimer::singleShot(0, [this]() {Q_EMIT mutedChanged();});
}
#include "moc_audiowrapper.cpp"
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