Caps problem when writing encoder/decoder

classic Classic list List threaded Threaded
16 messages Options
Reply | Threaded
Open this post in threaded view
|

Caps problem when writing encoder/decoder

Hunterwood

Hi,

 

I’m new to GStreamer and try to write a encoder and a decoder for a compressed audio format. But I have problems to get the Caps-negotiation to work.

I base the code on the gst-template and have basically been looking at the alawenc/alawdec as my example.

 

Everything works fine if I use “ANY” or “audio/x-raw-int” in the source of the encoder and sink of the decoder:

static GstStaticPadTemplate gtest_enc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",

    GST_PAD_SRC,

    GST_PAD_ALWAYS,

    GST_STATIC_CAPS ("ANY")

static GstStaticPadTemplate gtest_dec_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",

    GST_PAD_SINK,

    GST_PAD_ALWAYS,

    GST_STATIC_CAPS ("ANY")

 

But when I change the MIME-type to something else, like for example “audio/mytesttype”, I get the error “WARNING: erroneous pipeline: could not link gtestenc0 to gtestdec0”.

I’m using the pipeline:

gst-launch-0.10.exe audiotestsrc ! gtestenc ! gtestdec ! audioresample ! autoaudiosink

 

I get the same error if I only change one of the two caps:es and keep the other one as ANY.

What have I missed? Do I need to register my new type in some way, or what could be the problem?

 

Markus

Reply | Threaded
Open this post in threaded view
|

Re: Caps problem when writing encoder/decoder

Sudarshan Bisht
Hi ,

 I don't understand why do you want to change the mimetype . Because
decoded audio always would have mimetype either audio/x-raw-int or
audio/x-raw-float .

 Just go through the link below , may help you.

 http://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/html/section-types-definitions.html



On Mon, May 17, 2010 at 4:39 PM, Hunterwood
<[hidden email]> wrote:

