static GstFlowReturn gst_fake_sink_preroll (GstBaseSink * bsink, GstBuffer * buffer) { GstFakeSink *sink = GST_FAKE_SINK (bsink); if (sink->num_buffers_left == 0) goto eos; if (!sink->silent) { GST_OBJECT_LOCK (sink); g_free (sink->last_message); sink->last_message = g_strdup_printf ("preroll ******* "); GST_OBJECT_UNLOCK (sink); gst_fake_sink_notify_last_message (sink); } if (sink->signal_handoffs) { g_signal_emit (sink, gst_fake_sink_signals[SIGNAL_PREROLL_HANDOFF], 0, buffer, bsink->sinkpad); } return GST_FLOW_OK; /* ERRORS */ eos: { GST_DEBUG_OBJECT (sink, "we are EOS"); return GST_FLOW_EOS; } }
static void gst_fake_sink_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstFakeSink *sink; sink = GST_FAKE_SINK (object); switch (prop_id) { case PROP_STATE_ERROR: sink->state_error = (GstFakeSinkStateError) g_value_get_enum (value); break; case PROP_SILENT: sink->silent = g_value_get_boolean (value); break; case PROP_DUMP: sink->dump = g_value_get_boolean (value); break; case PROP_SIGNAL_HANDOFFS: sink->signal_handoffs = g_value_get_boolean (value); break; case PROP_CAN_ACTIVATE_PUSH: GST_BASE_SINK (sink)->can_activate_push = g_value_get_boolean (value); break; case PROP_CAN_ACTIVATE_PULL: GST_BASE_SINK (sink)->can_activate_pull = g_value_get_boolean (value); break; case PROP_NUM_BUFFERS: sink->num_buffers = g_value_get_int (value); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
static gboolean gst_fake_sink_event (GstBaseSink * bsink, GstEvent * event) { GstFakeSink *sink = GST_FAKE_SINK (bsink); if (!sink->silent) { const GstStructure *s; gchar *sstr; GST_OBJECT_LOCK (sink); g_free (sink->last_message); if ((s = gst_event_get_structure (event))) sstr = gst_structure_to_string (s); else sstr = g_strdup (""); sink->last_message = g_strdup_printf ("event ******* E (type: %d, %s) %p", GST_EVENT_TYPE (event), sstr, event); g_free (sstr); GST_OBJECT_UNLOCK (sink); gst_fake_sink_notify_last_message (sink); } if (GST_BASE_SINK_CLASS (parent_class)->event) { return GST_BASE_SINK_CLASS (parent_class)->event (bsink, event); } else { return TRUE; } }
static void gst_fake_sink_finalize (GObject * obj) { GstFakeSink *sink = GST_FAKE_SINK (obj); g_static_rec_mutex_free (&sink->notify_lock); G_OBJECT_CLASS (parent_class)->finalize (obj); }
static GstStateChangeReturn gst_fake_sink_change_state (GstElement * element, GstStateChange transition) { GstStateChangeReturn ret = GST_STATE_CHANGE_SUCCESS; GstFakeSink *fakesink = GST_FAKE_SINK (element); switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: if (fakesink->state_error == FAKE_SINK_STATE_ERROR_NULL_READY) goto error; break; case GST_STATE_CHANGE_READY_TO_PAUSED: if (fakesink->state_error == FAKE_SINK_STATE_ERROR_READY_PAUSED) goto error; fakesink->num_buffers_left = fakesink->num_buffers; break; case GST_STATE_CHANGE_PAUSED_TO_PLAYING: if (fakesink->state_error == FAKE_SINK_STATE_ERROR_PAUSED_PLAYING) goto error; break; default: break; } ret = GST_ELEMENT_CLASS (parent_class)->change_state (element, transition); switch (transition) { case GST_STATE_CHANGE_PLAYING_TO_PAUSED: if (fakesink->state_error == FAKE_SINK_STATE_ERROR_PLAYING_PAUSED) goto error; break; case GST_STATE_CHANGE_PAUSED_TO_READY: if (fakesink->state_error == FAKE_SINK_STATE_ERROR_PAUSED_READY) goto error; break; case GST_STATE_CHANGE_READY_TO_NULL: if (fakesink->state_error == FAKE_SINK_STATE_ERROR_READY_NULL) goto error; GST_OBJECT_LOCK (fakesink); g_free (fakesink->last_message); fakesink->last_message = NULL; GST_OBJECT_UNLOCK (fakesink); break; default: break; } return ret; /* ERROR */ error: GST_ELEMENT_ERROR (element, CORE, STATE_CHANGE, (NULL), ("Erroring out on state change as requested")); return GST_STATE_CHANGE_FAILURE; }
static gboolean gst_fake_sink_event (GstBaseSink * bsink, GstEvent * event) { GstFakeSink *sink = GST_FAKE_SINK (bsink); if (!sink->silent) { const GstStructure *s; const gchar *tstr; gchar *sstr; GST_OBJECT_LOCK (sink); g_free (sink->last_message); if (GST_EVENT_TYPE (event) == GST_EVENT_SINK_MESSAGE) { GstMessage *msg; const GstStructure *structure; gst_event_parse_sink_message (event, &msg); structure = gst_message_get_structure (msg); sstr = gst_structure_to_string (structure); sink->last_message = g_strdup_printf ("message ******* (%s:%s) M (type: %d, %s) %p", GST_DEBUG_PAD_NAME (GST_BASE_SINK_CAST (sink)->sinkpad), GST_MESSAGE_TYPE (msg), sstr, msg); gst_message_unref (msg); } else { tstr = gst_event_type_get_name (GST_EVENT_TYPE (event)); if ((s = gst_event_get_structure (event))) { sstr = gst_structure_to_string (s); } else { sstr = g_strdup (""); } sink->last_message = g_strdup_printf ("event ******* (%s:%s) E (type: %s (%d), %s) %p", GST_DEBUG_PAD_NAME (GST_BASE_SINK_CAST (sink)->sinkpad), tstr, GST_EVENT_TYPE (event), sstr, event); } g_free (sstr); GST_OBJECT_UNLOCK (sink); gst_fake_sink_notify_last_message (sink); } return GST_BASE_SINK_CLASS (parent_class)->event (bsink, event); }
static void gst_fake_sink_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec) { GstFakeSink *sink; sink = GST_FAKE_SINK (object); switch (prop_id) { case PROP_STATE_ERROR: g_value_set_enum (value, sink->state_error); break; case PROP_SILENT: g_value_set_boolean (value, sink->silent); break; case PROP_DUMP: g_value_set_boolean (value, sink->dump); break; case PROP_SIGNAL_HANDOFFS: g_value_set_boolean (value, sink->signal_handoffs); break; case PROP_DROP_OUT_OF_SEGMENT: g_value_set_boolean (value, gst_base_sink_get_drop_out_of_segment (GST_BASE_SINK (object))); break; case PROP_LAST_MESSAGE: GST_OBJECT_LOCK (sink); g_value_set_string (value, sink->last_message); GST_OBJECT_UNLOCK (sink); break; case PROP_CAN_ACTIVATE_PUSH: g_value_set_boolean (value, GST_BASE_SINK (sink)->can_activate_push); break; case PROP_CAN_ACTIVATE_PULL: g_value_set_boolean (value, GST_BASE_SINK (sink)->can_activate_pull); break; case PROP_NUM_BUFFERS: g_value_set_int (value, sink->num_buffers); break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }