1
0
mirror of https://github.com/clementine-player/Clementine synced 2024-12-17 03:45:56 +01:00

Use uridecodebin for Moodbar.

This commit is contained in:
John Maguire 2012-05-28 15:18:36 -07:00
parent 24ea8d3e05
commit 823b59e3a7
2 changed files with 29 additions and 35 deletions

View File

@ -20,9 +20,9 @@
#include <QCoreApplication>
#include <QThread>
#include <QUrl>
bool MoodbarPipeline::sIsAvailable = false;
QMutex MoodbarPipeline::sFftwMutex;
MoodbarPipeline::MoodbarPipeline(const QString& local_filename)
: QObject(NULL),
@ -78,27 +78,24 @@ void MoodbarPipeline::Start() {
pipeline_ = gst_pipeline_new("moodbar-pipeline");
GstElement* filesrc = CreateElement("filesrc");
GstElement* decodebin = CreateElement("decodebin");
GstElement* decodebin = CreateElement("uridecodebin");
convert_element_ = CreateElement("audioconvert");
GstElement* fftwspectrum = CreateElement("fftwspectrum");
GstElement* moodbar = CreateElement("moodbar");
GstElement* appsink = CreateElement("appsink");
if (!filesrc || !convert_element_ || !fftwspectrum || !moodbar || !appsink) {
if (!decodebin || !convert_element_ || !fftwspectrum || !moodbar || !appsink) {
pipeline_ = NULL;
emit Finished(false);
return;
}
QMutexLocker l(&sFftwMutex);
// Join them together
gst_element_link(filesrc, decodebin);
gst_element_link_many(convert_element_, fftwspectrum, moodbar, appsink, NULL);
QUrl local_url = QUrl::fromLocalFile(local_filename_);
// 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,
"def-step", 1024,
"hiquality", true, NULL);
@ -106,7 +103,7 @@ void MoodbarPipeline::Start() {
"max-width", 1000, NULL);
// 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);
// Set appsink callbacks
@ -133,7 +130,7 @@ void MoodbarPipeline::ReportError(GstMessage* msg) {
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);
GstPad* const audiopad = gst_element_get_pad(self->convert_element_, "sink");

View File

@ -18,8 +18,6 @@
#ifndef MOODBARPIPELINE_H
#define MOODBARPIPELINE_H
#include <QBuffer>
#include <QMutex>
#include <QObject>
#include <gst/gst.h>
@ -51,14 +49,13 @@ private:
void Stop(bool success);
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 gboolean BusCallback(GstBus*, GstMessage* msg, gpointer data);
static GstBusSyncReply BusCallbackSync(GstBus*, GstMessage* msg, gpointer data);
private:
static bool sIsAvailable;
static QMutex sFftwMutex;
QString local_filename_;
GstElement* pipeline_;