[gst-devel] source plugin blocked in PAUSE state

René Stadler mail at renestadler.de
Thu Jun 28 19:52:32 CEST 2007


Am Donnerstag, den 28.06.2007, 17:01 +0200 schrieb Riccardo Corona:
> Hi,
> thank's for the tips. When I told that I've started from
> GstPluginTemplate I mean something like this:
> 
> GST_BOILERPLATE (GstPluginTemplate, gst_plugin_template, GstBaseSrc,
>     GST_TYPE_ELEMENT);
> 
> Is it what did you mean?
> 
That should be

GST_BOILERPLATE (GstPluginTemplate, gst_plugin_template, GstBaseSrc,
GST_TYPE_BASE_SRC);

Have a look at the GstBaseSrc documentation and refer to the various
existing code that uses it (gnomevfssrc, videotestsrc, etc.).

What you had before as get_range function goes as the create vmethod of
your BaseSrc derived element (after you fix the function to return the
buffer as *buf = buffer and return GST_FLOW_OK).
> 
> 2007/6/28, René Stadler <mail at renestadler.de>:
>         Am Donnerstag, den 28.06.2007, 13:09 +0200 schrieb Riccardo
>         Corona:
>         > Hi,
>         > I'm writing a source plugin, I'm started from
>         GstPluginTemplate to
>         > make a simple plugin that generate only B&W frames... 
>         > The problem is that with this pipeline:
>         >
>         I strongly suggest deriving from GstBaseSrc instead.
>         
>         
>         > mysrc ! ffmpegcolorspace ! directdrawsink
>         >
>         > the pipeline is blocked on PREROLLING and in debug mode I
>         can see that 
>         > the last state of my plugin is PAUSED.
>         > Here the snipped of code in which I set the buffer:
>         >
>         >
>         >
>         > /* get_range function
>         >  * makes it a source of a stream
>         >  */
>         > static gboolean gst_plugin_template_get_range (GstPad *pad,
>         guint64 
>         > offset, guint lenght, GstBuffer **buf)
>         > {
>         >     static  gboolean white=1;
>         >
>         >     GstPluginTemplate *plug= GST_PLUGIN_TEMPLATE
>         (GST_OBJECT_PARENT
>         > (pad) );
>         >
>         >      GstBuffer *buffer; 
>         >       gint size, width, height, bpp;
>         >       width = 320; height = 240; bpp = 16;
>         >       size = width * height * bpp;
>         >       buffer = gst_buffer_new();
>         >       GST_BUFFER_SIZE (buffer) = size; 
>         >
>         >     if (white)GST_BUFFER_MALLOCDATA (buffer) =  g_memdup
>         (0xff,size);
>         >         else GST_BUFFER_MALLOCDATA (buffer) =  g_memdup
>         (0x0,size);
>         >
>         >     white=!white;
>         >
>         >       GST_BUFFER_DATA (buffer) = GST_BUFFER_MALLOCDATA
>         (buffer); 
>         >
>         >
>         >     ts = gst_util_uint64_scale_int (frame_num * GST_SECOND,
>         FPS_DEN,
>         > FPS_NUM);
>         >     next_ts = gst_util_uint64_scale_int ((frame_num + 1) *
>         GST_SECOND,
>         > FPS_DEN,  FPS_NUM);
>         >
>         >     GST_BUFFER_TIMESTAMP (buffer) = ts;
>         >     GST_BUFFER_DURATION (buffer) = next_ts-ts;
>         >
>         >     frame_num++;
>         >
>         >
>         >     return gst_pad_push (plug->srcpad, buffer);
>         > 
>         > }
>         >
>         This is completely wrong.  In a get_range function, you are
>         supposed to
>         return the buffer to the supplied location!  Take a look at
>         gstreamer/docs/design/part-scheduling.txt [1] and other docs
>         in that 
>         directory to get some insight.
>         
>         [1]:
>         http://webcvs.freedesktop.org/gstreamer/gstreamer/docs/design/part-scheduling.txt?view=markup
>         >
>         > I thought that setting the timestamp is enough to have
>         continuosly a
>         > stream of images but it seems that I'm wrong.
>         > Do I must force the state of the plugin in PLAY mode?
>         > Or maybe I'm wrong with the buffer management? 
>         >
>         > Any help will be very appreciate becouse I'm new to plugin
>         writing...
>         >
>         >
>         > Best Regards.
>         >
>         >
>         >
>         > --
>         > Riccardo Corona
>         
>         --
>         Regards,
>           René Stadler 
>         
> 
> 
> 
> -- 
> Riccardo Corona 

-- 
Regards,
  René Stadler





More information about the gstreamer-devel mailing list