GST-RTSP-Server + GST Pipelines (not in string/launch sintax)

Mariano Koremblum nicolas.koremblum at globant.com
Tue May 26 21:22:14 UTC 2020


Hi Michael! Thanks a lot, It helped me to solve the issue :). Later on I will
post the solution. Now I have another inconvenient. I can create "manually"
the pipelines by overriding this function, but now I want to have control of
the pipeline's bus, but can never catch the signals... Some of the code:

int main(void)
{
    GstRTSPMediaFactory *push = NULL;
    GstRTSPMediaFactory *pull = NULL;
    GstRTSPMountPoints *mounts = NULL;
    GstRTSPServer *server = NULL;

    int serviceID = -1;

    gst_init(NULL, NULL);

    push = g_object_new(TEST_TYPE_RTSP_MEDIA_FACTORY, NULL);
    pull = g_object_new(TEST_TYPE_RTSP_MEDIA_FACTORY, NULL);

    context = g_main_context_default();
    loop = g_main_loop_new(context, FALSE);

    server = gst_rtsp_server_new();

    gst_rtsp_server_set_address(server, IP);
    gst_rtsp_server_set_service(server, PORT);

    mounts = gst_rtsp_server_get_mount_points(server);

    gst_rtsp_media_factory_set_shared(push, TRUE);
    gst_rtsp_mount_points_add_factory(mounts, PLAY_MOUNT_POINT, push);

    gst_rtsp_media_factory_set_transport_mode(pull,
GST_RTSP_TRANSPORT_MODE_RECORD);
    gst_rtsp_media_factory_set_shared(pull, TRUE);
    gst_rtsp_mount_points_add_factory(mounts, RECORD_MOUNT_POINT, pull);

    serviceID = gst_rtsp_server_attach(server,
g_main_loop_get_context(loop));

    g_object_unref(mounts);

    g_main_loop_run(loop);

    return 0;
}

/*

.
.
.

*/

static GstElement *
custom_create_element(GstRTSPMediaFactory *factory, const GstRTSPUrl *url)
{
    pipe = (strPipeline *)malloc(sizeof(strPipeline));

    /* + + + + + Elements Linking and result checking + + + + + */
    pipe->pipeline = gst_pipeline_new("pipeline");               // Creates
Pipeline
    .
    .
    // MANY SUCCESSFULLY ELEMENTS CREATION, BIN ADDING AND LINKING
    .
    .

    pipe->bus = gst_pipeline_get_bus(GST_PIPELINE(pipe->pipeline));
    gst_bus_add_signal_watch_full (g_pushPipe->bus, G_PRIORITY_HIGH);
    g_signal_connect (g_pushPipe->bus, "message::error",(GCallback)
handle_bus, NULL);
    g_signal_connect (g_pushPipe->bus, "message::warning",(GCallback)
handle_bus, NULL);
    g_signal_connect (g_pushPipe->bus, "message::eos",(GCallback)
handle_bus, NULL);
    g_signal_connect (g_pushPipe->bus, "message::state-changed",(GCallback)
handle_bus, NULL);
}




/*

.
.
.

*/

static void
handle_bus_messages (GstBus * bus, GstMessage * message, GstPipeline *
pipeline)
{
    g_print("Just HI!\n\n");
}

/* +++++++++++++++++++  END OF CODE  +++++++++++++++++++++ */

This "custom_create_element" is asynchronously called when a client connects
to the server and is handled by gst/rtsp... the using of
"g_main_loop_get_context" was just an experiment, I get the same result just
using "NULL"...

So, the legend "Just HI!" never shows, and I can not think in any other
solution. Does anyone have any idea how to do it? The pipeline and server
works fine both, just can't access the bus' messages.



--
Sent from: http://gstreamer-devel.966125.n4.nabble.com/


More information about the gstreamer-devel mailing list