From 5a9a2f27a782b1ee539ee8c738bb84b3eada0890 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 28 May 2009 15:31:01 +0200 Subject: [PATCH] Implement Adapter.Peek() that returns a GstBuffer --- gstreamer-sharp/Adapter.custom | 7 +++++++ gstreamer-sharp/glue/Makefile.am | 3 ++- gstreamer-sharp/glue/adapter.c | 13 +++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 gstreamer-sharp/glue/adapter.c diff --git a/gstreamer-sharp/Adapter.custom b/gstreamer-sharp/Adapter.custom index 1e0ea64707..da49141f50 100644 --- a/gstreamer-sharp/Adapter.custom +++ b/gstreamer-sharp/Adapter.custom @@ -5,3 +5,10 @@ gst_adapter_push(Handle, buf == null ? IntPtr.Zero : buf.OwnedHandle); } + + [DllImport ("gstreamersharpglue-0.10.dll") ] + static extern IntPtr gstsharp_gst_adapter_peek_buffer (IntPtr adapter, uint size); + + public Gst.Buffer Peek (uint size) { + return (Gst.Buffer) Gst.MiniObject.GetObject (gstsharp_gst_adapter_peek_buffer (Handle, size), true); + } diff --git a/gstreamer-sharp/glue/Makefile.am b/gstreamer-sharp/glue/Makefile.am index 110c2bd44a..d7963eb1eb 100644 --- a/gstreamer-sharp/glue/Makefile.am +++ b/gstreamer-sharp/glue/Makefile.am @@ -17,7 +17,8 @@ libgstreamersharpglue_0_10_la_SOURCES = \ indexentry.c \ indexfactory.c \ mixertrack.c \ - tunernorm.c + tunernorm.c \ + adapter.c nodist_libgstreamersharpglue_0_10_la_SOURCES = generated.c diff --git a/gstreamer-sharp/glue/adapter.c b/gstreamer-sharp/glue/adapter.c new file mode 100644 index 0000000000..aa767bb33b --- /dev/null +++ b/gstreamer-sharp/glue/adapter.c @@ -0,0 +1,13 @@ +#include +#include + +GstBuffer * +gstsharp_gst_adapter_peek_buffer (GstAdapter *adapter, guint size) { + GstBuffer *ret = gst_buffer_new_and_try_alloc (size); + + if (ret == NULL) + return NULL; + + gst_adapter_copy (adapter, GST_BUFFER_DATA (ret), 0, size); + return ret; +}