static void fs_rtp_sub_stream_dispose (GObject *object) { FsRtpSubStream *self = FS_RTP_SUB_STREAM (object); fs_rtp_sub_stream_stop (self); fs_rtp_sub_stream_stop_no_rtcp_timeout_thread (self); if (self->priv->output_ghostpad) { gst_element_remove_pad (GST_ELEMENT (self->priv->conference), self->priv->output_ghostpad); self->priv->output_ghostpad = NULL; } if (self->priv->output_valve) { gst_element_set_locked_state (self->priv->output_valve, TRUE); gst_element_set_state (self->priv->output_valve, GST_STATE_NULL); gst_bin_remove (GST_BIN (self->priv->conference), self->priv->output_valve); self->priv->output_valve = NULL; } if (self->priv->codecbin) { gst_element_set_locked_state (self->priv->codecbin, TRUE); gst_element_set_state (self->priv->codecbin, GST_STATE_NULL); gst_bin_remove (GST_BIN (self->priv->conference), self->priv->codecbin); self->priv->codecbin = NULL; } if (self->priv->capsfilter) { gst_element_set_locked_state (self->priv->capsfilter, TRUE); gst_element_set_state (self->priv->capsfilter, GST_STATE_NULL); gst_bin_remove (GST_BIN (self->priv->conference), self->priv->capsfilter); self->priv->capsfilter = NULL; } if (self->priv->input_valve) { gst_element_set_locked_state (self->priv->input_valve, TRUE); gst_element_set_state (self->priv->input_valve, GST_STATE_NULL); gst_bin_remove (GST_BIN (self->priv->conference), self->priv->input_valve); self->priv->input_valve = NULL; } if (self->priv->blocking_id) { gst_pad_remove_data_probe (self->priv->rtpbin_pad, self->priv->blocking_id); self->priv->blocking_id = 0; } if (self->priv->rtpbin_pad) { gst_object_unref (self->priv->rtpbin_pad); self->priv->rtpbin_pad = NULL; } self->priv->disposed = TRUE; G_OBJECT_CLASS (fs_rtp_sub_stream_parent_class)->dispose (object); }
static gboolean _rtpbin_pad_have_data_callback (GstPad *pad, GstMiniObject *miniobj, gpointer user_data) { FsRtpSubStream *self = FS_RTP_SUB_STREAM (user_data); gboolean ret = TRUE; gboolean remove = FALSE; FsRtpSession *session; if (fs_rtp_session_has_disposed_enter (self->priv->session, NULL)) return FALSE; if (fs_rtp_sub_stream_has_stopped_enter (self)) { fs_rtp_session_has_disposed_exit (self->priv->session); return FALSE; } g_object_ref (self); session = g_object_ref (self->priv->session); FS_RTP_SESSION_LOCK (self->priv->session); if (!self->priv->codecbin || !self->codec || !self->priv->caps) { ret = FALSE; } else if (GST_IS_BUFFER (miniobj)) { if (!gst_caps_is_equal_fixed (GST_BUFFER_CAPS (miniobj), self->priv->caps)) { if (!gst_caps_can_intersect (GST_BUFFER_CAPS (miniobj), self->priv->caps)) ret = FALSE; } else { remove = TRUE; } } if (remove && self->priv->blocking_id) { gst_pad_remove_data_probe (pad, self->priv->blocking_id); self->priv->blocking_id = 0; } FS_RTP_SESSION_UNLOCK (self->priv->session); fs_rtp_sub_stream_has_stopped_exit (self); fs_rtp_session_has_disposed_exit (self->priv->session); g_object_unref (self); g_object_unref (session); return ret; }
static gboolean data_probe_once (GstPad * pad, GstMiniObject * obj, guint * data) { n_data_probes_once++; g_assert (GST_IS_MINI_OBJECT (obj)); gst_pad_remove_data_probe (pad, *data); return TRUE; }
static gboolean viewfinder_get_timestamp_probe (GstPad * pad, GstMiniObject * obj, gpointer udata) { CaptureTiming *timing; timing = (CaptureTiming *) g_list_first (capture_times)->data; timing->precapture = gst_util_get_timestamp (); gst_pad_remove_data_probe (pad, viewfinder_probe_id); return TRUE; }
static gboolean _rtpbin_pad_have_data_callback (GstPad *pad, GstMiniObject *miniobj, gpointer user_data) { FsRtpSubStream *self = FS_RTP_SUB_STREAM (user_data); gboolean ret = TRUE; gboolean remove = FALSE; FS_RTP_SESSION_LOCK (self->priv->session); if (!self->priv->codecbin || !self->codec || !self->priv->caps) { ret = FALSE; } else if (GST_IS_BUFFER (miniobj)) { if (!gst_caps_is_equal_fixed (GST_BUFFER_CAPS (miniobj), self->priv->caps)) { GstCaps *intersect = gst_caps_intersect (GST_BUFFER_CAPS (miniobj), self->priv->caps); if (gst_caps_is_empty (intersect)) ret = FALSE; else gst_buffer_set_caps (GST_BUFFER (miniobj), self->priv->caps); gst_caps_unref (intersect); } else { remove = TRUE; } } if (remove && self->priv->blocking_id) { gst_pad_remove_data_probe (pad, self->priv->blocking_id); self->priv->blocking_id = 0; } FS_RTP_SESSION_UNLOCK (self->priv->session); return ret; }
static void update_video_sink (GstFPSDisplaySink * self, GstElement * video_sink) { GstPad *sink_pad; if (self->video_sink) { /* remove pad probe */ sink_pad = gst_element_get_static_pad (self->video_sink, "sink"); gst_pad_remove_data_probe (sink_pad, self->data_probe_id); gst_object_unref (sink_pad); self->data_probe_id = -1; /* remove ghost pad target */ gst_ghost_pad_set_target (GST_GHOST_PAD (self->ghost_pad), NULL); /* remove old sink */ gst_bin_remove (GST_BIN (self), self->video_sink); gst_object_unref (self->video_sink); } /* create child elements */ self->video_sink = video_sink; if (self->video_sink == NULL) return; fps_display_sink_update_sink_sync (self); /* take a ref before bin takes the ownership */ gst_object_ref (self->video_sink); gst_bin_add (GST_BIN (self), self->video_sink); /* attach or pad probe */ sink_pad = gst_element_get_static_pad (self->video_sink, "sink"); self->data_probe_id = gst_pad_add_data_probe (sink_pad, G_CALLBACK (on_video_sink_data_flow), (gpointer) self); gst_object_unref (sink_pad); }
/* Create input-selector with given number of sink pads and switch given number of input buffers to each sink pad. */ void run_input_selector_buffer_count (gint num_input_pads, gint num_buffers_per_input) { /* set up input_pads ! selector ! output_pad */ gint i = 0, probe_id = 0; GList *input_pads = NULL, *output_pads = NULL; GstElement *sel = gst_check_setup_element ("input-selector"); GstPad *output_pad = gst_check_setup_sink_pad (sel, &sinktemplate, NULL); output_pads = g_list_append (output_pads, output_pad); gst_pad_set_active (output_pad, TRUE); for (i = 0; i < num_input_pads; i++) { input_pads = g_list_append (input_pads, setup_input_pad (sel)); } /* add probe */ probe_id = gst_pad_add_data_probe (output_pad, G_CALLBACK (probe_cb), NULL); g_object_set_data (G_OBJECT (output_pad), "probe_id", GINT_TO_POINTER (probe_id)); /* run the test */ fail_unless (gst_element_set_state (sel, GST_STATE_PLAYING) == GST_STATE_CHANGE_SUCCESS, "could not set to playing"); push_switched_buffers (input_pads, sel, input_pads, num_buffers_per_input); count_output_buffers (output_pads, (num_input_pads * num_buffers_per_input)); fail_unless (gst_element_set_state (sel, GST_STATE_NULL) == GST_STATE_CHANGE_SUCCESS, "could not set to null"); /* clean up */ gst_pad_remove_data_probe (output_pad, probe_id); gst_pad_set_active (output_pad, FALSE); gst_check_teardown_sink_pad (sel); GST_DEBUG ("setting selector pad to NULL"); selector_set_active_pad (sel, NULL); // unref input-selector active pad g_list_foreach (input_pads, (GFunc) cleanup_pad, sel); g_list_free (input_pads); g_list_free (output_pads); gst_check_teardown_element (sel); }
/* Clean up output/input pad and respective selector request pad */ void cleanup_pad (GstPad * pad, GstElement * element) { GstPad *selpad = NULL; guint probe_id = 0; fail_if (pad == NULL, "pad doesn't exist"); /* remove probe if necessary */ probe_id = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (pad), "probe_id")); if (probe_id) gst_pad_remove_data_probe (pad, probe_id); /* unlink */ selpad = gst_pad_get_peer (pad); if (GST_PAD_DIRECTION (selpad) == GST_PAD_SRC) { gst_pad_unlink (selpad, pad); } else { gst_pad_unlink (pad, selpad); } /* caps could have been set, make sure they get unset */ gst_pad_set_caps (pad, NULL); GST_DEBUG_OBJECT (pad, "clean up %" GST_PTR_FORMAT " and %" GST_PTR_FORMAT, selpad, pad); /* cleanup the pad */ gst_pad_set_active (pad, FALSE); ASSERT_OBJECT_REFCOUNT (pad, "pad", 1); gst_object_unref (pad); /* cleanup selector pad, reffed by this function (_get_peer) and creator */ gst_element_release_request_pad (element, selpad); gst_object_unref (selpad); }