Ejemplo n.º 1
0
int main( int argc, char *argv[] )
{
   /* GtkWidget *display_window; */
   GtkWidget *video_display;
   GtkWidget *device_selection;

   GtkWidget *widget;
   GTimer *fps_timer;

   g_thread_init(NULL);
   gdk_threads_init();
   gtk_init (&argc, &argv);

   //
   // Create the main application window
   // 
   display_window  = create_application_window( );
   

   video_display = g_object_get_data( G_OBJECT( display_window ), "ugtk_display" );
   g_assert( video_display );
   device_selection = g_object_get_data( G_OBJECT( video_display ), "device_selection" );
   g_assert( device_selection );
   fps_timer = g_timer_new();
   unicapgtk_video_display_set_new_frame_callback( UNICAPGTK_VIDEO_DISPLAY( video_display ), 
						   UNICAPGTK_CALLBACK_FLAGS_BEFORE, 
						   (unicap_new_frame_callback_t)new_frame_cb, 
						   fps_timer );

   //
   // Create a window containing the properties for the 
   // video capture device and a device selection menu
   //
   widget = unicapgtk_property_dialog_new( );
   gtk_widget_show_all( widget );
   g_object_set_data( G_OBJECT( video_display ), "property_dialog", widget );

   //
   // Rescan devices and select first device
   //
   if( unicapgtk_device_selection_rescan( UNICAPGTK_DEVICE_SELECTION( device_selection ) ) > 0 )
   {
      gtk_combo_box_set_active (GTK_COMBO_BOX( device_selection ), 0);
   }

   gdk_threads_enter();
   gtk_main ();
   gdk_threads_leave();

   return 0;
}
static void
device_combo_box_changed( GtkComboBox *combo )
{
   UnicapgtkDeviceSelection *device_combo = UNICAPGTK_DEVICE_SELECTION( combo );
   GtkTreeIter           iter;

   if( gtk_combo_box_get_active_iter (combo, &iter) )
   {
      GtkTreeModel *model  = gtk_combo_box_get_model( combo );
      gchar        *device_id;
      gint          special;

      gtk_tree_model_get( model, &iter,
                          UNICAPGTK_DEVICE_ID, &device_id,
                          SPECIAL,          &special,
                          -1 );

      if( device_id )
      {
	 device_combo_box_store_id( device_combo, device_id );
	 g_free( device_id );
	 g_signal_emit( G_OBJECT( combo ), 
			unicapgtk_device_selection_signals[UNICAPGTK_DEVICE_SELECTION_CHANGED_SIGNAL], 
			0, 
			device_combo->active_device );
	 return;
      }

      g_signal_stop_emission_by_name( combo, "changed" );

      switch( special )
      {
	 case NOT_SPECIAL:
	    break;

	 case SPECIAL_RESCAN:
	    unicapgtk_device_selection_rescan (device_combo);
	    break;

	 default:
	    device_combo_box_store_id (device_combo, NULL);
	    break;
      }
   }
}