summaryrefslogtreecommitdiffstats
path: root/ext/metadata/test
diff options
context:
space:
mode:
authorEdgard Lima <edgard.lima@indt.org.br>2007-12-17 12:37:36 +0000
committerEdgard Lima <edgard.lima@indt.org.br>2007-12-17 12:37:36 +0000
commit0058a7b30cc203cef07e1e4dea3e4eb8fa0f1ce6 (patch)
treecc964495757de4c648dcf6cbc2cd33f71e00fc98 /ext/metadata/test
parent6adccf1c543b9507ed895120d143ae61e8045d45 (diff)
downloadgst-plugins-bad-0058a7b30cc203cef07e1e4dea3e4eb8fa0f1ce6.tar.gz
gst-plugins-bad-0058a7b30cc203cef07e1e4dea3e4eb8fa0f1ce6.tar.bz2
gst-plugins-bad-0058a7b30cc203cef07e1e4dea3e4eb8fa0f1ce6.zip
Added "parse-only" property to metadatademux.
Original commit message from CVS: Added "parse-only" property to metadatademux.
Diffstat (limited to 'ext/metadata/test')
-rw-r--r--ext/metadata/test/MetadataEditorMain.glade15
-rw-r--r--ext/metadata/test/metadata_editor.c137
2 files changed, 144 insertions, 8 deletions
diff --git a/ext/metadata/test/MetadataEditorMain.glade b/ext/metadata/test/MetadataEditorMain.glade
index ecd09be5..871d8e6b 100644
--- a/ext/metadata/test/MetadataEditorMain.glade
+++ b/ext/metadata/test/MetadataEditorMain.glade
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.2.0 on Wed Dec 12 14:07:03 2007 by edlima@feisty-laptop-->
+<!--Generated with glade3 3.2.0 on Mon Dec 17 11:42:47 2007 by edlima@feisty-laptop-->
<glade-interface>
<widget class="GtkWindow" id="windowMain">
<property name="width_request">800</property>
@@ -123,6 +123,19 @@
<property name="position">1</property>
</packing>
</child>
+ <child>
+ <widget class="GtkCheckButton" id="checkbuttonCapture">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="events">GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK</property>
+ <property name="label" translatable="yes">Capture image from camera</property>
+ <property name="draw_indicator">True</property>
+ <signal name="toggled" handler="on_checkbuttonCapture_toggled"/>
+ </widget>
+ <packing>
+ <property name="position">2</property>
+ </packing>
+ </child>
</widget>
<packing>
<property name="expand">False</property>
diff --git a/ext/metadata/test/metadata_editor.c b/ext/metadata/test/metadata_editor.c
index e3b1cee5..0479e785 100644
--- a/ext/metadata/test/metadata_editor.c
+++ b/ext/metadata/test/metadata_editor.c
@@ -77,6 +77,9 @@ static void me_gst_cleanup_elements ();
static int
me_gst_setup_view_pipeline (const gchar * filename, GdkWindow * window);
static int
+me_gst_setup_capture_pipeline (const gchar * src_file, const gchar * dest_file,
+ gint * encode_status);
+static int
me_gst_setup_encode_pipeline (const gchar * src_file, const gchar * dest_file,
gint * encode_status);
@@ -92,6 +95,7 @@ GstElement *gst_source = NULL;
GstElement *gst_metadata_demux = NULL;
GstElement *gst_metadata_mux = NULL;
GstElement *gst_image_dec = NULL;
+GstElement *gst_image_enc = NULL;
GstElement *gst_video_scale = NULL;
GstElement *gst_video_convert = NULL;
GstElement *gst_video_sink = NULL;
@@ -108,6 +112,8 @@ GtkWidget *ui_tree = NULL;
GtkEntry *ui_entry_insert_tag = NULL;
GtkEntry *ui_entry_insert_value = NULL;
+GtkToggleButton *ui_chk_bnt_capture = NULL;
+
GString *filename = NULL;
/*
@@ -278,6 +284,29 @@ on_buttonInsert_clicked (GtkButton * button, gpointer user_data)
}
+static void
+setup_new_filename (GString * str, const gchar * ext)
+{
+ int i = 0;
+
+ for (i = str->len - 1; i > 0; --i) {
+ if (str->str[i] == '/') {
+ ++i;
+ break;
+ }
+ }
+ g_string_insert (str, i, "_new_");
+ if (ext) {
+ int len = strlen (ext);
+
+ if (len > str->len)
+ g_string_append (str, ext);
+ else if (strcasecmp (ext, &str->str[str->len - len]))
+ g_string_append (str, ext);
+
+ }
+}
+
void
on_buttonSaveFile_clicked (GtkButton * button, gpointer user_data)
{
@@ -290,14 +319,22 @@ on_buttonSaveFile_clicked (GtkButton * button, gpointer user_data)
src_file = g_string_new (filename->str);
- g_string_prepend (filename, "_new_");
- remove (filename->str);
+ if (gtk_toggle_button_get_active (ui_chk_bnt_capture)) {
+ setup_new_filename (filename, ".jpg");
+ if (me_gst_setup_capture_pipeline (src_file->str, filename->str,
+ &enc_status)) {
+ goto done;
+ }
+ } else {
+ setup_new_filename (filename, NULL);
+ if (me_gst_setup_encode_pipeline (src_file->str, filename->str,
+ &enc_status)) {
+ goto done;
+ }
+ }
ui_refresh ();
-
- if (me_gst_setup_encode_pipeline (src_file->str, filename->str, &enc_status)) {
- goto done;
- }
+ remove (filename->str);
if (tag_list && gst_metadata_mux) {
GstTagSetter *setter = GST_TAG_SETTER (gst_metadata_mux);
@@ -342,6 +379,14 @@ done:
}
+void
+on_checkbuttonCapture_toggled (GtkToggleButton * togglebutton,
+ gpointer user_data)
+{
+ if (gtk_toggle_button_get_active (togglebutton)) {
+ }
+}
+
/*
* UI handling functions
*/
@@ -498,8 +543,12 @@ ui_create ()
ui_entry_insert_value =
GTK_ENTRY (glade_xml_get_widget (ui_glade_xml, "entryValue"));
+ ui_chk_bnt_capture =
+ GTK_TOGGLE_BUTTON (glade_xml_get_widget (ui_glade_xml,
+ "checkbuttonCapture"));
+
if (!(ui_main_window && ui_drawing && ui_tree && ui_entry_insert_tag
- && ui_entry_insert_value)) {
+ && ui_entry_insert_value && ui_chk_bnt_capture)) {
fprintf (stderr, "Some widgets couldn't be created\n");
ret = -105;
goto done;
@@ -648,6 +697,10 @@ me_gst_cleanup_elements ()
gst_object_unref (gst_image_dec);
gst_image_dec = NULL;
}
+ if (gst_image_enc) {
+ gst_object_unref (gst_image_enc);
+ gst_image_enc = NULL;
+ }
if (gst_video_scale) {
gst_object_unref (gst_video_scale);
gst_video_scale = NULL;
@@ -697,6 +750,76 @@ done:
}
static int
+me_gst_setup_capture_pipeline (const gchar * src_file, const gchar * dest_file,
+ gint * encode_status)
+{
+ int ret = 0;
+ GstBus *bus = NULL;
+ gboolean linked;
+
+ *encode_status = ENC_ERROR;
+
+ me_gst_cleanup_elements ();
+
+ /* create elements */
+ gst_source = gst_element_factory_make ("v4l2src", NULL);
+ gst_video_convert = gst_element_factory_make ("ffmpegcolorspace", NULL);
+ gst_image_enc = gst_element_factory_make ("jpegenc", NULL);
+ gst_metadata_mux = gst_element_factory_make ("metadatamux", NULL);
+ gst_file_sink = gst_element_factory_make ("filesink", NULL);
+
+ if (!(gst_source && gst_video_convert && gst_image_enc && gst_metadata_mux
+ && gst_file_sink)) {
+ fprintf (stderr, "An element couldn't be created for ecoding\n");
+ ret = -300;
+ goto done;
+ }
+
+ /* create gst_pipeline */
+ gst_pipeline = gst_pipeline_new (NULL);
+
+ if (NULL == gst_pipeline) {
+ fprintf (stderr, "Pipeline couldn't be created\n");
+ ret = -305;
+ goto done;
+ }
+
+ /* set elements's properties */
+ g_object_set (gst_source, "num-buffers", 1, NULL);
+ g_object_set (gst_file_sink, "location", dest_file, NULL);
+
+ /* adding and linking elements */
+ gst_bin_add_many (GST_BIN (gst_pipeline), gst_source, gst_video_convert,
+ gst_image_enc, gst_metadata_mux, gst_file_sink, NULL);
+
+ linked =
+ gst_element_link_many (gst_source, gst_video_convert, gst_image_enc,
+ gst_metadata_mux, gst_file_sink, NULL);
+
+ /* now element are owned by pipeline (for videosink we keep a extra ref) */
+ gst_source = gst_video_convert = gst_image_enc = gst_file_sink = NULL;
+ gst_object_ref (gst_metadata_mux);
+
+ if (!linked) {
+ fprintf (stderr, "Elements couldn't be linked\n");
+ ret = -310;
+ goto done;
+ }
+
+ *encode_status = ENC_UNKNOWN;
+
+ /* adding message bus */
+ bus = gst_pipeline_get_bus (GST_PIPELINE (gst_pipeline));
+ gst_bus_add_watch (bus, me_gst_bus_callback_encode, encode_status);
+ gst_object_unref (bus);
+
+done:
+
+ return ret;
+
+}
+
+static int
me_gst_setup_encode_pipeline (const gchar * src_file, const gchar * dest_file,
gint * encode_status)
{