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