void *thread_vchannel_process (void * arg) { struct stream* s = NULL; int rv; int length; int total_length; signal(SIGCHLD, handler); cliprdr_send_ready(); cliprdr_send_capability(); while(running){ make_stream(s); init_stream(s, 1600); rv = vchannel_receive(cliprdr_channel, s->data, &length, &total_length); if( rv == ERROR ) { log_message(l_config, LOG_LEVEL_ERROR, "vchannel_cliprdr[thread_vchannel_process]: " "Invalid message"); vchannel_close(cliprdr_channel); pthread_exit ((void*)1); } switch(rv) { case ERROR: log_message(l_config, LOG_LEVEL_ERROR, "vchannel_cliprdr[thread_vchannel_process]: " "Invalid message"); break; case STATUS_CONNECTED: log_message(l_config, LOG_LEVEL_DEBUG, "vchannel_cliprdr[thread_vchannel_process]: " "Status connected"); break; case STATUS_DISCONNECTED: log_message(l_config, LOG_LEVEL_DEBUG, "vchannel_cliprdr[thread_vchannel_process]: " "Status disconnected"); running = 0; // Send a dummy event in order to unblock XNextEvent function send_dummy_event(); break; default: if (length == 0) { running = false; send_dummy_event(); pthread_exit (0); } cliprdr_process_message(s, length, total_length); break; } free_stream(s); } pthread_exit (0); }
static void remove_on_unlinked_cb (GstPad * pad, GstPad * peer, gpointer user_data) { GstElement *elem = gst_pad_get_parent_element (pad); GstObject *parent; KmsAgnosticBin2 *self; if (elem == NULL) { return; } parent = GST_OBJECT_PARENT (elem); if (parent == NULL) { goto end; } if (KMS_IS_AGNOSTIC_BIN2 (parent)) { self = KMS_AGNOSTIC_BIN2 (parent); } else { self = KMS_AGNOSTIC_BIN2 (GST_OBJECT_PARENT (parent)); } if (self != NULL) { GstPad *sink = gst_element_get_static_pad (elem, (gchar *) user_data); if (sink != NULL) { GstPad *peer = gst_pad_get_peer (sink); g_object_unref (sink); if (peer != NULL) { gst_pad_add_probe (peer, GST_PAD_PROBE_TYPE_BLOCK, remove_on_unlinked_blocked, g_object_ref (elem), g_object_unref); send_dummy_event (peer); gst_object_unref (peer); goto end; } } g_thread_pool_push (self->priv->remove_pool, g_object_ref (elem), NULL); } end: g_object_unref (elem); }
void kms_utils_execute_with_pad_blocked (GstPad * pad, gboolean drop, KmsPadCallback func, gpointer userData) { gulong probe_id; PadBlockedData *data = g_slice_new (PadBlockedData); data->callback = func; data->userData = userData; data->drop = drop; data->eventId = create_random_string (10); probe_id = gst_pad_add_probe (pad, (GstPadProbeType) (GST_PAD_PROBE_TYPE_BLOCK), pad_blocked_callback, data, NULL); send_dummy_event (pad, data->eventId); gst_pad_remove_probe (pad, probe_id); g_free (data->eventId); g_slice_free (PadBlockedData, data); }