-
Notifications
You must be signed in to change notification settings - Fork 68
/
Copy pathrb-player-gst-tee.c
162 lines (144 loc) · 4.67 KB
/
rb-player-gst-tee.c
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
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*-
*
* Copyright (C) 2006 James Livingston <[email protected]>
*
* 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, see <http://www.gnu.org/licenses/>.
*
*/
#include <config.h>
#include "rb-player-gst-tee.h"
/**
* SECTION:rbplayergsttee
* @short_description: player interface for inserting additional sinks
* @include: rb-player-gst-tee.h
*
* This interface allows a caller to add a new sink to the GStreamer playback
* pipeline.
*/
enum {
TEE_INSERTED,
TEE_PRE_REMOVE,
LAST_SIGNAL
};
static guint signals[LAST_SIGNAL] = { 0 };
static void
rb_player_gst_tee_interface_init (RBPlayerGstTeeIface *iface)
{
/**
* RBPlayerGstTee::tee-inserted:
* @player: the #RBPlayerGstTee implementation
* @tee: the element which has been inserted
*
* The 'tee-inserted' signal is emitted when the tee element has been
* inserted into the pipeline and fully linked
**/
signals[TEE_INSERTED] =
g_signal_new ("tee-inserted",
G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
G_STRUCT_OFFSET (RBPlayerGstTeeIface, tee_inserted),
NULL, NULL,
NULL,
G_TYPE_NONE,
1, G_TYPE_OBJECT);
/**
* RBPlayerGstTee::tee-pre-remove:
* @player: the #RBPlayerGstTee implementation
* @tee: the element which is about to be removed
*
* The 'tee-pre-remove' signal is emitted immediately before the element
* is unlinked and removed from the pipeline
**/
signals[TEE_PRE_REMOVE] =
g_signal_new ("tee-pre-remove",
G_TYPE_FROM_INTERFACE (iface),
G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE,
G_STRUCT_OFFSET (RBPlayerGstTeeIface, tee_pre_remove),
NULL, NULL,
NULL,
G_TYPE_NONE,
1, G_TYPE_OBJECT);
}
GType
rb_player_gst_tee_get_type (void)
{
static GType our_type = 0;
if (!our_type) {
static const GTypeInfo our_info = {
sizeof (RBPlayerGstTeeIface),
NULL, /* base_init */
NULL, /* base_finalize */
(GClassInitFunc)rb_player_gst_tee_interface_init,
NULL, /* class_finalize */
NULL, /* class_data */
0,
0,
NULL
};
our_type = g_type_register_static (G_TYPE_INTERFACE, "RBPlayerGstTee", &our_info, 0);
}
return our_type;
}
/**
* rb_player_gst_tee_add_tee:
* @player: #RBPlayerGstTee implementation
* @element: new sink element (or bin) to add
*
* Adds a new sink to the playback pipeline. The sink may not be
* inserted immediately. The 'tee-inserted' signal will be emitted
* when this actually happens.
*
* Return value: TRUE if the sink will be added
*/
gboolean
rb_player_gst_tee_add_tee (RBPlayerGstTee *player, GstElement *element)
{
RBPlayerGstTeeIface *iface = RB_PLAYER_GST_TEE_GET_IFACE (player);
return iface->add_tee (player, element);
}
/**
* rb_player_gst_tee_remove_tee:
* @player: #RBPlayerGstTee implementation
* @element: the sink element (or bin) to remove
*
* Removes a sink from the playback pipeline. The sink may not be
* removed immediately. The 'tee-pre-remove' signal will be emitted
* immediately before this actually happens.
*
* Return value: TRUE if the sink was found and will be removed
*/
gboolean
rb_player_gst_tee_remove_tee (RBPlayerGstTee *player, GstElement *element)
{
RBPlayerGstTeeIface *iface = RB_PLAYER_GST_TEE_GET_IFACE (player);
return iface->remove_tee (player, element);
}
void
_rb_player_gst_tee_emit_tee_inserted (RBPlayerGstTee *player, GstElement *tee)
{
g_signal_emit (player, signals[TEE_INSERTED], 0, tee);
}
void
_rb_player_gst_tee_emit_tee_pre_remove (RBPlayerGstTee *player, GstElement *tee)
{
g_signal_emit (player, signals[TEE_PRE_REMOVE], 0, tee);
}