Commit 4af46cd9 authored by Scott Wheeler's avatar Scott Wheeler

Remove the GStreamer 0.8 support from trunk.

svn path=/trunk/KDE/kdemultimedia/juk/; revision=513957
parent e4d77f38
......@@ -32,163 +32,6 @@
#define JUK_GLIB_NULL static_cast<gpointer>(0)
#if GSTREAMER_VERSION == 8
/******************************************************************************/
/******************************************************************************/
/****************************** GSTREAMER 0.8 *******************************/
/******************************************************************************/
/******************************************************************************/
////////////////////////////////////////////////////////////////////////////////
// public methods
////////////////////////////////////////////////////////////////////////////////
GStreamerPlayer::GStreamerPlayer() :
Player(),
m_pipeline(0),
m_source(0),
m_decoder(0),
m_volume(0),
m_sink(0)
{
readConfig();
setupPipeline();
}
GStreamerPlayer::~GStreamerPlayer()
{
stop();
gst_object_unref(GST_OBJECT(m_pipeline));
}
void GStreamerPlayer::play(const FileHandle &file)
{
if(!file.isNull()) {
stop();
g_object_set(G_OBJECT(m_source), "location", file.absFilePath().local8Bit().data(), JUK_GLIB_NULL);
}
gst_element_set_state(m_pipeline, GST_STATE_PLAYING);
}
void GStreamerPlayer::pause()
{
gst_element_set_state(m_pipeline, GST_STATE_PAUSED);
}
void GStreamerPlayer::stop()
{
gst_element_set_state(m_pipeline, GST_STATE_NULL);
}
void GStreamerPlayer::setVolume(float volume)
{
g_object_set(G_OBJECT(m_volume), "volume", volume, JUK_GLIB_NULL);
}
float GStreamerPlayer::volume() const
{
gdouble value;
g_object_get(G_OBJECT(m_volume), "volume", &value, JUK_GLIB_NULL);
return (float) value;
}
bool GStreamerPlayer::playing() const
{
return gst_element_get_state(m_pipeline) == GST_STATE_PLAYING;
}
bool GStreamerPlayer::paused() const
{
return gst_element_get_state(m_pipeline) == GST_STATE_PAUSED;
}
int GStreamerPlayer::totalTime() const
{
return time(GST_QUERY_TOTAL) / GST_SECOND;
}
int GStreamerPlayer::currentTime() const
{
return time(GST_QUERY_POSITION) / GST_SECOND;
}
int GStreamerPlayer::position() const
{
long long total = time(GST_QUERY_TOTAL);
long long current = time(GST_QUERY_POSITION);
return total > 0 ? int((double(current) / double(total)) * double(1000) + 0.5) : 0;
}
void GStreamerPlayer::seek(int seekTime)
{
int type = (GST_FORMAT_TIME | GST_SEEK_METHOD_SET | GST_SEEK_FLAG_FLUSH);
gst_element_seek(m_sink, GstSeekType(type), seekTime * GST_SECOND);
}
void GStreamerPlayer::seekPosition(int position)
{
long long total = time(GST_QUERY_TOTAL);
if(total > 0)
seek(int(double(position) / double(1000) * double(totalTime()) + 0.5));
}
////////////////////////////////////////////////////////////////////////////////
// private methods
////////////////////////////////////////////////////////////////////////////////
void GStreamerPlayer::readConfig()
{
KConfigGroup config(KGlobal::config(), "GStreamerPlayer");
m_sinkName = config.readEntry("SinkName", QString::null);
}
void GStreamerPlayer::setupPipeline()
{
static bool initialized = false;
if(!initialized) {
int argc = kapp->argc();
char **argv = kapp->argv();
gst_init(&argc, &argv);
initialized = true;
}
m_pipeline = gst_thread_new("pipeline");
m_source = gst_element_factory_make("filesrc", "source");
m_decoder = gst_element_factory_make("spider", "decoder");
m_volume = gst_element_factory_make("volume", "volume");
if(!m_sinkName.isNull())
m_sink = gst_element_factory_make(m_sinkName.utf8().data(), "sink");
else {
m_sink = gst_element_factory_make("alsasink", "sink");
if(!m_sink)
m_sink = gst_element_factory_make("osssink", "sink");
}
gst_bin_add_many(GST_BIN(m_pipeline), m_source, m_decoder, m_volume, m_sink, 0);
gst_element_link_many(m_source, m_decoder, m_volume, m_sink, 0);
}
long long GStreamerPlayer::time(GstQueryType type) const
{
gint64 ns = 0;
GstFormat format = GST_FORMAT_TIME;
gst_element_query(m_sink, type, &format, &ns);
return ns;
}
#else
/******************************************************************************/
/******************************************************************************/
/****************************** GSTREAMER 0.10 ******************************/
/******************************************************************************/
/******************************************************************************/
static GstBusSyncReply messageHandler(GstBus *, GstMessage *message, gpointer data)
{
if(GST_MESSAGE_TYPE(message) == GST_MESSAGE_EOS) {
......@@ -338,8 +181,6 @@ GstState GStreamerPlayer::state() const
return state;
}
#endif
#include "gstreamerplayer.moc"
#endif
......
......@@ -54,27 +54,11 @@ public slots:
private:
void setupPipeline();
#if GSTREAMER_VERSION == 8
void readConfig();
long long time(GstQueryType type) const;
QString m_sinkName;
GstElement *m_pipeline;
GstElement *m_source;
GstElement *m_decoder;
GstElement *m_volume;
GstElement *m_sink;
#else
enum TimeQuery { CurrentPosition, TotalLength };
long long time(TimeQuery type) const;
GstState state() const;
GstElement *m_playbin;
#endif
};
#endif /* HAVE_GSTREAMER */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment