19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 * Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
20 * Boston, MA 02111-1307, USA. |
20 * Boston, MA 02111-1307, USA. |
21 */ |
21 */ |
22 /** |
22 /** |
23 * SECTION:element-fakesink |
23 * SECTION:element-fakesink |
24 * @short_description: black hole for data |
|
25 * @see_also: #GstFakeSrc |
24 * @see_also: #GstFakeSrc |
26 * |
25 * |
27 * Dummy sink that swallows everything. |
26 * Dummy sink that swallows everything. |
28 */ |
27 */ |
29 |
28 |
30 #ifdef HAVE_CONFIG_H |
29 #ifdef HAVE_CONFIG_H |
31 # include "config.h" |
30 # include "config.h" |
32 #endif |
31 #endif |
33 #ifdef __SYMBIAN32__ |
|
34 #include <gst_global.h> |
|
35 #endif |
|
36 |
32 |
37 #include "gstfakesink.h" |
33 #include "gstfakesink.h" |
38 #include <gst/gstmarshal.h> |
34 #include <gst/gstmarshal.h> |
39 #ifdef __SYMBIAN32__ |
|
40 #include <glib_global.h> |
|
41 #include <gobject_global.h> |
|
42 |
|
43 #include <gstelement.h> |
|
44 #endif |
|
45 |
35 |
46 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", |
36 static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", |
47 GST_PAD_SINK, |
37 GST_PAD_SINK, |
48 GST_PAD_ALWAYS, |
38 GST_PAD_ALWAYS, |
49 GST_STATIC_CAPS_ANY); |
39 GST_STATIC_CAPS_ANY); |
132 static GstFlowReturn gst_fake_sink_render (GstBaseSink * bsink, |
123 static GstFlowReturn gst_fake_sink_render (GstBaseSink * bsink, |
133 GstBuffer * buffer); |
124 GstBuffer * buffer); |
134 static gboolean gst_fake_sink_event (GstBaseSink * bsink, GstEvent * event); |
125 static gboolean gst_fake_sink_event (GstBaseSink * bsink, GstEvent * event); |
135 |
126 |
136 static guint gst_fake_sink_signals[LAST_SIGNAL] = { 0 }; |
127 static guint gst_fake_sink_signals[LAST_SIGNAL] = { 0 }; |
|
128 |
|
129 static void |
|
130 marshal_VOID__MINIOBJECT_OBJECT (GClosure * closure, GValue * return_value, |
|
131 guint n_param_values, const GValue * param_values, gpointer invocation_hint, |
|
132 gpointer marshal_data) |
|
133 { |
|
134 typedef void (*marshalfunc_VOID__MINIOBJECT_OBJECT) (gpointer obj, |
|
135 gpointer arg1, gpointer arg2, gpointer data2); |
|
136 register marshalfunc_VOID__MINIOBJECT_OBJECT callback; |
|
137 register GCClosure *cc = (GCClosure *) closure; |
|
138 register gpointer data1, data2; |
|
139 |
|
140 g_return_if_fail (n_param_values == 3); |
|
141 |
|
142 if (G_CCLOSURE_SWAP_DATA (closure)) { |
|
143 data1 = closure->data; |
|
144 data2 = g_value_peek_pointer (param_values + 0); |
|
145 } else { |
|
146 data1 = g_value_peek_pointer (param_values + 0); |
|
147 data2 = closure->data; |
|
148 } |
|
149 callback = |
|
150 (marshalfunc_VOID__MINIOBJECT_OBJECT) (marshal_data ? marshal_data : |
|
151 cc->callback); |
|
152 |
|
153 callback (data1, gst_value_get_mini_object (param_values + 1), |
|
154 g_value_get_object (param_values + 2), data2); |
|
155 } |
137 |
156 |
138 static void |
157 static void |
139 gst_fake_sink_base_init (gpointer g_class) |
158 gst_fake_sink_base_init (gpointer g_class) |
140 { |
159 { |
141 GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); |
160 GstElementClass *gstelement_class = GST_ELEMENT_CLASS (g_class); |
162 gstelement_class = GST_ELEMENT_CLASS (klass); |
181 gstelement_class = GST_ELEMENT_CLASS (klass); |
163 gstbase_sink_class = GST_BASE_SINK_CLASS (klass); |
182 gstbase_sink_class = GST_BASE_SINK_CLASS (klass); |
164 |
183 |
165 gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fake_sink_set_property); |
184 gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_fake_sink_set_property); |
166 gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fake_sink_get_property); |
185 gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_fake_sink_get_property); |
|
186 gobject_class->finalize = gst_fake_sink_finalize; |
167 |
187 |
168 g_object_class_install_property (gobject_class, PROP_STATE_ERROR, |
188 g_object_class_install_property (gobject_class, PROP_STATE_ERROR, |
169 g_param_spec_enum ("state_error", "State Error", |
189 g_param_spec_enum ("state-error", "State Error", |
170 "Generate a state change error", GST_TYPE_FAKE_SINK_STATE_ERROR, |
190 "Generate a state change error", GST_TYPE_FAKE_SINK_STATE_ERROR, |
171 DEFAULT_STATE_ERROR, G_PARAM_READWRITE)); |
191 DEFAULT_STATE_ERROR, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
172 g_object_class_install_property (gobject_class, PROP_LAST_MESSAGE, |
192 g_object_class_install_property (gobject_class, PROP_LAST_MESSAGE, |
173 g_param_spec_string ("last_message", "Last Message", |
193 g_param_spec_string ("last-message", "Last Message", |
174 "The message describing current status", DEFAULT_LAST_MESSAGE, |
194 "The message describing current status", DEFAULT_LAST_MESSAGE, |
175 G_PARAM_READABLE)); |
195 G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); |
176 g_object_class_install_property (gobject_class, PROP_SIGNAL_HANDOFFS, |
196 g_object_class_install_property (gobject_class, PROP_SIGNAL_HANDOFFS, |
177 g_param_spec_boolean ("signal-handoffs", "Signal handoffs", |
197 g_param_spec_boolean ("signal-handoffs", "Signal handoffs", |
178 "Send a signal before unreffing the buffer", DEFAULT_SIGNAL_HANDOFFS, |
198 "Send a signal before unreffing the buffer", DEFAULT_SIGNAL_HANDOFFS, |
179 G_PARAM_READWRITE)); |
199 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
180 g_object_class_install_property (gobject_class, PROP_SILENT, |
200 g_object_class_install_property (gobject_class, PROP_SILENT, |
181 g_param_spec_boolean ("silent", "Silent", |
201 g_param_spec_boolean ("silent", "Silent", |
182 "Don't produce last_message events", DEFAULT_SILENT, |
202 "Don't produce last_message events", DEFAULT_SILENT, |
183 G_PARAM_READWRITE)); |
203 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
184 g_object_class_install_property (gobject_class, PROP_DUMP, |
204 g_object_class_install_property (gobject_class, PROP_DUMP, |
185 g_param_spec_boolean ("dump", "Dump", "Dump buffer contents to stdout", |
205 g_param_spec_boolean ("dump", "Dump", "Dump buffer contents to stdout", |
186 DEFAULT_DUMP, G_PARAM_READWRITE)); |
206 DEFAULT_DUMP, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
187 g_object_class_install_property (gobject_class, |
207 g_object_class_install_property (gobject_class, |
188 PROP_CAN_ACTIVATE_PUSH, |
208 PROP_CAN_ACTIVATE_PUSH, |
189 g_param_spec_boolean ("can-activate-push", "Can activate push", |
209 g_param_spec_boolean ("can-activate-push", "Can activate push", |
190 "Can activate in push mode", DEFAULT_CAN_ACTIVATE_PUSH, |
210 "Can activate in push mode", DEFAULT_CAN_ACTIVATE_PUSH, |
191 G_PARAM_READWRITE)); |
211 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
192 g_object_class_install_property (gobject_class, |
212 g_object_class_install_property (gobject_class, |
193 PROP_CAN_ACTIVATE_PULL, |
213 PROP_CAN_ACTIVATE_PULL, |
194 g_param_spec_boolean ("can-activate-pull", "Can activate pull", |
214 g_param_spec_boolean ("can-activate-pull", "Can activate pull", |
195 "Can activate in pull mode", DEFAULT_CAN_ACTIVATE_PULL, |
215 "Can activate in pull mode", DEFAULT_CAN_ACTIVATE_PULL, |
196 G_PARAM_READWRITE)); |
216 G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
197 g_object_class_install_property (gobject_class, PROP_NUM_BUFFERS, |
217 g_object_class_install_property (gobject_class, PROP_NUM_BUFFERS, |
198 g_param_spec_int ("num-buffers", "num-buffers", |
218 g_param_spec_int ("num-buffers", "num-buffers", |
199 "Number of buffers to accept going EOS", -1, G_MAXINT, |
219 "Number of buffers to accept going EOS", -1, G_MAXINT, |
200 DEFAULT_NUM_BUFFERS, G_PARAM_READWRITE)); |
220 DEFAULT_NUM_BUFFERS, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); |
201 |
221 |
202 /** |
222 /** |
203 * GstFakeSink::handoff: |
223 * GstFakeSink::handoff: |
204 * @fakesink: the fakesink instance |
224 * @fakesink: the fakesink instance |
205 * @buffer: the buffer that just has been received |
225 * @buffer: the buffer that just has been received |
208 * This signal gets emitted before unreffing the buffer. |
228 * This signal gets emitted before unreffing the buffer. |
209 */ |
229 */ |
210 gst_fake_sink_signals[SIGNAL_HANDOFF] = |
230 gst_fake_sink_signals[SIGNAL_HANDOFF] = |
211 g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, |
231 g_signal_new ("handoff", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_LAST, |
212 G_STRUCT_OFFSET (GstFakeSinkClass, handoff), NULL, NULL, |
232 G_STRUCT_OFFSET (GstFakeSinkClass, handoff), NULL, NULL, |
213 gst_marshal_VOID__OBJECT_OBJECT, G_TYPE_NONE, 2, |
233 marshal_VOID__MINIOBJECT_OBJECT, G_TYPE_NONE, 2, |
214 GST_TYPE_BUFFER, GST_TYPE_PAD); |
234 GST_TYPE_BUFFER, GST_TYPE_PAD); |
215 |
235 |
216 /** |
236 /** |
217 * GstFakeSink::preroll-handoff: |
237 * GstFakeSink::preroll-handoff: |
218 * @fakesink: the fakesink instance |
238 * @fakesink: the fakesink instance |
421 sink->last_message = |
470 sink->last_message = |
422 g_strdup_printf ("chain ******* < (%5d bytes, timestamp: %s" |
471 g_strdup_printf ("chain ******* < (%5d bytes, timestamp: %s" |
423 ", duration: %s, offset: %" G_GINT64_FORMAT ", offset_end: %" |
472 ", duration: %s, offset: %" G_GINT64_FORMAT ", offset_end: %" |
424 G_GINT64_FORMAT ", flags: %d) %p", GST_BUFFER_SIZE (buf), ts_str, |
473 G_GINT64_FORMAT ", flags: %d) %p", GST_BUFFER_SIZE (buf), ts_str, |
425 dur_str, GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf), |
474 dur_str, GST_BUFFER_OFFSET (buf), GST_BUFFER_OFFSET_END (buf), |
426 GST_MINI_OBJECT (buf)->flags, buf); |
475 GST_MINI_OBJECT_CAST (buf)->flags, buf); |
427 GST_OBJECT_UNLOCK (sink); |
476 GST_OBJECT_UNLOCK (sink); |
428 |
477 |
429 g_object_notify (G_OBJECT (sink), "last_message"); |
478 gst_fake_sink_notify_last_message (sink); |
430 } |
479 } |
431 if (sink->signal_handoffs) |
480 if (sink->signal_handoffs) |
432 g_signal_emit (G_OBJECT (sink), gst_fake_sink_signals[SIGNAL_HANDOFF], 0, |
481 g_signal_emit (G_OBJECT (sink), gst_fake_sink_signals[SIGNAL_HANDOFF], 0, |
433 buf, bsink->sinkpad); |
482 buf, bsink->sinkpad); |
434 |
483 |