--- oalsound.cpp	2013-11-19 11:54:00.238362394 +0100
+++ oalsound-test.cpp	2014-01-31 01:20:38.000000000 +0100
@@ -214,8 +215,13 @@ static ALenum FormatFromDesc(int bits, i
 #include <gst/gst.h>
 #include <gst/app/gstappsrc.h>
 #include <gst/app/gstappsink.h>
-#include <gst/app/gstappbuffer.h>
+#if !GST_CHECK_VERSION(1, 0, 0)
 #include <gst/audio/multichannel.h>
+#else
+#include <gst/audio/audio-channels.h>
+#define GST_AUDIO_CHANNEL_POSITION_FRONT_MONO GST_AUDIO_CHANNEL_POSITION_MONO
+#define GST_AUDIO_CHANNEL_POSITION_LFE GST_AUDIO_CHANNEL_POSITION_LFE1
+#endif
 
 /* Bad GStreamer, using enums for bit fields... */
 static GstMessageType operator|(const GstMessageType &a, const GstMessageType &b)
@@ -240,6 +246,7 @@ static GstCaps *SupportedBufferFormatCap
 {
 	GstStructure *structure;
 	GstCaps *caps;
+	guint64 channel_mask;
 
 	caps = gst_caps_new_empty();
 	if(alIsExtensionPresent("AL_EXT_MCFORMATS"))
@@ -296,6 +303,13 @@ static GstCaps *SupportedBufferFormatCap
 			"AL_FORMAT_51CHN8", "AL_FORMAT_61CHN8", "AL_FORMAT_71CHN8", NULL
 		};
 
+#if !GST_CHECK_VERSION(1, 0, 0)
+#define RAW_AUDIO_FLOAT "audio/x-raw-float"
+#define RAW_AUDIO_INT "audio/x-raw-int"
+#else
+#define RAW_AUDIO_FLOAT "audio/x-raw"
+#define RAW_AUDIO_INT "audio/x-raw"
+#endif
 		if(alIsExtensionPresent("AL_EXT_FLOAT32"))
 		{
 			for(size_t i = 0;fmt32[i];i++)
@@ -307,13 +321,24 @@ static GstCaps *SupportedBufferFormatCap
 				if(getALError() != AL_NO_ERROR || val == 0 || val == -1)
 					continue;
 
-				structure = gst_structure_new("audio/x-raw-float",
+#if GST_CHECK_VERSION(1, 0, 0)
+				gst_audio_channel_positions_to_mask(chans[i].pos,
+				    chans[i].count, FALSE, &channel_mask);
+				structure = gst_structure_new(RAW_AUDIO_FLOAT,
+				    "format", G_TYPE_STRING, GST_AUDIO_NE(F32),
+				    "channel-mask", GST_TYPE_BITMASK, channel_mask,
+				    "layout", G_TYPE_STRING, "interleaved", NULL);
+#else
+				structure = gst_structure_new(RAW_AUDIO_FLOAT,
 				    "endianness", G_TYPE_INT, G_BYTE_ORDER,
 				    "width", G_TYPE_INT, 32, NULL);
+#endif
 				gst_structure_set(structure, "channels", G_TYPE_INT,
 				                  chans[i].count, NULL);
+#if !GST_CHECK_VERSION(1, 0, 0)
 				if(chans[i].count > 2)
 					gst_audio_set_channel_positions(structure, chans[i].pos);
+#endif
 				gst_caps_append_structure(caps, structure);
 			}
 		}
@@ -326,15 +351,26 @@ static GstCaps *SupportedBufferFormatCap
 			if(getALError() != AL_NO_ERROR || val == 0 || val == -1)
 				continue;
 
-			structure = gst_structure_new("audio/x-raw-int",
+#if GST_CHECK_VERSION(1, 0, 0)
+			gst_audio_channel_positions_to_mask(chans[i].pos,
+			    chans[i].count, FALSE, &channel_mask);
+			structure = gst_structure_new(RAW_AUDIO_INT,
+			    "format", G_TYPE_STRING, GST_AUDIO_NE(S16),
+			    "channel-mask", GST_TYPE_BITMASK, channel_mask,
+			    "layout", G_TYPE_STRING, "interleaved", NULL);
+#else
+			structure = gst_structure_new(RAW_AUDIO_INT,
 			    "endianness", G_TYPE_INT, G_BYTE_ORDER,
 			    "width", G_TYPE_INT, 16,
 			    "depth", G_TYPE_INT, 16,
 			    "signed", G_TYPE_BOOLEAN, TRUE, NULL);
+#endif
 			gst_structure_set(structure, "channels", G_TYPE_INT,
 			                  chans[i].count, NULL);
+#if !GST_CHECK_VERSION(1, 0, 0)
 			if(chans[i].count > 2)
 				gst_audio_set_channel_positions(structure, chans[i].pos);
+#endif
 			gst_caps_append_structure(caps, structure);
 		}
 		for(size_t i = 0;fmt8[i];i++)
@@ -346,14 +382,24 @@ static GstCaps *SupportedBufferFormatCap
 			if(getALError() != AL_NO_ERROR || val == 0 || val == -1)
 				continue;
 
-			structure = gst_structure_new("audio/x-raw-int",
+#if GST_CHECK_VERSION(1, 0, 0)
+			gst_audio_channel_positions_to_mask(chans[i].pos,
+			    chans[i].count, FALSE, &channel_mask);
+			structure = gst_structure_new(RAW_AUDIO_INT,
+			    "format", G_TYPE_STRING, "U8",
+			    "channel-mask", GST_TYPE_BITMASK, channel_mask, NULL);
+#else
+			structure = gst_structure_new(RAW_AUDIO_INT,
 			    "width", G_TYPE_INT, 8,
 			    "depth", G_TYPE_INT, 8,
 			    "signed", G_TYPE_BOOLEAN, FALSE, NULL);
+#endif
 			gst_structure_set(structure, "channels", G_TYPE_INT,
 			                  chans[i].count, NULL);
+#if !GST_CHECK_VERSION(1, 0, 0)
 			if(chans[i].count > 2)
 				gst_audio_set_channel_positions(structure, chans[i].pos);
+#endif
 			gst_caps_append_structure(caps, structure);
 		}
 	}
