1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
/*
* empathy-gst-video-src.c - Source for EmpathyGstVideoSrc
* Copyright (C) 2008 Collabora Ltd.
* @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 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
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <stdio.h>
#include <stdlib.h>
#include "empathy-video-src.h"
G_DEFINE_TYPE(EmpathyGstVideoSrc, empathy_video_src, GST_TYPE_BIN)
/* signal enum */
#if 0
enum
{
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = {0};
#endif
/* private structure */
typedef struct _EmpathyGstVideoSrcPrivate EmpathyGstVideoSrcPrivate;
struct _EmpathyGstVideoSrcPrivate
{
gboolean dispose_has_run;
GstElement *src;
};
#define EMPATHY_GST_VIDEO_SRC_GET_PRIVATE(o) \
(G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_GST_VIDEO_SRC, \
EmpathyGstVideoSrcPrivate))
static void
empathy_video_src_init (EmpathyGstVideoSrc *obj)
{
EmpathyGstVideoSrcPrivate *priv = EMPATHY_GST_VIDEO_SRC_GET_PRIVATE (obj);
GstElement *scale, *rate, *colorspace, *capsfilter;
GstPad *ghost, *src;
GstCaps *caps;
/* allocate any data required by the object here */
scale = gst_element_factory_make ("videoscale", NULL);
rate = gst_element_factory_make ("videorate", NULL);
colorspace = gst_element_factory_make ("ffmpegcolorspace", NULL);
capsfilter = gst_element_factory_make ("capsfilter", NULL);
caps = gst_caps_new_simple ("video/x-raw-yuv",
"width", G_TYPE_INT, 320,
"height", G_TYPE_INT, 240,
NULL);
g_object_set (G_OBJECT (capsfilter), "caps", caps, NULL);
priv->src = gst_element_factory_make ("gconfvideosrc", NULL);
gst_bin_add_many (GST_BIN (obj), priv->src, scale, rate,
colorspace, capsfilter, NULL);
gst_element_link_many (priv->src, scale, rate, colorspace, capsfilter, NULL);
src = gst_element_get_static_pad (capsfilter, "src");
ghost = gst_ghost_pad_new ("src", src);
gst_element_add_pad (GST_ELEMENT (obj), ghost);
gst_object_unref (G_OBJECT (src));
}
static void empathy_video_src_dispose (GObject *object);
static void empathy_video_src_finalize (GObject *object);
static void
empathy_video_src_class_init (EmpathyGstVideoSrcClass *empathy_video_src_class)
{
GObjectClass *object_class = G_OBJECT_CLASS (empathy_video_src_class);
g_type_class_add_private (empathy_video_src_class,
sizeof (EmpathyGstVideoSrcPrivate));
object_class->dispose = empathy_video_src_dispose;
object_class->finalize = empathy_video_src_finalize;
}
void
empathy_video_src_dispose (GObject *object)
{
EmpathyGstVideoSrc *self = EMPATHY_GST_VIDEO_SRC (object);
EmpathyGstVideoSrcPrivate *priv = EMPATHY_GST_VIDEO_SRC_GET_PRIVATE (self);
if (priv->dispose_has_run)
return;
priv->dispose_has_run = TRUE;
/* release any references held by the object here */
if (G_OBJECT_CLASS (empathy_video_src_parent_class)->dispose)
G_OBJECT_CLASS (empathy_video_src_parent_class)->dispose (object);
}
void
empathy_video_src_finalize (GObject *object)
{
//EmpathyGstVideoSrc *self = EMPATHY_GST_VIDEO_SRC (object);
//EmpathyGstVideoSrcPrivate *priv = EMPATHY_GST_VIDEO_SRC_GET_PRIVATE (self);
/* free any data held directly by the object here */
G_OBJECT_CLASS (empathy_video_src_parent_class)->finalize (object);
}
GstElement *
empathy_video_src_new (void)
{
return GST_ELEMENT (g_object_new (EMPATHY_TYPE_GST_VIDEO_SRC, NULL));
}
|