camerabin2: Removing videorecordingbin

Removing videorecordingbin as we now use encodebin for it
This commit is contained in:
Thiago Santos 2011-01-11 08:44:41 -03:00
parent f1d02cf0c0
commit e5f267f682
6 changed files with 0 additions and 648 deletions

View file

@ -2,7 +2,6 @@ plugin_LTLIBRARIES = libgstcamerabin2.la
libgstcamerabin2_la_SOURCES = gstviewfinderbin.c \
gstimagecapturebin.c \
gstvideorecordingbin.c \
camerabingeneral.c \
gstwrappercamerabinsrc.c \
gstcamerabin2.c \
@ -25,7 +24,6 @@ libgstcamerabin2_la_LIBTOOLFLAGS = --tag=disable-static
noinst_HEADERS = gstviewfinderbin.h \
gstimagecapturebin.h \
gstvideorecordingbin.h \
camerabingeneral.h \
gstwrappercamerabinsrc.h \
gstcamerabin2.h

View file

@ -25,7 +25,6 @@
#include "gstviewfinderbin.h"
#include "gstimagecapturebin.h"
#include "gstvideorecordingbin.h"
#include "gstwrappercamerabinsrc.h"
#include "gstcamerabin2.h"
@ -36,8 +35,6 @@ plugin_init (GstPlugin * plugin)
return FALSE;
if (!gst_image_capture_bin_plugin_init (plugin))
return FALSE;
if (!gst_video_recording_bin_plugin_init (plugin))
return FALSE;
if (!gst_wrapper_camera_bin_src_plugin_init (plugin))
return FALSE;
if (!gst_camera_bin_plugin_init (plugin))

View file