@@ -362,29 +408,47 @@ static GstCaps *SupportedBufferFormatCap
 		if(alIsExtensionPresent("AL_EXT_FLOAT32") &&
 		   (!forcebits || forcebits == 32))
 		{
-			structure = gst_structure_new("audio/x-raw-float",
+			structure = gst_structure_new(RAW_AUDIO_FLOAT,
+#if GST_CHECK_VERSION(1, 0, 0)
+			    "format", G_TYPE_STRING, GST_AUDIO_NE(F32),
+			    "layout", G_TYPE_STRING, "interleaved",
+#else
 			    "endianness", G_TYPE_INT, G_BYTE_ORDER,
 			    "width", G_TYPE_INT, 32,
-			    "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
+			    "channels", GST_TYPE_INT_RANGE, 1, 2,
+#endif
+			    NULL);
 			gst_caps_append_structure(caps, structure);
 		}
 		if(!forcebits || forcebits == 16)
 		{
-			structure = gst_structure_new("audio/x-raw-int",
+			structure = gst_structure_new(RAW_AUDIO_INT,
+#if GST_CHECK_VERSION(1, 0, 0)
+			    "format", G_TYPE_STRING, GST_AUDIO_NE(S16),
+			    "layout", G_TYPE_STRING, "interleaved",
+#else
 			    "endianness", G_TYPE_INT, G_BYTE_ORDER,
 			    "width", G_TYPE_INT, 16,
 			    "depth", G_TYPE_INT, 16,
 			    "signed", G_TYPE_BOOLEAN, TRUE,
-			    "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
+			    "channels", GST_TYPE_INT_RANGE, 1, 2,
+#endif
+			    NULL);
 			gst_caps_append_structure(caps, structure);
 		}
 		if(!forcebits || forcebits == 8)
 		{
-			structure = gst_structure_new("audio/x-raw-int",
+			structure = gst_structure_new(RAW_AUDIO_INT,
+#if GST_CHECK_VERSION(1, 0, 0)
+			    "format", G_TYPE_STRING, "U8",
+			    "layout", G_TYPE_STRING, "interleaved",
+#else
 			    "width", G_TYPE_INT, 8,
 			    "depth", G_TYPE_INT, 8,
 			    "signed", G_TYPE_BOOLEAN, FALSE,
-			    "channels", GST_TYPE_INT_RANGE, 1, 2, NULL);
+			    "channels", GST_TYPE_INT_RANGE, 1, 2,
+#endif
+			    NULL);
 			gst_caps_append_structure(caps, structure);
 		}
 	}
@@ -432,10 +496,17 @@ class OpenALSoundStream : public SoundSt
 		OpenALSoundStream *self = static_cast<OpenALSoundStream*>(user_data);
 
 		// get the buffer from appsink
+#if !GST_CHECK_VERSION(1, 0, 0)
 		GstBuffer *buffer = gst_app_sink_pull_preroll(sink);
 		if(!buffer) return GST_FLOW_ERROR;
 
 		GstCaps *caps = GST_BUFFER_CAPS(buffer);
+#else
+		GstSample *sample = gst_app_sink_pull_preroll(sink);
+		if(!sample) return GST_FLOW_ERROR;
+
+		GstCaps *caps = gst_sample_get_caps(sample);
+#endif
 		gint bits = 0, channels = 0, rate = 0, i;
 		for(i = gst_caps_get_size(caps)-1;i >= 0;i--)
 		{
@@ -451,7 +522,11 @@ class OpenALSoundStream : public SoundSt
 		self->SampleRate = rate;
 		self->Format = FormatFromDesc(bits, channels);
 
+#if !GST_CHECK_VERSION(1, 0, 0)
 		gst_buffer_unref(buffer);
+#else
+		gst_sample_unref(sample);
+#endif
 		if(self->Format == AL_NONE || self->SampleRate <= 0)
 			return GST_FLOW_ERROR;
 		return GST_FLOW_OK;
@@ -461,14 +536,29 @@ class OpenALSoundStream : public SoundSt
 	{
 		OpenALSoundStream *self = static_cast<OpenALSoundStream*>(user_data);
 
+#if !GST_CHECK_VERSION(1, 0, 0)
 		GstBuffer *buffer = gst_app_sink_pull_buffer(sink);
 		if(!buffer) return GST_FLOW_ERROR;
+#else
+		GstSample *sample = gst_app_sink_pull_sample(sink);
+		if(!sample) return GST_FLOW_ERROR;
+		GstBuffer *buffer = gst_sample_get_buffer(sample);
+		if(!buffer) return GST_FLOW_ERROR;
+#endif
 
+#if !GST_CHECK_VERSION(1, 0, 0)
 		if(GST_BUFFER_SIZE(buffer) == 0)
 		{
 			gst_buffer_unref(buffer);
 			return GST_FLOW_OK;
 		}
+#else
+		if(gst_buffer_get_size(buffer) == 0)
+		{
+			gst_sample_unref(sample);
+			return GST_FLOW_OK;
+		}
+#endif
 
 		ALint processed, state;
 	next_buffer:
@@ -477,7 +567,11 @@ class OpenALSoundStream : public SoundSt
 			alGetSourcei(self->Source, AL_BUFFERS_PROCESSED, &processed);
 			if(getALError() != AL_NO_ERROR)
 			{
+#if !GST_CHECK_VERSION(1, 0, 0)
 				gst_buffer_unref(buffer);
+#else
+				gst_sample_unref(sample);
+#endif
 				return GST_FLOW_ERROR;
 			}
 			if(processed > 0 || self->SamplesQueued < MaxSamplesQueued ||
@@ -489,7 +583,11 @@ class OpenALSoundStream : public SoundSt
 
 		if(!self->Playing)
 		{
+#if !GST_CHECK_VERSION(1, 0, 0)
 			gst_buffer_unref(buffer);
+#else
+			gst_sample_unref(sample);
+#endif
 			return GST_FLOW_OK;
 		}
 
@@ -499,7 +597,11 @@ class OpenALSoundStream : public SoundSt
 			alGenBuffers(1, &bufID);
 			if(getALError() != AL_NO_ERROR)
 			{
+#if !GST_CHECK_VERSION(1, 0, 0)
 				gst_buffer_unref(buffer);
+#else
+				gst_sample_unref(sample);
+#endif
 				return GST_FLOW_ERROR;
 			}
 			self->Buffers.push_back(bufID);
@@ -509,7 +611,11 @@ class OpenALSoundStream : public SoundSt
 			alSourceUnqueueBuffers(self->Source, 1, &bufID);
 			if(getALError() != AL_NO_ERROR)
 			{
+#if !GST_CHECK_VERSION(1, 0, 0)
 				gst_buffer_unref(buffer);
+#else
+				gst_sample_unref(sample);
+#endif
 				return GST_FLOW_ERROR;
 			}
 
@@ -523,10 +629,22 @@ class OpenALSoundStream : public SoundSt
 			alDeleteBuffers(1, &bufID);
 		}
 
+#if !GST_CHECK_VERSION(1, 0, 0)
 		alBufferData(bufID, self->Format, GST_BUFFER_DATA(buffer),
 		             GST_BUFFER_SIZE(buffer), self->SampleRate);
+#else
+		GstMapInfo info;
+		gst_buffer_map(buffer, &info, GST_MAP_READ);
+		alBufferData(bufID, self->Format, info.data,
+		             info.size, self->SampleRate);
+#endif
 		alSourceQueueBuffers(self->Source, 1, &bufID);
+#if !GST_CHECK_VERSION(1, 0, 0)
 		gst_buffer_unref(buffer);
+#else
+		gst_buffer_unmap(buffer, &info);
+		gst_sample_unref(sample);
+#endif
 
 		if(getALError() != AL_NO_ERROR)
 			return GST_FLOW_ERROR;
@@ -560,9 +678,13 @@ class OpenALSoundStream : public SoundSt
 		size = std::min<guint>(size, self->MemData.size() - self->MemDataPos);
 		self->MemDataPos += size;
 
+#if !GST_CHECK_VERSION(1, 0, 0)
 		GstBuffer *buffer = gst_buffer_new();
 		GST_BUFFER_DATA(buffer) = data;
 		GST_BUFFER_SIZE(buffer) = size;
+#else
+		GstBuffer *buffer = gst_buffer_new_wrapped(data, size);
+#endif
 
 		// this takes ownership of the buffer; don't unref
 		gst_app_src_push_buffer(appsrc, buffer);
@@ -582,6 +704,7 @@ class OpenALSoundStream : public SoundSt
 	{
 		GstElement *elem;
 		g_object_get(self->gstPipeline, "source", &elem, NULL);
+		//gst_base_src_set_format(GST_BASE_SRC(elem), GST_FORMAT_BYTES);
 
 		GstAppSrc *appsrc = GST_APP_SRC(elem);
 		GstAppSrcCallbacks callbacks = {
@@ -610,13 +733,25 @@ class OpenALSoundStream : public SoundSt
 		else
 		{
 			buffer = gst_buffer_new_and_alloc(size);
+#if !GST_CHECK_VERSION(1, 0, 0)
 			if(!self->Callback(self, GST_BUFFER_DATA(buffer), GST_BUFFER_SIZE(buffer), self->UserData))
+#else
+			GstMapInfo info;
+			gst_buffer_map(buffer, &info, GST_MAP_WRITE);
+			if(!self->Callback(self, info.data, info.size, self->UserData))
+#endif
 			{
+#if GST_CHECK_VERSION(1, 0, 0)
+				gst_buffer_unmap(buffer, &info);
+#endif
 				gst_buffer_unref(buffer);
 
 				gst_app_src_end_of_stream(appsrc);
 				return;
 			}
+#if GST_CHECK_VERSION(1, 0, 0)
+			gst_buffer_unmap(buffer, &info);
+#endif
 		}
 
 		gst_app_src_push_buffer(appsrc, buffer);
@@ -626,11 +761,14 @@ class OpenALSoundStream : public SoundSt
 	{
 		GstElement *elem;
 		g_object_get(self->gstPipeline, "source", &elem, NULL);
+		//gst_base_src_set_format(GST_BASE_SRC(elem), GST_FORMAT_BYTES);
 
 		GstAppSrc *appsrc = GST_APP_SRC(elem);
 		GstAppSrcCallbacks callbacks = {
 		    need_callback, NULL, NULL
 		};
+		//gst_base_src_set_format(GST_BASE_SRC(appsrc), GST_FORMAT_TIME);
+		//gst_base_src_set_do_timestamp(GST_BASE_SRC(appsrc), TRUE);
 		gst_app_src_set_callbacks(appsrc, &callbacks, self, NULL);
 		gst_app_src_set_size(appsrc, -1);
 		gst_app_src_set_max_bytes(appsrc, self->BufferBytes);
@@ -680,7 +818,11 @@ class OpenALSoundStream : public SoundSt
 
 	bool PipelineSetup()
 	{
+#if !GST_CHECK_VERSION(1, 0, 0)
 		TagList = gst_tag_list_new();
+#else
+		TagList = gst_tag_list_new_empty();
+#endif
 		g_return_val_if_fail(TagList != NULL, false);
 
 		// Flags (can be combined):
@@ -694,16 +836,23 @@ class OpenALSoundStream : public SoundSt
 		// 0x80: download     - Attempt progressive download buffering
 		int flags = 0x02 | 0x10;
 
+#if !GST_CHECK_VERSION(1, 0, 0)
 		gstPipeline = gst_element_factory_make("playbin2", NULL);
+#else
+		gstPipeline = gst_element_factory_make("playbin", NULL);
+#endif
 		g_return_val_if_fail(gstPipeline != NULL, false);
 
-		//GstElement *sink = gst_element_factory_make("openalsink", NULL);
+		// GstElement *sink = gst_element_factory_make("openalsink", NULL);
 		GstElement *sink = gst_element_factory_make("autoaudiosink", NULL);
+		//GstElement *sink = NULL;
+		//GstElement *sink = gst_element_factory_make("alsasink", NULL);
 		if(sink != NULL)
 		{
 			// Give the sink our device, so it can create its own context and
 			// source to play with (and not risk cross-contaminating errors)
 			// g_object_set(sink, "device-handle", Renderer->Device, NULL);
+			// g_object_set(sink, "async-handling", true, "message-forward", true, NULL);
 		}
 		else
 		{
@@ -728,7 +877,7 @@ class OpenALSoundStream : public SoundSt
 		}
 
 		// This takes ownership of the element; don't unref it
-		g_object_set(gstPipeline, "audio-sink", sink, NULL);
+		// g_object_set(gstPipeline, "audio-sink", sink, NULL);
 		g_object_set(gstPipeline, "flags", flags, NULL);
 		return true;
 	}
@@ -1008,7 +1157,11 @@ public:
 		gint64 pos;
 
 		// Position will be handled in milliseconds; GStreamer's time format is in nanoseconds
+#if !GST_CHECK_VERSION(1, 0, 0)
 		if(gst_element_query_position(gstPipeline, &format, &pos) && format == GST_FORMAT_TIME)
+#else
+		if(gst_element_query_position(gstPipeline, format, &pos))
+#endif
 			return (unsigned int)(pos / 1000000);
 		return 0;
 	}
@@ -1110,6 +1263,8 @@ public:
 			return false;
 
 		g_object_set(gstPipeline, "uri", "appsrc://", NULL);
+		//GstElement *appsrc = gst_bin_get_by_name(GST_BIN(gstPipeline), "source");
+		//gst_base_src_set_format(GST_BASE_SRC(appsrc), GST_FORMAT_TIME);
 		g_signal_connect(gstPipeline, "deep-notify::source", G_CALLBACK(memdata_source), this);
 
 		return PreparePipeline();
@@ -1123,27 +1278,54 @@ public:
 
 		GstStructure *structure;
 		if((flags&Float))
-			structure = gst_structure_new("audio/x-raw-float",
+			structure = gst_structure_new(RAW_AUDIO_FLOAT,
+#if GST_CHECK_VERSION(1, 0, 0)
+			    "format", G_TYPE_STRING, GST_AUDIO_NE(F32),
+			    "layout", G_TYPE_STRING, "interleaved",
+#else
 			    "endianness", G_TYPE_INT, G_BYTE_ORDER,
-			    "width", G_TYPE_INT, 32, NULL);
+			    "width", G_TYPE_INT, 32,
+#endif
+			    NULL);
 		else if((flags&Bits32))
-			structure = gst_structure_new("audio/x-raw-int",
+			structure = gst_structure_new(RAW_AUDIO_INT,
+#if GST_CHECK_VERSION(1, 0, 0)
+			    "format", G_TYPE_STRING, GST_AUDIO_NE(S32),
+			    "layout", G_TYPE_STRING, "interleaved",
+#else
 			    "endianness", G_TYPE_INT, G_BYTE_ORDER,
 			    "width", G_TYPE_INT, 32,
 			    "depth", G_TYPE_INT, 32,
-			    "signed", G_TYPE_BOOLEAN, TRUE, NULL);
+			    "signed", G_TYPE_BOOLEAN, TRUE,
+#endif
+			    NULL);
 		else if((flags&Bits8))
-			structure = gst_structure_new("audio/x-raw-int",
+			structure = gst_structure_new(RAW_AUDIO_INT,
+#if GST_CHECK_VERSION(1, 0, 0)
+			    "format", G_TYPE_STRING, "S8",
+#else
 			    "width", G_TYPE_INT, 8,
 			    "depth", G_TYPE_INT, 8,
-			    "signed", G_TYPE_BOOLEAN, TRUE, NULL);
+			    "signed", G_TYPE_BOOLEAN, TRUE,
+#endif
+			    NULL);
 		else
-			structure = gst_structure_new("audio/x-raw-int",
+			structure = gst_structure_new(RAW_AUDIO_INT,
+#if GST_CHECK_VERSION(1, 0, 0)
+			    "format", G_TYPE_STRING, GST_AUDIO_NE(S16),
+			    "layout", G_TYPE_STRING, "interleaved",
+#else
 			    "endianness", G_TYPE_INT, G_BYTE_ORDER,
 			    "width", G_TYPE_INT, 16,
 			    "depth", G_TYPE_INT, 16,
-			    "signed", G_TYPE_BOOLEAN, TRUE, NULL);
+			    "signed", G_TYPE_BOOLEAN, TRUE,
+#endif
+			    NULL);
 		gst_structure_set(structure, "channels", G_TYPE_INT, (flags&Mono)?1:2, NULL);
+#if GST_CHECK_VERSION(1, 0, 0)
+		if(!(flags&Mono))
+			gst_structure_set(structure, "channel-mask", GST_TYPE_BITMASK, 0x3, NULL);
+#endif
 		gst_structure_set(structure, "rate", G_TYPE_INT, samplerate, NULL);
 
 		SrcCaps = gst_caps_new_full(structure, NULL);
@@ -1152,6 +1334,8 @@ public:
 			return false;
 
 		g_object_set(gstPipeline, "uri", "appsrc://", NULL);
+		//GstElement *appsrc = gst_bin_get_by_name(GST_BIN(gstPipeline), "source");
+		//gst_base_src_set_format(GST_BASE_SRC(appsrc), GST_FORMAT_TIME);
 		g_signal_connect(gstPipeline, "deep-notify::source", G_CALLBACK(callback_source), this);
 
 		return PreparePipeline();
@@ -1183,9 +1367,13 @@ class Decoder
 		size = (std::min)(size, (guint)(self->MemDataSize - self->MemDataPos));
 		self->MemDataPos += size;
 
+#if !GST_CHECK_VERSION(1, 0, 0)
 		GstBuffer *buffer = gst_buffer_new();
 		GST_BUFFER_DATA(buffer) = const_cast<guint8*>(data);
 		GST_BUFFER_SIZE(buffer) = size;
+#else
+		GstBuffer *buffer = gst_buffer_new_wrapped(const_cast<guint8*>(data), size);
+#endif
 
 		gst_app_src_push_buffer(appsrc, buffer);
 	}
@@ -1220,12 +1408,21 @@ class Decoder
 	{
 		Decoder *self = static_cast<Decoder*>(user_data);
 
+#if !GST_CHECK_VERSION(1, 0, 0)
 		GstBuffer *buffer = gst_app_sink_pull_preroll(sink);
 		if(!buffer) return GST_FLOW_ERROR;
+#else
+		GstSample *sample = gst_app_sink_pull_preroll(sink);
+		if(!sample) return GST_FLOW_ERROR;
+#endif
 
 		if(self->OutRate == 0)
 		{
+#if !GST_CHECK_VERSION(1, 0, 0)
 			GstCaps *caps = GST_BUFFER_CAPS(buffer);
+#else
+			GstCaps *caps = gst_sample_get_caps(sample);
+#endif
 
 			gint channels = 0, rate = 0, bits = 0, i;
 			for(i = gst_caps_get_size(caps)-1;i >= 0;i--)
@@ -1244,7 +1441,11 @@ class Decoder
 			self->OutRate = rate;
 		}
 
+#if !GST_CHECK_VERSION(1, 0, 0)
 		gst_buffer_unref(buffer);
+#else
+		gst_sample_unref(sample);
+#endif
 		if(self->OutRate <= 0)
 			return GST_FLOW_ERROR;
 		return GST_FLOW_OK;
@@ -1254,6 +1455,7 @@ class Decoder
 	{
 		Decoder *self = static_cast<Decoder*>(user_data);
 
+#if !GST_CHECK_VERSION(1, 0, 0)
 		GstBuffer *buffer = gst_app_sink_pull_buffer(sink);
 		if(!buffer) return GST_FLOW_ERROR;
 
@@ -1264,6 +1466,22 @@ class Decoder
 		memcpy(&self->OutData[pos], GST_BUFFER_DATA(buffer), newsize);
 
 		gst_buffer_unref(buffer);
+#else
+		GstSample *sample = gst_app_sink_pull_sample(sink);
+		if(!sample) return GST_FLOW_ERROR;
+		GstBuffer *buffer = gst_sample_get_buffer(sample);
+		if(!buffer) return GST_FLOW_ERROR;
+
+		GstMapInfo info;
+		gst_buffer_map(buffer, &info, GST_MAP_READ);
+		size_t pos = self->OutData.size();
+		self->OutData.resize(pos+info.size);
+
+		memcpy(&self->OutData[pos], info.data, info.size);
+
+		gst_buffer_unmap(buffer, &info);
+		gst_sample_unref(sample);
+#endif
 		return GST_FLOW_OK;
 	}
 
@@ -1272,10 +1490,18 @@ class Decoder
 		if(forcebits && forcebits != 8 && forcebits != 16)
 			return false;
 
+#if !GST_CHECK_VERSION(1, 0, 0)
 		TagList = gst_tag_list_new();
+#else
+		TagList = gst_tag_list_new_empty();
+#endif
 		g_return_val_if_fail(TagList != NULL, false);
 
+#if !GST_CHECK_VERSION(1, 0, 0)
 		gstPipeline = gst_element_factory_make("playbin2", NULL);
+#else
+		gstPipeline = gst_element_factory_make("playbin", NULL);
+#endif
 		g_return_val_if_fail(gstPipeline != NULL, false);
 
 		gstSink = gst_element_factory_make("appsink", NULL);
