Search code examples
gstreamerfullscreenwayland

How to change gstreamer Element property


I want to make the gstreamer app full screen. Waylandsink property has fullscreen, how do I change it? Or is there a way to go full screen without changing the Waylandsink property?


Solution

  • When setting by command $ gst-launch-1.0 filesrc location=/home/root/testpi.h264 ! decodebin ! vspmfilter ! waylandsink fullscreen=TRUE

    When writing in code

    `#define INPUT_FILE    "/home/root/testpi.h264"
    GstElement *pipeline, *source, *parser, *decoder, *filter, *sink;
    const gchar *input_file = INPUT_FILE;
    
    gst_init(&argc, &argv);
    
    /* Create gstreamer elements */
    pipeline = gst_pipeline_new ("video-play");
    source = gst_element_factory_make ("filesrc", "file-source");
    parser = gst_element_factory_make ("h264parse", "h264-parser");
    decoder = gst_element_factory_make ("omxh264dec", "h264-decoder");
    filter = gst_element_factory_make ("vspmfilter", "filter");
    sink = gst_element_factory_make ("waylandsink", "video-output");
    
    /* Set input video file for source element */
    g_object_set (G_OBJECT (source), "location", input_file, NULL);
    
    /* Set element property */
    g_object_set(G_OBJECT(sink),"fullscreen",TRUE,NULL);
    
    /* Add all elements into the pipeline */
    /* pipeline---[ file-source + h264-parser + h264-decoder + filter + video-output ] */
    gst_bin_add_many (GST_BIN (pipeline), source, parser, decoder, filter, sink, NULL);
    
    /* Link the elements together */
    /* file-source -> h264-parser -> h264-decoder -> filter -> video-output */
    if (gst_element_link_many (source, parser, decoder, filter, sink, NULL) != TRUE) {
            g_printerr ("Elements could not be linked.\n");
            gst_object_unref (pipeline);
            return -1;
    }
    
     /* Set the pipeline to "playing" state */
     g_print ("Now playing: %s\n", input_file);
     if (gst_element_set_state (pipeline,
      GST_STATE_PLAYING) == GST_STATE_CHANGE_FAILURE) {
       g_printerr ("Unable to set the pipeline to the playing state.\n");
       gst_object_unref (pipeline);
       return -1;
     }
    g_print ("Running...\n");
    while(1)
    {
    ;
    }
    

    `