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

88 lines
2.7 KiB
C
Raw Normal View History

/*
* Strawberry Music Player
* This file was part of Clementine.
* Copyright 2010, David Sansome <me@davidsansome.com>
* 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 <vlc/vlc.h>
2018-02-27 18:06:05 +01:00
#include <QtGlobal>
#include <QObject>
#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:
2021-06-20 19:04:08 +02:00
explicit VLCEngine(TaskManager *task_manager, QObject *parent = nullptr);
2020-06-15 21:55:05 +02:00
~VLCEngine() override;
bool Init() override;
Engine::State state() const override { return state_; }
bool Load(const QUrl &stream_url, const QUrl &original_url, const Engine::TrackChangeFlags change, const bool force_stop_at_end, const quint64 beginning_nanosec, const qint64 end_nanosec) override;
bool Play(const quint64 offset_nanosec) override;
void Stop(const bool stop_after = false) override;
void Pause() override;
void Unpause() override;
void Seek(const quint64 offset_nanosec) override;
2018-02-27 18:06:05 +01:00
protected:
2020-06-15 21:55:05 +02:00
void SetVolumeSW(const uint percent) override;
public:
2020-06-15 21:55:05 +02:00
qint64 position_nanosec() const override;
qint64 length_nanosec() const override;
OutputDetailsList GetOutputsList() const override;
bool ValidOutput(const QString &output) override;
QString DefaultOutput() override { return ""; }
bool CustomDeviceSupport(const QString &output) override;
bool ALSADeviceSupport(const QString &output) override;
2018-02-27 18:06:05 +01:00
private:
libvlc_instance_t *instance_;
libvlc_media_player_t *player_;
Engine::State state_;
2020-10-17 17:29:09 +02:00
bool Initialized() const { return (instance_ && player_); }
uint position() const;
uint length() const;
2021-06-22 13:41:38 +02:00
static bool CanDecode(const QUrl &url);
2021-06-12 20:53:23 +02:00
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;
2019-09-15 20:27:32 +02:00
void GetDevicesList(const QString &output) const;
2018-02-27 18:06:05 +01:00
};
2021-01-26 16:48:04 +01:00
#endif // VLCENGINE_H