[gst-devel] caps understanding problem

Stefan Kost kost at imn.htwk-leipzig.de
Thu Jan 20 06:22:17 CET 2005


I have a understanding problem with caps

I've got a level element and would like to connect vu-meters to it.
Therefore I need to find out how many channels of audio are going through it.
When is it negotiated? AFter everything is connected or only when going to
playing state?
When I query it after connecting everything by doing:

static gint gst_caps_get_channels(GstCaps *caps) {
   GstStructure *structure;
   gint channels=0,size,i;

   g_assert(caps);
     if(GST_CAPS_IS_SIMPLE(caps)) {
       if((structure=gst_caps_get_structure(caps,0))) {
           gst_structure_get_int(structure,"channels",&channels);
           channels++;
           GST_DEBUG("---    simple caps with channels=%d",channels);
       }
   }
   else {
       size=gst_caps_get_size(caps);
       for(i=0;i<size;i++) {
           if((structure=gst_caps_get_structure(caps,i))) {
               gst_structure_get_int(structure,"channels",&channels);
               channels++;
               GST_DEBUG("---    caps %d with channels=%d",i,channels);
           }
       }
   }
   return(channels);
}

....

   if((pad=gst_element_get_pad(level,"sink")) && (caps=gst_pad_get_caps(pad))) {
       channels_i=gst_caps_get_channels(caps);
       GST_INFO("!!!  input level sink has %d inputs channels",channels_i);
       gst_caps_free(caps);
   }
   if((pad=gst_element_get_pad(level,"src")) && (caps=gst_pad_get_caps(pad))) {
       channels_o=gst_caps_get_channels(caps);
       GST_INFO("!!!  input level sink has %d output channels",channels_o);
       gst_caps_free(caps);
   }
   channels=(channels_i<channels_o)?channels_o:channels_i;
   if(channels>MAX_VUMETER) channels=MAX_VUMETER;


I'll get:
---    caps 0 with channels=1
---    caps 1 with channels=2
!!!  input level sink has 2 inputs channels
---    simple caps with channels=1
!!!  input level sink has 1 output channels
!!!  input level analyser will process 2 channels

or for other networks:
---    caps 0 with channels=1
---    caps 1 with channels=2
!!!  input level sink has 2 inputs channels
---    caps 0 with channels=1
---    caps 1 with channels=2
!!!  input level sink has 2 output channels
!!!  input level analyser will process 2 channels

to me this sounds like it is not yet negotoated. Any suggestions.

Stefan

-- 
      \|/            Stefan Kost
     <@ @>           private            business
+-oOO-(_)-OOo------------------------------------------------------ - - -  -   -
|       __  Address  Simildenstr. 5     HTWK Leipzig, Fb IMN, Postfach 301166
|      ///           04277 Leipzig      04251 Leipzig
| __  ///            Germany            Germany
| \\\///    Phone    +49341 2253538     +49341 30766101
|  \__/     EMail    st_kost_at_gmx.net kost_at_imn.htwk-leipzig.de
|           WWW      www.sonicpulse.de  www.imn.htwk-leipzig.de/~kost/about.html
===-=-=--=---=---------------------------------- - - -  -    -




More information about the gstreamer-devel mailing list