[gst-devel] Plugin creation

Iago Toral Quiroga itoral at igalia.com
Fri Mar 6 11:00:06 CET 2009


(I sent another email with an implementation of a silly video filter
that applies different color masks to an rgb stream, but for some reason
it did not hit the list, guess it does not like attachments so I removed
it, hopefully this one will make it. If you want the code, say so and
I'll send it to you directly).

In summary, you just need to get the red_mask from the caps:

gst_filter_set_caps (GstPad * pad, GstCaps * caps)
{
  Gstmyvideo *filter;
  GstPad *otherpad;

  filter = GST_MYVIDEO (gst_pad_get_parent (pad));
  otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
  gst_object_unref (filter);

  GstStructure *structure = gst_caps_get_structure (caps, 0);
  ...
  gst_structure_get_int (structure, "red_mask", &filter->red_mask);
  ...
}

Then, in your process function, apply the mask to the samples, something
like this does the trick:

...
guint samples = GST_BUFFER_SIZE (buf) / 2;
guint16 *data = (guint16 *) GST_BUFFER_DATA (buf);
gint i;

for (i=0; i<samples; i++) {
    data[i] = data[i] & filter->red_mask;
 }
...

Iago

El vie, 06-03-2009 a las 09:05 +0100, cammille at polytech.unice.fr
escribió: 
> Nobody knows how to filter the red color ?
> 
> If someone can explain me how to manipulate the buffer just to keep the
> red color it would be great.
> 
> Thank you.
> 
> > Thanks everybody !
> >
> > I'm ok with you Albert, I think the simplest is RGB.. but there still is a
> > problem.
> > If I define a cap I have an error which is :
> > ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Could not
> > negotiate format
> >
> > So I tried to force the format in the pipeline and I have the same error !
> >
> > here is my command : gst-launch
> > --gst-plugin-path=$HOME/gst-template/gst-plugin/src/.libs/ v4l2src  !
> > videoscale !  ffmpegcolorspace ! testfilter ! xvimagesink
> >
> > I have searched in vain other examples...
> >
> > It's strange, because in my code, if I change my buffer like that :
> > int i;
> > int size = GST_BUFFER_CAST(buf)->size;
> >
> > for(i=1; i < size; i++) {
> >   (buf->data)[i] = 0;
> > }
> >
> > The images become all green... I really don't understand why.
> >
> > I think there is a simple way to just keep the red color.. but I don't
> > find it.
> >
> >
> >
> >> Hi,
> >> the plugin name and description can (must...) be changed in the
> >> plugin_init function and GST_PLUGIN_DEFINE macro definition in the code
> >> that must be present in your code.
> >> Concerning the filtering itself, you must check that you have RGB (I
> >> guess
> >> that's the simplest) image buffers coming to your plugin in order to
> >> make
> >> your processing in the chain function. Best way would be to set the caps
> >> of your sink pad to video/x-rgb flow. Check other exisitng plugins to
> >> see
> >> how to do this. You'll need a ffmpegcolorspace element before your
> >> plugin
> >> to let the flow be in the good format.
> >> The example plugin is just a skeleton, you need now to specialize it
> >> with
> >> your own code... Read the gstreamer plugin writer's guide, it will give
> >> you information.
> >> Regards,
> >> Al
> >>
> >>
> >>
> >> ________________________________
> >> De : "cammille at polytech.unice.fr" <cammille at polytech.unice.fr>
> >> À : Discussion of the development of GStreamer
> >> <gstreamer-devel at lists.sourceforge.net>
> >> Envoyé le : Jeudi, 5 Mars 2009, 12h15mn 55s
> >> Objet : Re: [gst-devel] Plugin creation
> >>
> >> I found the problem ! The fact is that my plugin is not named
> >> "testfilter".. It's named "plugin". How can I change this name ?
> >> beacause
> >> I have never specified that my plugin is named "plugin".
> >>
> >> Another question, : now, I would like to create a simple plugin :
> >> I would like to filter the video taken by my webcam and filter the red
> >> color (i would like to apply an effect like the effectv plugin).
> >> I know the algorithm, but I'm not sure how to do that.
> >>
> >> Do you think I should create this plugin by using the example plugin ?
> >>
> >>
> >>> assuming that the shared library name is libgsttestfilters.so
> >>>
> >>> On Thu, Mar 5, 2009 at 4:28 PM, ved kpl <ved.kpl at gmail.com> wrote:
> >>>> Try gst-inspect on your plugin
> >>>>
> >>>> Assuming that the plugin is installed in
> >>>> "$HOME/gst-template/gst-plugin/src/.libs/"
> >>>> do the following and see what you get
> >>>>
> >>>>  gst-inspect
> >>>> $HOME/gst-template/gst-plugin/src/.libs/libgsttestfilters.so
> >>>>
> >>>> On Thu, Mar 5, 2009 at 4:15 PM,  <cammille at polytech.unice.fr> wrote:
> >>>>> Hello !
> >>>>> I would like to create a simple plugin such as effectv..
> >>>>>
> >>>>> But, first of all, I would like to create a "test plugin".
> >>>>> So, I tried to make the example described in the GStreamer Plugin
> >>>>> Writer's
> >>>>> Guide.
> >>>>>
> >>>>> I compiled the "test plugin" with the makefile, and now I'm trying to
> >>>>> launch this plugin, but I have an error..
> >>>>>
> >>>>> What's wrong with :
> >>>>>
> >>>>> $ gst-launch
> >>>>> --gst-plugin-path=$HOME/gst-template/gst-plugin/src/.libs/
> >>>>> fakesrc ! testfilters ! fakesink silent=TRUE
> >>>>>  > WARNING: erroneous pipeline: no element "testfilters"
> >>>>>
> >>>>> Maybe I have forgotten something ?
> >>>>>
> >>>>>
> >>>>> Thank you.
> >>>>>
> >>>>>
> >>>>>
> >>>>> ------------------------------------------------------------------------------
> >>>>> Open Source Business Conference (OSBC), March 24-25, 2009, San
> >>>>> Francisco, CA
> >>>>> -OSBC tackles the biggest issue in open source: Open Sourcing the
> >>>>> Enterprise
> >>>>> -Strategies to boost innovation and cut costs with open source
> >>>>> participation
> >>>>> -Receive a $600 discount off the registration fee with the source
> >>>>> code:
> >>>>> SFAD
> >>>>> http://p.sf.net/sfu/XcvMzF8H
> >>>>> _______________________________________________
> >>>>> gstreamer-devel mailing list
> >>>>> gstreamer-devel at lists.sourceforge.net
> >>>>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> >>>>>
> >>>>
> >>>
> >>> ------------------------------------------------------------------------------
> >>> Open Source Business Conference (OSBC), March 24-25, 2009, San
> >>> Francisco,
> >>> CA
> >>> -OSBC tackles the biggest issue in open source: Open Sourcing the
> >>> Enterprise
> >>> -Strategies to boost innovation and cut costs with open source
> >>> participation
> >>> -Receive a $600 discount off the registration fee with the source code:
> >>> SFAD
> >>> http://p.sf.net/sfu/XcvMzF8H
> >>> _______________________________________________
> >>> gstreamer-devel mailing list
> >>> gstreamer-devel at lists.sourceforge.net
> >>> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> >>>
> >>
> >>
> >>
> >> ------------------------------------------------------------------------------
> >> Open Source Business Conference (OSBC), March 24-25, 2009, San
> >> Francisco,
> >> CA
> >> -OSBC tackles the biggest issue in open source: Open Sourcing the
> >> Enterprise
> >> -Strategies to boost innovation and cut costs with open source
> >> participation
> >> -Receive a $600 discount off the registration fee with the source code:
> >> SFAD
> >> http://p.sf.net/sfu/XcvMzF8H
> >> _______________________________________________
> >> gstreamer-devel mailing list
> >> gstreamer-devel at lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> >>
> >>
> >>
> >>       ------------------------------------------------------------------------------
> >> Open Source Business Conference (OSBC), March 24-25, 2009, San
> >> Francisco,
> >> CA
> >> -OSBC tackles the biggest issue in open source: Open Sourcing the
> >> Enterprise
> >> -Strategies to boost innovation and cut costs with open source
> >> participation
> >> -Receive a $600 discount off the registration fee with the source code:
> >> SFAD
> >> http://p.sf.net/sfu/XcvMzF8H_______________________________________________
> >> gstreamer-devel mailing list
> >> gstreamer-devel at lists.sourceforge.net
> >> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> >>
> >
> >
> >
> > ------------------------------------------------------------------------------
> > Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco,
> > CA
> > -OSBC tackles the biggest issue in open source: Open Sourcing the
> > Enterprise
> > -Strategies to boost innovation and cut costs with open source
> > participation
> > -Receive a $600 discount off the registration fee with the source code:
> > SFAD
> > http://p.sf.net/sfu/XcvMzF8H
> > _______________________________________________
> > gstreamer-devel mailing list
> > gstreamer-devel at lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> >
> 
> 
> 
> ------------------------------------------------------------------------------
> Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
> -OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
> -Strategies to boost innovation and cut costs with open source participation
> -Receive a $600 discount off the registration fee with the source code: SFAD
> http://p.sf.net/sfu/XcvMzF8H
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
> 





More information about the gstreamer-devel mailing list