> Hi,
>
>
>
> I’m new to GStreamer and try to write a encoder and a decoder for a
> compressed audio format. But I have problems to get the Caps-negotiation to
> work.
>
> I base the code on the gst-template and have basically been looking at the
> alawenc/alawdec as my example.
>
>
>
> Everything works fine if I use “ANY” or “audio/x-raw-int” in the source of
> the encoder and sink of the decoder:
>
> static GstStaticPadTemplate gtest_enc_src_factory = GST_STATIC_PAD_TEMPLATE
> ("src",
>
>     GST_PAD_SRC,
>
>     GST_PAD_ALWAYS,
>
>     GST_STATIC_CAPS ("ANY")
>
> static GstStaticPadTemplate gtest_dec_sink_factory = GST_STATIC_PAD_TEMPLATE
> ("sink",
>
>     GST_PAD_SINK,
>
>     GST_PAD_ALWAYS,
>
>     GST_STATIC_CAPS ("ANY")
>
>
>
> But when I change the MIME-type to something else, like for example
> “audio/mytesttype”, I get the error “WARNING: erroneous pipeline: could not
> link gtestenc0 to gtestdec0”.
>
> I’m using the pipeline:
>
> gst-launch-0.10.exe audiotestsrc ! gtestenc ! gtestdec ! audioresample !
> autoaudiosink
>
>
>
> I get the same error if I only change one of the two caps:es and keep the
> other one as ANY.
>
> What have I missed? Do I need to register my new type in some way, or what
> could be the problem?
>
>
>
> Markus
>
> ________________________________
> View this message in context: Caps problem when writing encoder/decoder
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
>
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>



--
Regards,

Sudarshan Bisht

------------------------------------------------------------------------------

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Caps problem when writing encoder/decoder

Hunterwood
Hi Sudarshan,

I am writing both the encoder and the decoder. The goal is to sent raw audio into the encoder, pass the compressed audio over a network and then decod the audio back into raw and pass it on to another sink.

Since the audio is compressed while transmitted over the network I need another MIME-type for it.

Markus
Reply | Threaded
Open this post in threaded view
|

Re: Caps problem when writing encoder/decoder

Sudarshan Bisht
 Ok ,
As u have written earlier ;
 
Everything works fine if I use “ANY” or “audio/x-raw-int” in the source of the encoder and sink of the decoder
 
But source of the encoder is the pad which generates compressed audio ( that means caps would have mimetype "audio/xyz"  instead of "audio/x-raw-int" ) and sink of decoder will consume again compressed audio .
 
I think you are missing something here .
 
Please have a look at lame and mad plugins which are encoder and decoder respectively for mp3 audio format .
 
 
pad details of lame ;
 

name

sink

direction

sink

presence

always

details

audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int){ 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, channels=(int)[ 1, 2 ]

name

src

direction

source

presence

always

details

audio/mpeg, mpegversion=(int)1, layer=(int)3, rate=(int){ 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, channels=(int)[ 1, 2 ]
 
 
 
 pad details of mad ;
 

name

src

direction

source

presence

always

details

audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)32, rate=(int){ 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, channels=(int)[ 1, 2 ]

name

sink

direction

sink

presence

always

details

audio/mpeg, mpegversion=(int)1, layer=(int)[ 1, 3 ], rate=(int){ 8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000 }, channels=(int)[ 1, 2 ]
 
 
On Mon, May 17, 2010 at 9:06 PM, Hunterwood <[hidden email]> wrote:
>
> Hi Sudarshan,
>
> I am writing both the encoder and the decoder. The goal is to sent raw audio
> into the encoder, pass the compressed audio over a network and then decod
> the audio back into raw and pass it on to another sink.
>
> Since the audio is compressed while transmitted over the network I need
> another MIME-type for it.
>
> Markus
> --
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> gstreamer-devel mailing list
>
 
 
 
--
Regards,
 
Sudarshan Bisht
 
 

------------------------------------------------------------------------------


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Caps problem when writing encoder/decoder

Hunterwood
Hi,

thanks for the tip - I will have a look at those.
But I realize that this is what I need to do, but when I do use my "audio/xyz" for the compressed audio in the encoder and decoder, the caps negitiation fails. gst-inspect shows the same caps for both the encoder source and the decoder sink, namely the "audio/xyz", but gst-launch says that "could not link encoder to decoder".
Then I tried to change the "audio/xyz" into "ANY". And when I did, the pipeline is set up and the audio is passed through...

Markus
Reply | Threaded
Open this post in threaded view
|

Re: Caps problem when writing encoder/decoder

Sudarshan Bisht
Hi ,
 
what is you xyz in "audio/xyz" ?

On Tue, May 18, 2010 at 2:59 AM, Hunterwood <[hidden email]> wrote:

Hi,

thanks for the tip - I will have a look at those.
But I realize that this is what I need to do, but when I do use my
"audio/xyz" for the compressed audio in the encoder and decoder, the caps
negitiation fails. gst-inspect shows the same caps for both the encoder
source and the decoder sink, namely the "audio/xyz", but gst-launch says
that "could not link encoder to decoder".
Then I tried to change the "audio/xyz" into "ANY". And when I did, the
pipeline is set up and the audio is passed through...

Markus
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Caps-problem-when-writing-encoder-decoder-tp2219436p2220399.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.

------------------------------------------------------------------------------

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



--
Regards,

Sudarshan Bisht

------------------------------------------------------------------------------


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Caps problem when writing encoder/decoder

Hunterwood
Hi,

I have tried several different non-existing types: audio/x-test, audio/xyz, audio/x-xyz, audio/x-qwertyuiop, audio/x-test, ...

Since my encoder is passing data to my decoder, I thought that the only imortant thing was that they have the same caps to make it work (when I'm finished, I want them to use a currently non-existing type), but it doesn't work.
gst-inspect shows the same type for the source of the encoder and the sink of the decoder, but when trying with gst-launch, it doesn't work:

C:\gstreamer\bin>gst-launch-0.10.exe audiotestsrc ! gtestenc ! gtestdec ! audioresample ! autoaudiosink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstAudioTestSrc:audiotestsrc0: Internal data flow error.
Additional debug info:
..\Source\gstreamer\libs\gst\base\gstbasesrc.c(2378): gst_base_src_loop (): /GstPipeline:pipeline0/GstAudioTestSrc:audiotestsrc0:
streaming task paused, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
C:\gstreamer\bin>


Since I couldn't make it work with non-existing types i tried several different existing types, but the only types that work are ANY and  audio/x-raw-int:

C:\gstreamer\bin>gst-launch-0.10.exe audiotestsrc ! gtestenc ! gtestdec ! audioresample ! autoaudiosink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstAudioSinkClock
^C
C:\gstreamer\bin>


To isolate the problem with the caps, the code just passes on the incomming buffer (just as the gst-template, which I used as base), and the interresting parts of the encoder looks like this (I have omited gst_gtestenc_class_init and parts of gst_gtestenc_base_init bellow):

static GstStaticPadTemplate gtest_enc_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
    GST_PAD_SINK,
    GST_PAD_ALWAYS,
    GST_STATIC_CAPS ("audio/x-raw-int, "
        "rate = (int) { 48000 }, "
        "channels = (int) { 1 }, "
        "endianness = (int) BYTE_ORDER, "
        "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) True")
    );

static GstStaticPadTemplate gtest_enc_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
    GST_PAD_SRC,
    GST_PAD_ALWAYS,
    GST_STATIC_CAPS ("audio/x-test")
    );

GST_BOILERPLATE (Gstgtestenc, gst_gtestenc, GstElement, GST_TYPE_ELEMENT);

static void gst_gtestenc_base_init (gpointer gclass)
{
  GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);

// ...

  gst_element_class_add_pad_template (element_class,
      gst_static_pad_template_get (&gtest_enc_src_factory));
  gst_element_class_add_pad_template (element_class,
      gst_static_pad_template_get (&gtest_enc_sink_factory));
}

static void gst_gtestenc_init (Gstgtestenc * filter,
    GstgtestencClass * gclass)
{
  filter->sinkpad = gst_pad_new_from_static_template (&gtest_enc_sink_factory, "sink");
  gst_pad_set_chain_function (filter->sinkpad,
                              GST_DEBUG_FUNCPTR(gst_gtestenc_chain));

  filter->srcpad = gst_pad_new_from_static_template (&gtest_enc_src_factory, "src");
  gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
  gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
  gst_pad_use_fixed_caps (filter->sinkpad);
  gst_pad_use_fixed_caps (filter->srcpad);
}

static GstFlowReturn gst_gtestenc_chain (GstPad * pad, GstBuffer * buf)
{
  Gstgtestenc *filter;

  filter = GST_GtestENC (GST_OBJECT_PARENT (pad));

  /* just push out the incoming buffer without touching it */
  return gst_pad_push (filter->srcpad, buf);
}



The code in the decoder is basicly the same - pass on the incomming data. The main difference at the moment is the caps definitions:


static GstStaticPadTemplate gtest_dec_sink_factory = GST_STATIC_PAD_TEMPLATE ("sink",
    GST_PAD_SINK,
    GST_PAD_ALWAYS,
    GST_STATIC_CAPS ("audio/x-test")
    );

static GstStaticPadTemplate gtest_dec_src_factory = GST_STATIC_PAD_TEMPLATE ("src",
    GST_PAD_SRC,
    GST_PAD_ALWAYS,
    GST_STATIC_CAPS ("audio/x-raw-int, "
        "rate = (int) { 48000 }, "
                "channels = (int) { 1 }, "
        "endianness = (int) BYTE_ORDER, "
        "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) True")
    );



What am I doing wrong?
Why is it working with audio/x-raw-int, but not with audio/x-test?

Regards,
 Markus
Reply | Threaded
Open this post in threaded view
|

Re: Caps problem when writing encoder/decoder

Sudarshan Bisht
I think you can't simply put any mimetype in the caps , it must be some valid mimetype .
 
On Tue, May 18, 2010 at 4:01 PM, Hunterwood <[hidden email]> wrote:

Hi,

I have tried several different non-existing types: audio/x-test, audio/xyz,
audio/x-xyz, audio/x-qwertyuiop, audio/x-test, ...

Since my encoder is passing data to my decoder, I thought that the only
imortant thing was that they have the same caps to make it work (when I'm
finished, I want them to use a currently non-existing type), but it doesn't
work.
gst-inspect shows the same type for the source of the encoder and the sink
of the decoder, but when trying with gst-launch, it doesn't work:

C:\gstreamer\bin>gst-launch-0.10.exe audiotestsrc ! gtestenc ! gtestdec !
audioresample ! autoaudiosink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
ERROR: from element /GstPipeline:pipeline0/GstAudioTestSrc:audiotestsrc0:
Internal data flow error.
Additional debug info:
..\Source\gstreamer\libs\gst\base\gstbasesrc.c(2378): gst_base_src_loop ():
/GstPipeline:pipeline0/GstAudioTestSrc:audiotestsrc0:
streaming task paused, reason not-negotiated (-4)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...
C:\gstreamer\bin>

Since I couldn't make it work with non-existing types i tried several
different existing types, but the only types that work are ANY and
audio/x-raw-int:

C:\gstreamer\bin>gst-launch-0.10.exe audiotestsrc ! gtestenc ! gtestdec !
audioresample ! autoaudiosink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstAudioSinkClock
^C
C:\gstreamer\bin>

To isolate the problem with the caps, the code just passes on the incomming
buffer (just as the gst-template, which I used as base), and the
interresting parts of the encoder looks like this (I have omited
gst_gtestenc_class_init and parts of gst_gtestenc_base_init bellow):

static GstStaticPadTemplate gtest_enc_sink_factory = GST_STATIC_PAD_TEMPLATE
("sink",
   GST_PAD_SINK,
   GST_PAD_ALWAYS,
   GST_STATIC_CAPS ("audio/x-raw-int, "
       "rate = (int) { 48000 }, "
       "channels = (int) { 1 }, "
       "endianness = (int) BYTE_ORDER, "
       "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) True")
   );

static GstStaticPadTemplate gtest_enc_src_factory = GST_STATIC_PAD_TEMPLATE
("src",
   GST_PAD_SRC,
   GST_PAD_ALWAYS,
   GST_STATIC_CAPS ("audio/x-test")
   );

GST_BOILERPLATE (Gstgtestenc, gst_gtestenc, GstElement, GST_TYPE_ELEMENT);

static void gst_gtestenc_base_init (gpointer gclass)
{
 GstElementClass *element_class = GST_ELEMENT_CLASS (gclass);

// ...

 gst_element_class_add_pad_template (element_class,
     gst_static_pad_template_get (&amp;gtest_enc_src_factory));
 gst_element_class_add_pad_template (element_class,
     gst_static_pad_template_get (&amp;gtest_enc_sink_factory));
}

static void gst_gtestenc_init (Gstgtestenc * filter,
   GstgtestencClass * gclass)
{
 filter->sinkpad = gst_pad_new_from_static_template
(&amp;gtest_enc_sink_factory, "sink");
 gst_pad_set_chain_function (filter->sinkpad,
                             GST_DEBUG_FUNCPTR(gst_gtestenc_chain));

 filter->srcpad = gst_pad_new_from_static_template
(&amp;gtest_enc_src_factory, "src");
 gst_element_add_pad (GST_ELEMENT (filter), filter->sinkpad);
 gst_element_add_pad (GST_ELEMENT (filter), filter->srcpad);
 gst_pad_use_fixed_caps (filter->sinkpad);
 gst_pad_use_fixed_caps (filter->srcpad);
}

static GstFlowReturn gst_gtestenc_chain (GstPad * pad, GstBuffer * buf)
{
 Gstgtestenc *filter;

 filter = GST_GtestENC (GST_OBJECT_PARENT (pad));

 /* just push out the incoming buffer without touching it */
 return gst_pad_push (filter->srcpad, buf);
}


The code in the decoder is basicly the same - pass on the incomming data.
The main difference at the moment is the caps definitions:


static GstStaticPadTemplate gtest_dec_sink_factory = GST_STATIC_PAD_TEMPLATE
("sink",
   GST_PAD_SINK,
   GST_PAD_ALWAYS,
   GST_STATIC_CAPS ("audio/x-test")
   );

static GstStaticPadTemplate gtest_dec_src_factory = GST_STATIC_PAD_TEMPLATE
("src",
   GST_PAD_SRC,
   GST_PAD_ALWAYS,
   GST_STATIC_CAPS ("audio/x-raw-int, "
       "rate = (int) { 48000 }, "
               "channels = (int) { 1 }, "
       "endianness = (int) BYTE_ORDER, "
       "width = (int) 16, " "depth = (int) 16, " "signed = (boolean) True")
   );



What am I doing wrong?
Why is it working with audio/x-raw-int, but not with audio/x-test?

Regards,
 Markus
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Caps-problem-when-writing-encoder-decoder-tp2219436p2221067.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.

------------------------------------------------------------------------------

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



--
Regards,

Sudarshan Bisht

------------------------------------------------------------------------------


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Caps problem when writing encoder/decoder

Hunterwood
Hi Sudarshan,

Thank you for your quick reply.

I have read through the pwg and also had a look at the list in the link you passed.

But I can't see why it is not working. I <u>have</u> tried with defined types aswell; audio/x-alaw and audio/x-ac3, but using theese gives the same error as using an undefined type.

The goal of my project to get an encoder and a decoder for audio/G719, which also is a real MIME-type, although not in the list of defined types.

Why doesn't it work to use the types alaw and ac3? Does GStreamer validate the data against the specified type?
How can I add a new type to GStreamer?

Regards,
Markus
Reply | Threaded
Open this post in threaded view
|

Re: Caps problem when writing encoder/decoder

Sudarshan Bisht
HI ,
 
 Yes Gstreamer do validate the data against the specified mimetype .

 
  I don't know how we can add the new mimetype , but you can refer  gstomx_g729enc.c file from gst-openmax package.
 
 
 
On Tue, May 18, 2010 at 4:23 PM, Hunterwood <[hidden email]> wrote:

Hi Sudarshan,

Thank you for your quick reply.

I have read through the pwg and also had a look at the list in the link you
passed.

But I can't see why it is not working. I <u>have</u> tried with defined
types aswell; audio/x-alaw and audio/x-ac3, but using theese gives the same
error as using an undefined type.

The goal of my project to get an encoder and a decoder for audio/G719, which
also is a real MIME-type, although not in the list of defined types.

Why doesn't it work to use the types alaw and ac3? Does GStreamer validate
the data against the specified type?
How can I add a new type to GStreamer?

Regards,
Markus
--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/Caps-problem-when-writing-encoder-decoder-tp2219436p2221094.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.

------------------------------------------------------------------------------

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



--
Regards,

Sudarshan Bisht

------------------------------------------------------------------------------


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Caps problem when writing encoder/decoder

Marco Ballesio
In reply to this post by Hunterwood


On Tue, May 18, 2010 at 1:31 PM, Hunterwood <[hidden email]> wrote:


To isolate the problem with the caps, the code just passes on the incomming
buffer (just as the gst-template, which I used as base), and the
interresting parts of the encoder looks like this (I have omited
gst_gtestenc_class_init and parts of gst_gtestenc_base_init bellow):


 


static GstFlowReturn gst_gtestenc_chain (GstPad * pad, GstBuffer * buf)
{
 Gstgtestenc *filter;

 filter = GST_GtestENC (GST_OBJECT_PARENT (pad));

 /* just push out the incoming buffer without touching it */
 return gst_pad_push (filter->srcpad, buf);
}

Are you setting the proper caps/type on the buffer itself?

http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstBuffer.html#gst-buffer-set-caps

Imho you're passing a buffer incompatible with the pad caps.

Regards

------------------------------------------------------------------------------


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

SV: Caps problem when writing encoder/decoder

Hunterwood

Hi again,

 

I think you are right, Marco, about the caps of the buffer. I didn’t think about that!

I haven’t been able to get it to work, though.

At first I tried:

  base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (filter->srcpad));

  gst_buffer_set_caps(outbuf, base_caps);

 

