Hello,
I'm trying to create the simplest text source element that outputs the same string over and over again. I tried doing something with the audiotestsrc, but I know is wrong. Below is what I have so far. Any ideas? thanks /* GStreamer * Copyright (C) 2005 Stefan Kost <ensonic@users.sf.net> * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /** * SECTION:element-texttestsrc * * Texttestsrc can be used to generate basic strings. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <stdlib.h> #include <string.h> #include <gst/controller/gstcontroller.h> #include "texttestsrc.h" GST_DEBUG_CATEGORY_STATIC (text_test_src_debug); #define GST_CAT_DEFAULT text_test_src_debug enum { PROP_0, PROP_LAST }; static GstStaticPadTemplate gst_text_test_src_src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("text/plain") ); GST_BOILERPLATE (GstTexttestsrc, gst_text_test_src, GstBaseSrc, GST_TYPE_BASE_SRC); #define GST_TYPE_TEXT_TEST_SRC_WAVE (gst_audiostestsrc_wave_get_type()) static void gst_text_test_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_text_test_src_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); static GstFlowReturn gst_text_test_src_create (GstBaseSrc * basesrc, guint64 offset, guint length, GstBuffer ** buffer); static void gst_text_test_src_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_text_test_src_src_template)); gst_element_class_set_details_simple (element_class, "Audio test source", "Source/Audio", "Creates audio test signals of given frequency and volume", "Stefan Kost <ensonic@users.sf.net>"); } static void gst_text_test_src_class_init (GstTexttestsrcClass * klass) { GObjectClass *gobject_class; GstBaseSrcClass *gstbasesrc_class; gobject_class = (GObjectClass *) klass; gstbasesrc_class = (GstBaseSrcClass *) klass; gobject_class->set_property = gst_text_test_src_set_property; gobject_class->get_property = gst_text_test_src_get_property; gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_text_test_src_create); } static void gst_text_test_src_init (GstTexttestsrc * src, GstTexttestsrcClass * g_class) { GstPad *pad = GST_BASE_SRC_PAD (src); /* we operate in time */ gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME); gst_base_src_set_blocksize (GST_BASE_SRC (src), -1); } static gboolean gst_text_test_src_stop (GstBaseSrc * basesrc) { return TRUE; } 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); *buffer = "This is my test string"; return GST_FLOW_OK; } static void gst_text_test_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstTexttestsrc *src = GST_TEXT_TEST_SRC (object); switch (prop_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } static void gst_text_test_src_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { GstTexttestsrc *src = GST_TEXT_TEST_SRC (object); switch (prop_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } static gboolean plugin_init (GstPlugin * plugin) { /* initialize gst controller library */ gst_controller_init (NULL, NULL); GST_DEBUG_CATEGORY_INIT (text_test_src_debug, "texttestsrc", 0, "Text Test Source"); return gst_element_register (plugin, "texttestsrc", GST_RANK_NONE, GST_TYPE_TEXT_TEST_SRC); } GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, "texttestsrc", "Creates test string", plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN);
All your bases are belong to us.
|
On Thu, Jun 14, 2012 at 10:44 AM, iron_guitarist1987
<[hidden email]> wrote: > I'm trying to create the simplest text source element that outputs the same > string over and over again. I tried doing something with the audiotestsrc, > but I know is wrong. Below is what I have so far. Any ideas? I recommend you go through the plugin writers guide first: http://gstreamer.freedesktop.org/data/doc/gstreamer/0.10.36/pwg/html/index.html The first problem I see is in _create, you can't just assign a static string to the *buffer pointer. After going through the tutorials look at the docs such as: http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstBuffer.html http://gstreamer.freedesktop.org/data/doc/gstreamer/0.10.36/gstreamer-libs/html/GstBaseSrc.html http://developer.gnome.org/glib/2.32/glib-String-Utility-Functions.html#g-strdup You need to allocate a new buffer, set the data (see g_strdup), size, etc using GST_BUFFER_*. -Josh _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
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; } When I run it I get: $ gst-launch texttestsrc ! georeg_test ! fakesink Setting pipeline to PAUSED ... Pipeline is PREROLLING ... Caught SIGSEGV accessing address 0x74736574 Spinning. Please run 'gdb gst-launch 14052' to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.
All your bases are belong to us.
|
On Thu, Jun 14, 2012 at 11:51 AM, iron_guitarist1987
<[hidden email]> 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 _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
This post was updated on .
Sorry for being so naive, but I am still new to gstreamer, and the development guide isn't as thorough as I would like it to be.
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; char *data = "test string"; buf = gst_buffer_new_and_alloc (sizeof(data)); buf->data = data; buffer = buf; return GST_FLOW_OK; } I get: $ gst-launch -v videotestsrc pattern=1 ! georeg name=s ! ffmpegcolorspace ! ximagesink texttestsrc ! s. Setting pipeline to PAUSED ... ERROR: Pipeline doesn't want to pause. ERROR: from element /GstPipeline:pipeline0/GstTexttestsrc:texttestsrc0: Could not negotiate format Additional debug info: gstbasesrc.c(2787): gst_base_src_start (): /GstPipeline:pipeline0/GstTexttestsrc:texttestsrc0: Check your filtered caps, if any Setting pipeline to NULL ... Freeing pipeline ... georeg has an "any" and a text/plain sinkpads
All your bases are belong to us.
|
On Thu, Jun 14, 2012 at 2:11 PM, iron_guitarist1987
<[hidden email]> wrote: > Sorry for being so naive, but I am still new to gstreamer, and the > development guide isn't as thorough as I would like it to be. True, it could use improvement. You also need to set the caps on the buffer, and it's better style to use the GST_BUFFER_* macros instead of accessing members directly. I'm not familiar with the georeg element, so I don't know what it's doing, the problem could lie with either element. I just noticed you have the type MACRO incorrectly set to be the audiotestsrc. Is this supposed to be a live source? I suggest you spend a day or two thoroughly reading the existing docs (PWG from beginning to end, then API docs of GstBaseSrc, Element, Buffer, etc.) and look at existing plugins. -Josh _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
In reply to this post by iron_guitarist1987
On 06/14/2012 04:44 PM, iron_guitarist1987 wrote:
Hello, I'm trying to create the simplest text source element that outputs the same string over and over again. I tried doing something with the audiotestsrc, but I know is wrong. Below is what I have so far. Any ideas? https://bugzilla.gnome.org/show_bug.cgi?id=657684 Stefan thanks /* GStreamer * Copyright (C) 2005 Stefan Kost [hidden email] * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License as published by the Free Software Foundation; either * version 2 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the * Free Software Foundation, Inc., 59 Temple Place - Suite 330, * Boston, MA 02111-1307, USA. */ /** * SECTION:element-texttestsrc * * Texttestsrc can be used to generate basic strings. */ #ifdef HAVE_CONFIG_H #include "config.h" #endif #include <stdlib.h> #include <string.h> #include <gst/controller/gstcontroller.h> #include "texttestsrc.h" GST_DEBUG_CATEGORY_STATIC (text_test_src_debug); #define GST_CAT_DEFAULT text_test_src_debug enum { PROP_0, PROP_LAST }; static GstStaticPadTemplate gst_text_test_src_src_template = GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_SRC, GST_PAD_ALWAYS, GST_STATIC_CAPS ("text/plain") ); GST_BOILERPLATE (GstTexttestsrc, gst_text_test_src, GstBaseSrc, GST_TYPE_BASE_SRC); #define GST_TYPE_TEXT_TEST_SRC_WAVE (gst_audiostestsrc_wave_get_type()) static void gst_text_test_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_text_test_src_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); static GstFlowReturn gst_text_test_src_create (GstBaseSrc * basesrc, guint64 offset, guint length, GstBuffer ** buffer); static void gst_text_test_src_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_text_test_src_src_template)); gst_element_class_set_details_simple (element_class, "Audio test source", "Source/Audio", "Creates audio test signals of given frequency and volume", "Stefan Kost [hidden email]"); } static void gst_text_test_src_class_init (GstTexttestsrcClass * klass) { GObjectClass *gobject_class; GstBaseSrcClass *gstbasesrc_class; gobject_class = (GObjectClass *) klass; gstbasesrc_class = (GstBaseSrcClass *) klass; gobject_class->set_property = gst_text_test_src_set_property; gobject_class->get_property = gst_text_test_src_get_property; gstbasesrc_class->create = GST_DEBUG_FUNCPTR (gst_text_test_src_create); } static void gst_text_test_src_init (GstTexttestsrc * src, GstTexttestsrcClass * g_class) { GstPad *pad = GST_BASE_SRC_PAD (src); /* we operate in time */ gst_base_src_set_format (GST_BASE_SRC (src), GST_FORMAT_TIME); gst_base_src_set_blocksize (GST_BASE_SRC (src), -1); } static gboolean gst_text_test_src_stop (GstBaseSrc * basesrc) { return TRUE; } 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); *buffer = "This is my test string"; return GST_FLOW_OK; } static void gst_text_test_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstTexttestsrc *src = GST_TEXT_TEST_SRC (object); switch (prop_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } static void gst_text_test_src_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { GstTexttestsrc *src = GST_TEXT_TEST_SRC (object); switch (prop_id) { default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } } static gboolean plugin_init (GstPlugin * plugin) { /* initialize gst controller library */ gst_controller_init (NULL, NULL); GST_DEBUG_CATEGORY_INIT (text_test_src_debug, "texttestsrc", 0, "Text Test Source"); return gst_element_register (plugin, "texttestsrc", GST_RANK_NONE, GST_TYPE_TEXT_TEST_SRC); } GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, "texttestsrc", "Creates test string", plugin_init, VERSION, "LGPL", GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN); ----- The greatest trick the devil ever pulled was convincing the World that Java was better than C++. -- View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Text-test-source-element-tp4655287.html Sent from the GStreamer-devel mailing list archive at Nabble.com. _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel _______________________________________________ gstreamer-devel mailing list [hidden email] http://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |