Text test source element

Josh Doe josh at joshdoe.com
Thu Jun 14 09:07:46 PDT 2012


On Thu, Jun 14, 2012 at 11:51 AM, iron_guitarist1987
<jtrinidadperez at gmail.com> wrote:
> Does this look better?
>
> static GstFlowReturn
> gst_text_test_src_create (GstBaseSrc * basesrc, guint64 offset,
>    guint length, GstBuffer ** buffer)
> {
>  GstFlowReturn res;
>  GstTexttestsrc *src;
>  src = GST_TEXT_TEST_SRC (basesrc);
>  GstBuffer *buf;
>
>  buf = gst_buffer_new_and_alloc (sizeof("test"));
>  buf = g_strdup("test string");
>
>  *buffer = buf;
>
>  return GST_FLOW_OK;
> }

I'd recommend taking a second look at some more tutorials on C.
GstBuffer is an object (glorified struct) that holds many pieces of
information, not just a pointer to memory. You need to tell the buffer
where the memory is (GST_BUFFER_DATA), the size (GST_BUFFER_SIZE), and
the pointer to free (GST_BUFFER_MALLOCDATA, typically the same as
GST_BUFFER_DATA). Since you're using new_and_alloc you don't dup the
string, but copy it into the existing memory.
-Josh


More information about the gstreamer-devel mailing list