How to use autovideosink instead of nveglglessink?

I am launching sample GStreamer app over VNC or x2go which creates following pipeline:

source = gst_element_factory_make ("videotestsrc", "source");
    sink = gst_element_factory_make ("autovideosink", "sink");
    pipeline = gst_pipeline_new ("test-pipeline");

And it works successfully under both remote desktops. But when I use this pipeline, it works on normal PC and fails over VNC/x2go:

pipeline = gst_pipeline_new ("dstest1-pipeline");
    source = gst_element_factory_make ("filesrc", "file-source");
    h264parser = gst_element_factory_make ("h264parse", "h264-parser");
    decoder = gst_element_factory_make ("nvv4l2decoder", "nvv4l2-decoder");
    streammux = gst_element_factory_make ("nvstreammux", "stream-muxer");
    if (!pipeline || !streammux) {
        g_printerr ("One element could not be created. Exiting.\n");
        return -1;
    pgie = gst_element_factory_make ("nvinfer", "primary-nvinference-engine");
    nvvidconv = gst_element_factory_make ("nvvideoconvert", "nvvideo-converter");
    nvosd = gst_element_factory_make ("nvdsosd", "nv-onscreendisplay");
    sink = gst_element_factory_make ("nveglglessink", "nvvideo-renderer");

how can I connect autovideosink instead of nveglglessink? I tried to replace one with another, but it doesn’t work. What is a right way to do it?

In DeepStream usecases, we only support nvoverlaysink and nveglglessink, so it is not recommended to use autovideosink.

But may be its possible to make it work over VNC?

You may check which sink is picked and apply the same into the code.

$ export GST_DEBUG=*FACTORY*:4