@ -1,360 +0,0 @@
/* GStreamer
* Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:element-gstvideorecordingbin
*
* The gstvideorecordingbin element does FIXME stuff.
*
* <refsect2>
* <title>Example launch line</title>
* |[
* gst-launch -v videotestsrc num-buffers=3 ! videorecordingbin
* ]|
* FIXME Describe what the pipeline does.
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstvideorecordingbin.h"
#include "camerabingeneral.h"
/* prototypes */
enum
{
PROP_0,
PROP_LOCATION,
PROP_VIDEO_ENCODER,
PROP_MUXER
};
#define DEFAULT_LOCATION "vidcap"
#define DEFAULT_COLORSPACE "ffmpegcolorspace"
#define DEFAULT_VIDEO_ENCODER "theoraenc"
#define DEFAULT_MUXER "oggmux"
#define DEFAULT_SINK "filesink"
/* pad templates */
static GstStaticPadTemplate sink_template = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS ("video/x-raw-yuv; video/x-raw-rgb")
);
/* class initialization */
GST_BOILERPLATE (GstVideoRecordingBin, gst_video_recording_bin, GstBin,
GST_TYPE_BIN);
/* GObject callbacks */
static void gst_video_recording_bin_dispose (GObject * object);
static void gst_video_recording_bin_finalize (GObject * object);
/* Element class functions */
static GstStateChangeReturn
gst_video_recording_bin_change_state (GstElement * element,
GstStateChange trans);
static void
gst_video_recording_bin_set_video_encoder (GstVideoRecordingBin * videobin,
GstElement * encoder)
{
GST_DEBUG_OBJECT (GST_OBJECT (videobin),
"Setting video encoder %" GST_PTR_FORMAT, encoder);
if (videobin->user_video_encoder)
g_object_unref (videobin->user_video_encoder);
if (encoder)
g_object_ref (encoder);
videobin->user_video_encoder = encoder;
}
static void
gst_video_recording_bin_set_muxer (GstVideoRecordingBin * videobin,
GstElement * muxer)
{
GST_DEBUG_OBJECT (GST_OBJECT (videobin),
"Setting video muxer %" GST_PTR_FORMAT, muxer);
if (videobin->user_muxer)
g_object_unref (videobin->user_muxer);
if (muxer)
g_object_ref (muxer);
videobin->user_muxer = muxer;
}
static void
gst_video_recording_bin_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstVideoRecordingBin *videobin = GST_VIDEO_RECORDING_BIN_CAST (object);
switch (prop_id) {
case PROP_LOCATION:
if (videobin->location)
g_free (videobin->location);
videobin->location = g_value_dup_string (value);
if (videobin->sink) {
g_object_set (videobin->sink, "location", videobin->location, NULL);
}
break;
case PROP_VIDEO_ENCODER:
gst_video_recording_bin_set_video_encoder (videobin,
g_value_get_object (value));
break;
case PROP_MUXER:
gst_video_recording_bin_set_muxer (videobin, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_video_recording_bin_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstVideoRecordingBin *videobin = GST_VIDEO_RECORDING_BIN_CAST (object);
switch (prop_id) {
case PROP_LOCATION:
g_value_set_string (value, videobin->location);
break;
case PROP_VIDEO_ENCODER:
g_value_set_object (value, videobin->video_encoder);
break;
case PROP_MUXER:
g_value_set_object (value, videobin->muxer);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_video_recording_bin_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sink_template));
gst_element_class_set_details_simple (element_class, "Video Recording Bin",
"Sink/Video", "Video Recording Bin used in camerabin2",
"Thiago Santos <thiago.sousa.santos@collabora.co.uk>");
}
static void
gst_video_recording_bin_class_init (GstVideoRecordingBinClass * klass)
{
GObjectClass *gobject_class;
GstElementClass *element_class;
gobject_class = G_OBJECT_CLASS (klass);
element_class = GST_ELEMENT_CLASS (klass);
gobject_class->dispose = gst_video_recording_bin_dispose;
gobject_class->finalize = gst_video_recording_bin_finalize;
gobject_class->set_property = gst_video_recording_bin_set_property;
gobject_class->get_property = gst_video_recording_bin_get_property;
element_class->change_state =
GST_DEBUG_FUNCPTR (gst_video_recording_bin_change_state);
g_object_class_install_property (gobject_class, PROP_LOCATION,
g_param_spec_string ("location", "Location",
"Location to save the captured files.",
DEFAULT_LOCATION, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_VIDEO_ENCODER,
g_param_spec_object ("video-encoder", "Video encoder",
"Video encoder GstElement (default is theoraenc).",
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (gobject_class, PROP_MUXER,
g_param_spec_object ("video-muxer", "Video muxer",
"Video muxer GstElement (default is oggmux).",
GST_TYPE_ELEMENT, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS));
}
static void
gst_video_recording_bin_init (GstVideoRecordingBin * videobin,
GstVideoRecordingBinClass * videobin_class)
{
GstPadTemplate *templ;
templ = gst_static_pad_template_get (&sink_template);
videobin->ghostpad =
gst_ghost_pad_new_no_target_from_template ("sink", templ);
gst_object_unref (templ);
gst_element_add_pad (GST_ELEMENT_CAST (videobin), videobin->ghostpad);
videobin->location = g_strdup (DEFAULT_LOCATION);
videobin->video_encoder = NULL;
videobin->user_video_encoder = NULL;
videobin->muxer = NULL;
videobin->user_muxer = NULL;
}
static void
gst_video_recording_bin_dispose (GObject * object)
{
GstVideoRecordingBin *videobin = GST_VIDEO_RECORDING_BIN_CAST (object);
if (videobin->user_video_encoder) {
gst_object_unref (videobin->user_video_encoder);
videobin->user_video_encoder = NULL;
}
if (videobin->user_muxer) {
gst_object_unref (videobin->user_muxer);
videobin->user_muxer = NULL;
}
G_OBJECT_CLASS (parent_class)->dispose ((GObject *) videobin);
}
static void
gst_video_recording_bin_finalize (GObject * object)
{
GstVideoRecordingBin *videobin = GST_VIDEO_RECORDING_BIN_CAST (object);
g_free (videobin->location);
videobin->location = NULL;
G_OBJECT_CLASS (parent_class)->finalize ((GObject *) videobin);
}
static gboolean
gst_video_recording_bin_create_elements (GstVideoRecordingBin * videobin)
{
GstElement *colorspace;
GstPad *pad = NULL;
if (videobin->elements_created)
return TRUE;
/* create elements */
colorspace =
gst_camerabin_create_and_add_element (GST_BIN (videobin),
DEFAULT_COLORSPACE);
if (!colorspace)
goto error;
if (videobin->user_video_encoder) {
videobin->video_encoder = videobin->user_video_encoder;
if (!gst_camerabin_add_element (GST_BIN (videobin),
videobin->video_encoder)) {
goto error;
}
} else {
videobin->video_encoder =
gst_camerabin_create_and_add_element (GST_BIN (videobin),
DEFAULT_VIDEO_ENCODER);
if (!videobin->video_encoder)
goto error;
}
if (videobin->user_muxer) {
videobin->muxer = videobin->user_muxer;
if (!gst_camerabin_add_element (GST_BIN (videobin), videobin->muxer)) {
goto error;
}
} else {
videobin->muxer =
gst_camerabin_create_and_add_element (GST_BIN (videobin),
DEFAULT_MUXER);
if (!videobin->muxer)
goto error;
}
videobin->sink = gst_camerabin_create_and_add_element (GST_BIN (videobin),
DEFAULT_SINK);
if (!videobin->sink)
goto error;
g_object_set (videobin->sink, "location", videobin->location, "async", FALSE,
NULL);
/* add ghostpad */
pad = gst_element_get_static_pad (colorspace, "sink");
if (!gst_ghost_pad_set_target (GST_GHOST_PAD (videobin->ghostpad), pad))
goto error;
gst_object_unref (pad);
pad = NULL;
videobin->elements_created = TRUE;
return TRUE;
error:
GST_DEBUG_OBJECT (videobin, "Create elements failed");
if (pad)
gst_object_unref (pad);
return FALSE;
}
static GstStateChangeReturn
gst_video_recording_bin_change_state (GstElement * element,
GstStateChange trans)
{
GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS;
GstVideoRecordingBin *videobin = GST_VIDEO_RECORDING_BIN_CAST (element);
switch (trans) {
case GST_STATE_CHANGE_NULL_TO_READY:
if (!gst_video_recording_bin_create_elements (videobin)) {
return GST_STATE_CHANGE_FAILURE;
}
break;
default:
break;
}
ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, trans);
switch (trans) {
case GST_STATE_CHANGE_READY_TO_NULL:
break;
default:
break;
}
return ret;
}
gboolean
gst_video_recording_bin_plugin_init (GstPlugin * plugin)
{
return gst_element_register (plugin, "videorecordingbin", GST_RANK_NONE,
gst_video_recording_bin_get_type ());
}

View file

@ -1,63 +0,0 @@
/* GStreamer
* Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef _GST_VIDEO_RECORDING_BIN_H_
#define _GST_VIDEO_RECORDING_BIN_H_
#include <gst/gst.h>
G_BEGIN_DECLS
#define GST_TYPE_VIDEO_RECORDING_BIN (gst_video_recording_bin_get_type())
#define GST_VIDEO_RECORDING_BIN(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_VIDEO_RECORDING_BIN,GstVideoRecordingBin))
#define GST_VIDEO_RECORDING_BIN_CAST(obj) ((GstVideoRecordingBin *) obj)
#define GST_VIDEO_RECORDING_BIN_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_VIDEO_RECORDING_BIN,GstVideoRecordingBinClass))
#define GST_IS_VIDEO_RECORDING_BIN(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_VIDEO_RECORDING_BIN))
#define GST_IS_VIDEO_RECORDING_BIN_CLASS(obj) (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_VIDEO_RECORDING_BIN))
typedef struct _GstVideoRecordingBin GstVideoRecordingBin;
typedef struct _GstVideoRecordingBinClass GstVideoRecordingBinClass;
struct _GstVideoRecordingBin
{
GstBin bin;
GstPad *ghostpad;
GstElement *sink;
/* props */
gchar *location;
GstElement *video_encoder;
GstElement *user_video_encoder;
GstElement *muxer;
GstElement *user_muxer;
gboolean elements_created;
};
struct _GstVideoRecordingBinClass
{
GstBinClass bin_class;
};
GType gst_video_recording_bin_get_type (void);
gboolean gst_video_recording_bin_plugin_init (GstPlugin * plugin);
G_END_DECLS
#endif

View file

@ -130,7 +130,6 @@ VALGRIND_TESTS_DISABLE = \
if BUILD_EXPERIMENTAL
EXPERIMENTAL_CHECKS=elements/camerabin2 \
elements/imagecapturebin \
elements/videorecordingbin \
elements/viewfinderbin
endif

View file

@ -1,219 +0,0 @@
/* GStreamer unit test for the videorecordingbin element
* Copyright (C) 2010 Thiago Santos <thiago.sousa.santos@collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <stdio.h>
#include <gst/check/gstcheck.h>
#define N_BUFFERS 100
typedef struct
{
GstElement *pipe;
GstElement *src;
GstElement *vrbin;
} GstVideoRecordingBinTestContext;
static void
gstvideorecordingbin_init_test_context (GstVideoRecordingBinTestContext * ctx,
gint num_buffers)
{
fail_unless (ctx != NULL);
ctx->pipe = gst_pipeline_new ("pipeline");
fail_unless (ctx->pipe != NULL);
ctx->src = gst_element_factory_make ("videotestsrc", "src");
fail_unless (ctx->src != NULL, "Failed to create videotestsrc element");
ctx->vrbin = gst_element_factory_make ("videorecordingbin", "icbin");
fail_unless (ctx->vrbin != NULL,
"Failed to create videorecordingbin element");
if (num_buffers > 0)
g_object_set (ctx->src, "num-buffers", num_buffers, NULL);
fail_unless (gst_bin_add (GST_BIN (ctx->pipe), ctx->src));
fail_unless (gst_bin_add (GST_BIN (ctx->pipe), ctx->vrbin));
fail_unless (gst_element_link (ctx->src, ctx->vrbin));
}
static void
gstvideorecordingbin_unset_test_context (GstVideoRecordingBinTestContext * ctx)
{
gst_element_set_state (ctx->pipe, GST_STATE_NULL);
gst_object_unref (ctx->pipe);
memset (ctx, 0, sizeof (GstVideoRecordingBinTestContext));
}
static gchar *
make_test_file_name (gint num)
{
return g_strdup_printf ("%s" G_DIR_SEPARATOR_S
"videorecordingbintest_%d.cap", g_get_tmp_dir (), num);
}
GST_START_TEST (test_simple_recording)
{
GstVideoRecordingBinTestContext ctx;
GstBus *bus;
GstMessage *msg;
gchar *test_file_name;
FILE *f;
gstvideorecordingbin_init_test_context (&ctx, N_BUFFERS);
bus = gst_element_get_bus (ctx.pipe);
test_file_name = make_test_file_name (0);
g_object_set (ctx.vrbin, "location", test_file_name, NULL);
fail_if (gst_element_set_state (ctx.pipe, GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE);
msg = gst_bus_timed_pop_filtered (bus, GST_SECOND * 10,
GST_MESSAGE_EOS | GST_MESSAGE_ERROR);
fail_unless (msg != NULL);
fail_unless (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS);
/* check there is a recorded file */
fail_unless (g_file_test (test_file_name, G_FILE_TEST_EXISTS));
fail_unless (g_file_test (test_file_name, G_FILE_TEST_IS_REGULAR));
fail_if (g_file_test (test_file_name, G_FILE_TEST_IS_SYMLINK));
/* check the file isn't empty */
f = fopen (test_file_name, "r");
fseek (f, 0, SEEK_END);
fail_unless (ftell (f) > 0);
fclose (f);
gstvideorecordingbin_unset_test_context (&ctx);
gst_object_unref (bus);
g_free (test_file_name);
}
GST_END_TEST;
GST_START_TEST (test_setting_video_encoder)
{
GstVideoRecordingBinTestContext ctx;
GstBus *bus;
GstMessage *msg;
GstElement *encoder;
gchar *test_file_name;
FILE *f;
gstvideorecordingbin_init_test_context (&ctx, N_BUFFERS);
bus = gst_element_get_bus (ctx.pipe);
test_file_name = make_test_file_name (0);
g_object_set (ctx.vrbin, "location", test_file_name, NULL);
encoder = gst_element_factory_make ("theoraenc", NULL);
g_object_set (ctx.vrbin, "video-encoder", encoder, NULL);
fail_if (gst_element_set_state (ctx.pipe, GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE);
msg = gst_bus_timed_pop_filtered (bus, GST_SECOND * 10,
GST_MESSAGE_EOS | GST_MESSAGE_ERROR);
fail_unless (msg != NULL);
fail_unless (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS);
/* check there is a recorded file */
fail_unless (g_file_test (test_file_name, G_FILE_TEST_EXISTS));
fail_unless (g_file_test (test_file_name, G_FILE_TEST_IS_REGULAR));
fail_if (g_file_test (test_file_name, G_FILE_TEST_IS_SYMLINK));
/* check the file isn't empty */
f = fopen (test_file_name, "r");
fseek (f, 0, SEEK_END);
fail_unless (ftell (f) > 0);
fclose (f);
gstvideorecordingbin_unset_test_context (&ctx);
gst_object_unref (bus);
g_free (test_file_name);
}
GST_END_TEST;
GST_START_TEST (test_setting_video_muxer)
{
GstVideoRecordingBinTestContext ctx;
GstBus *bus;
GstMessage *msg;
GstElement *encoder;
GstElement *muxer;
gchar *test_file_name;
FILE *f;
gstvideorecordingbin_init_test_context (&ctx, N_BUFFERS);
bus = gst_element_get_bus (ctx.pipe);
test_file_name = make_test_file_name (0);
g_object_set (ctx.vrbin, "location", test_file_name, NULL);
encoder = gst_element_factory_make ("theoraenc", NULL);
g_object_set (ctx.vrbin, "video-encoder", encoder, NULL);
muxer = gst_element_factory_make ("oggmux", NULL);
g_object_set (ctx.vrbin, "video-muxer", muxer, NULL);
fail_if (gst_element_set_state (ctx.pipe, GST_STATE_PLAYING) ==
GST_STATE_CHANGE_FAILURE);
msg = gst_bus_timed_pop_filtered (bus, GST_SECOND * 10,
GST_MESSAGE_EOS | GST_MESSAGE_ERROR);
fail_unless (msg != NULL);
fail_unless (GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS);
/* check there is a recorded file */
fail_unless (g_file_test (test_file_name, G_FILE_TEST_EXISTS));
fail_unless (g_file_test (test_file_name, G_FILE_TEST_IS_REGULAR));
fail_if (g_file_test (test_file_name, G_FILE_TEST_IS_SYMLINK));
/* check the file isn't empty */
f = fopen (test_file_name, "r");
fseek (f, 0, SEEK_END);
fail_unless (ftell (f) > 0);
fclose (f);
gstvideorecordingbin_unset_test_context (&ctx);
gst_object_unref (bus);
g_free (test_file_name);
}
GST_END_TEST;
static Suite *
videorecordingbin_suite (void)
{
Suite *s = suite_create ("videorecordingbin");
TCase *tc_chain = tcase_create ("general");
suite_add_tcase (s, tc_chain);
tcase_add_test (tc_chain, test_simple_recording);
tcase_add_test (tc_chain, test_setting_video_encoder);
tcase_add_test (tc_chain, test_setting_video_muxer);
return s;
}
GST_CHECK_MAIN (videorecordingbin);