summaryrefslogtreecommitdiff
path: root/tests/examples/camerabin2
diff options
context:
space:
mode:
authorTeemu Katajisto <teemu.katajisto@digia.com>2011-02-21 17:04:06 +0200
committerThiago Santos <thiago.sousa.santos@collabora.co.uk>2011-03-10 08:42:01 -0300
commit2b9b0854605bb69c1b6420b4d8e32cd19cfbb46e (patch)
tree65df54ffa46ec1bc9682c0811fce609cb626c48a /tests/examples/camerabin2
parent582c1506586de7249942d4d96bd94df230df6fe0 (diff)
downloadgstreamer-plugins-bad-2b9b0854605bb69c1b6420b4d8e32cd19cfbb46e.tar.gz
examples: camerabin2: add encoding profile loading
Diffstat (limited to 'tests/examples/camerabin2')
-rw-r--r--tests/examples/camerabin2/Makefile.am1
-rw-r--r--tests/examples/camerabin2/gst-camerabin2-test.c66
2 files changed, 65 insertions, 2 deletions
diff --git a/tests/examples/camerabin2/Makefile.am b/tests/examples/camerabin2/Makefile.am
index 3af2c653b..060269343 100644
--- a/tests/examples/camerabin2/Makefile.am
+++ b/tests/examples/camerabin2/Makefile.am
@@ -36,6 +36,7 @@ gst_camerabin2_test_CFLAGS = $(GST_CFLAGS) $(GST_PLUGINS_BASE_CFLAGS) $(GST_PLU
gst_camerabin2_test_LDADD = \
$(top_builddir)/gst-libs/gst/interfaces/libgstphotography-@GST_MAJORMINOR@.la \
-lgstinterfaces-@GST_MAJORMINOR@ \
+ -lgstpbutils-$(GST_MAJORMINOR) \
$(GST_LIBS) \
$(GST_PLUGINS_BASE_LIBS) \
$(X11_LIBS)
diff --git a/tests/examples/camerabin2/gst-camerabin2-test.c b/tests/examples/camerabin2/gst-camerabin2-test.c
index a51f6df76..c46d6a4ba 100644
--- a/tests/examples/camerabin2/gst-camerabin2-test.c
+++ b/tests/examples/camerabin2/gst-camerabin2-test.c
@@ -63,6 +63,9 @@
--x-width X window width (default = 320)
--x-height X window height (default = 240)
--no-xwindow Do not create XWindow
+ --encoding-target Video encoding target name
+ --encoding-profile Video encoding profile name
+ --encoding-profile-filename Video encoding profile filename
*/
@@ -85,7 +88,8 @@
#include <stdlib.h>
#include <glib.h>
#include <glib/gstdio.h>
-
+#include <gst/pbutils/encoding-profile.h>
+#include <gst/pbutils/encoding-target.h>
#include <X11/Xlib.h>
#include <X11/Xatom.h>
/*
@@ -116,6 +120,10 @@ static gint image_height = 0;
static gint view_framerate_num = 0;
static gint view_framerate_den = 0;
static gboolean no_xwindow = FALSE;
+static gchar *gep_targetname = NULL;
+static gchar *gep_profilename = NULL;
+static gchar *gep_filename = NULL;
+
#define MODE_VIDEO 2
#define MODE_IMAGE 1
@@ -370,6 +378,47 @@ create_ipp_bin (void)
return bin;
}
+static GstEncodingProfile *
+load_encoding_profile (void)
+{
+ GstEncodingProfile *prof = NULL;
+ GstEncodingTarget *target = NULL;
+ GError *error = NULL;
+
+ /* if profile file was given, try to load profile from there */
+ if (gep_filename && gep_profilename) {
+ target = gst_encoding_target_load_from_file (gep_filename, &error);
+ if (!target) {
+ GST_WARNING ("Could not load target %s from file %s", gep_targetname,
+ gep_filename);
+ if (error) {
+ GST_WARNING ("Error from file loading: %s", error->message);
+ g_error_free (error);
+ error = NULL;
+ }
+ } else {
+ prof = gst_encoding_target_get_profile (target, gep_profilename);
+ if (prof)
+ GST_DEBUG ("Loaded encoding profile %s from %s", gep_profilename,
+ gep_filename);
+ else
+ GST_WARNING
+ ("Could not load specified encoding profile %s from file %s",
+ gep_profilename, gep_filename);
+ }
+ /* if we could not load profile from file then try to find one from system */
+ } else if (gep_profilename && gep_targetname) {
+ prof = gst_encoding_profile_find (gep_targetname, gep_profilename, NULL);
+ if (prof)
+ GST_DEBUG ("Loaded encoding profile %s from target %s", gep_profilename,
+ gep_targetname);
+ } else
+ GST_DEBUG
+ ("Encoding profile not set, using camerabin2 default encoding profile");
+
+ return prof;
+}
+
static gboolean
setup_pipeline_element (GstElement * element, const gchar * property_name,
const gchar * element_name, GstElement ** res_elem)
@@ -404,7 +453,7 @@ setup_pipeline (void)
gboolean res = TRUE;
GstBus *bus;
GstElement *sink = NULL, *ipp = NULL;
-
+ GstEncodingProfile *prof = NULL;
camerabin = gst_element_factory_make ("camerabin2", NULL);
if (NULL == camerabin) {
g_warning ("can't create camerabin element\n");
@@ -445,6 +494,10 @@ setup_pipeline (void)
GST_WARNING ("Could not create ipp elements");
}
+ prof = load_encoding_profile ();
+ if (prof)
+ g_object_set (G_OBJECT (camerabin), "video-profile", prof, NULL);
+
GST_INFO_OBJECT (camerabin, "elements created");
if (sink)
@@ -693,6 +746,12 @@ main (int argc, char *argv[])
"X window height (default = 240)", NULL},
{"no-xwindow", '\0', 0, G_OPTION_ARG_NONE, &no_xwindow,
"Do not create XWindow", NULL},
+ {"encoding-target", '\0', 0, G_OPTION_ARG_STRING, &gep_targetname,
+ "Video encoding target name", NULL},
+ {"encoding-profile", '\0', 0, G_OPTION_ARG_STRING, &gep_profilename,
+ "Video encoding profile name", NULL},
+ {"encoding-profile-filename", '\0', 0, G_OPTION_ARG_STRING, &gep_filename,
+ "Video encoding profile filename", NULL},
{NULL}
};
@@ -746,6 +805,9 @@ main (int argc, char *argv[])
g_free (imagepp_name);
g_free (vfsink_name);
g_free (target_times);
+ g_free (gep_targetname);
+ g_free (gep_profilename);
+ g_free (gep_filename);
g_timer_destroy (timer);
if (window)