hythmbox-2.98/backends/rb-player-gst-filter.c

No issues found

  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, write to the Free Software
 25  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 26  *
 27  */
 28 
 29 #include <config.h>
 30 
 31 #include "rb-player-gst-filter.h"
 32 #include "rb-marshal.h"
 33 
 34 /**
 35  * SECTION:rb-player-gst-filter
 36  * @short_description: player interface for inserting filter elements
 37  * @include: rb-player-gst-filter.h
 38  *
 39  * This interface allows a caller to add filter elements to the GStreamer playback
 40  * pipeline.
 41  */
 42 
 43 enum {
 44 	FILTER_INSERTED,
 45 	FILTER_PRE_REMOVE,
 46 	LAST_SIGNAL
 47 };
 48 
 49 static guint signals[LAST_SIGNAL] = { 0 };
 50 
 51 static void
 52 rb_player_gst_filter_interface_init (RBPlayerGstFilterIface *iface)
 53 {
 54 	/**
 55 	 * RBPlayerGstFilter::filter-inserted:
 56 	 * @player: the #RBPlayerGstFilter implementation
 57 	 * @filter: the element which has been inserted
 58 	 *
 59 	 * The 'filter-inserted' signal is emitted when the tee element has been
 60 	 * inserted into the pipeline and fully linked
 61 	 **/
 62 	signals[FILTER_INSERTED] =
 63 		g_signal_new ("filter-inserted",
 64 			      G_TYPE_FROM_INTERFACE (iface),
 65 			      G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
 66 			      G_STRUCT_OFFSET (RBPlayerGstFilterIface, filter_inserted),
 67 			      NULL, NULL,
 68 			      g_cclosure_marshal_VOID__OBJECT,
 69 			      G_TYPE_NONE,
 70 			      1, G_TYPE_OBJECT);
 71 
 72 	/**
 73 	 * RBPlayerGstFilter::filter-pre-remove:
 74 	 * @player: the #RBPlayerGstFilter implementation
 75 	 * @filter: the element which is about to be removed
 76 	 *
 77 	 * The 'filter-pre-remove' signal is emitted immediately before the element
 78 	 * is unlinked and removed from the pipeline
 79 	 **/
 80 	signals[FILTER_PRE_REMOVE] =
 81 		g_signal_new ("filter-pre-remove",
 82 			      G_TYPE_FROM_INTERFACE (iface),
 83 			      G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
 84 			      G_STRUCT_OFFSET (RBPlayerGstFilterIface, filter_pre_remove),
 85 			      NULL, NULL,
 86 			      g_cclosure_marshal_VOID__OBJECT,
 87 			      G_TYPE_NONE,
 88 			      1, G_TYPE_OBJECT);
 89 
 90 }
 91 
 92 GType
 93 rb_player_gst_filter_get_type (void)
 94 {
 95 	static GType our_type = 0;
 96 
 97 	if (!our_type) {
 98 		static const GTypeInfo our_info = {
 99 			sizeof (RBPlayerGstFilterIface),
100 			NULL,	/* base_init */
101 			NULL,	/* base_finalize */
102 			(GClassInitFunc)rb_player_gst_filter_interface_init,
103 			NULL,	/* class_finalize */
104 			NULL,	/* class_data */
105 			0,
106 			0,
107 			NULL
108 		};
109 
110 		our_type = g_type_register_static (G_TYPE_INTERFACE, "RBPlayerGstFilter", &our_info, 0);
111 	}
112 
113 	return our_type;
114 }
115 
116 /**
117  * rb_player_gst_filter_add_filter:
118  * @player: #RBPlayerGstFilter implementation
119  * @element: new filter element (or bin) to add
120  *
121  * Adds a new filter to the playback pipeline.  The filter may not be
122  * inserted immediately.  The 'filter-inserted' signal will be emitted
123  * when this actually happens.
124  *
125  * Return value: TRUE if the filter will be added
126  */
127 gboolean
128 rb_player_gst_filter_add_filter (RBPlayerGstFilter *player, GstElement *element)
129 {
130 	RBPlayerGstFilterIface *iface = RB_PLAYER_GST_FILTER_GET_IFACE (player);
131 
132 	return iface->add_filter (player, element);
133 }
134 
135 /**
136  * rb_player_gst_filter_remove_filter:
137  * @player: #RBPlayerGstFilter implementation
138  * @element: the filter element (or bin) to remove
139  *
140  * Removes a filter from the playback pipeline.  The filter may not be
141  * removed immediately.  The 'filter-pre-remove' signal will be emitted
142  * immediately before this actually happens.
143  *
144  * Return value: TRUE if the filter was found and will be removed
145  */
146 gboolean
147 rb_player_gst_filter_remove_filter (RBPlayerGstFilter *player, GstElement *element)
148 {
149 	RBPlayerGstFilterIface *iface = RB_PLAYER_GST_FILTER_GET_IFACE (player);
150 
151 	return iface->remove_filter (player, element);
152 }
153 
154 void
155 _rb_player_gst_filter_emit_filter_inserted (RBPlayerGstFilter *player, GstElement *filter)
156 {
157 	g_signal_emit (player, signals[FILTER_INSERTED], 0, filter);
158 }
159 
160 void
161 _rb_player_gst_filter_emit_filter_pre_remove (RBPlayerGstFilter *player, GstElement *filter)
162 {
163 	g_signal_emit (player, signals[FILTER_PRE_REMOVE], 0, filter);
164 }