static GstPadProbeReturn buffer_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) { gboolean call; GST_DEBUG_OBJECT (pad, "Removing probe %lu", GST_PAD_PROBE_INFO_ID (info)); G_LOCK (hash_mutex); if (!g_hash_table_contains (padhash, pad)) { GST_DEBUG ("Inserting %" GST_PTR_FORMAT, pad); g_hash_table_insert (padhash, GST_OBJECT_NAME (pad), NULL); G_UNLOCK (hash_mutex); call = g_atomic_int_dec_and_test (&counter); } else { G_UNLOCK (hash_mutex); call = FALSE; } gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info)); if (call) { g_idle_add (recv_callback, cb_data); } return GST_PAD_PROBE_OK; }
static GstPadProbeReturn tee_idle_probe_cb(GstPad *teepad, GstPadProbeInfo *info, gpointer user_data) { OwrMediaSource * media_source = user_data; GstElement *sink_bin; GstPad *sinkpad; GstObject *parent; GstElement *tee; gst_pad_remove_probe(teepad, GST_PAD_PROBE_INFO_ID(info)); sinkpad = gst_pad_get_peer(teepad); g_assert(sinkpad); sink_bin = GST_ELEMENT(gst_object_get_parent(GST_OBJECT(sinkpad))); g_warn_if_fail(gst_pad_unlink(teepad, sinkpad)); parent = gst_pad_get_parent(teepad); tee = GST_ELEMENT(parent); gst_element_release_request_pad(tee, teepad); gst_object_unref(parent); gst_object_unref(sinkpad); parent = gst_object_get_parent(GST_OBJECT(sink_bin)); g_assert(parent); gst_bin_remove(GST_BIN(parent), sink_bin); gst_element_set_state(sink_bin, GST_STATE_NULL); gst_object_unref(sink_bin); gst_object_unref(parent); GST_DEBUG_OBJECT(media_source, "Source successfully unlinked"); return GST_PAD_PROBE_OK; }
static GstPadProbeReturn pad_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) { GstElement *dummysrc; gboolean success; gchar *padname; GST_DEBUG_OBJECT (pad, "pad is blocked now"); /* remove the probe first */ gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info)); dummysrc = gst_pad_get_parent_element (pad); fail_if (dummysrc == NULL); padname = gst_pad_get_name (pad); GST_DEBUG_OBJECT (dummysrc, "Invoking action release-requested-pad for %s", padname); g_signal_emit_by_name (dummysrc, "release-requested-pad", padname, &success); fail_if (!success); g_object_unref (dummysrc); g_free (padname); return GST_PAD_PROBE_OK; }
GstPadProbeReturn MediaPlayer::cb_event_probe_toggle_splitter(GstPad *pad, GstPadProbeInfo *info, gpointer user_data) { MediaPlayer * self = reinterpret_cast<MediaPlayer*>( user_data ); // remove the probe first gst_pad_remove_probe( pad, GST_PAD_PROBE_INFO_ID (info) ); // Is the element already in the bin? if ( self->m_gst_audio_karaokesplitter == 0 ) { Logger::debug( "GstMediaPlayer: karaokesplitter is not enabled, enabling"); self->m_gst_audio_karaokesplitter = self->createElement ("audiokaraoke", "karaoke", false ); // This might happen if the player requested it despite us returning no such capability if ( !self->m_gst_audio_karaokesplitter ) return GST_PAD_PROBE_OK; // Add splitter into the bin gst_bin_add( GST_BIN (self->m_gst_pipeline), self->m_gst_audio_karaokesplitter ); // Unlink the place for the splitter gst_element_unlink( self->m_gst_audioconverter, self->m_gst_audio_volume ); // Link it in gst_element_link_many( self->m_gst_audioconverter, self->m_gst_audio_karaokesplitter, self->m_gst_audio_volume, NULL ); // And start playing it gst_element_set_state( self->m_gst_audio_karaokesplitter, GST_STATE_PLAYING ); Logger::debug( "GstMediaPlayer: karaoke splitter enabled"); } else { Logger::debug( "GstMediaPlayer: karaokesplitter is enabled, disabling"); // Stop the splitter gst_element_set_state( self->m_gst_audio_karaokesplitter, GST_STATE_NULL ); // Remove splitter from the bin (it unlinks it too) gst_bin_remove( GST_BIN (self->m_gst_pipeline), self->m_gst_audio_karaokesplitter ); self->m_gst_audio_karaokesplitter = 0; // And link the disconnected elements again gst_element_link_many( self->m_gst_audioconverter, self->m_gst_audio_volume, NULL ); Logger::debug( "GstMediaPlayer: karaoke splitter disabled"); } return GST_PAD_PROBE_OK; }
static GstPadProbeReturn data_probe_cb (GstPad * pad, GstPadProbeInfo * info, KmsConnectData * data) { GstBuffer *buffer; GstMapInfo minfo; gchar *msg; buffer = GST_PAD_PROBE_INFO_BUFFER (info); if (!gst_buffer_map (buffer, &minfo, GST_MAP_READ)) { GST_ERROR_OBJECT (pad, "Failed to map input buffer"); return GST_FLOW_ERROR; } msg = g_strndup ((const gchar *) minfo.data, minfo.size); GST_INFO ("Buffer content: (%s)", msg); g_free (msg); gst_buffer_unmap (buffer, &minfo); gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info)); CONNECT_DATA_LOCK (data); if (!data->data_buff) { gboolean actived; data->data_buff = TRUE; CONNECT_DATA_UNLOCK (data); GST_DEBUG_OBJECT (data->sink, "Disabling reception of data stream"); g_object_get (G_OBJECT (data->sink), "data", &actived, NULL); if (actived) { /* Do not accept more data */ g_object_set (G_OBJECT (data->sink), "data", FALSE, NULL); } else { gchar *padname; gboolean success; padname = gst_pad_get_name (pad); g_signal_emit_by_name (data->sink, "release-requested-pad", padname, &success); fail_if (!success); } } else { CONNECT_DATA_UNLOCK (data); } return GST_PAD_PROBE_OK; }
static GstPadProbeReturn event_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) { GMainLoop *loop = user_data; GstElement *next; if (GST_EVENT_TYPE (GST_PAD_PROBE_INFO_DATA (info)) != GST_EVENT_EOS) return GST_PAD_PROBE_OK; gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info)); /* push current event back into the queue */ g_queue_push_tail (&effects, gst_object_ref (cur_effect)); /* take next effect from the queue */ next = g_queue_pop_head (&effects); if (next == NULL) { GST_DEBUG_OBJECT (pad, "no more effects"); g_main_loop_quit (loop); return GST_PAD_PROBE_DROP; } g_print ("Switching from '%s' to '%s'..\n", GST_OBJECT_NAME (cur_effect), GST_OBJECT_NAME (next)); gst_element_set_state (cur_effect, GST_STATE_NULL); /* remove unlinks automatically */ GST_DEBUG_OBJECT (pipeline, "removing %" GST_PTR_FORMAT, cur_effect); gst_bin_remove (GST_BIN (pipeline), cur_effect); GST_DEBUG_OBJECT (pipeline, "adding %" GST_PTR_FORMAT, next); gst_bin_add (GST_BIN (pipeline), next); GST_DEBUG_OBJECT (pipeline, "linking.."); gst_element_link_many (conv_before, next, conv_after, NULL); gst_element_set_state (next, GST_STATE_PLAYING); cur_effect = next; GST_DEBUG_OBJECT (pipeline, "done"); return GST_PAD_PROBE_DROP; }
static GstPadProbeReturn video_probe_cb (GstPad * pad, GstPadProbeInfo * info, KmsConnectData * data) { GST_DEBUG_OBJECT (pad, "buffer received"); gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info)); CONNECT_DATA_LOCK (data); if (!data->video_buff) { data->video_buff = TRUE; CONNECT_DATA_UNLOCK (data); GST_DEBUG_OBJECT (data->sink, "Disabling reception of video stream"); /* Do not accept more video data */ g_object_set (G_OBJECT (data->sink), "video", FALSE, NULL); } else { CONNECT_DATA_UNLOCK (data); } return GST_PAD_PROBE_OK; }
GstPadProbeReturn stop_pad_cb (GstPad *pad, GstPadProbeInfo *info, gpointer data) { MbMedia *media = NULL; GstPad *peer; GST_DEBUG_OBJECT(pad, "pad is blocked now"); /* first remove the probe */ gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID(info)); media = (MbMedia *) data; g_assert (media); peer = gst_pad_get_peer (pad); g_assert(peer); gst_pad_send_event (peer, gst_event_new_eos ()); gst_object_unref(peer); return GST_PAD_PROBE_OK; }
static GstPadProbeReturn pad_probe_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) { GstPad *srcpad, *sinkpad; GST_DEBUG_OBJECT (pad, "pad is blocked now"); /* remove the probe first */ gst_pad_remove_probe (pad, GST_PAD_PROBE_INFO_ID (info)); /* install new probe for EOS */ srcpad = gst_element_get_static_pad (cur_effect, "src"); gst_pad_add_probe (srcpad, GST_PAD_PROBE_TYPE_BLOCK | GST_PAD_PROBE_TYPE_EVENT_DOWNSTREAM, event_probe_cb, user_data, NULL); gst_object_unref (srcpad); /* push EOS into the element, the probe will be fired when the * EOS leaves the effect and it has thus drained all of its data */ sinkpad = gst_element_get_static_pad (cur_effect, "sink"); gst_pad_send_event (sinkpad, gst_event_new_eos ()); gst_object_unref (sinkpad); return GST_PAD_PROBE_OK; }