string connection_start (string name, string session, bool again) { // cout << "Start " << name << ", " << session << "\n"; if (!connection_declared (name)) return "Error: connection " * name * " has not been declared"; connection con= connection (name * "-" * session); if (is_nil (con)) { if (DEBUG_VERBOSE) debug_io << "Starting session '" << session << "'\n"; tree t= connection_info (name, session); if (is_tuple (t, "pipe", 1)) { tm_link ln= make_pipe_link (t[1]->label); con= tm_new<connection_rep> (name, session, ln); } #ifndef QTTEXMACS else if (is_tuple (t, "socket", 2)) { tm_link ln= make_socket_link (t[1]->label, as_int (t[2]->label)); con= tm_new<connection_rep> (name, session, ln); } #endif else if (is_tuple (t, "dynlink", 3)) { tm_link ln= make_dynamic_link (t[1]->label, t[2]->label, t[3]->label, session); con= tm_new<connection_rep> (name, session, ln); } } return con->start (again); }
gboolean gst_editor_link_link (GstEditorLink * link) { GObject * src, *sink; GstPad * srcpad = NULL, * sinkpad = NULL; GooCanvasItem * item; GooCanvasLineDash * dash; g_return_val_if_fail (GST_IS_EDITOR_LINK (link), FALSE); if (!link->srcpad || !link->sinkpad) goto error; src = (GObject *)GST_EDITOR_ITEM (link->srcpad)->object; sink = (GObject *)GST_EDITOR_ITEM (link->sinkpad)->object; if (!GST_EDITOR_PAD (link->srcpad)->istemplate) { if (!GST_EDITOR_PAD (link->sinkpad)->istemplate) { if (GST_PAD_PEER (src) || GST_PAD_PEER (sink)) { /*if (GST_PAD_PEER (src) != (GstPad *) sink) { g_warning ("The src pad is linked, but not to the sink pad"); goto error; } if (GST_PAD_PEER (sink) != (GstPad *) src) { g_warning ("The sink pad is linked, but not to the src pad"); goto error; } */ srcpad = GST_PAD (src); sinkpad = GST_PAD (sink); goto linked; /* yay goto */ } } else if (GST_PAD_PEER (src)) { /* the to pad is a template */ g_warning ("The src pad is linked, but not to the sink pad"); goto error; } } else if (!GST_EDITOR_PAD (link->sinkpad)->istemplate && GST_PAD_PEER (sink)) { /* from pad is a template */ g_warning ("The sink pad is linked, but not to the src pad"); goto error; } if (link->ghost) { g_object_set ( G_OBJECT (GOO_CANVAS_ITEM (link)), "fill-color", "grey70", NULL); goto linked; } else if (GST_IS_EDITOR_PAD_SOMETIMES (link->srcpad) || GST_IS_EDITOR_PAD_SOMETIMES (link->sinkpad)) { make_dynamic_link (link); g_object_set ( G_OBJECT (GOO_CANVAS_ITEM (link)), "fill-color", "grey50", NULL); goto linked; } else { if (!GST_EDITOR_PAD (link->srcpad)->istemplate) { srcpad = GST_PAD (src); } else if (GST_IS_EDITOR_PAD_REQUEST (link->srcpad)) { srcpad = gst_element_get_request_pad ( (GstElement *)GST_EDITOR_ITEM ( goo_canvas_item_get_parent (GOO_CANVAS_ITEM (link->srcpad))) ->object, GST_PAD_TEMPLATE (src)->name_template); /* the new_pad signal will cause a new pad to made automagically in the element */ g_object_set (G_OBJECT (GOO_CANVAS_ITEM (link)), "src-pad", gst_editor_item_get ((GstObject *)srcpad), NULL); } else { goto error; } if (!srcpad) goto error; if (!GST_EDITOR_PAD (link->sinkpad)->istemplate) { sinkpad = GST_PAD (sink); } else if (GST_IS_EDITOR_PAD_REQUEST (link->sinkpad)) { sinkpad = gst_element_get_request_pad ( (GstElement *)GST_EDITOR_ITEM ( goo_canvas_item_get_parent (GOO_CANVAS_ITEM (link->sinkpad))) ->object, GST_PAD_TEMPLATE (sink)->name_template); g_object_set (G_OBJECT (GOO_CANVAS_ITEM (link)), "sink-pad", gst_editor_item_get ((GstObject *)sinkpad), NULL); } else { goto error; } if (!sinkpad) goto error; if (gst_pad_link (srcpad, sinkpad) == GST_PAD_LINK_OK) { GstEditorBin * srcbin, *sinkbin; g_object_set ( G_OBJECT (GOO_CANVAS_ITEM (link)), "fill-color", "black", NULL); linked: srcbin = sinkbin = NULL; dash = goo_canvas_line_dash_new (0, NULL); g_object_set (G_OBJECT (GOO_CANVAS_ITEM (link)), "line-dash", dash, NULL); goo_canvas_line_dash_unref (dash); g_signal_connect (link->srcpad, "position-changed", G_CALLBACK (on_editor_pad_position_changed), G_OBJECT (link)); g_signal_connect (link->sinkpad, "position-changed", G_CALLBACK (on_editor_pad_position_changed), G_OBJECT (link)); /* don't connect a signal on a ghost or dynamic link */ g_print ( "adding unlinked signal for src: %p and sink %p", srcpad, sinkpad); if (srcpad && sinkpad) { GST_CAT_DEBUG (gste_debug_cat, "link pad signal (%s:%s from %s:%s) with link %p", GST_DEBUG_PAD_NAME (srcpad), GST_DEBUG_PAD_NAME (sinkpad), link); g_signal_connect (srcpad, "unlinked", G_CALLBACK (on_pad_unlink), link); g_signal_connect ( sinkpad, "unlinked", G_CALLBACK (on_pad_unlink), link); } item = goo_canvas_item_get_parent ( goo_canvas_item_get_parent (GOO_CANVAS_ITEM (link->srcpad))); if (GST_IS_EDITOR_BIN (item)) srcbin = GST_EDITOR_BIN (item); item = goo_canvas_item_get_parent ( goo_canvas_item_get_parent (GOO_CANVAS_ITEM (link->sinkpad))); if (GST_IS_EDITOR_BIN (item)) sinkbin = GST_EDITOR_BIN (item); if (sinkbin) sinkbin->links = g_list_prepend (sinkbin->links, link); if (srcbin && sinkbin != srcbin) srcbin->links = g_list_prepend (srcbin->links, link); return TRUE; } } error: g_message ("could not link"); if (link->srcpad) GST_EDITOR_PAD (link->srcpad)->link = NULL; if (link->sinkpad) GST_EDITOR_PAD (link->sinkpad)->link = NULL; return FALSE; }