But I got the error:

** (gst-launch-0.10:6344): CRITICAL **: file ..\Source\gstreamer\gst\gstpad.c: line 2508: assertion `caps == NULL || gst_caps_is_fixed (caps)' failed

 

So I tried to remove the fixed caps and use _set_caps-functions for the pads.

But what do I need to do in the _set_caps-functions? The input to the encoder has a fixed format and the output from the decoder has the same fixed format.

The compressed audio could have different rates, that could be represented in the caps. Do the _set_caps for the sink-pad need to set the caps of the source?

I tried:

  ...

  filter = GST_GtestENC (gst_pad_get_parent (pad));

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

  base_caps = gst_caps_copy (GST_PAD_CAPS(otherpad));

  return gst_pad_set_caps (otherpad, base_caps);

 

But I get an empty caps from GST_PAD_CAPS(filter->sinkpad) and gst_caps_copy gives this error:

** (gst-launch-0.10:6724): CRITICAL **: file ..\Source\gstreamer\gst\gstcaps.c: line 280: assertion `GST_IS_CAPS (caps)' failed

 

However. In my “real” encoder/decoder I do set the caps in my _chain-function:

  ret =

    gst_pad_alloc_buffer_and_set_caps (filter->srcpad, GST_BUFFER_OFFSET_NONE,

               FRAME_LENGTH, GST_PAD_CAPS (filter->srcpad), &outbuf);

 

But I get an error in the _set_caps-function for the sink in the decoder:

static gboolean

gst_mydec_sink_set_caps (GstPad * pad, GstCaps * caps)

{

  mydec *filter;

  GstPad *otherpad;

  GstCaps *base_caps;

  GstFlowReturn ret;

 

  filter = GST_MYDEC (gst_pad_get_parent (pad));

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

  base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (otherpad));

 

  ret = gst_pad_set_caps (otherpad, base_caps); // error

 

  return ret;

}

 

The error I get is:

** (gst-launch-0.10:2964): CRITICAL **: file ..\Source\gstreamer\gst\gstpad.c: line 2508: assertion `caps == NULL || gst_caps_is_fixed (caps)' failed

 

But I checked with GST_IS_CAPS (base_caps) and gst_caps_is_fixed(base_caps) and base_caps IS a caps and it is not fixed, so why do I get an error?

 

Clearly there is something I have done wrong or misunderstood, but I can’t figure it out…

 

Regards

Markus

Reply | Threaded
Open this post in threaded view
|

Re: Caps problem when writing encoder/decoder

Marco Ballesio
Hi,

looks like the mailing list is getting your emails twice.. can you
please check your mail client settings?

On Thu, May 20, 2010 at 1:54 PM, Hunterwood
<[hidden email]> wrote:

> Hi again,
>
>
>
> I think you are right, Marco, about the caps of the buffer. I didn’t think
> about that!
>
> I haven’t been able to get it to work, though.
>
> At first I tried:
>
>   base_caps = gst_caps_copy (gst_pad_get_pad_template_caps
> (filter->srcpad));
>
>   gst_buffer_set_caps(outbuf, base_caps);
>
>
>
> But I got the error:
>
> ** (gst-launch-0.10:6344): CRITICAL **: file
> ..\Source\gstreamer\gst\gstpad.c: line 2508: assertion `caps == NULL ||
> gst_caps_is_fixed (caps)' failed
>
>

