]> git.0d.be Git - empathy.git/blob - libempathy-gtk/empathy-audio-src.c
Add audio/video sink and source abstractions
[empathy.git] / libempathy-gtk / empathy-audio-src.c
1 /*
2  * empathy-gst-audio-src.c - Source for EmpathyGstAudioSrc
3  * Copyright (C) 2008 Collabora Ltd.
4  * @author Sjoerd Simons <sjoerd.simons@collabora.co.uk>
5  *
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.
10  *
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.
15  *
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
19  */
20
21
22 #include <stdio.h>
23 #include <stdlib.h>
24
25 #include "empathy-audio-src.h"
26
27 G_DEFINE_TYPE(EmpathyGstAudioSrc, empathy_audio_src, GST_TYPE_BIN)
28
29 /* signal enum */
30 #if 0
31 enum
32 {
33     LAST_SIGNAL
34 };
35
36 static guint signals[LAST_SIGNAL] = {0};
37 #endif
38
39 /* private structure */
40 typedef struct _EmpathyGstAudioSrcPrivate EmpathyGstAudioSrcPrivate;
41
42 struct _EmpathyGstAudioSrcPrivate
43 {
44   gboolean dispose_has_run;
45   GstElement *src;
46 };
47
48 #define EMPATHY_GST_AUDIO_SRC_GET_PRIVATE(o) \
49   (G_TYPE_INSTANCE_GET_PRIVATE ((o), EMPATHY_TYPE_GST_AUDIO_SRC, \
50   EmpathyGstAudioSrcPrivate))
51
52 static void
53 empathy_audio_src_init (EmpathyGstAudioSrc *obj)
54 {
55   EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (obj);
56   //GstElement *resample;
57   GstPad *ghost, *src;
58
59   /* allocate any data required by the object here */
60   //resample = gst_element_factory_make ("audioresample", NULL);
61
62   priv->src = gst_element_factory_make ("gconfaudiosrc", NULL);
63
64   //gst_bin_add_many (GST_BIN (obj), priv->src, resample, NULL);
65   gst_bin_add_many (GST_BIN (obj), priv->src, NULL);
66   //gst_element_link_many (priv->src, resample, NULL);
67
68   //src = gst_element_get_static_pad (resample, "src");
69   src = gst_element_get_static_pad (priv->src, "src");
70
71   ghost = gst_ghost_pad_new ("src", src);
72   gst_element_add_pad (GST_ELEMENT (obj), ghost);
73
74   gst_object_unref (G_OBJECT (src));
75 }
76
77 static void empathy_audio_src_dispose (GObject *object);
78 static void empathy_audio_src_finalize (GObject *object);
79
80 static void
81 empathy_audio_src_class_init (EmpathyGstAudioSrcClass
82   *empathy_audio_src_class)
83 {
84   GObjectClass *object_class = G_OBJECT_CLASS (empathy_audio_src_class);
85
86   g_type_class_add_private (empathy_audio_src_class,
87     sizeof (EmpathyGstAudioSrcPrivate));
88
89   object_class->dispose = empathy_audio_src_dispose;
90   object_class->finalize = empathy_audio_src_finalize;
91 }
92
93 void
94 empathy_audio_src_dispose (GObject *object)
95 {
96   EmpathyGstAudioSrc *self = EMPATHY_GST_AUDIO_SRC (object);
97   EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (self);
98
99   if (priv->dispose_has_run)
100     return;
101
102   priv->dispose_has_run = TRUE;
103
104   /* release any references held by the object here */
105
106   if (G_OBJECT_CLASS (empathy_audio_src_parent_class)->dispose)
107     G_OBJECT_CLASS (empathy_audio_src_parent_class)->dispose (object);
108 }
109
110 void
111 empathy_audio_src_finalize (GObject *object)
112 {
113   //EmpathyGstAudioSrc *self = EMPATHY_GST_AUDIO_SRC (object);
114   //EmpathyGstAudioSrcPrivate *priv = EMPATHY_GST_AUDIO_SRC_GET_PRIVATE (self);
115
116   /* free any data held directly by the object here */
117
118   G_OBJECT_CLASS (empathy_audio_src_parent_class)->finalize (object);
119 }
120
121 GstElement *
122 empathy_audio_src_new (void)
123 {
124   return GST_ELEMENT (g_object_new (EMPATHY_TYPE_GST_AUDIO_SRC, NULL));
125 }