2012-05-25 18:18:07 +02:00
|
|
|
/* This file is part of Clementine.
|
|
|
|
Copyright 2012, David Sansome <me@davidsansome.com>
|
|
|
|
|
|
|
|
Clementine 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.
|
|
|
|
|
|
|
|
Clementine 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 Clementine. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef MOODBARPIPELINE_H
|
|
|
|
#define MOODBARPIPELINE_H
|
|
|
|
|
|
|
|
#include <QObject>
|
2012-05-29 00:33:37 +02:00
|
|
|
#include <QUrl>
|
2012-05-25 18:18:07 +02:00
|
|
|
|
|
|
|
#include <gst/gst.h>
|
|
|
|
#include <gst/app/gstappsink.h>
|
|
|
|
|
|
|
|
// Creates moodbar data for a single local music file.
|
|
|
|
class MoodbarPipeline : public QObject {
|
|
|
|
Q_OBJECT
|
2012-05-29 00:18:36 +02:00
|
|
|
|
2012-05-25 18:18:07 +02:00
|
|
|
public:
|
2012-05-29 00:33:37 +02:00
|
|
|
MoodbarPipeline(const QUrl& local_filename);
|
2012-05-25 18:18:07 +02:00
|
|
|
~MoodbarPipeline();
|
2012-05-29 00:18:36 +02:00
|
|
|
|
2012-05-25 18:18:07 +02:00
|
|
|
static bool IsAvailable();
|
2012-05-29 00:18:36 +02:00
|
|
|
|
2012-05-25 18:18:07 +02:00
|
|
|
bool success() const { return success_; }
|
|
|
|
const QByteArray& data() const { return data_; }
|
|
|
|
|
2012-05-27 21:05:01 +02:00
|
|
|
public slots:
|
|
|
|
void Start();
|
|
|
|
|
2012-05-25 18:18:07 +02:00
|
|
|
signals:
|
|
|
|
void Finished(bool success);
|
2012-05-29 00:18:36 +02:00
|
|
|
|
2012-05-25 18:18:07 +02:00
|
|
|
private:
|
|
|
|
GstElement* CreateElement(const QString& factory_name);
|
2012-05-29 00:18:36 +02:00
|
|
|
|
2012-05-25 18:18:07 +02:00
|
|
|
void ReportError(GstMessage* message);
|
|
|
|
void Stop(bool success);
|
|
|
|
void Cleanup();
|
2012-05-29 00:18:36 +02:00
|
|
|
|
|
|
|
static void NewPadCallback(GstElement*, GstPad* pad, gpointer data);
|
2012-05-25 18:18:07 +02:00
|
|
|
static GstFlowReturn NewBufferCallback(GstAppSink* app_sink, gpointer self);
|
|
|
|
static gboolean BusCallback(GstBus*, GstMessage* msg, gpointer data);
|
|
|
|
static GstBusSyncReply BusCallbackSync(GstBus*, GstMessage* msg, gpointer data);
|
2012-05-29 00:18:36 +02:00
|
|
|
|
2012-05-25 18:18:07 +02:00
|
|
|
private:
|
|
|
|
static bool sIsAvailable;
|
2012-05-29 00:18:36 +02:00
|
|
|
|
2012-05-29 00:33:37 +02:00
|
|
|
QUrl local_filename_;
|
2012-05-25 18:18:07 +02:00
|
|
|
GstElement* pipeline_;
|
|
|
|
GstElement* convert_element_;
|
2012-05-29 00:18:36 +02:00
|
|
|
|
2012-05-25 18:18:07 +02:00
|
|
|
bool success_;
|
|
|
|
QByteArray data_;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // MOODBARPIPELINE_H
|