2 * empathy-gst-video-src.c - Source for EmpathyGstVideoSrc
3 * Copyright (C) 2008 Collabora Ltd.
4 * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 #include "empathy-video-src.h"
27 G_DEFINE_TYPE(EmpathyGstVideoSrc, empathy_video_src, GST_TYPE_BIN)
36 static guint signals[LAST_SIGNAL] = {0};
39 /* private structure */
40 typedef struct _EmpathyGstVideoSrcPrivate EmpathyGstVideoSrcPrivate;
42 struct _EmpathyGstVideoSrcPrivate
44 gboolean dispose_has_run;
48 #define EMPATHY_GST_VIDEO_SRC_GET_PRIVATE(o) \
49 (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_GST_VIDEO_SRC, \
50 EmpathyGstVideoSrcPrivate))
53 empathy_video_src_init (EmpathyGstVideoSrc *obj)
55 EmpathyGstVideoSrcPrivate *priv = EMPATHY_GST_VIDEO_SRC_GET_PRIVATE (obj);
56 GstElement *scale, *rate, *colorspace, *capsfilter;
60 /* allocate any data required by the object here */
61 scale = gst_element_factory_make ("videoscale", NULL);
62 rate = gst_element_factory_make ("videorate", NULL);
63 colorspace = gst_element_factory_make ("ffmpegcolorspace", NULL);
65 capsfilter = gst_element_factory_make ("capsfilter", NULL);
66 caps = gst_caps_new_simple ("video/x-raw-yuv",
67 "width", G_TYPE_INT, 320,
68 "height", G_TYPE_INT, 240,
71 g_object_set (G_OBJECT (capsfilter), "caps", caps, NULL);
73 priv->src = gst_element_factory_make ("gconfvideosrc", NULL);
75 gst_bin_add_many (GST_BIN (obj), priv->src, scale, rate,
76 colorspace, capsfilter, NULL);
77 gst_element_link_many (priv->src, scale, rate, colorspace, capsfilter, NULL);
79 src = gst_element_get_static_pad (capsfilter, "src");
81 ghost = gst_ghost_pad_new ("src", src);
82 gst_element_add_pad (GST_ELEMENT (obj), ghost);
84 gst_object_unref (G_OBJECT (src));
87 static void empathy_video_src_dispose (GObject *object);
88 static void empathy_video_src_finalize (GObject *object);
91 empathy_video_src_class_init (EmpathyGstVideoSrcClass *empathy_video_src_class)
93 GObjectClass *object_class = G_OBJECT_CLASS (empathy_video_src_class);
95 g_type_class_add_private (empathy_video_src_class,
96 sizeof (EmpathyGstVideoSrcPrivate));
98 object_class->dispose = empathy_video_src_dispose;
99 object_class->finalize = empathy_video_src_finalize;
103 empathy_video_src_dispose (GObject *object)
105 EmpathyGstVideoSrc *self = EMPATHY_GST_VIDEO_SRC (object);
106 EmpathyGstVideoSrcPrivate *priv = EMPATHY_GST_VIDEO_SRC_GET_PRIVATE (self);
108 if (priv->dispose_has_run)
111 priv->dispose_has_run = TRUE;
113 /* release any references held by the object here */
115 if (G_OBJECT_CLASS (empathy_video_src_parent_class)->dispose)
116 G_OBJECT_CLASS (empathy_video_src_parent_class)->dispose (object);
120 empathy_video_src_finalize (GObject *object)
122 //EmpathyGstVideoSrc *self = EMPATHY_GST_VIDEO_SRC (object);
123 //EmpathyGstVideoSrcPrivate *priv = EMPATHY_GST_VIDEO_SRC_GET_PRIVATE (self);
125 /* free any data held directly by the object here */
127 G_OBJECT_CLASS (empathy_video_src_parent_class)->finalize (object);
131 empathy_video_src_new (void)
133 return GST_ELEMENT (g_object_new (EMPATHY_TYPE_GST_VIDEO_SRC, NULL));