1 /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2006 James Livingston <doclivingston@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * The Rhythmbox authors hereby grant permission for non-GPL compatible
11 * GStreamer plugins to be used and distributed together with GStreamer
12 * and Rhythmbox. This permission is above and beyond the permissions granted
13 * by the GPL license by which Rhythmbox is covered. If you modify this code
14 * you may extend this exception to your version of the code, but you are not
15 * obligated to do so. If you do not wish to do so, delete this exception
16 * statement from your version.
17 *
18 * This program is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program; if not, see <http://www.gnu.org/licenses/>.
25 *
26 */
27
28 #include <config.h>
29
30 #include "rb-player-gst-filter.h"
31
32 /**
33 * SECTION:rb-player-gst-filter
34 * @short_description: player interface for inserting filter elements
35 * @include: rb-player-gst-filter.h
36 *
37 * This interface allows a caller to add filter elements to the GStreamer playback
38 * pipeline.
39 */
40
41 enum {
42 FILTER_INSERTED,
43 FILTER_PRE_REMOVE,
44 LAST_SIGNAL
45 };
46
47 static guint signals[LAST_SIGNAL] = { 0 };
48
49 static void
rb_player_gst_filter_interface_init(RBPlayerGstFilterIface * iface)50 rb_player_gst_filter_interface_init (RBPlayerGstFilterIface *iface)
51 {
52 /**
53 * RBPlayerGstFilter::filter-inserted:
54 * @player: the #RBPlayerGstFilter implementation
55 * @filter: the element which has been inserted
56 *
57 * The 'filter-inserted' signal is emitted when the tee element has been
58 * inserted into the pipeline and fully linked
59 **/
60 signals[FILTER_INSERTED] =
61 g_signal_new ("filter-inserted",
62 G_TYPE_FROM_INTERFACE (iface),
63 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
64 G_STRUCT_OFFSET (RBPlayerGstFilterIface, filter_inserted),
65 NULL, NULL,
66 NULL,
67 G_TYPE_NONE,
68 1, G_TYPE_OBJECT);
69
70 /**
71 * RBPlayerGstFilter::filter-pre-remove:
72 * @player: the #RBPlayerGstFilter implementation
73 * @filter: the element which is about to be removed
74 *
75 * The 'filter-pre-remove' signal is emitted immediately before the element
76 * is unlinked and removed from the pipeline
77 **/
78 signals[FILTER_PRE_REMOVE] =
79 g_signal_new ("filter-pre-remove",
80 G_TYPE_FROM_INTERFACE (iface),
81 G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
82 G_STRUCT_OFFSET (RBPlayerGstFilterIface, filter_pre_remove),
83 NULL, NULL,
84 NULL,
85 G_TYPE_NONE,
86 1, G_TYPE_OBJECT);
87
88 }
89
90 GType
rb_player_gst_filter_get_type(void)91 rb_player_gst_filter_get_type (void)
92 {
93 static GType our_type = 0;
94
95 if (!our_type) {
96 static const GTypeInfo our_info = {
97 sizeof (RBPlayerGstFilterIface),
98 NULL, /* base_init */
99 NULL, /* base_finalize */
100 (GClassInitFunc)rb_player_gst_filter_interface_init,
101 NULL, /* class_finalize */
102 NULL, /* class_data */
103 0,
104 0,
105 NULL
106 };
107
108 our_type = g_type_register_static (G_TYPE_INTERFACE, "RBPlayerGstFilter", &our_info, 0);
109 }
110
111 return our_type;
112 }
113
114 /**
115 * rb_player_gst_filter_add_filter:
116 * @player: #RBPlayerGstFilter implementation
117 * @element: new filter element (or bin) to add
118 *
119 * Adds a new filter to the playback pipeline. The filter may not be
120 * inserted immediately. The 'filter-inserted' signal will be emitted
121 * when this actually happens.
122 *
123 * Return value: TRUE if the filter will be added
124 */
125 gboolean
rb_player_gst_filter_add_filter(RBPlayerGstFilter * player,GstElement * element)126 rb_player_gst_filter_add_filter (RBPlayerGstFilter *player, GstElement *element)
127 {
128 RBPlayerGstFilterIface *iface = RB_PLAYER_GST_FILTER_GET_IFACE (player);
129
130 return iface->add_filter (player, element);
131 }
132
133 /**
134 * rb_player_gst_filter_remove_filter:
135 * @player: #RBPlayerGstFilter implementation
136 * @element: the filter element (or bin) to remove
137 *
138 * Removes a filter from the playback pipeline. The filter may not be
139 * removed immediately. The 'filter-pre-remove' signal will be emitted
140 * immediately before this actually happens.
141 *
142 * Return value: TRUE if the filter was found and will be removed
143 */
144 gboolean
rb_player_gst_filter_remove_filter(RBPlayerGstFilter * player,GstElement * element)145 rb_player_gst_filter_remove_filter (RBPlayerGstFilter *player, GstElement *element)
146 {
147 RBPlayerGstFilterIface *iface = RB_PLAYER_GST_FILTER_GET_IFACE (player);
148
149 return iface->remove_filter (player, element);
150 }
151
152 void
_rb_player_gst_filter_emit_filter_inserted(RBPlayerGstFilter * player,GstElement * filter)153 _rb_player_gst_filter_emit_filter_inserted (RBPlayerGstFilter *player, GstElement *filter)
154 {
155 g_signal_emit (player, signals[FILTER_INSERTED], 0, filter);
156 }
157
158 void
_rb_player_gst_filter_emit_filter_pre_remove(RBPlayerGstFilter * player,GstElement * filter)159 _rb_player_gst_filter_emit_filter_pre_remove (RBPlayerGstFilter *player, GstElement *filter)
160 {
161 g_signal_emit (player, signals[FILTER_PRE_REMOVE], 0, filter);
162 }
163
164