it's because template caps are not fixed. Try the following:

gst_buffer_set_caps(buf, GST_PAD_CAPS (filter->srcpad));

>
> So I tried to remove the fixed caps and use _set_caps-functions for the
> pads.
>
> But what do I need to do in the _set_caps-functions? The input to the
> encoder has a fixed format and the output from the decoder has the same
> fixed format.
>
> The compressed audio could have different rates, that could be represented
> in the caps. Do the _set_caps for the sink-pad need to set the caps of the
> source?
>
> I tried:
>
>   ...
>
>   filter = GST_GtestENC (gst_pad_get_parent (pad));
>
>   otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
>
>   base_caps = gst_caps_copy (GST_PAD_CAPS(otherpad));
>
>   return gst_pad_set_caps (otherpad, base_caps);

here you're setting the caps of one pad of your filter into another..
what's the purpose of this?

>
> But I get an empty caps from GST_PAD_CAPS(filter->sinkpad) and gst_caps_copy
> gives this error:
>
> ** (gst-launch-0.10:6724): CRITICAL **: file
> ..\Source\gstreamer\gst\gstcaps.c: line 280: assertion `GST_IS_CAPS (caps)'
> failed
>
>
>
> However. In my “real” encoder/decoder I do set the caps in my
> _chain-function:
>
>   ret =
>
>     gst_pad_alloc_buffer_and_set_caps (filter->srcpad,
> GST_BUFFER_OFFSET_NONE,
>
>                FRAME_LENGTH, GST_PAD_CAPS (filter->srcpad), &outbuf);
>
>
>
> But I get an error in the _set_caps-function for the sink in the decoder:
>
> static gboolean
>
> gst_mydec_sink_set_caps (GstPad * pad, GstCaps * caps)
>
> {
>
>   mydec *filter;
>
>   GstPad *otherpad;
>
>   GstCaps *base_caps;
>
>   GstFlowReturn ret;
>
>
>
>   filter = GST_MYDEC (gst_pad_get_parent (pad));
>
>   otherpad = (pad == filter->srcpad) ? filter->sinkpad : filter->srcpad;
>
>   base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (otherpad));
>
>
>
>   ret = gst_pad_set_caps (otherpad, base_caps); // error
>
>
>
>   return ret;
>
> }
>
>
>
> The error I get is:
>
> ** (gst-launch-0.10:2964): CRITICAL **: file
> ..\Source\gstreamer\gst\gstpad.c: line 2508: assertion `caps == NULL ||
> gst_caps_is_fixed (caps)' failed
>
>
>
> But I checked with GST_IS_CAPS (base_caps) and gst_caps_is_fixed(base_caps)
> and base_caps IS a caps and it is not fixed, so why do I get an error?
>

