diff --git a/tests/examples/camerabin2/Makefile.am b/tests/examples/camerabin2/Makefile.am index 6b38bd2786..4431e94447 100644 --- a/tests/examples/camerabin2/Makefile.am +++ b/tests/examples/camerabin2/Makefile.am @@ -15,6 +15,7 @@ gst_camera2_LDADD = \ $(top_builddir)/gst-libs/gst/interfaces/libgstphotography-@GST_MAJORMINOR@.la \ $(GST_PLUGINS_BASE_LIBS) \ -lgstinterfaces-@GST_MAJORMINOR@ \ + -lgstpbutils-@GST_MAJORMINOR@ \ $(GST_LIBS) \ $(GTK_LIBS) \ $(GMODULE_EXPORT_LIBS) diff --git a/tests/examples/camerabin2/gst-camera2.c b/tests/examples/camerabin2/gst-camera2.c index bd612e7014..e57709487b 100644 --- a/tests/examples/camerabin2/gst-camera2.c +++ b/tests/examples/camerabin2/gst-camera2.c @@ -31,6 +31,9 @@ #include "gst-camera2.h" +#include + +#include #include #include #include @@ -42,6 +45,77 @@ static GstElement *camera; static GtkBuilder *builder; +typedef struct +{ + const gchar *name; + GstEncodingProfile *(*create_profile) (); +} GstCameraVideoFormat; + +static GstEncodingProfile * +create_ogg_profile (void) +{ + GstEncodingContainerProfile *container; + + container = gst_encoding_container_profile_new ("ogg", NULL, + gst_caps_new_simple ("application/ogg", NULL), NULL); + + gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *) + gst_encoding_video_profile_new (gst_caps_new_simple ("video/theora", + NULL), NULL, NULL, 1)); + gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *) + gst_encoding_audio_profile_new (gst_caps_new_simple ("audio/vorbis", + NULL), NULL, NULL, 1)); + + return (GstEncodingProfile *) container; +} + +static GstEncodingProfile * +create_webm_profile (void) +{ + GstEncodingContainerProfile *container; + + container = gst_encoding_container_profile_new ("webm", NULL, + gst_caps_new_simple ("video/webm", NULL), NULL); + + gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *) + gst_encoding_video_profile_new (gst_caps_new_simple ("video/x-vp8", NULL), + NULL, NULL, 1)); + gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *) + gst_encoding_audio_profile_new (gst_caps_new_simple ("audio/vorbis", + NULL), NULL, NULL, 1)); + + return (GstEncodingProfile *) container; +} + +static GstEncodingProfile * +create_mp4_profile (void) +{ + GstEncodingContainerProfile *container; + + container = gst_encoding_container_profile_new ("mp4", NULL, + gst_caps_new_simple ("video/quicktime", "variant", G_TYPE_STRING, "iso", + NULL), NULL); + + gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *) + gst_encoding_video_profile_new (gst_caps_new_simple ("video/x-h264", + NULL), NULL, NULL, 1)); + gst_encoding_container_profile_add_profile (container, (GstEncodingProfile *) + gst_encoding_audio_profile_new (gst_caps_new_simple ("audio/mpeg", + "version", G_TYPE_INT, 4, NULL), NULL, NULL, 1)); + + return (GstEncodingProfile *) container; +} + +GstCameraVideoFormat formats[] = { + {"ogg (theora/vorbis)", create_ogg_profile} + , + {"webm (vp8/vorbis)", create_webm_profile} + , + {"mp4 (h264+aac)", create_mp4_profile} + , + {NULL, NULL} +}; + void on_mainWindow_delete_event (GtkWidget * widget, GdkEvent * event, gpointer data) { @@ -84,6 +158,23 @@ on_viewfinderArea_realize (GtkWidget * widget, gpointer data) #endif } +void +on_formatComboBox_changed (GtkWidget * widget, gpointer data) +{ + GstEncodingProfile *profile = NULL; + gint index = gtk_combo_box_get_active (GTK_COMBO_BOX (widget)); + + if (formats[index].create_profile) { + profile = formats[index].create_profile (); + } + + g_return_if_fail (profile != NULL); + gst_element_set_state (camera, GST_STATE_NULL); + g_object_set (camera, "video-profile", profile, NULL); + gst_element_set_state (camera, GST_STATE_PLAYING); + gst_encoding_profile_unref (profile); +} + static GstBusSyncReply bus_sync_callback (GstBus * bus, GstMessage * message, gpointer data) { @@ -152,6 +243,24 @@ bus_callback (GstBus * bus, GstMessage * message, gpointer data) return TRUE; } +static void +init_gtkwidgets_data (void) +{ + gint i; + GtkComboBoxText *combobox = + GTK_COMBO_BOX_TEXT (gtk_builder_get_object (builder, "formatComboBox")); + + /* init formats combobox */ + i = 0; + while (formats[i].name) { + gtk_combo_box_text_append_text (combobox, formats[i].name); + i++; + } + + /* default to the first one -> ogg */ + gtk_combo_box_set_active (GTK_COMBO_BOX (combobox), 0); +} + int main (int argc, char *argv[]) { @@ -176,6 +285,8 @@ main (int argc, char *argv[]) gst_bus_set_sync_handler (bus, bus_sync_callback, NULL); gst_object_unref (bus); + init_gtkwidgets_data (); + ui_main_window = GTK_WIDGET (gtk_builder_get_object (builder, "mainWindow")); gtk_builder_connect_signals (builder, NULL); gtk_widget_show_all (ui_main_window); diff --git a/tests/examples/camerabin2/gst-camera2.h b/tests/examples/camerabin2/gst-camera2.h index d96e2de63a..10bea027aa 100644 --- a/tests/examples/camerabin2/gst-camera2.h +++ b/tests/examples/camerabin2/gst-camera2.h @@ -45,4 +45,7 @@ on_videoRButton_toggled (GtkToggleButton * button, gpointer user_data); void on_viewfinderArea_realize (GtkWidget * widget, gpointer data); +void +on_formatComboBox_changed (GtkWidget * widget, gpointer data); + #endif /* __GST_CAMERA_BIN_H__ */ diff --git a/tests/examples/camerabin2/gst-camera2.ui b/tests/examples/camerabin2/gst-camera2.ui index 48fe1410ab..9dc1fee3d5 100644 --- a/tests/examples/camerabin2/gst-camera2.ui +++ b/tests/examples/camerabin2/gst-camera2.ui @@ -1,43 +1,53 @@ - + False 800 600 - + True + False True + False Image + False True True False + False True True - + + True + True 0 Video + False True True False + False True True imageRButton - + + True + True 1 @@ -51,39 +61,44 @@ True + False True - + False + + True + True 0 True + False - - Capture + True - True - True - + False + Actions False - False + True 0 - - Stop Capture + + Capture + False True True True - + False + False @@ -91,6 +106,47 @@ 1 + + + Stop Capture + False + True + True + True + False + + + + False + False + 2 + + + + + True + False + Video format + + + False + True + 5 + 3 + + + + + True + False + + + + False + True + 4 + + False @@ -100,6 +156,8 @@ + True + True 1