2019-04-18 15:03:01 +02:00
|
|
|
/* This file was part of Clementine.
|
|
|
|
Copyright 2012, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MOODBARPIPELINE_H
|
|
|
|
#define MOODBARPIPELINE_H
|
|
|
|
|
|
|
|
#include <QObject>
|
|
|
|
#include <QByteArray>
|
|
|
|
#include <QString>
|
|
|
|
#include <QUrl>
|
|
|
|
|
2020-02-09 02:29:35 +01:00
|
|
|
#include <glib.h>
|
2019-04-18 15:03:01 +02:00
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/app/gstappsink.h>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class MoodbarBuilder;
|
|
|
|
|
|
|
|
// Creates moodbar data for a single local music file.
|
|
|
|
class MoodbarPipeline : public QObject {
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2021-06-20 19:04:08 +02:00
|
|
|
explicit MoodbarPipeline(const QUrl &local_filename, QObject *parent = nullptr);
|
2020-06-15 21:55:05 +02:00
|
|
|
~MoodbarPipeline() override;
|
2019-04-18 15:03:01 +02:00
|
|
|
|
|
|
|
bool success() const { return success_; }
|
2021-01-26 16:48:04 +01:00
|
|
|
const QByteArray &data() const { return data_; }
|
2019-04-18 15:03:01 +02:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
void Start();
|
|
|
|
|
|
|
|
signals:
|
|
|
|
void Finished(bool success);
|
|
|
|
|
|
|
|
private:
|
2021-01-26 16:48:04 +01:00
|
|
|
GstElement *CreateElement(const QString &factory_name);
|
2019-04-18 15:03:01 +02:00
|
|
|
|
2020-06-14 18:58:24 +02:00
|
|
|
void ReportError(GstMessage *msg);
|
2021-01-26 16:48:04 +01:00
|
|
|
void Stop(const bool success);
|
2019-04-18 15:03:01 +02:00
|
|
|
void Cleanup();
|
|
|
|
|
2021-01-26 16:48:04 +01:00
|
|
|
static void NewPadCallback(GstElement*, GstPad *pad, gpointer data);
|
|
|
|
static GstFlowReturn NewBufferCallback(GstAppSink *app_sink, gpointer self);
|
|
|
|
static gboolean BusCallback(GstBus*, GstMessage *msg, gpointer data);
|
|
|
|
static GstBusSyncReply BusCallbackSync(GstBus*, GstMessage *msg, gpointer data);
|
2019-04-18 15:03:01 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
static const int kBands;
|
|
|
|
|
|
|
|
QUrl local_filename_;
|
2021-01-26 16:48:04 +01:00
|
|
|
GstElement *pipeline_;
|
|
|
|
GstElement *convert_element_;
|
2019-04-18 15:03:01 +02:00
|
|
|
|
|
|
|
std::unique_ptr<MoodbarBuilder> builder_;
|
|
|
|
|
|
|
|
bool success_;
|
|
|
|
bool running_;
|
|
|
|
QByteArray data_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MOODBARPIPELINE_H
|