~ubuntu-branches/ubuntu/trusty/rhythmbox/trusty-proposed

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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
 *
 *  Copyright (C) 2006  James Livingston  <doclivingston@gmail.com>
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  The Rhythmbox authors hereby grant permission for non-GPL compatible
 *  GStreamer plugins to be used and distributed together with GStreamer
 *  and Rhythmbox. This permission is above and beyond the permissions granted
 *  by the GPL license by which Rhythmbox is covered. If you modify this code
 *  you may extend this exception to your version of the code, but you are not
 *  obligated to do so. If you do not wish to do so, delete this exception
 *  statement from your version.
 *
 *  This program 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 General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program; if not, write to the Free Software
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *
 */

#include <config.h>

#include "rb-player-gst-filter.h"
#include "rb-marshal.h"

/**
 * SECTION:rb-player-gst-filter
 * @short_description: player interface for inserting filter elements
 * @include: rb-player-gst-filter.h
 *
 * This interface allows a caller to add filter elements to the GStreamer playback
 * pipeline.
 */

enum {
	FILTER_INSERTED,
	FILTER_PRE_REMOVE,
	LAST_SIGNAL
};

static guint signals[LAST_SIGNAL] = { 0 };

static void
rb_player_gst_filter_interface_init (RBPlayerGstFilterIface *iface)
{
	/**
	 * RBPlayerGstFilter::filter-inserted:
	 * @player: the #RBPlayerGstFilter implementation
	 * @filter: the element which has been inserted
	 *
	 * The 'filter-inserted' signal is emitted when the tee element has been
	 * inserted into the pipeline and fully linked
	 **/
	signals[FILTER_INSERTED] =
		g_signal_new ("filter-inserted",
			      G_TYPE_FROM_INTERFACE (iface),
			      G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
			      G_STRUCT_OFFSET (RBPlayerGstFilterIface, filter_inserted),
			      NULL, NULL,
			      g_cclosure_marshal_VOID__OBJECT,
			      G_TYPE_NONE,
			      1, G_TYPE_OBJECT);

	/**
	 * RBPlayerGstFilter::filter-pre-remove:
	 * @player: the #RBPlayerGstFilter implementation
	 * @filter: the element which is about to be removed
	 *
	 * The 'filter-pre-remove' signal is emitted immediately before the element
	 * is unlinked and removed from the pipeline
	 **/
	signals[FILTER_PRE_REMOVE] =
		g_signal_new ("filter-pre-remove",
			      G_TYPE_FROM_INTERFACE (iface),
			      G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
			      G_STRUCT_OFFSET (RBPlayerGstFilterIface, filter_pre_remove),
			      NULL, NULL,
			      g_cclosure_marshal_VOID__OBJECT,
			      G_TYPE_NONE,
			      1, G_TYPE_OBJECT);

}

GType
rb_player_gst_filter_get_type (void)
{
	static GType our_type = 0;

	if (!our_type) {
		static const GTypeInfo our_info = {
			sizeof (RBPlayerGstFilterIface),
			NULL,	/* base_init */
			NULL,	/* base_finalize */
			(GClassInitFunc)rb_player_gst_filter_interface_init,
			NULL,	/* class_finalize */
			NULL,	/* class_data */
			0,
			0,
			NULL
		};

		our_type = g_type_register_static (G_TYPE_INTERFACE, "RBPlayerGstFilter", &our_info, 0);
	}

	return our_type;
}

/**
 * rb_player_gst_filter_add_filter:
 * @player: #RBPlayerGstFilter implementation
 * @element: new filter element (or bin) to add
 *
 * Adds a new filter to the playback pipeline.  The filter may not be
 * inserted immediately.  The 'filter-inserted' signal will be emitted
 * when this actually happens.
 *
 * Return value: TRUE if the filter will be added
 */
gboolean
rb_player_gst_filter_add_filter (RBPlayerGstFilter *player, GstElement *element)
{
	RBPlayerGstFilterIface *iface = RB_PLAYER_GST_FILTER_GET_IFACE (player);

	return iface->add_filter (player, element);
}

/**
 * rb_player_gst_filter_remove_filter:
 * @player: #RBPlayerGstFilter implementation
 * @element: the filter element (or bin) to remove
 *
 * Removes a filter from the playback pipeline.  The filter may not be
 * removed immediately.  The 'filter-pre-remove' signal will be emitted
 * immediately before this actually happens.
 *
 * Return value: TRUE if the filter was found and will be removed
 */
gboolean
rb_player_gst_filter_remove_filter (RBPlayerGstFilter *player, GstElement *element)
{
	RBPlayerGstFilterIface *iface = RB_PLAYER_GST_FILTER_GET_IFACE (player);

	return iface->remove_filter (player, element);
}

void
_rb_player_gst_filter_emit_filter_inserted (RBPlayerGstFilter *player, GstElement *filter)
{
	g_signal_emit (player, signals[FILTER_INSERTED], 0, filter);
}

void
_rb_player_gst_filter_emit_filter_pre_remove (RBPlayerGstFilter *player, GstElement *filter)
{
	g_signal_emit (player, signals[FILTER_PRE_REMOVE], 0, filter);
}