strawberry-audio-player-win.../src/engine/vlcengine.h

92 lines
2.5 KiB
C
Raw Normal View History

/*
* Strawberry Music Player
* This file was part of Clementine
* Copyright 2017-2018, Jonas Kvinge <jonas@jkvinge.net>
*
* Strawberry is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Strawberry 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Strawberry. If not, see <http://www.gnu.org/licenses/>.
*
*/
2018-02-27 18:06:05 +01:00
#ifndef VLCENGINE_H
#define VLCENGINE_H
#include "config.h"
#include <stdbool.h>
2018-02-27 18:06:05 +01:00
#include <boost/circular_buffer.hpp>
#include <vlc/vlc.h>
2018-02-27 18:06:05 +01:00
#include <QtGlobal>
#include <QObject>
2018-02-27 18:06:05 +01:00
#include <QMutex>
#include <QString>
#include <QUrl>
#include "engine_fwd.h"
#include "enginebase.h"
struct libvlc_event_t;
2018-02-27 18:06:05 +01:00
class TaskManager;
class VLCEngine : public Engine::Base {
Q_OBJECT
public:
VLCEngine(TaskManager *task_manager);
~VLCEngine();
bool Init();
Engine::State state() const { return state_; }
2018-02-27 18:06:05 +01:00
bool Load(const QUrl &url, Engine::TrackChangeFlags change, bool force_stop_at_end, quint64 beginning_nanosec, qint64 end_nanosec);
bool Play(quint64 offset_nanosec);
void Stop(bool stop_after = false);
void Pause();
void Unpause();
void Seek(quint64 offset_nanosec);
protected:
void SetVolumeSW(uint percent);
public:
virtual qint64 position_nanosec() const;
virtual qint64 length_nanosec() const;
const Engine::Scope& Scope();
2018-02-27 18:06:05 +01:00
OutputDetailsList GetOutputsList() const;
QString DefaultOutput() { return ""; }
bool CustomDeviceSupport(const QString &name);
2018-02-27 18:06:05 +01:00
private:
libvlc_instance_t *instance_;
libvlc_media_player_t *player_;
Engine::State state_;
2018-02-27 18:06:05 +01:00
boost::circular_buffer<float> scope_data_;
static VLCEngine *sInstance;
QMutex scope_mutex_;
uint position() const;
uint length() const;
bool CanDecode(const QUrl &url);
static void SetScopeData(float* data, int size);
void HandleErrors() const;
void AttachCallback(libvlc_event_manager_t* em, libvlc_event_type_t type, libvlc_callback_t callback);
static void StateChangedCallback(const libvlc_event_t* e, void* data);
PluginDetailsList GetPluginList() const;
void GetDevicesList(QString output) const;
2018-02-27 18:06:05 +01:00
};
#endif // VLCENGINE_H