From: unknown Date: Tue, 17 Apr 2012 11:50:28 +0000 (+0200) Subject: Add more projects. gitignore. Whitespace. Fix warning in tut5. X-Git-Tag: 1.19.3~489^2~562^2~236 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=86f2c5c9a34d408729e70fe78b969287fcfe2c4e;p=platform%2Fupstream%2Fgstreamer.git Add more projects. gitignore. Whitespace. Fix warning in tut5. --- diff --git a/.gitignore b/.gitignore index 0c7f502..09dc148 100644 --- a/.gitignore +++ b/.gitignore @@ -3,5 +3,6 @@ Debug ipch *.user *.sdf +*.suo *.opensdf vs/2010/libs \ No newline at end of file diff --git a/gst-sdk/tutorials/basic-tutorial-5.c b/gst-sdk/tutorials/basic-tutorial-5.c index b777c6f..a50ecd0 100644 --- a/gst-sdk/tutorials/basic-tutorial-5.c +++ b/gst-sdk/tutorials/basic-tutorial-5.c @@ -1,4 +1,4 @@ -#include +#include #include #include @@ -9,27 +9,27 @@ #elif defined (GDK_WINDOWING_QUARTZ) #include #endif - -#include -#include - -/* Structure to contain all our information, so we can pass it around */ -typedef struct _CustomData { - GstElement *playbin2; /* Our one and only pipeline */ - GtkWidget *main_window; + +#include +#include + +/* Structure to contain all our information, so we can pass it around */ +typedef struct _CustomData { + GstElement *playbin2; /* Our one and only pipeline */ + GtkWidget *main_window; GtkWidget *video_window; GtkWidget *slider; GstState state; gint64 duration; - guintptr embed_xid; -} CustomData; - -/* Forward definition of the message processing function */ -static gboolean handle_message (GstBus *bus, GstMessage *msg, CustomData *data); -static GstBusSyncReply bus_sync_handler (GstBus *bus, GstMessage *msg, CustomData *data); - + guintptr embed_xid; +} CustomData; + +/* Forward definition of the message processing function */ +static gboolean handle_message (GstBus *bus, GstMessage *msg, CustomData *data); +static GstBusSyncReply bus_sync_handler (GstBus *bus, GstMessage *msg, CustomData *data); + static void realize_cb (GtkWidget *widget, CustomData *data) { GdkWindow *window = gtk_widget_get_window (widget); @@ -44,26 +44,26 @@ static void realize_cb (GtkWidget *widget, CustomData *data) { data->embed_xid = gdk_quartz_window_get_nsview (window); #elif defined (GDK_WINDOWING_X11) data->embed_xid = GDK_WINDOW_XID (window); -#endif -} - -static void play_cb (GtkButton *button, CustomData *data) { - gst_element_set_state (data->playbin2, GST_STATE_PLAYING); -} - -static void pause_cb (GtkButton *button, CustomData *data) { - gst_element_set_state (data->playbin2, GST_STATE_PAUSED); -} - -static void stop_cb (GtkButton *button, CustomData *data) { - gst_element_set_state (data->playbin2, GST_STATE_READY); -} - +#endif +} + +static void play_cb (GtkButton *button, CustomData *data) { + gst_element_set_state (data->playbin2, GST_STATE_PLAYING); +} + +static void pause_cb (GtkButton *button, CustomData *data) { + gst_element_set_state (data->playbin2, GST_STATE_PAUSED); +} + +static void stop_cb (GtkButton *button, CustomData *data) { + gst_element_set_state (data->playbin2, GST_STATE_READY); +} + static void delete_event_cb (GtkWidget *widget, GdkEvent *event, CustomData *data) { stop_cb (NULL, data); gtk_main_quit (); -} - +} + static gboolean draw_cb (GtkWidget *widget, GdkEventExpose *event, CustomData *data) { if (data->state < GST_STATE_PAUSED) { GtkAllocation allocation; @@ -83,7 +83,7 @@ static gboolean draw_cb (GtkWidget *widget, GdkEventExpose *event, CustomData *d */ return FALSE; } - + static void create_ui (CustomData *data) { GtkWidget *controls, *main_box; GtkWidget *play_button, *pause_button, *stop_button; @@ -94,7 +94,7 @@ static void create_ui (CustomData *data) { data->video_window = gtk_drawing_area_new (); gtk_widget_set_double_buffered (data->video_window, FALSE); g_signal_connect (data->video_window, "realize", G_CALLBACK (realize_cb), data); - g_signal_connect (data->video_window, "expose_event", G_CALLBACK (draw_cb), data); + g_signal_connect (data->video_window, "expose_event", G_CALLBACK (draw_cb), data); play_button = gtk_button_new_from_stock (GTK_STOCK_MEDIA_PLAY); g_signal_connect (G_OBJECT (play_button), "clicked", G_CALLBACK (play_cb), data); @@ -122,127 +122,126 @@ static void create_ui (CustomData *data) { gtk_widget_show_all (data->main_window); - gtk_widget_realize (data->main_window); -} - -static gboolean refresh_ui (CustomData *data) { - GstFormat fmt = GST_FORMAT_TIME; - gint64 current = -1; - - /* We do not want to update anything unless we are in the PLAYING state */ - if (data->state != GST_STATE_PLAYING) return TRUE; - - /* If we didn't know it yet, query the stream duration */ - if (!GST_CLOCK_TIME_IS_VALID (data->duration)) { - if (!gst_element_query_duration (data->playbin2, &fmt, &data->duration)) { - g_printerr ("Could not query current duration.\n"); - } else { - gtk_range_set_range (GTK_RANGE (data->slider), 0, data->duration / GST_SECOND); - } - } - - if (gst_element_query_position (data->playbin2, &fmt, ¤t)) { - gtk_range_set_value (GTK_RANGE (data->slider), current / GST_SECOND); - } - return TRUE; -} - -int main(int argc, char *argv[]) { - CustomData data; - GstStateChangeReturn ret; - GstBus *bus; - - /* Initialize GTK */ - gtk_init (&argc, &argv); - - /* Initialize GStreamer */ - gst_init (&argc, &argv); - - /* Initialize our data structure */ - memset (&data, 0, sizeof (data)); - data.duration = GST_CLOCK_TIME_NONE; - - /* Create the elements */ - data.playbin2 = gst_element_factory_make ("playbin2", "playbin2"); - - if (!data.playbin2) { - g_printerr ("Not all elements could be created.\n"); - return -1; - } - - /* Set the URI to play */ -// g_object_set (data.playbin2, "uri", "http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL); - g_object_set (data.playbin2, "uri", "file:///f:/media/big_buck_bunny_480p.H264.mov", NULL); - - create_ui (&data); - - bus = gst_element_get_bus (data.playbin2); - gst_bus_set_sync_handler (bus, (GstBusSyncHandler)bus_sync_handler, &data); - gst_bus_add_watch (bus, (GstBusFunc)handle_message, &data); - gst_object_unref (bus); - - /* Start playing */ - ret = gst_element_set_state (data.playbin2, GST_STATE_PLAYING); - if (ret == GST_STATE_CHANGE_FAILURE) { - g_printerr ("Unable to set the pipeline to the playing state.\n"); - gst_object_unref (data.playbin2); - return -1; - } - - g_timeout_add (500, (GSourceFunc)refresh_ui, &data); - // add timeout to refresh UI: query position and duration (if unknown), gtk_range_set_value() on the slider - gtk_main (); - - /* Free resources */ - gst_element_set_state (data.playbin2, GST_STATE_NULL); - gst_object_unref (data.playbin2); - return 0; -} - -static gboolean handle_message (GstBus *bus, GstMessage *msg, CustomData *data) { - GError *err; - gchar *debug_info; - - switch (GST_MESSAGE_TYPE (msg)) { - case GST_MESSAGE_ERROR: - gst_message_parse_error (msg, &err, &debug_info); - g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message); - g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none"); - g_clear_error (&err); - g_free (debug_info); - gtk_main_quit (); - break; - case GST_MESSAGE_EOS: - g_print ("End-Of-Stream reached.\n"); - gst_element_set_state (data->playbin2, GST_STATE_READY); - break; - case GST_MESSAGE_STATE_CHANGED: { - GstState old_state, new_state, pending_state; - gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state); - if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data->playbin2)) { - data->state = new_state; - g_print ("State set to %s\n", gst_element_state_get_name (new_state)); - } - } break; - } - - return TRUE; -} -static GstBusSyncReply bus_sync_handler (GstBus *bus, GstMessage *msg, CustomData *data) { - /*ignore anything but 'prepare-xwindow-id' element messages */ - if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ELEMENT) - return GST_BUS_PASS; - if (!gst_structure_has_name (msg->structure, "prepare-xwindow-id")) - return GST_BUS_PASS; - - if (data->embed_xid != 0) { - /* GST_MESSAGE_SRC (message) will be the video sink element */ - GstXOverlay *xoverlay = GST_X_OVERLAY (GST_MESSAGE_SRC (msg)); - gst_x_overlay_set_window_handle (xoverlay, data->embed_xid); - } else { - g_warning ("Should have obtained an xid by now!"); - } - - gst_message_unref (msg); - return GST_BUS_DROP; -} + gtk_widget_realize (data->main_window); +} + +static gboolean refresh_ui (CustomData *data) { + GstFormat fmt = GST_FORMAT_TIME; + gint64 current = -1; + + /* We do not want to update anything unless we are in the PLAYING state */ + if (data->state != GST_STATE_PLAYING) return TRUE; + + /* If we didn't know it yet, query the stream duration */ + if (!GST_CLOCK_TIME_IS_VALID (data->duration)) { + if (!gst_element_query_duration (data->playbin2, &fmt, &data->duration)) { + g_printerr ("Could not query current duration.\n"); + } else { + gtk_range_set_range (GTK_RANGE (data->slider), 0, (gdouble)data->duration / GST_SECOND); + } + } + + if (gst_element_query_position (data->playbin2, &fmt, ¤t)) { + gtk_range_set_value (GTK_RANGE (data->slider), (gdouble)current / GST_SECOND); + } + return TRUE; +} + +int main(int argc, char *argv[]) { + CustomData data; + GstStateChangeReturn ret; + GstBus *bus; + + /* Initialize GTK */ + gtk_init (&argc, &argv); + + /* Initialize GStreamer */ + gst_init (&argc, &argv); + + /* Initialize our data structure */ + memset (&data, 0, sizeof (data)); + data.duration = GST_CLOCK_TIME_NONE; + + /* Create the elements */ + data.playbin2 = gst_element_factory_make ("playbin2", "playbin2"); + + if (!data.playbin2) { + g_printerr ("Not all elements could be created.\n"); + return -1; + } + + /* Set the URI to play */ + g_object_set (data.playbin2, "uri", "http://docs.gstreamer.com/media/sintel_trailer-480p.webm", NULL); + + create_ui (&data); + + bus = gst_element_get_bus (data.playbin2); + gst_bus_set_sync_handler (bus, (GstBusSyncHandler)bus_sync_handler, &data); + gst_bus_add_watch (bus, (GstBusFunc)handle_message, &data); + gst_object_unref (bus); + + /* Start playing */ + ret = gst_element_set_state (data.playbin2, GST_STATE_PLAYING); + if (ret == GST_STATE_CHANGE_FAILURE) { + g_printerr ("Unable to set the pipeline to the playing state.\n"); + gst_object_unref (data.playbin2); + return -1; + } + + g_timeout_add (500, (GSourceFunc)refresh_ui, &data); + // add timeout to refresh UI: query position and duration (if unknown), gtk_range_set_value() on the slider + gtk_main (); + + /* Free resources */ + gst_element_set_state (data.playbin2, GST_STATE_NULL); + gst_object_unref (data.playbin2); + return 0; +} + +static gboolean handle_message (GstBus *bus, GstMessage *msg, CustomData *data) { + GError *err; + gchar *debug_info; + + switch (GST_MESSAGE_TYPE (msg)) { + case GST_MESSAGE_ERROR: + gst_message_parse_error (msg, &err, &debug_info); + g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message); + g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none"); + g_clear_error (&err); + g_free (debug_info); + gtk_main_quit (); + break; + case GST_MESSAGE_EOS: + g_print ("End-Of-Stream reached.\n"); + gst_element_set_state (data->playbin2, GST_STATE_READY); + break; + case GST_MESSAGE_STATE_CHANGED: { + GstState old_state, new_state, pending_state; + gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state); + if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data->playbin2)) { + data->state = new_state; + g_print ("State set to %s\n", gst_element_state_get_name (new_state)); + } + } break; + } + + return TRUE; +} +static GstBusSyncReply bus_sync_handler (GstBus *bus, GstMessage *msg, CustomData *data) { + /*ignore anything but 'prepare-xwindow-id' element messages */ + if (GST_MESSAGE_TYPE (msg) != GST_MESSAGE_ELEMENT) + return GST_BUS_PASS; + if (!gst_structure_has_name (msg->structure, "prepare-xwindow-id")) + return GST_BUS_PASS; + + if (data->embed_xid != 0) { + /* GST_MESSAGE_SRC (message) will be the video sink element */ + GstXOverlay *xoverlay = GST_X_OVERLAY (GST_MESSAGE_SRC (msg)); + gst_x_overlay_set_window_handle (xoverlay, data->embed_xid); + } else { + g_warning ("Should have obtained an xid by now!"); + } + + gst_message_unref (msg); + return GST_BUS_DROP; +} diff --git a/vs/2010/tutorials/tutorials.sln b/vs/2010/tutorials/tutorials.sln index a79fc42..d772502 100644 --- a/vs/2010/tutorials/tutorials.sln +++ b/vs/2010/tutorials/tutorials.sln @@ -3,6 +3,16 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual C++ Express 2010 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic-tutorial-1", "basic-tutorial-1\basic-tutorial-1.vcxproj", "{9DEC64B5-E1FA-4A55-9174-58FF94BDF432}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic-tutorial-2", "basic-tutorial-2\basic-tutorial-2.vcxproj", "{F9127BA2-C3CB-4123-8967-32D5BABB3C34}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic-tutorial-3", "basic-tutorial-3\basic-tutorial-3.vcxproj", "{D8595056-4F87-4767-A84C-07B7F67A6560}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic-tutorial-4", "basic-tutorial-4\basic-tutorial-4.vcxproj", "{1F5D411C-72FE-43BA-85BB-96DA7AC9C8D3}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "basic-tutorial-5", "basic-tutorial-5\basic-tutorial-5.vcxproj", "{BB88B26A-DD54-42BF-9893-26E0FDF28050}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "playback-tutorial-1", "playback-tutorial-1\playback-tutorial-1.vcxproj", "{474353B0-D353-4DB7-A9EE-E210D1ED954B}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Win32 = Debug|Win32 @@ -13,6 +23,26 @@ Global {9DEC64B5-E1FA-4A55-9174-58FF94BDF432}.Debug|Win32.Build.0 = Debug|Win32 {9DEC64B5-E1FA-4A55-9174-58FF94BDF432}.Release|Win32.ActiveCfg = Release|Win32 {9DEC64B5-E1FA-4A55-9174-58FF94BDF432}.Release|Win32.Build.0 = Release|Win32 + {F9127BA2-C3CB-4123-8967-32D5BABB3C34}.Debug|Win32.ActiveCfg = Debug|Win32 + {F9127BA2-C3CB-4123-8967-32D5BABB3C34}.Debug|Win32.Build.0 = Debug|Win32 + {F9127BA2-C3CB-4123-8967-32D5BABB3C34}.Release|Win32.ActiveCfg = Release|Win32 + {F9127BA2-C3CB-4123-8967-32D5BABB3C34}.Release|Win32.Build.0 = Release|Win32 + {D8595056-4F87-4767-A84C-07B7F67A6560}.Debug|Win32.ActiveCfg = Debug|Win32 + {D8595056-4F87-4767-A84C-07B7F67A6560}.Debug|Win32.Build.0 = Debug|Win32 + {D8595056-4F87-4767-A84C-07B7F67A6560}.Release|Win32.ActiveCfg = Release|Win32 + {D8595056-4F87-4767-A84C-07B7F67A6560}.Release|Win32.Build.0 = Release|Win32 + {1F5D411C-72FE-43BA-85BB-96DA7AC9C8D3}.Debug|Win32.ActiveCfg = Debug|Win32 + {1F5D411C-72FE-43BA-85BB-96DA7AC9C8D3}.Debug|Win32.Build.0 = Debug|Win32 + {1F5D411C-72FE-43BA-85BB-96DA7AC9C8D3}.Release|Win32.ActiveCfg = Release|Win32 + {1F5D411C-72FE-43BA-85BB-96DA7AC9C8D3}.Release|Win32.Build.0 = Release|Win32 + {BB88B26A-DD54-42BF-9893-26E0FDF28050}.Debug|Win32.ActiveCfg = Debug|Win32 + {BB88B26A-DD54-42BF-9893-26E0FDF28050}.Debug|Win32.Build.0 = Debug|Win32 + {BB88B26A-DD54-42BF-9893-26E0FDF28050}.Release|Win32.ActiveCfg = Release|Win32 + {BB88B26A-DD54-42BF-9893-26E0FDF28050}.Release|Win32.Build.0 = Release|Win32 + {474353B0-D353-4DB7-A9EE-E210D1ED954B}.Debug|Win32.ActiveCfg = Debug|Win32 + {474353B0-D353-4DB7-A9EE-E210D1ED954B}.Debug|Win32.Build.0 = Debug|Win32 + {474353B0-D353-4DB7-A9EE-E210D1ED954B}.Release|Win32.ActiveCfg = Release|Win32 + {474353B0-D353-4DB7-A9EE-E210D1ED954B}.Release|Win32.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE