static void type_found (GstElement * typefind, guint probability, GstCaps * caps, GstSplitMuxPartReader * reader) { GstElement *demux; GST_INFO_OBJECT (reader, "Got type %" GST_PTR_FORMAT, caps); /* typefind found a type. Look for the demuxer to handle it */ demux = reader->demux = find_demuxer (caps); if (reader->demux == NULL) { GST_ERROR_OBJECT (reader, "Failed to create demuxer element"); return; } /* Connect to demux signals */ g_signal_connect (demux, "pad-added", G_CALLBACK (new_decoded_pad_added_cb), reader); g_signal_connect (demux, "no-more-pads", G_CALLBACK (no_more_pads), reader); gst_element_set_locked_state (demux, TRUE); gst_bin_add (GST_BIN_CAST (reader), demux); gst_element_link_pads (reader->typefind, "src", demux, NULL); gst_element_set_state (reader->demux, GST_STATE_TARGET (reader)); gst_element_set_locked_state (demux, FALSE); }
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); }
bool PlayerGst::prepare() { GstElement *dec, *conv, *sink, *audio, *vol, *playbin; GstPad *audiopad; pipeline = gst_pipeline_new ("pipeline"); bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline)); dec = gst_element_factory_make ("decodebin", "decoder"); g_signal_connect (dec, "new-decoded-pad", G_CALLBACK (cb_newpad), NULL); gst_bin_add (GST_BIN (pipeline), dec); audio = gst_bin_new ("audiobin"); conv = gst_element_factory_make ("audioconvert", "aconv"); audiopad = gst_element_get_static_pad (conv, "sink"); vol = gst_element_factory_make ("volume", "volume"); sink = gst_element_factory_make ("autoaudiosink", "sink"); gst_bin_add_many (GST_BIN (audio), conv, vol, sink, NULL); gst_element_link (conv, vol); gst_element_link (vol, sink); gst_element_add_pad (audio, gst_ghost_pad_new ("sink", audiopad)); gst_object_unref (audiopad); gst_bin_add (GST_BIN (pipeline), audio); GstElement *l_src, *http_src; l_src = gst_element_factory_make ("filesrc", "localsrc"); http_src = gst_element_factory_make("neonhttpsrc", "httpsrc"); gst_bin_add_many (GST_BIN (pipeline), l_src, http_src, NULL); gst_element_set_state (l_src, GST_STATE_NULL); gst_element_set_locked_state (l_src, TRUE); gst_element_set_state (http_src, GST_STATE_NULL); gst_element_set_locked_state (http_src, TRUE); //gst_element_link (src, dec); if(canUsePlaybin) { playbin = gst_element_factory_make ("playbin2", "player"); if(playbin) g_signal_connect(playbin, "about-to-finish", G_CALLBACK(gst_finish), NULL); else playbin = gst_element_factory_make ("playbin", "player"); gst_bin_add (GST_BIN (pipeline), playbin); //g_object_set (G_OBJECT(playbin), "audio-sink", audio, NULL); gst_element_set_state (playbin, GST_STATE_NULL); gst_element_set_locked_state (playbin, TRUE); //sync_set_state(player, GST_STATE_NULL); // gst_element_set_state (GST_ELEMENT (player), GST_STATE_NULL); } return pipeline; }
static gpointer stop_source_thread (gpointer data) { FsRtpSpecialSource *self = FS_RTP_SPECIAL_SOURCE (data); gst_element_set_locked_state (self->priv->src, TRUE); gst_element_set_state (self->priv->src, GST_STATE_NULL); FS_RTP_SPECIAL_SOURCE_LOCK (self); if (self->priv->muxer_request_pad) { gst_element_release_request_pad (self->priv->rtpmuxer, self->priv->muxer_request_pad); gst_object_unref (self->priv->muxer_request_pad); } self->priv->muxer_request_pad = NULL; gst_bin_remove (GST_BIN (self->priv->outer_bin), self->priv->src); self->priv->src = NULL; FS_RTP_SPECIAL_SOURCE_UNLOCK (self); g_object_unref (self); return NULL; }
int main (int argc, char *argv[]) { TestPipeline *pipeline = test_pipeline_new (argc, argv); if (!pipeline) { return 1; } g_object_set (pipeline->src, "mode", 2, NULL); GstElement *filesink = gst_element_factory_make ("filesink", NULL); gst_element_set_locked_state (filesink, TRUE); g_object_set (filesink, "location", "foo.yuv", NULL); gst_bin_add (GST_BIN (pipeline->pipeline), filesink); if (!gst_element_link_pads (pipeline->src, "vidsrc", filesink, "sink")) { g_printerr ("Failed to link filesink"); return 1; } GstPad *pad = gst_element_get_static_pad (pipeline->src, "vidsrc"); gst_pad_add_data_probe (pad, G_CALLBACK (vidsrc_data_probe), filesink); gst_object_unref (pad); g_timeout_add (5000, start_video_capture, pipeline); g_timeout_add (10000, stop_video_capture, pipeline); return test_pipeline_exec (pipeline, 11000); }
static gboolean remove_adder (GstElement * adder) { KmsAudioMixer *self; self = (KmsAudioMixer *) gst_element_get_parent (adder); if (self == NULL) { GST_WARNING_OBJECT (adder, "No parent element"); return FALSE; } GST_DEBUG ("Removing element %" GST_PTR_FORMAT, adder); kms_audio_mixer_remove_sometimes_src_pad (self, adder); gst_object_ref (adder); gst_element_set_locked_state (adder, TRUE); gst_element_set_state (adder, GST_STATE_NULL); gst_bin_remove (GST_BIN (self), adder); gst_object_unref (adder); gst_object_unref (self); return G_SOURCE_REMOVE; }
static void pad_removed (GstElement * element, GstPad * pad, KmsPlayerEndPoint * self) { GST_DEBUG ("Pad removed"); GstElement *appsink, *appsrc; if (GST_PAD_IS_SINK (pad)) return; appsink = g_object_steal_data (G_OBJECT (pad), APPSINK_DATA); appsrc = g_object_steal_data (G_OBJECT (pad), APPSRC_DATA); if (appsrc != NULL) { GST_INFO ("Removing %" GST_PTR_FORMAT " from its parent", appsrc); if (GST_OBJECT_PARENT (appsrc) != NULL) { g_object_ref (appsrc); gst_bin_remove (GST_BIN (GST_OBJECT_PARENT (appsrc)), appsrc); gst_element_set_state (appsrc, GST_STATE_NULL); g_object_unref (appsrc); } } if (appsink == NULL) { GST_ERROR ("No appsink was found associated with %" GST_PTR_FORMAT, pad); return; } if (!gst_element_set_locked_state (appsink, TRUE)) GST_ERROR ("Could not block element %s", GST_ELEMENT_NAME (appsink)); GST_DEBUG ("Removing appsink %s from %s", GST_ELEMENT_NAME (appsink), GST_ELEMENT_NAME (self->priv->pipeline)); gst_element_set_state (appsink, GST_STATE_NULL); gst_bin_remove (GST_BIN (self->priv->pipeline), appsink); }
static void gst_camerabin_image_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec) { GstCameraBinImage *bin = GST_CAMERABIN_IMAGE (object); switch (prop_id) { case PROP_FILENAME: g_string_assign (bin->filename, g_value_get_string (value)); GST_INFO_OBJECT (bin, "received filename: '%s'", bin->filename->str); if (bin->sink) { if (!g_str_equal (bin->filename->str, "")) { g_object_set (G_OBJECT (bin->sink), "location", bin->filename->str, NULL); gst_element_set_locked_state (bin->sink, FALSE); gst_element_sync_state_with_parent (bin->sink); } else { GST_INFO_OBJECT (bin, "empty filename"); } } else { GST_INFO_OBJECT (bin, "no sink, not setting name yet"); } break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); break; } }
/* remove the source from the pipeline after removing it from adder */ static void remove_source (SourceInfo * info) { g_print ("remove freq %f\n", info->freq); /* lock the state so that we can put it to NULL without the parent messing * with our state */ gst_element_set_locked_state (info->element, TRUE); /* first stop the source. Remember that this might block when in the PAUSED * state. Alternatively one could send EOS to the source, install an event * probe and schedule a state change/unlink/release from the mainthread. * Note that changing the state of a source makes it emit an EOS, which can * make adder go EOS. */ gst_element_set_state (info->element, GST_STATE_NULL); /* unlink from adder */ gst_pad_unlink (info->srcpad, info->sinkpad); gst_object_unref (info->srcpad); /* remove from the bin */ gst_bin_remove (GST_BIN (pipeline), info->element); /* give back the pad */ gst_element_release_request_pad (adder, info->sinkpad); gst_object_unref (info->sinkpad); g_free (info); }
static void fs_rtp_sub_stream_try_stop (FsRtpSubStream *substream) { FS_RTP_SUB_STREAM_LOCK (substream); if (!substream->priv->stopped || substream->priv->modifying) { FS_RTP_SUB_STREAM_UNLOCK (substream); return; } FS_RTP_SUB_STREAM_UNLOCK (substream); if (substream->priv->rtpbin_unlinked_sig) { g_signal_handler_disconnect (substream->priv->rtpbin_pad, substream->priv->rtpbin_unlinked_sig); substream->priv->rtpbin_unlinked_sig = 0; } gst_pad_set_blocked_async (substream->priv->rtpbin_pad, FALSE, do_nothing_blocked_callback, NULL); if (substream->priv->output_ghostpad) gst_pad_set_active (substream->priv->output_ghostpad, FALSE); if (substream->priv->output_valve) { gst_element_set_locked_state (substream->priv->output_valve, TRUE); gst_element_set_state (substream->priv->output_valve, GST_STATE_NULL); } if (substream->priv->codecbin) { gst_element_set_locked_state (substream->priv->codecbin, TRUE); gst_element_set_state (substream->priv->codecbin, GST_STATE_NULL); } if (substream->priv->capsfilter) { gst_element_set_locked_state (substream->priv->capsfilter, TRUE); gst_element_set_state (substream->priv->capsfilter, GST_STATE_NULL); } if (substream->priv->input_valve) { gst_element_set_locked_state (substream->priv->input_valve, TRUE); gst_element_set_state (substream->priv->input_valve, GST_STATE_NULL); } }
static void fs_msn_stream_dispose (GObject *object) { FsMsnStream *self = FS_MSN_STREAM (object); FsMsnConference *conference = fs_msn_stream_get_conference (self, NULL); if (!conference) return; g_mutex_lock (&self->priv->mutex); self->priv->conference = NULL; g_mutex_unlock (&self->priv->mutex); if (self->priv->src_pad) { gst_pad_set_active (self->priv->src_pad, FALSE); gst_element_remove_pad (GST_ELEMENT (conference), self->priv->src_pad); self->priv->src_pad = NULL; } if (self->priv->recv_valve) { gst_object_unref (self->priv->recv_valve); self->priv->recv_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 (conference), self->priv->codecbin); self->priv->codecbin = NULL; } if (self->priv->participant) { g_object_unref (self->priv->participant); self->priv->participant = NULL; } if (self->priv->session) { g_object_unref (self->priv->session); self->priv->session = NULL; } if (self->priv->connection) { g_object_unref (self->priv->connection); self->priv->connection = NULL; } gst_object_unref (conference); gst_object_unref (conference); G_OBJECT_CLASS (fs_msn_stream_parent_class)->dispose (object); }
void fs_rtp_sub_stream_stop (FsRtpSubStream *substream) { substream->priv->stopped = TRUE; g_static_rw_lock_writer_lock (&substream->priv->stopped_lock); substream->priv->stopped = TRUE; g_static_rw_lock_writer_unlock (&substream->priv->stopped_lock); if (substream->priv->rtpbin_unlinked_sig) { g_signal_handler_disconnect (substream->priv->rtpbin_pad, substream->priv->rtpbin_unlinked_sig); substream->priv->rtpbin_unlinked_sig = 0; } gst_pad_set_blocked_async (substream->priv->rtpbin_pad, FALSE, do_nothing_blocked_callback, NULL); if (substream->priv->output_ghostpad) gst_pad_set_active (substream->priv->output_ghostpad, FALSE); if (substream->priv->output_valve) { gst_element_set_locked_state (substream->priv->output_valve, TRUE); gst_element_set_state (substream->priv->output_valve, GST_STATE_NULL); } if (substream->priv->codecbin) { gst_element_set_locked_state (substream->priv->codecbin, TRUE); gst_element_set_state (substream->priv->codecbin, GST_STATE_NULL); } if (substream->priv->capsfilter) { gst_element_set_locked_state (substream->priv->capsfilter, TRUE); gst_element_set_state (substream->priv->capsfilter, GST_STATE_NULL); } if (substream->priv->input_valve) { gst_element_set_locked_state (substream->priv->input_valve, TRUE); gst_element_set_state (substream->priv->input_valve, GST_STATE_NULL); } }
void empathy_video_src_set_resolution (GstElement *src, guint width, guint height) { EmpathyGstVideoSrcPrivate *priv = EMPATHY_GST_VIDEO_SRC_GET_PRIVATE (src); GstCaps *caps; GstPad *srcpad, *peer; g_return_if_fail (priv->capsfilter != NULL); gst_element_set_locked_state (priv->src, TRUE); gst_element_set_state (priv->src, GST_STATE_NULL); srcpad = gst_element_get_static_pad (priv->src, "src"); peer = gst_pad_get_peer (srcpad); /* Keep a ref as removing it from the bin will loose our reference */ gst_object_ref (priv->src); gst_bin_remove (GST_BIN (src), priv->src); g_object_get (priv->capsfilter, "caps", &caps, NULL); caps = gst_caps_make_writable (caps); gst_caps_set_simple (caps, "width", G_TYPE_INT, width, "height", G_TYPE_INT, height, NULL); g_object_set (priv->capsfilter, "caps", caps, NULL); gst_caps_unref (caps); gst_bin_add (GST_BIN (src), priv->src); /* We as the bin own the source again, so drop the temporary ref */ gst_object_unref (priv->src); gst_pad_link (srcpad, peer); gst_element_set_locked_state (priv->src, FALSE); gst_element_sync_state_with_parent (priv->src); gst_object_unref (srcpad); gst_object_unref (peer); }
static gboolean stop_data(GstElement *source) { if (gst_element_is_locked_state(source) == FALSE) { if (gst_element_set_locked_state(source, TRUE) == TRUE) { std::clog << "##### LOCK OK" << std::endl; std::clog << "##### LOCK NOW" << std::endl; GstState rtspstate; gst_element_get_state(source, &rtspstate, NULL, GST_CLOCK_TIME_NONE); switch (rtspstate) { case GST_STATE_PLAYING: gst_element_set_state(source, GST_STATE_PAUSED); gst_element_set_locked_state(source, FALSE); break; case GST_STATE_PAUSED: gst_element_set_state(source, GST_STATE_READY); gst_element_set_locked_state(source, FALSE); break; case GST_STATE_READY: gst_element_set_state(source, GST_STATE_NULL); gst_element_set_locked_state(source, FALSE); break; case GST_STATE_NULL: gst_object_unref(GST_OBJECT(source)); g_idle_remove_by_data(source); break; } std::clog << "########## State: " << gst_element_state_get_name( rtspstate) << std::endl; // gst_object_unref(GST_OBJECT(source)); } } }
static void mex_telepathy_channel_update_video_parameters (MexTelepathyChannel *self, gboolean restart) { MexTelepathyChannelPrivate *priv = self->priv; GstCaps *caps; GstPad *src, *peer; src = gst_element_get_static_pad (priv->video_input, "src"); peer = gst_pad_get_peer (src); if (restart) { /* Assuming the pipeline is in playing state */ gst_element_set_locked_state (priv->video_input, TRUE); gst_element_set_state (priv->video_input, GST_STATE_NULL); gst_bin_remove (GST_BIN (priv->pipeline), priv->video_input); } g_object_get (priv->video_capsfilter, "caps", &caps, NULL); caps = gst_caps_make_writable (caps); gst_caps_set_simple (caps, "framerate", GST_TYPE_FRACTION, priv->framerate, 1, "width", G_TYPE_INT, priv->width, "height", G_TYPE_INT, priv->height, NULL); g_object_set (priv->video_capsfilter, "caps", caps, NULL); if (restart) { gst_bin_add (GST_BIN (priv->pipeline), priv->video_input); gst_pad_link (src, peer); gst_element_set_locked_state (priv->video_input, FALSE); gst_element_sync_state_with_parent (priv->video_input); } gst_object_unref (src); gst_object_unref (peer); }
MediaElementImpl::~MediaElementImpl() { std::shared_ptr<MediaPipelineImpl> pipe; pipe = std::dynamic_pointer_cast<MediaPipelineImpl> (getMediaPipeline() ); gst_element_set_locked_state (element, TRUE); gst_element_set_state (element, GST_STATE_NULL); gst_bin_remove (GST_BIN ( pipe->getPipeline() ), element); g_object_unref (element); }
static GstStateChangeReturn ges_pipeline_change_state (GstElement * element, GstStateChange transition) { GESPipeline *self; GstStateChangeReturn ret; self = GES_PIPELINE (element); switch (transition) { case GST_STATE_CHANGE_READY_TO_PAUSED: if (G_UNLIKELY (self->priv->timeline == NULL)) { GST_ERROR_OBJECT (element, "No GESTimeline set on the pipeline, cannot play !"); ret = GST_STATE_CHANGE_FAILURE; goto done; } if (self->priv->mode & (GES_PIPELINE_MODE_RENDER | GES_PIPELINE_MODE_SMART_RENDER)) GST_DEBUG ("rendering => Updating pipeline caps"); /* Set caps on all tracks according to profile if present */ if (!ges_pipeline_update_caps (self)) { GST_ERROR_OBJECT (element, "Error setting the caps for rendering"); ret = GST_STATE_CHANGE_FAILURE; goto done; } _link_tracks (self); break; case GST_STATE_CHANGE_PAUSED_TO_READY: { GList *tmp; for (tmp = self->priv->not_rendered_tracks; tmp; tmp = tmp->next) gst_element_set_locked_state (tmp->data, FALSE); } break; default: break; } ret = GST_ELEMENT_CLASS (ges_pipeline_parent_class)->change_state (element, transition); switch (transition) { case GST_STATE_CHANGE_PAUSED_TO_READY: _unlink_tracks (self); break; default: break; } done: return ret; }
static gboolean vidsrc_data_probe (GstPad * pad, GstMiniObject * obj, gpointer user_data) { GstElement *elem = (GstElement *) user_data; gst_element_set_locked_state (elem, FALSE); gst_element_set_state (elem, GST_STATE_PLAYING); return TRUE; /* keep data. */ }
static void remove_from_parent (GstElement *element) { GstBin *parent = GST_BIN (GST_OBJECT_PARENT (element) ); if (parent == NULL) { return; } gst_element_set_locked_state (element, TRUE); gst_element_set_state (element, GST_STATE_NULL); gst_bin_remove (parent, element); }
/* remove the source from the pipeline after removing it from adder */ static void remove_source (SourceInfo * info) { g_print ("remove freq %5.0f, pos %3.1f\n", info->freq, info->pos); /* lock the state so that we can put it to NULL without the parent messing * with our state */ gst_element_set_locked_state (info->src, TRUE); gst_element_set_locked_state (info->fx, TRUE); /* first stop the source. Remember that this might block when in the PAUSED * state. Alternatively one could send EOS to the source, install an event * probe and schedule a state change/unlink/release from the mainthread. */ gst_element_set_state (info->fx, GST_STATE_NULL); /* NOTE that the source emits EOS when shutting down but the EOS will not * reach the adder sinkpad because the effect is in the NULL state. We will * send an EOS to adder later. */ gst_element_set_state (info->src, GST_STATE_NULL); /* unlink from adder */ gst_pad_unlink (info->src_srcpad, info->fx_sinkpad); gst_pad_unlink (info->fx_srcpad, info->adder_sinkpad); gst_object_unref (info->src_srcpad); gst_object_unref (info->fx_srcpad); gst_object_unref (info->fx_sinkpad); /* remove from the bin */ gst_bin_remove (GST_BIN (pipeline), info->src); gst_bin_remove (GST_BIN (pipeline), info->fx); /* send EOS to the sinkpad to make adder EOS when needed */ gst_pad_send_event (info->adder_sinkpad, gst_event_new_eos ()); /* give back the pad */ gst_element_release_request_pad (adder, info->adder_sinkpad); gst_object_unref (info->adder_sinkpad); g_free (info); }
static void gst_egueb_demux_init (GstEguebDemux * thiz, GstEguebDemuxClass * g_class) { GstPad *pad; GstPad *ghost_pad; /* Create the sink */ thiz->sink = gst_element_factory_make ("eguebxmlsink", "sink"); if (!thiz->sink) { GST_ERROR_OBJECT (thiz, "Unable to create 'eguebxmlsink' element"); goto error_parser; } /* Create svg source */ thiz->src = gst_element_factory_make ("eguebsrc", "src"); if (!thiz->src) { GST_ERROR_OBJECT (thiz, "Unable to create 'eguebsrc' element"); goto error_src; } /* until the element does not receive the xml, lock its state */ gst_element_set_locked_state (thiz->src, TRUE); /* Add it to the bin */ gst_bin_add_many (GST_BIN (thiz), thiz->src, thiz->sink, NULL); /* Create ghost pad and link it to the sink */ pad = gst_element_get_static_pad (thiz->sink, "sink"); ghost_pad = gst_ghost_pad_new ("sink", pad); gst_pad_set_active (ghost_pad, TRUE); gst_element_add_pad (GST_ELEMENT (thiz), ghost_pad); gst_object_unref (pad); /* Create ghost pad and link it to the src */ pad = gst_element_get_static_pad (thiz->src, "src"); ghost_pad = gst_ghost_pad_new ("video", pad); gst_pad_set_active (ghost_pad, TRUE); gst_element_add_pad (GST_ELEMENT (thiz), ghost_pad); gst_object_unref (pad); /* Initialize our internal members */ /* Set default property values */ return; error_src: gst_object_unref (thiz->sink); error_parser: return; }
GST_END_TEST static gboolean remove_audiotestsrc (GstElement * audiotestsrc) { GstElement *pipeline = GST_ELEMENT (gst_element_get_parent (audiotestsrc)); gst_object_ref (audiotestsrc); gst_element_set_locked_state (audiotestsrc, TRUE); gst_element_set_state (audiotestsrc, GST_STATE_NULL); if (!gst_bin_remove (GST_BIN (pipeline), audiotestsrc)) GST_ERROR ("Can not remove %" GST_PTR_FORMAT, audiotestsrc); gst_object_unref (pipeline); gst_object_unref (audiotestsrc); return G_SOURCE_REMOVE; }
static gboolean gst_a2dp_sink_remove_fakesink(GstA2dpSink *self) { g_mutex_lock(self->cb_mutex); if (self->fakesink != NULL) { gst_element_set_locked_state(self->fakesink, TRUE); gst_element_set_state(self->fakesink, GST_STATE_NULL); gst_bin_remove(GST_BIN(self), self->fakesink); self->fakesink = NULL; } g_mutex_unlock(self->cb_mutex); return TRUE; }
static void post_decodebin_pad_removed_handler (GstElement * decodebin, GstPad * pad, KmsHttpEndpoint * self) { GstElement *appsink, *appsrc; GstPad *sinkpad; if (GST_PAD_IS_SINK (pad)) return; GST_DEBUG ("pad %" GST_PTR_FORMAT " removed", pad); appsink = g_object_steal_qdata (G_OBJECT (pad), appsink_data_quark ()); if (appsink == NULL) { GST_ERROR ("No appsink was found associated with %" GST_PTR_FORMAT, pad); return; } sinkpad = gst_element_get_static_pad (appsink, "sink"); appsrc = g_object_get_qdata (G_OBJECT (sinkpad), appsrc_data_quark ()); g_object_unref (sinkpad); if (!gst_element_set_locked_state (appsink, TRUE)) GST_ERROR ("Could not block element %s", GST_ELEMENT_NAME (appsink)); GST_DEBUG ("Removing appsink %s from %s", GST_ELEMENT_NAME (appsink), GST_ELEMENT_NAME (self->pipeline)); gst_element_set_state (appsink, GST_STATE_NULL); gst_bin_remove (GST_BIN (self->pipeline), appsink); if (appsrc == NULL) { GST_ERROR ("No appsink was found associated with %" GST_PTR_FORMAT, pad); return; } if (GST_OBJECT_PARENT (appsrc) != NULL) { g_object_ref (appsrc); gst_bin_remove (GST_BIN (GST_OBJECT_PARENT (appsrc)), appsrc); gst_element_set_state (appsrc, GST_STATE_NULL); g_object_unref (appsrc); } }
static void remove_on_unlinked_async (gpointer data, gpointer not_used) { GstElement *elem = GST_ELEMENT_CAST (data); GstObject *parent = gst_object_get_parent (GST_OBJECT (elem)); gst_element_set_locked_state (elem, TRUE); if (g_strcmp0 (GST_OBJECT_NAME (gst_element_get_factory (elem)), "queue") == 0) { g_object_set (G_OBJECT (elem), "flush-on-eos", TRUE, NULL); gst_element_send_event (elem, gst_event_new_eos ()); } gst_element_set_state (elem, GST_STATE_NULL); if (parent != NULL) { gst_bin_remove (GST_BIN (parent), elem); g_object_unref (parent); } g_object_unref (data); }
static void request_pad_unlinked_cb(GstPad *pad, GstPad *peer, gpointer user_data) { GstElement *parent = GST_ELEMENT_PARENT(pad); GstIterator *iter; GstPad *remaining_pad; GstIteratorResult result; gst_element_release_request_pad(GST_ELEMENT_PARENT(pad), pad); iter = gst_element_iterate_src_pads(parent); result = gst_iterator_next(iter, (gpointer)&remaining_pad); if (result == GST_ITERATOR_DONE) { gst_element_set_locked_state(parent, TRUE); gst_element_set_state(parent, GST_STATE_NULL); gst_bin_remove(GST_BIN(GST_ELEMENT_PARENT(parent)), parent); } else if (result == GST_ITERATOR_OK) { gst_object_unref(remaining_pad); } gst_iterator_free(iter); }
/* * @mixer: (transfer floating): */ static gboolean gst_gl_mixer_bin_set_mixer (GstGLMixerBin * self, GstElement * mixer) { g_return_val_if_fail (GST_IS_ELEMENT (mixer), FALSE); if (self->mixer) { gst_element_set_locked_state (self->mixer, TRUE); gst_bin_remove (GST_BIN (self), self->mixer); gst_element_set_state (self->mixer, GST_STATE_NULL); gst_object_unref (self->mixer); self->mixer = NULL; } self->mixer = mixer; gst_object_ref_sink (mixer); if (mixer && !_connect_mixer_element (self)) { gst_object_unref (self->mixer); self->mixer = NULL; return FALSE; } return TRUE; }
/* * @src: (transfer full): */ static gboolean gst_gl_src_bin_set_src (GstGLSrcBin * self, GstElement * src) { g_return_val_if_fail (GST_IS_ELEMENT (src), FALSE); if (self->src) { gst_element_set_locked_state (self->src, TRUE); gst_bin_remove (GST_BIN (self), self->src); gst_element_set_state (self->src, GST_STATE_NULL); gst_object_unref (self->src); self->src = NULL; } self->src = src; if (src && g_object_is_floating (src)) gst_object_ref_sink (src); if (src && !_connect_src_element (self)) { self->src = NULL; return FALSE; } return TRUE; }
static gboolean gst_egueb_demux_handle_sink_message_sync (GstEguebDemux * thiz, GstMessage * message) { const GstStructure *s; const GValue *value; const gchar *uri; GstBuffer *buffer; GST_DEBUG_OBJECT (thiz, "XML buffer received"); s = gst_message_get_structure (message); value = gst_structure_get_value (s, "xml"); buffer = gst_value_get_buffer (value); uri = gst_structure_get_string (s, "uri"); /* now we have received the whole XML, is time to create our own * svg instance and start sending buffers! */ g_object_set (G_OBJECT (thiz->src), "xml", buffer, "uri", uri, NULL); gst_element_set_locked_state (thiz->src, FALSE); gst_element_sync_state_with_parent (thiz->src); return TRUE; }
static void gst_insert_bin_do_change (GstInsertBin * self, GstPad * pad) { struct ChangeData *data; GST_OBJECT_LOCK (self); if (!is_right_direction_for_block (pad)) { GST_WARNING_OBJECT (self, "Block pad does not have the expected direction"); goto next; } while ((data = g_queue_pop_head (&self->priv->change_queue)) != NULL) { GstPad *peer = NULL; GstPad *other_peer = NULL; GST_OBJECT_UNLOCK (self); if (data->action == GST_INSERT_BIN_ACTION_ADD && !validate_element (self, data->element)) goto error; peer = gst_pad_get_peer (pad); if (peer == NULL) { GST_WARNING_OBJECT (self, "Blocked pad has no peer"); goto error; } if (data->action == GST_INSERT_BIN_ACTION_ADD) { GstPad *srcpad = NULL, *sinkpad = NULL; GstPad *peersrcpad, *peersinkpad; /* First let's make sure we have the right pad */ if (data->sibling) { GstElement *parent = NULL; GstPad *siblingpad; if ((gst_pad_get_direction (pad) == GST_PAD_SRC && data->direction == DIRECTION_BEFORE) || (gst_pad_get_direction (pad) == GST_PAD_SINK && data->direction == DIRECTION_AFTER)) siblingpad = peer; else siblingpad = pad; parent = gst_pad_get_parent_element (siblingpad); if (parent != NULL) gst_object_unref (parent); if (parent != data->sibling) goto retry; } else { GstObject *parent; GstPad *ghost; GstPad *proxypad; if (data->direction == DIRECTION_BEFORE) { ghost = self->priv->srcpad; if (gst_pad_get_direction (pad) == GST_PAD_SINK) proxypad = pad; else proxypad = peer; } else { ghost = self->priv->sinkpad; if (gst_pad_get_direction (pad) == GST_PAD_SINK) proxypad = peer; else proxypad = pad; } if (!GST_IS_PROXY_PAD (proxypad)) goto retry; parent = gst_pad_get_parent (proxypad); if (!parent) goto retry; gst_object_unref (parent); if (GST_PAD_CAST (parent) != ghost) goto retry; } if (gst_pad_get_direction (pad) == GST_PAD_SRC) { peersrcpad = pad; peersinkpad = peer; } else { peersrcpad = peer; peersinkpad = pad; } if (GST_IS_PROXY_PAD (peersrcpad)) { GstObject *parent = gst_pad_get_parent (peersrcpad); if (GST_PAD_CAST (parent) == self->priv->sinkpad) peersrcpad = NULL; if (parent) gst_object_unref (parent); } if (GST_IS_PROXY_PAD (peersinkpad)) { GstObject *parent = gst_pad_get_parent (peersinkpad); if (GST_PAD_CAST (parent) == self->priv->srcpad) peersinkpad = NULL; if (parent) gst_object_unref (parent); } if (peersinkpad && peersrcpad) { gst_pad_unlink (peersrcpad, peersinkpad); } else { if (!peersinkpad) gst_ghost_pad_set_target (GST_GHOST_PAD (self->priv->srcpad), NULL); if (!peersrcpad) gst_ghost_pad_set_target (GST_GHOST_PAD (self->priv->sinkpad), NULL); } srcpad = get_single_pad (data->element, GST_PAD_SRC); sinkpad = get_single_pad (data->element, GST_PAD_SINK); if (srcpad == NULL || sinkpad == NULL) { GST_WARNING_OBJECT (self, "Can not get element src or sink pad"); goto error; } if (!gst_bin_add (GST_BIN (self), data->element)) { GST_WARNING_OBJECT (self, "Can not add element to bin"); goto error; } if (peersrcpad) { if (GST_PAD_LINK_FAILED (gst_pad_link (peersrcpad, sinkpad))) { GST_WARNING_OBJECT (self, "Can not link sibling's %s:%s pad" " to element's %s:%s pad", GST_DEBUG_PAD_NAME (peersrcpad), GST_DEBUG_PAD_NAME (sinkpad)); goto error; } } else { if (!gst_ghost_pad_set_target (GST_GHOST_PAD (self->priv->sinkpad), sinkpad)) { GST_WARNING_OBJECT (self, "Can not set %s:%s as target for %s:%s", GST_DEBUG_PAD_NAME (sinkpad), GST_DEBUG_PAD_NAME (self->priv->sinkpad)); goto error; } } if (peersinkpad) { if (GST_PAD_LINK_FAILED (gst_pad_link (srcpad, peersinkpad))) { GST_WARNING_OBJECT (self, "Can not link element's %s:%s pad" " to sibling's %s:%s pad", GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (peersinkpad)); goto error; } } else { if (!gst_ghost_pad_set_target (GST_GHOST_PAD (self->priv->srcpad), srcpad)) { GST_WARNING_OBJECT (self, "Can not set %s:%s as target for %s:%s", GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (self->priv->srcpad)); goto error; } } gst_object_unref (srcpad); gst_object_unref (sinkpad); if (!gst_element_sync_state_with_parent (data->element)) { GST_WARNING_OBJECT (self, "Can not sync element's state with parent"); goto error; } } else { GstElement *parent = NULL; GstPad *other_pad; GstCaps *caps = NULL, *peercaps = NULL; gboolean can_intersect; gboolean success; parent = gst_pad_get_parent_element (peer); if (parent != NULL) gst_object_unref (parent); if (parent != data->element) goto retry; if (gst_pad_get_direction (peer) == GST_PAD_SRC) other_pad = get_single_pad (data->element, GST_PAD_SINK); else other_pad = get_single_pad (data->element, GST_PAD_SRC); if (!other_pad) { GST_WARNING_OBJECT (self, "Can not get element's other pad"); goto error; } other_peer = gst_pad_get_peer (other_pad); gst_object_unref (other_pad); if (!other_peer) { GST_WARNING_OBJECT (self, "Can not get element's other peer"); goto error; } /* Get the negotiated caps for the source pad peer, * because renegotiation while the pipeline is playing doesn't work * that fast. */ if (gst_pad_get_direction (pad) == GST_PAD_SRC) caps = gst_pad_get_current_caps (pad); else peercaps = gst_pad_get_current_caps (other_peer); if (!caps) caps = gst_pad_query_caps (pad, NULL); if (!peercaps) peercaps = gst_pad_query_caps (other_peer, NULL); can_intersect = gst_caps_can_intersect (caps, peercaps); gst_caps_unref (caps); gst_caps_unref (peercaps); if (!can_intersect) { GST_WARNING_OBJECT (self, "Pads are incompatible without the element"); goto error; } if (gst_pad_get_direction (other_peer) == GST_PAD_SRC && gst_pad_is_active (other_peer)) { gulong probe_id; probe_id = gst_pad_add_probe (other_peer, GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, wait_and_drop_eos_cb, NULL, NULL); gst_pad_send_event (peer, gst_event_new_eos ()); gst_pad_remove_probe (other_peer, probe_id); } gst_element_set_locked_state (data->element, TRUE); gst_element_set_state (data->element, GST_STATE_NULL); if (!gst_bin_remove (GST_BIN (self), data->element)) { GST_WARNING_OBJECT (self, "Element removal rejected"); goto error; } gst_element_set_locked_state (data->element, FALSE); if (gst_pad_get_direction (pad) == GST_PAD_SRC) success = GST_PAD_LINK_SUCCESSFUL (gst_pad_link_full (pad, other_peer, GST_PAD_LINK_CHECK_HIERARCHY | GST_PAD_LINK_CHECK_TEMPLATE_CAPS)); else success = GST_PAD_LINK_SUCCESSFUL (gst_pad_link_full (other_peer, pad, GST_PAD_LINK_CHECK_HIERARCHY | GST_PAD_LINK_CHECK_TEMPLATE_CAPS)); gst_object_unref (other_peer); other_peer = NULL; if (!success) { GST_ERROR_OBJECT (self, "Could not re-link after the element's" " removal"); goto error; } } gst_insert_bin_change_data_complete (self, data, TRUE); gst_object_unref (peer); GST_OBJECT_LOCK (self); continue; done: if (other_peer != NULL) gst_object_unref (other_peer); if (peer != NULL) gst_object_unref (peer); break; retry: GST_OBJECT_LOCK (self); g_queue_push_head (&self->priv->change_queue, data); goto done; error: /* Handle error */ gst_insert_bin_change_data_complete (self, data, FALSE); GST_OBJECT_LOCK (self); goto done; } next: gst_insert_bin_block_pad_unlock (self); }