diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index a3473d5fa..970592ed7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -111,10 +111,6 @@ set(SOURCES radio/savedradio.cpp radio/somafmservice.cpp - transcoder/transcodedialog.cpp - transcoder/transcoder.cpp - transcoder/transcoderformats.cpp - ui/about.cpp ui/addstreamdialog.cpp ui/albumcovermanager.cpp @@ -224,9 +220,6 @@ set(HEADERS radio/savedradio.h radio/somafmservice.h - transcoder/transcodedialog.h - transcoder/transcoder.h - ui/about.h ui/addstreamdialog.h ui/albumcovermanager.h @@ -275,9 +268,6 @@ set(UI radio/magnatunedownloaddialog.ui radio/radioviewcontainer.ui - transcoder/transcodedialog.ui - transcoder/transcodelogdialog.ui - ui/about.ui ui/addstreamdialog.ui ui/albumcovermanager.ui @@ -378,6 +368,25 @@ if(ENABLE_VISUALISATIONS) ) endif(ENABLE_VISUALISATIONS) +# Transcoder +if(HAVE_GSTREAMER) + list(APPEND SOURCES + transcoder/transcodedialog.cpp + transcoder/transcoder.cpp + transcoder/transcoderformats.cpp + ) + + list(APPEND HEADERS + transcoder/transcodedialog.h + transcoder/transcoder.h + ) + + list(APPEND UI + transcoder/transcodedialog.ui + transcoder/transcodelogdialog.ui + ) +endif(HAVE_GSTREAMER) + # OSDs if(APPLE) list(APPEND SOURCES widgets/osd_mac.mm) diff --git a/src/core/songloader.cpp b/src/core/songloader.cpp index c7a6bdc62..7de1c1d62 100644 --- a/src/core/songloader.cpp +++ b/src/core/songloader.cpp @@ -47,14 +47,19 @@ SongLoader::SongLoader(QObject *parent) } timeout_timer_->setSingleShot(true); + +#ifdef HAVE_GSTREAMER connect(timeout_timer_, SIGNAL(timeout()), SLOT(Timeout())); +#endif } SongLoader::~SongLoader() { +#ifdef HAVE_GSTREAMER if (pipeline_) { state_ = Finished; gst_element_set_state(pipeline_.get(), GST_STATE_NULL); } +#endif // HAVE_GSTREAMER } SongLoader::Result SongLoader::Load(const QUrl& url) { @@ -71,8 +76,15 @@ SongLoader::Result SongLoader::Load(const QUrl& url) { return Success; } +#ifdef HAVE_GSTREAMER timeout_timer_->start(timeout_); return LoadRemote(); +#else + // If we don't have GStreamer we can't check the type of remote playlists, + // so just assume it's a raw stream and get on with our lives. + AddAsRawStream(); + return Success; +#endif } SongLoader::Result SongLoader::LoadLocal() { @@ -139,6 +151,16 @@ void SongLoader::LoadLocalDirectory(const QString& filename) { emit LoadFinished(true); } +void SongLoader::AddAsRawStream() { + Song song; + song.set_valid(true); + song.set_filetype(Song::Type_Stream); + song.set_filename(url_.toString()); + song.set_title(url_.toString()); + songs_ << song; +} + +#ifdef HAVE_GSTREAMER SongLoader::Result SongLoader::LoadRemote() { qDebug() << "Loading remote file" << url_; @@ -226,6 +248,12 @@ void SongLoader::DataReady(GstPad *, GstBuffer *buf, void *self) { } } +void SongLoader::Timeout() { + state_ = Finished; + success_ = false; + StopTypefind(); +} + gboolean SongLoader::BusCallback(GstBus*, GstMessage* msg, gpointer self) { SongLoader* instance = reinterpret_cast(self); @@ -346,18 +374,4 @@ void SongLoader::StopTypefind() { emit LoadFinished(success_); } - -void SongLoader::AddAsRawStream() { - Song song; - song.set_valid(true); - song.set_filetype(Song::Type_Stream); - song.set_filename(url_.toString()); - song.set_title(url_.toString()); - songs_ << song; -} - -void SongLoader::Timeout() { - state_ = Finished; - success_ = false; - StopTypefind(); -} +#endif // HAVE_GSTREAMER diff --git a/src/core/songloader.h b/src/core/songloader.h index 77bc8bf1c..1bf1517e2 100644 --- a/src/core/songloader.h +++ b/src/core/songloader.h @@ -20,10 +20,14 @@ #include #include +#include "config.h" #include "song.h" #include -#include + +#ifdef HAVE_GSTREAMER +# include +#endif class ParserBase; class PlaylistParser; @@ -54,8 +58,10 @@ signals: void LoadFinished(bool success); private slots: +#ifdef HAVE_GSTREAMER void Timeout(); void StopTypefind(); +#endif // HAVE_GSTREAMER private: enum State { @@ -66,9 +72,13 @@ private: }; Result LoadLocal(); - Result LoadRemote(); void LoadLocalDirectory(const QString& filename); + void AddAsRawStream(); + +#ifdef HAVE_GSTREAMER + Result LoadRemote(); + // GStreamer callbacks static void TypeFound(GstElement* typefind, uint probability, GstCaps* caps, void* self); static void DataReady(GstPad*, GstBuffer* buf, void* self); @@ -79,8 +89,7 @@ private: void ErrorMessageReceived(GstMessage* msg); void EndOfStreamReached(); void MagicReady(); - - void AddAsRawStream(); +#endif // HAVE_GSTREAMER private: static QSet sRawUriSchemes; @@ -95,10 +104,13 @@ private: int timeout_; State state_; bool success_; - boost::shared_ptr pipeline_; ParserBase* parser_; QString mime_type_; QByteArray buffer_; + +#ifdef HAVE_GSTREAMER + boost::shared_ptr pipeline_; +#endif }; #endif // SONGLOADER_H diff --git a/src/ui/mainwindow.cpp b/src/ui/mainwindow.cpp index 124bf087e..798957b63 100644 --- a/src/ui/mainwindow.cpp +++ b/src/ui/mainwindow.cpp @@ -123,7 +123,9 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg add_stream_dialog_(new AddStreamDialog), cover_manager_(NULL), equalizer_(new Equalizer), +#ifdef HAVE_GSTREAMER transcode_dialog_(new TranscodeDialog), +#endif error_dialog_(new ErrorDialog), organise_dialog_(new OrganiseDialog(task_manager_)), #ifdef ENABLE_VISUALISATIONS @@ -171,7 +173,11 @@ MainWindow::MainWindow(NetworkAccessManager* network, Engine::Type engine, QWidg # ifdef ENABLE_VISUALISATIONS visualisation_->SetEngine(engine); # endif + } else { + ui_->action_transcode->setEnabled(false); } +#else // HAVE_GSTREAMER + ui_->action_transcode->setEnabled(false); #endif // HAVE_GSTREAMER // Models diff --git a/src/visualisations/projectmvisualisation.cpp b/src/visualisations/projectmvisualisation.cpp index a06013171..d35fc9593 100644 --- a/src/visualisations/projectmvisualisation.cpp +++ b/src/visualisations/projectmvisualisation.cpp @@ -145,12 +145,14 @@ void ProjectMVisualisation::SetDuration(int seconds) { } void ProjectMVisualisation::ConsumeBuffer(GstBuffer *buffer, GstEnginePipeline*) { +#ifdef HAVE_GSTREAMER const int samples_per_channel = GST_BUFFER_SIZE(buffer) / sizeof(short) / 2; const short* data = reinterpret_cast(GST_BUFFER_DATA(buffer)); if (projectm_) projectm_->pcm()->addPCM16Data(data, samples_per_channel); gst_buffer_unref(buffer); +#endif } void ProjectMVisualisation::SetSelected(const QStringList& paths, bool selected) {