[gst-devel] how to get the final caps of gstplaybin (or gstdecodebin)?

Stefan Kost ensonic at hora-obscura.de
Mon Nov 17 09:15:37 CET 2008


hi,
Zhao, Halley schrieb:
>
> In gstplaybin.c, after the dynamic pipeline has created, I try to get
> the final src pad (caps) of gstplaybin (gstdecodebin), but failed in
> function: gen_video_element();
>
> I recursively parse the element in gstplaybin, but
> gst_caps_get_structure() will report error that
> “gst_caps_get_structure: assertion `GST_IS_CAPS (caps)' failed”.
>
You can also connect signal handlers to "notify:caps" on the pad you get
from decodebin. In your handler you can check if the caps are fixed and
use them.

Stefan


> The error msg and my source code is as following, thanks for your help
>
>  
>
> ################error message:
>
> ====element name -2:mpeg2dec0
>
>     file: gstplaybin.c, func: gen_video_element,      line: 920
>
>     file: gstplaybin.c, func: gen_video_element,      line: 926
>
> it is not a bin
>
>     file: gstplaybin.c, func: gen_video_element,      line: 935
>
>  
>
> (gst-launch-0.10:14448): GStreamer-CRITICAL **:
> gst_caps_get_structure: assertion `GST_IS_CAPS (caps)' failed
>
> ===Error, we can't find the src structure of play_bin, wuwu~~~
>
> ====element name -2:fakesink
>
> ===Error, we can't find the src pad of play_bin, wuwu~~~
>
> ====element name -2:typefind
>
>     file: gstplaybin.c, func: gen_video_element,      line: 920
>
>     file: gstplaybin.c, func: gen_video_element,      line: 926
>
> it is not a bin
>
>     file: gstplaybin.c, func: gen_video_element,      line: 935
>
>  
>
> ################my src codec
>
> iter = gst_bin_iterate_elements (GST_BIN_CAST(play_bin));
>
>    
>
>     while (!done) {
>
>         switch (gst_iterator_next (iter, &data)) {
>
>           case GST_ITERATOR_OK:
>
>           {
>
>               child = GST_ELEMENT_CAST (data);
>
>               temp_name = gst_element_get_name (child);
>
>               if(!strncmp(temp_name, "decodebin",9))
>
>               {
>
>                   GstIterator *iter_2 = NULL;
>
>                   gboolean done_2 = FALSE;
>
>                   gpointer data_2 = NULL;
>
>                   GstElement *child_2=NULL;
>
>                   gboolean res_2 = TRUE;
>
>                   gchar *temp_name_2 = NULL;
>
>  
>
>                   iter_2 = gst_bin_iterate_elements (GST_BIN_CAST(child));
>
>                  
>
>                   while (!done_2) {
>
>                       switch (gst_iterator_next (iter_2, &data_2)) {
>
>                         case GST_ITERATOR_OK:
>
>                         {
>
>                             child_2 = GST_ELEMENT_CAST (data_2);
>
>                             temp_name_2 = gst_element_get_name (child_2);
>
>                             PRINTF("====element name
> -2:%s\n",temp_name_2);
>
>                             g_free (temp_name_2);
>
>                                        
>
>                             if ((play_bin_src_pad =
> gst_element_get_pad (child_2, "src")) == NULL) {
>
>                                 PRINTF("===Error, we can't find the
> src pad of play_bin, wuwu~~~\n");
>
>                                 break;
>
>                             }
>
>                            
>
>                             PRINT_MARK;
>
>                             if (play_bin_src_caps = gst_pad_get_caps
> (play_bin_src_pad) == NULL) {
>
>                                 PRINTF("===Error, we can't find the
> src caps of play_bin, wuwu~~~\n");
>
>                                 break;
>
>                             }
>
>  
>
>                             PRINT_MARK;
>
>                             if (GST_IS_BIN(child_2)) {
>
>                                 PRINTF("it is a bin\n");
>
>                             }
>
>                             else
>
>                             {
>
>                                 PRINTF("it is not a bin\n");
>
>                             }
>
>                            
>
>                             PRINT_MARK;   
>
>                             if ((structure = gst_caps_get_structure
> (play_bin_src_caps, 0)) == NULL) {
>
>                             PRINTF("===Error, we can't find the src
> structure of play_bin, wuwu~~~\n");
>
>                             break;
>
>                             }
>
>  
>
>                             PRINT_MARK;
>
>                           structure_name =
> gst_structure_get_name(structure);
>
>                           PRINTF("==== structure_name:
> %s====\n",structure_name);
>
>            
>
>                             gst_object_unref (structure);
>
>                             gst_object_unref (structure_name);
>
>                             gst_object_unref (child_2);
>
>  
>
>                         }
>
>                        break;
>
>                         case GST_ITERATOR_RESYNC:
>
>                           gst_iterator_resync (iter_2);
>
>                           res_2 = TRUE;
>
>                           break;
>
>                         case GST_ITERATOR_DONE:
>
>                           done_2 = TRUE;
>
>                           break;
>
>                         case GST_ITERATOR_ERROR:
>
>                           g_assert_not_reached ();
>
>                           break;
>
>                       }
>
>                   }
>
>                 gst_iterator_free (iter_2);
>
>  
>
>               }
>
>  
>
>               g_free (temp_name);
>
>  
>
>                 // gst_object_unref (child);
>
>             }     
>
>            break;
>
>             case GST_ITERATOR_RESYNC:
>
>               gst_iterator_resync (iter);
>
>               res = TRUE;
>
>               break;
>
>             case GST_ITERATOR_DONE:
>
>               done = TRUE;
>
>               break;
>
>             case GST_ITERATOR_ERROR:
>
>               g_assert_not_reached ();
>
>               break;
>
>           }
>
>     }
>
>     gst_iterator_free (iter);
>
> *ZHAO, Halley (Aihua)*
>
> Email: halley.zhao at intel.com <mailto:aihua.zhao at intel.com>
>
> Tel: +86(21)61166476
>
> iNet: 8821-6476
>
> SSG/OTC/UMD 3W033
>
>  
>
> ------------------------------------------------------------------------
>
> -------------------------------------------------------------------------
> This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
> Build the coolest Linux based applications with Moblin SDK & win great prizes
> Grand prize is a trip for two to an Open Source event anywhere in the world
> http://moblin-contest.org/redirect.php?banner_id=100&url=/
> ------------------------------------------------------------------------
>
> _______________________________________________
> 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