it looks pretty strange that gst_pad_get_pad_template_caps () can
return fixed caps, but maybe you encoder is defining exactly one value
for each field in the structure so it may make sense. Please check
again with the correct GST_DEBUG messages.

For a good caps negotation example, please check e.g.
ext/speex/gstspeexenc.c in gst-plugins-good.

Regards

>
>
> Clearly there is something I have done wrong or misunderstood, but I can’t
> figure it out…
>
>
>
> Regards
>
> Markus
>
> ________________________________
> View this message in context: SV: Caps problem when writing encoder/decoder
> Sent from the GStreamer-devel mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
>
>
> _______________________________________________
> gstreamer-devel mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
>
>

------------------------------------------------------------------------------

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Caps problem when writing encoder/decoder

Martin Bisson
In reply to this post by Marco Ballesio
Hi,

I don't know if you're still having problem, but I just went to the exact same thing of adding new caps type, I managed to make it work, but doing so I got some errors that you might still be having.

As Marco said, it's true that the caps of the buffers have to be set.

But the main error I got might be the same problem you're having.  Basically, I also had NULL caps so the caps negociation was failing.  This was caused by the use of gst_caps_proxy_getcaps as the function passed to gst_cap_set_getcaps_function.  I was using it because it was used in the gst-template example, but I didn't really understand what it did.  Since it basically computes the intersection of the caps of all pads, it can only works for plugin with pads that have pretty much the same caps.  So in a plugin with different caps for different pads, the intersection is empty...  If that is your problem, you just have to write your own get_caps function.

