mirror of
https://github.com/clementine-player/Clementine
synced 2024-12-17 12:02:48 +01:00
Use uridecodebin for Moodbar.
This commit is contained in:
parent
24ea8d3e05
commit
823b59e3a7
@ -20,9 +20,9 @@
|
|||||||
|
|
||||||
#include <QCoreApplication>
|
#include <QCoreApplication>
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
#include <QUrl>
|
||||||
|
|
||||||
bool MoodbarPipeline::sIsAvailable = false;
|
bool MoodbarPipeline::sIsAvailable = false;
|
||||||
QMutex MoodbarPipeline::sFftwMutex;
|
|
||||||
|
|
||||||
MoodbarPipeline::MoodbarPipeline(const QString& local_filename)
|
MoodbarPipeline::MoodbarPipeline(const QString& local_filename)
|
||||||
: QObject(NULL),
|
: QObject(NULL),
|
||||||
@ -78,27 +78,24 @@ void MoodbarPipeline::Start() {
|
|||||||
|
|
||||||
pipeline_ = gst_pipeline_new("moodbar-pipeline");
|
pipeline_ = gst_pipeline_new("moodbar-pipeline");
|
||||||
|
|
||||||
GstElement* filesrc = CreateElement("filesrc");
|
GstElement* decodebin = CreateElement("uridecodebin");
|
||||||
GstElement* decodebin = CreateElement("decodebin");
|
|
||||||
convert_element_ = CreateElement("audioconvert");
|
convert_element_ = CreateElement("audioconvert");
|
||||||
GstElement* fftwspectrum = CreateElement("fftwspectrum");
|
GstElement* fftwspectrum = CreateElement("fftwspectrum");
|
||||||
GstElement* moodbar = CreateElement("moodbar");
|
GstElement* moodbar = CreateElement("moodbar");
|
||||||
GstElement* appsink = CreateElement("appsink");
|
GstElement* appsink = CreateElement("appsink");
|
||||||
|
|
||||||
if (!filesrc || !convert_element_ || !fftwspectrum || !moodbar || !appsink) {
|
if (!decodebin || !convert_element_ || !fftwspectrum || !moodbar || !appsink) {
|
||||||
pipeline_ = NULL;
|
pipeline_ = NULL;
|
||||||
emit Finished(false);
|
emit Finished(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
QMutexLocker l(&sFftwMutex);
|
|
||||||
|
|
||||||
// Join them together
|
// Join them together
|
||||||
gst_element_link(filesrc, decodebin);
|
|
||||||
gst_element_link_many(convert_element_, fftwspectrum, moodbar, appsink, NULL);
|
gst_element_link_many(convert_element_, fftwspectrum, moodbar, appsink, NULL);
|
||||||
|
|
||||||
|
QUrl local_url = QUrl::fromLocalFile(local_filename_);
|
||||||
// Set properties
|
// Set properties
|
||||||
g_object_set(filesrc, "location", local_filename_.toUtf8().constData(), NULL);
|
g_object_set(decodebin, "uri", local_url.toEncoded().constData(), NULL);
|
||||||
g_object_set(fftwspectrum, "def-size", 2048,
|
g_object_set(fftwspectrum, "def-size", 2048,
|
||||||
"def-step", 1024,
|
"def-step", 1024,
|
||||||
"hiquality", true, NULL);
|
"hiquality", true, NULL);
|
||||||
@ -106,7 +103,7 @@ void MoodbarPipeline::Start() {
|
|||||||
"max-width", 1000, NULL);
|
"max-width", 1000, NULL);
|
||||||
|
|
||||||
// Connect signals
|
// Connect signals
|
||||||
g_signal_connect(decodebin, "new-decoded-pad", G_CALLBACK(NewPadCallback), this);
|
g_signal_connect(decodebin, "pad-added", G_CALLBACK(NewPadCallback), this);
|
||||||
gst_bus_set_sync_handler(gst_pipeline_get_bus(GST_PIPELINE(pipeline_)), BusCallbackSync, this);
|
gst_bus_set_sync_handler(gst_pipeline_get_bus(GST_PIPELINE(pipeline_)), BusCallbackSync, this);
|
||||||
|
|
||||||
// Set appsink callbacks
|
// Set appsink callbacks
|
||||||
@ -133,7 +130,7 @@ void MoodbarPipeline::ReportError(GstMessage* msg) {
|
|||||||
qLog(Error) << "Error processing" << local_filename_ << ":" << message;
|
qLog(Error) << "Error processing" << local_filename_ << ":" << message;
|
||||||
}
|
}
|
||||||
|
|
||||||
void MoodbarPipeline::NewPadCallback(GstElement*, GstPad* pad, gboolean, gpointer data) {
|
void MoodbarPipeline::NewPadCallback(GstElement*, GstPad* pad, gpointer data) {
|
||||||
MoodbarPipeline* self = reinterpret_cast<MoodbarPipeline*>(data);
|
MoodbarPipeline* self = reinterpret_cast<MoodbarPipeline*>(data);
|
||||||
GstPad* const audiopad = gst_element_get_pad(self->convert_element_, "sink");
|
GstPad* const audiopad = gst_element_get_pad(self->convert_element_, "sink");
|
||||||
|
|
||||||
|
@ -18,8 +18,6 @@
|
|||||||
#ifndef MOODBARPIPELINE_H
|
#ifndef MOODBARPIPELINE_H
|
||||||
#define MOODBARPIPELINE_H
|
#define MOODBARPIPELINE_H
|
||||||
|
|
||||||
#include <QBuffer>
|
|
||||||
#include <QMutex>
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
|
|
||||||
#include <gst/gst.h>
|
#include <gst/gst.h>
|
||||||
@ -51,14 +49,13 @@ private:
|
|||||||
void Stop(bool success);
|
void Stop(bool success);
|
||||||
void Cleanup();
|
void Cleanup();
|
||||||
|
|
||||||
static void NewPadCallback(GstElement*, GstPad* pad, gboolean, gpointer data);
|
static void NewPadCallback(GstElement*, GstPad* pad, gpointer data);
|
||||||
static GstFlowReturn NewBufferCallback(GstAppSink* app_sink, gpointer self);
|
static GstFlowReturn NewBufferCallback(GstAppSink* app_sink, gpointer self);
|
||||||
static gboolean BusCallback(GstBus*, GstMessage* msg, gpointer data);
|
static gboolean BusCallback(GstBus*, GstMessage* msg, gpointer data);
|
||||||
static GstBusSyncReply BusCallbackSync(GstBus*, GstMessage* msg, gpointer data);
|
static GstBusSyncReply BusCallbackSync(GstBus*, GstMessage* msg, gpointer data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static bool sIsAvailable;
|
static bool sIsAvailable;
|
||||||
static QMutex sFftwMutex;
|
|
||||||
|
|
||||||
QString local_filename_;
|
QString local_filename_;
|
||||||
GstElement* pipeline_;
|
GstElement* pipeline_;
|
||||||
|
Loading…
Reference in New Issue
Block a user