[longomatch] Add new test for the capturer



commit a583520392e9d70c283b62bba7ca92ece59dca8b
Author: Andoni Morales Alastruey <ylatuya gmail com>
Date:   Sun Apr 7 15:35:34 2013 +0200

    Add new test for the capturer

 libcesarplayer/Makefile.am     |   13 ++++--
 libcesarplayer/test-capturer.c |   96 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 105 insertions(+), 4 deletions(-)
---
diff --git a/libcesarplayer/Makefile.am b/libcesarplayer/Makefile.am
index 236c6de..1a4851d 100644
--- a/libcesarplayer/Makefile.am
+++ b/libcesarplayer/Makefile.am
@@ -60,8 +60,13 @@ EXTRA_DIST = \
        baconvideowidget-marshal.list
 
 
-test-encoder: test-encoder.c gst-video-encoder.c
-       ${CC} -o test-encoder test-encoder.c gst-video-encoder.c video-utils.c $(CESARPLAYER_CFLAGS) 
$(CESARPLAYER_LIBS) -O0 -g
+noinst_PROGRAMS = test-capturer test-encoder test-discoverer
 
-test-discoverer: test-discoverer.c video-utils.c
-       ${CC} -o test-discoverer test-discoverer.c video-utils.c $(CESARPLAYER_CFLAGS) $(CESARPLAYER_LIBS) 
-O0 -g
+test_capturer_SOURCES = test-capturer.c
+test_capturer_LDADD =  libcesarplayer.la
+
+test_encoder_SOURCES = test-encoder.c
+test_encoder_LDADD =  libcesarplayer.la
+
+test_discoverer_SOURCES = test-discoverer.c
+test_discoverer_LDADD =  libcesarplayer.la
diff --git a/libcesarplayer/test-capturer.c b/libcesarplayer/test-capturer.c
new file mode 100644
index 0000000..c4d5b70
--- /dev/null
+++ b/libcesarplayer/test-capturer.c
@@ -0,0 +1,96 @@
+/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 4; tab-width: 4 -*- */
+/*
+ * main.c
+ * Copyright (C) Andoni Morales Alastruey 2008 <ylatuya gmail com>
+ * 
+ * main.c is free software: you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License as published by the
+ * Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * 
+ * main.c is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ * See the GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License along
+ * with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include <gtk/gtk.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "gst-camera-capturer.h"
+
+
+static void
+rec_clicked_cb (GtkButton *b, GstCameraCapturer *gcc)
+{
+  gst_camera_capturer_start (gcc);
+}
+
+static void
+stop_clicked (GtkButton *b, GstCameraCapturer *gcc)
+{
+  gst_camera_capturer_stop (gcc);
+}
+
+void
+create_window (GstCameraCapturer * gvc)
+{
+  GtkWidget *window, *recbutton, *stopbutton, *vbox, *hbox;
+
+  /* Create a new window */
+  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
+  gtk_window_set_title (GTK_WINDOW (window), "Capturer");
+  vbox = gtk_vbox_new (TRUE, 0);
+  hbox = gtk_hbox_new (TRUE, 0);
+  recbutton = gtk_button_new_from_stock ("gtk-rec");
+  stopbutton = gtk_button_new_from_stock ("gtk-stop");
+
+  gtk_container_add (GTK_CONTAINER (window), GTK_WIDGET (vbox));
+  gtk_box_pack_start (GTK_BOX(vbox), GTK_WIDGET (gvc), TRUE, TRUE, 0);
+  gtk_box_pack_start (GTK_BOX(vbox), GTK_WIDGET (hbox), FALSE, FALSE, 0);
+  gtk_box_pack_start(GTK_BOX(hbox), recbutton, TRUE, TRUE, 0);
+  gtk_box_pack_start(GTK_BOX(hbox), stopbutton, TRUE, TRUE, 0);
+  gtk_widget_show_all (window);
+
+  g_signal_connect (G_OBJECT (recbutton), "clicked",
+      G_CALLBACK (rec_clicked_cb), gvc);
+  g_signal_connect (G_OBJECT (stopbutton), "clicked",
+      G_CALLBACK (stop_clicked), gvc);
+}
+
+
+int
+main (int argc, char *argv[])
+{
+  GstCameraCapturer *gvc;
+  GError *error = NULL;
+
+  if (argc != 4) {
+    g_print("Usage: test-encoder output_file device_type device-id\n");
+    return 1;
+  }
+  gtk_init (&argc, &argv);
+
+  /*Create GstVideoCapturer */
+  gst_camera_capturer_init_backend (&argc, &argv);
+  gvc = gst_camera_capturer_new ("test", &error);
+
+  g_print("JANDER             %d\n", atoi(argv[2]));
+  g_print("JANDER             %d\n", atoi(argv[3]));
+  g_print("JANDER             %d\n", atoi(argv[1]));
+  gst_camera_capturer_set_source (gvc, atoi(argv[2]));
+  gst_camera_capturer_set_video_encoder (gvc, VIDEO_ENCODER_H264);
+  gst_camera_capturer_set_audio_encoder (gvc, AUDIO_ENCODER_AAC);
+  gst_camera_capturer_set_video_muxer (gvc, VIDEO_MUXER_MP4);
+  g_object_set (gvc, "device-id", argv[3], NULL);
+  g_object_set (gvc, "output_file", argv[1], NULL);
+
+  create_window (gvc);
+  gst_camera_capturer_run(gvc);
+  gtk_main ();
+
+  return 0;
+}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]