Hope this helps,

Martin



On Thu, May 20, 2010 at 10:52 AM, Hunterwood <[hidden email]> wrote:

Hi again,

 

I think you are right, Marco, about the caps of the buffer. I didn’t think about that!

I haven’t been able to get it to work, though.

At first I tried:

  base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (filter->srcpad));

  gst_buffer_set_caps(outbuf, base_caps);

 

But I got the error:

** (gst-launch-0.10:6344): CRITICAL **: file ..\Source\gstreamer\gst\gstpad.c: line 2508: assertion `caps == NULL || gst_caps_is_fixed (caps)' failed

 

So I tried to remove the fixed caps and use _set_caps-functions for the pads.

But what do I need to do in the _set_caps-functions? The input to the encoder has a fixed format and the output from the decoder has the same fixed format.

The compressed audio could have different rates, that could be represented in the caps. Do the _set_caps for the sink-pad need to set the caps of the source?

I tried:

  ...

  filter = GST_GtestENC (gst_pad_get_parent (pad));

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

  base_caps = gst_caps_copy (GST_PAD_CAPS(otherpad));

  return gst_pad_set_caps (otherpad, base_caps);

 

But I get an empty caps from GST_PAD_CAPS(filter->sinkpad) and gst_caps_copy gives this error:

** (gst-launch-0.10:6724): CRITICAL **: file ..\Source\gstreamer\gst\gstcaps.c: line 280: assertion `GST_IS_CAPS (caps)' failed

 

However. In my “real” encoder/decoder I do set the caps in my _chain-function:

  ret =

    gst_pad_alloc_buffer_and_set_caps (filter->srcpad, GST_BUFFER_OFFSET_NONE,

               FRAME_LENGTH, GST_PAD_CAPS (filter->srcpad), &outbuf);

 

But I get an error in the _set_caps-function for the sink in the decoder:

static gboolean

gst_mydec_sink_set_caps (GstPad * pad, GstCaps * caps)

{

  mydec *filter;

  GstPad *otherpad;

  GstCaps *base_caps;

  GstFlowReturn ret;

 

  filter = GST_MYDEC (gst_pad_get_parent (pad));

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

  base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (otherpad));

 

  ret = gst_pad_set_caps (otherpad, base_caps); // error

 

  return ret;

}

 

The error I get is:

