#include #include #include #include int main( int argc, char *argv[] ) { gtk_init( NULL, NULL ); gst_init( NULL, NULL ); void infos_on_file( GtkButton *, gpointer ); GtkWidget *win = gtk_window_new( GTK_WINDOW_TOPLEVEL ); GtkWidget *entry = gtk_entry_new(); GtkWidget *hbox = gtk_box_new( GTK_ORIENTATION_HORIZONTAL, 3 ); GtkWidget *but = gtk_button_new_from_stock( GTK_STOCK_OK ); gtk_entry_set_width_chars( GTK_ENTRY( entry ), 25 ); gtk_box_pack_start( GTK_BOX( hbox ), entry, TRUE, TRUE, 2 ); gtk_box_pack_start( GTK_BOX( hbox ), but , TRUE, TRUE, 2 ); gtk_widget_set_hexpand( hbox, FALSE ); gtk_widget_set_vexpand( hbox, FALSE ); gtk_widget_set_halign( hbox, GTK_ALIGN_START ); gtk_widget_set_valign( hbox, GTK_ALIGN_START ); gtk_entry_set_placeholder_text( GTK_ENTRY( entry ), "enter a file path"); gtk_container_add( GTK_CONTAINER( win ), hbox ); g_signal_connect( G_OBJECT( but ), "clicked", G_CALLBACK( infos_on_file ), (gpointer)entry ); gtk_widget_show_all( win ); gtk_main(); printf("Hello world!\n"); return 0; } void infos_on_file( GtkButton *but, gpointer data ) { guint i = 0, j = 0, k = 0; GstStructure *stru = NULL; gchar *fieldname = NULL, *stru_name = NULL; gchar *text = ( gchar * )gtk_entry_get_text( GTK_ENTRY( data ) ); GstElementFactory *fact = gst_element_factory_find("filesrc"); if( fact == NULL )printf( "NULL\n"); GstElement *element = gst_element_factory_make( "filesrc", "insp" ); if( element == NULL ) { printf("element is null "); return ; } g_object_set_valist( G_OBJECT( element ), "location", text ); GstPad* pad = gst_element_get_static_pad( element, "src" ); GstCaps *caps = gst_pad_get_caps( pad ); guint siz = gst_caps_get_size( caps ); for( i = 0; i < siz; i++ ) { stru = gst_caps_get_structure( caps, i ); stru_name = ( gchar *)gst_structure_get_name( stru ); printf(" caps: %s\n", stru_name ); k = gst_structure_n_fields( stru ); for( j = 0; j < k; j++ ) { fieldname = ( gchar * )gst_structure_nth_field_name( stru, j ); printf( "%dièmé fieldname: %s\n", j, fieldname ); } printf("\n\n"); } }