** (gst-launch-0.10:2964): CRITICAL **: file ..\Source\gstreamer\gst\gstpad.c: line 2508: assertion `caps == NULL || gst_caps_is_fixed (caps)' failed

 

But I checked with GST_IS_CAPS (base_caps) and gst_caps_is_fixed(base_caps) and base_caps IS a caps and it is not fixed, so why do I get an error?

 

Clearly there is something I have done wrong or misunderstood, but I can’t figure it out…

 

Regards

Markus

 

 

Från: Marco Ballesio [via GStreamer-devel] [mailto:[hidden email]]
Skickat: den 18 maj 2010 14:54
Till: Markus Jagerskogh
Ämne: Re: Caps problem when writing encoder/decoder

 


Are you setting the proper caps/type on the buffer itself?

http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gstreamer/html/gstreamer-GstBuffer.html#gst-buffer-set-caps

Imho you're passing a buffer incompatible with the pad caps.

Regards

 

 



View this message in context: SV: Caps problem when writing encoder/decoder

Sent from the GStreamer-devel mailing list archive at Nabble.com.

------------------------------------------------------------------------------


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel



------------------------------------------------------------------------------


_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel
Reply | Threaded
Open this post in threaded view
|

Re: Caps problem when writing encoder/decoder

Hunterwood
Hi Martin,

thanks for your reply, it solved the problem!

The "caps=NULL"-error in the setcaps-function was actually due to the use of:
  base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (otherpad));

It seems as if the the caps returned by gst_pad_get_pad_template_caps changed after a call to gst_pad_set_caps:

The  first time I recieved:
  caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)1
The second time it was:
  caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=, channels= (where "rate" and "channels" had no type nor value).

So I created the caps by gst_caps_new_simple instead.

I still had some problems after that, but the getcaps-function solved it!

At the moment the getcaps-function returns the caps created by gst_caps_new_simple. Is this a good way to solve it, or what do you suggest?

/Markus
Reply | Threaded
Open this post in threaded view
|

Re: Caps problem when writing encoder/decoder

Martin Bisson
Hunterwood wrote:
> Hi Martin,
>
> thanks for your reply, it solved the problem!
>  
Very glad, I was following your thread closely because I know I was
going to face pretty much the same obstacles ;)

> The "caps=NULL"-error in the setcaps-function was actually due to the use
> of:
>   base_caps = gst_caps_copy (gst_pad_get_pad_template_caps (otherpad));
>
> It seems as if the the caps returned by gst_pad_get_pad_template_caps
> changed after a call to gst_pad_set_caps:
>
> The  first time I recieved:
>   caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true,
> width=(int)16, depth=(int)16, rate=(int)48000, channels=(int)1
> The second time it was:
>   caps = audio/x-raw-int, endianness=(int)1234, signed=(boolean)true,
> width=(int)16, depth=(int)16, rate=, channels= (where "rate" and "channels"
> had no type nor value).
>  
Mmm I'm surprised, I didn't think that pad template caps were likely to
change between calls...  Are you sure the otherpad is the same between
the 2 calls?
> So I created the caps by gst_caps_new_simple instead.
>
> I still had some problems after that, but the getcaps-function solved it!
>
> At the moment the getcaps-function returns the caps created by
> gst_caps_new_simple. Is this a good way to solve it, or what do you suggest?
>  
You can take a look at the documentation for
gst_pad_set_getcaps_function
(http://www.gstreamer.net/data/doc/gstreamer/head/gstreamer/html/GstPad.html#gst-pad-set-getcaps-function).

Basically, from what I understand from your situation, let's say you
have an audio/x-raw-int sink pad in your encoder outputing through a
audio/your-xyz-caps source pad.

The get_caps function for your source pad should :
1) get the caps from the sink pad (I use gst_pad_peer_get_caps)
2) convert these (actually, a copy) to equivalent caps for your source
pad.  In your case, it might just involve changing the name (from
audio/x-raw-int to audio/your-xyz-caps) using gst_structure_set_name,
but you might have other changes to make
3) intersect (gst_caps_intersect) these converted caps with the template
caps from your output pad
4) return this intersection

The get_caps function for your input pad would follow the same
principles, but reversed.

This is what I did in my case, and from what I understand, it's the
proper thing to do.

Anyone please feel free to correct me,

Martin

------------------------------------------------------------------------------

_______________________________________________
gstreamer-devel mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/gstreamer-devel