# GStreamer Camera Application

Source: [https://docs.qualcomm.com/doc/80-70015-17/topic/gstreamer_camera_application.html](https://docs.qualcomm.com/doc/80-70015-17/topic/gstreamer_camera_application.html)

GStreamer is an open source framework for creating streaming media applications.
        Examples illustrating how to develop camera applications using GStreamer and Qualcomm Camera
        are provided.

## Using gst-launch-1.0

Source: [https://docs.qualcomm.com/doc/80-70015-17/topic/gstreamer_camera_application.html](https://docs.qualcomm.com/doc/80-70015-17/topic/gstreamer_camera_application.html)

Use gst-launch-1.0 command-line GStreamer utility to build and run a GStreamer
        pipeline.

The pipeline is specified as a collection of elements with properties separated by
                `!`.

### Prerequisites

To use [gst-launch-1.0](https://gstreamer.freedesktop.org/documentation/tools/gst-launch.html?gi-language=c) and GStreamer plugins,
                QIM-SDK (meta-qcom-qim-product-sdk) must be installed on the device. Refer to [Qualcomm Linux Build Guide](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-254/introduction.html) for QIM-SDK
                build and installation information.

Note: Connect to the device console using SSH. See [How To SSH?](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-254/how_to.html#use-ssh) for instructions.

Run the following commands in an SSH
                terminal:

    # mount -o rw,remount /
    # export XDG_RUNTIME_DIR=/dev/socket/weston
    # export WAYLAND_DISPLAY=wayland-1
    Copy to clipboard

### Single camera stream start

1. Run the following command in the device
                    terminal:

        gst-launch-1.0 -e qtiqmmfsrc name=camsrc ! 'video/x-raw(memory:GBM),format=NV12,\
        width=1280,height=720,framerate=30/1' ! fakesink
        Copy to clipboard
2. This example shows how to start the camera with 720p@30 FPS configuration. The
                    frame coming from the camera sensor is thrown away by fakesink. If the gst
                    pipeline status is changed to “PLAYING” as shown below, this indicates that the
                    camera is running. Since this command dumps camera frames to fakesink, nothing
                    will be saved on the device. Refer to [Video encoding](https://docs.qualcomm.com/doc/80-70015-17/topic/gstreamer_camera_application.html#id_kfw_tg2_wcc__d7e83) and [Video encoding and snapshot](https://docs.qualcomm.com/doc/80-70015-17/topic/gstreamer_camera_application.html#id_kfw_tg2_wcc__d7e114) for
                    information on operating the camera and saving the video file.

        gbm_create_device(187): Info: backend name is: msm_drm 
        Setting pipeline to PAUSED ...
        Pipeline is live and does not need PREROLL ...
        Setting pipeline to PLAYING ... 
        New clock: GstSystemClockCopy to clipboard

To stop the camera, press CTRL+C.

### Video encoding

1. Run the following command in the device
                        terminal:

        gst-launch-1.0 -e qtiqmmfsrc name=camsrc camera=0 ! \
        video/x-raw\(memory:GBM\),format=NV12,width=1280,height=720,framerate=30/1,\
        compression=ubwc,interlace-mode=progressive,colorimetry=bt601 ! v4l2h264enc \
        capture-io-mode=5 output-io-mode=5 extra-controls="controls,video_bitrate=6000000,\
        video_bitrate_mode=0;" ! h264parse ! mp4mux ! filesink location=/opt/mux_avc.mp4
        Copy to clipboard

    This command starts the camera with 720p@30 FPS configuration
                        and saves it as a video file after h264 video encoding. If the gst pipeline
                        status is changed to “PLAYING”, this indicates the camera is running.

    To stop the camera, press
                            CTRL+C.
2. /opt/mux\_avc.mp4 is generated on the device. The recorded
                    content can be pulled from the device by running the following scp command on
                    the host
                    PC:

        $ scp -r root@[ip-addr]:/opt/mux_avc.mp4 .Copy to clipboard

### Video encoding and snapshot

1. Run the following command in the device
                    terminal:

        gst-pipeline-app -e qtiqmmfsrc name=camsrc camera=0 ! \
        video/x-raw\(memory:GBM\),format=NV12,width=1280,height=720,framerate=30/1,\
        compression=ubwc,interlace-mode=progressive,colorimetry=bt601 ! v4l2h264enc \
        capture-io-mode=5 output-io-mode=5 extra-controls="controls,video_bitrate=6000000,\
        video_bitrate_mode=0;" ! h264parse ! mp4mux ! filesink location=/opt/mux_avc.mp4 \
        camsrc.image_1 ! "image/jpeg,width=1280,height=720,framerate=30/1" \
        ! multifilesink location=/opt/frame%d.jpg async=false sync=true
        Copy to clipboard
2. Press Enter. This command will print the following menu
                    and wait for user
                    input.

        ##################################### MENU #####################################
        
         ============================== Pipeline Controls ==============================
           (0) NULL                     : Set the pipeline into NULL state
           (1) READY                    : Set the pipeline into READY state
           (2) PAUSED                   : Set the pipeline into PAUSED state
           (3) PLAYING                  : Set the pipeline into PLAYING state
         ==================================== Other ====================================
           (p) Plugin Mode              : Choose a plugin which to control
           (q) Quit                     : Exit the application

        Choose an option:
        Copy to clipboard
3. Use the following menu steps to take a snapshot while recording
                    video.

        (1) ready -> (3) Playing -> (p)Plugin Mode : Select (8)camerasrc ->(36) capture-image -> (1): still – Snapshot ->(1) Snapshot count ('guint' value for arg1)Copy to clipboard
4. To stop the camera, press **Enter**, press **b** (back), and then press
                        **q** (quit). The recorded video file and snapshot images are saved in
                    /opt/. The recorded content can be pulled from the device by running the
                    following scp command on the host
                    PC:

        $ scp -r root@[ip-addr]:/opt/<file name> .Copy to clipboard

## Writing source code

Source: [https://docs.qualcomm.com/doc/80-70015-17/topic/gstreamer_camera_application.html](https://docs.qualcomm.com/doc/80-70015-17/topic/gstreamer_camera_application.html)

Use case examples and source code examples enable developers to create a camera
    application using Qualcomm's qtiqmmfsrc GStreamer plug-in.

The GStreamer community provides extensive [documentation](https://gstreamer.freedesktop.org/documentation/?gi-language=c)  as a resource for developers.

### Single pipeline video recording

The following is an example of a single pipeline video recording use case using Qualcomm's
        qtiqmmfsrc GStreamer plug-in. The qtiqmmfsrc plug-in provides various properties to control
        the camera subsystem which are explained in the [Qualcomm Linux Intelligent Multimedia Software Development
          Kit (QIM SDK) Reference](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/qtiqmmfsrc.html).

    #include <stdio.h>
    #include <glib-unix.h>
    #include <gst/gst.h>
    
    #define DISABLE_BITRATE        0
    #define VARIABLE_BITRATE       1
    #define CONSTANT_BITRATE       2
    #define FILE_SINK_LOCATION "/home/root/test_app_mux.mp4"
    
    typedef struct _AppContext {
        GstElement         *pipeline;
        GstElement         *qtiqmmfsrc;
        GstElement         *x_raw;
        GstElement         *v4l2h264enc;
        GstElement         *enc_queue;
        GstElement         *h264parse;
        GstElement         *mp4mux;
        GstElement         *mux_queue;
        GstElement         *filesink;
        GMainLoop          *mloop;             /* Main application event loop */
    } AppContext;
    
    /* Interreupt handler */
    static gboolean  handle_interrupt_signal (gpointer userdata) {
      AppContext *appctx = (AppContext *) userdata;
      GstState state = GST_STATE_VOID_PENDING;
      static gboolean waiting_eos = FALSE;
    
      g_print ("Received an interrupt signal!\n");
      if (!gst_element_get_state (appctx->pipeline, &state, NULL, GST_CLOCK_TIME_NONE)) {
        gst_printerr ("Failed to get current state!\n");
        gst_element_send_event (appctx->pipeline, gst_event_new_eos ());
        //gst_element_set_state (appctx->pipeline, GST_STATE_NULL);
        //g_main_loop_quit (appctx->mloop);
        return TRUE;
      }
    
      g_printerr ("current state is %d\n", state);
    
      //update_pipeline_state (appctx->pipeline, appctx->messages, GST_STATE_NULL);
      g_printerr ("Sending EOS event\n");
      gst_element_send_event (appctx->pipeline, gst_event_new_eos ());
    
      return TRUE;
    }
    
    /* Handle state change transition */
    static void state_changed_cb (GstBus * bus, GstMessage * message, gpointer userdata) {
      GstElement *pipeline = GST_ELEMENT (userdata);
      GstState old, new_st, pending;
    
      /* Handle pipeline state change only */
      if (GST_MESSAGE_SRC (message) != GST_OBJECT_CAST (pipeline))
        return;
    
      gst_message_parse_state_changed (message, &old, &new_st, &pending);
      g_print ("\nPipeline state changed from %s to %s, pending: %s\n",
       gst_element_state_get_name (old), gst_element_state_get_name (new_st),
       gst_element_state_get_name (pending));
    }
    
    /* Error handler */
    static void error_cb (GstBus *bus, GstMessage *msg, gpointer data) {
      AppContext *appctx = (AppContext *) data;
      GMainLoop *mloop = appctx->mloop;
      GError *error = NULL;
      gchar *debug = NULL;
    
      gst_message_parse_error (msg, &error, &debug);
      gst_object_default_error (GST_MESSAGE_SRC (msg), error, debug);
    
      g_free (debug);
      g_error_free (error);
    
      g_main_loop_quit (mloop);
    }
    
    /* EOS handler */
    static void eos_cb (GstBus *bus, GstMessage *msg, gpointer userdata)
    {
      AppContext *appctx = (AppContext *) userdata;
      g_print ("Received EOS from '%s' ... \n", GST_MESSAGE_SRC_NAME (msg));
    
      g_main_loop_quit (appctx->mloop);
    }
    
    static void destroy_pipeline (AppContext *appctx) {
      /* destroy pipeline */
      gst_element_unlink_many (appctx->qtiqmmfsrc, appctx->x_raw,
       appctx->v4l2h264enc, appctx->enc_queue, appctx->h264parse,
       appctx->mp4mux, appctx->mux_queue, appctx->filesink, NULL);
      gst_bin_remove_many (GST_BIN(appctx->pipeline), appctx->qtiqmmfsrc, appctx->x_raw,
       appctx->v4l2h264enc, appctx->enc_queue, appctx->h264parse, appctx->mp4mux,
       appctx->mux_queue, appctx->filesink, NULL);
      gst_object_unref (appctx->pipeline);
    }
    
    int main(int argc, char *argv[]) {
      AppContext appctx;
      GstBus *bus;
      GstMessage *msg;
      GstCaps *filtercaps;
      guint interrupt_watch_id;
    
      /* Initilize GStreamer */
      gst_init (&argc, &argv);
    
      /* Create all elements */
      appctx.qtiqmmfsrc = gst_element_factory_make ("qtiqmmfsrc", "qtiqmmfsrc");
      appctx.x_raw = gst_element_factory_make ("capsfilter", "x_raw");
      appctx.v4l2h264enc = gst_element_factory_make ("v4l2h264enc", "v4l2h264enc");
      appctx.enc_queue = gst_element_factory_make ("queue", "enc_queue");
      appctx.h264parse = gst_element_factory_make ("h264parse", "h264parse");
      appctx.mp4mux = gst_element_factory_make ("mp4mux", "mp4mux");
      appctx.mux_queue = gst_element_factory_make ("queue", "mux_queue");
      appctx.filesink = gst_element_factory_make ("filesink", "filesink");
    
      /* Create the pipeline */
      appctx.pipeline = gst_pipeline_new ("basic-recording");
    
      if (!appctx.pipeline || !appctx.qtiqmmfsrc || !appctx.x_raw ||
       !appctx.v4l2h264enc || !appctx.enc_queue || !appctx.h264parse ||
       !appctx.mp4mux || !appctx.mux_queue || !appctx.filesink) {
        g_printerr ("Failed to create pipeline or elements.\n");
        return -1;
      }
    
      /* Add the elements to the pipeline */
      gst_bin_add_many (GST_BIN(appctx.pipeline), appctx.qtiqmmfsrc, appctx.x_raw,
       appctx.v4l2h264enc, appctx.enc_queue, appctx.h264parse, appctx.mp4mux,
       appctx.mux_queue, appctx.filesink, NULL);
    
      /* Configure stream caps */
        filtercaps = gst_caps_new_simple ("video/x-raw",
       "format", G_TYPE_STRING, "NV12",
       "width", G_TYPE_INT, 1280,
       "height", G_TYPE_INT, 720,
       "framerate", GST_TYPE_FRACTION, 30, 1,
       "compression", G_TYPE_STRING, "ubwc",
       "interlace-mode", G_TYPE_STRING, "progressive",
       "colorimetry", G_TYPE_STRING, "bt601",
       NULL);
      gst_caps_set_features (filtercaps, 0,
       gst_caps_features_new ("memory:GBM", NULL));
      g_object_set (G_OBJECT (appctx.x_raw), "caps", filtercaps, NULL);
      gst_caps_unref (filtercaps);
    
      /* Set v4l2h264enc */
      g_object_set (G_OBJECT (appctx.v4l2h264enc), "capture-io-mode", 5, NULL);
      g_object_set (G_OBJECT (appctx.v4l2h264enc), "output-io-mode", 5, NULL);
      g_object_set (G_OBJECT (appctx.v4l2h264enc), "controls,video_bitrate", 5000000, NULL);
      g_object_set (G_OBJECT (appctx.v4l2h264enc), "video_bitrate_mode", 0, NULL);
    
      /* Set filesink */
      g_object_set (G_OBJECT (appctx.filesink), "location", FILE_SINK_LOCATION, NULL);
    
      /* Link elements */
      if (!gst_element_link_many (appctx.qtiqmmfsrc, appctx.x_raw,
       appctx.v4l2h264enc, appctx.enc_queue, appctx.h264parse, appctx.mp4mux,
       appctx.mux_queue, appctx.filesink, NULL)) {
        g_printerr ("Faile to link elements\n");
        gst_bin_remove_many (GST_BIN(appctx.pipeline), appctx.qtiqmmfsrc, appctx.x_raw,
         appctx.v4l2h264enc, appctx.enc_queue, appctx.h264parse, appctx.mp4mux,
         appctx.mux_queue, appctx.filesink, NULL);
        gst_object_unref (appctx.pipeline);
        return -1;
      }
    
      /* Initialize main loop */
      if ((appctx.mloop = g_main_loop_new (NULL, FALSE)) == NULL) {
        g_printerr ("ERROR: Failed to create Main loop!\n");
        destroy_pipeline(&appctx);
        return -1;
      }
    
      /* Retrieve reference of the pipeline bus */
      if ((bus = gst_pipeline_get_bus (GST_PIPELINE (appctx.pipeline))) == NULL) {
        g_printerr ("Failed to retrieve pipeline bus\n");
        g_main_loop_unref (appctx.mloop);
        destroy_pipeline(&appctx);
        return -1;
      }
    
      /* Connect watcher to bus signal */
      gst_bus_add_signal_watch (bus);
      g_signal_connect (bus, "message::state-changed",
       G_CALLBACK (state_changed_cb), appctx.pipeline);
      g_signal_connect (bus, "message::error", G_CALLBACK (error_cb), &appctx);
      g_signal_connect (bus, "message::eos", G_CALLBACK (eos_cb), &appctx);
      gst_object_unref (bus);
    
      /* Set pipeline state to PLAYING */
      gst_element_set_state (appctx.pipeline, GST_STATE_PLAYING);
    
      /* Register interrupt handler for main_loop */
      interrupt_watch_id = g_unix_signal_add (SIGINT, handle_interrupt_signal, &appctx);
    
      /* Run mainloop */
      g_main_loop_run (appctx.mloop);
    
      /* Release/Free resources */
      gst_element_set_state (appctx.pipeline, GST_STATE_NULL);
      g_main_loop_unref (appctx.mloop);
      /* destroy pipeline */
      destroy_pipeline(&appctx);
    
      return 0;
    }
    Copy to clipboard

Code can be compiled with the QIM Product SDK. The QIM SDK can be downloaded or created
        from a workspace. To install the QIM SDK:
- [Download QIM Platform SDK](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-51/install-sdk.html)
- To generate the platform SDK from a workspace, see the [Build Guide](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-254/introduction.html) and [How to generate eSDK](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-254/how_to.html).

After installing the QIM SDK:

1. Save the above code to simple\_camera.c and run the following
          command to compile it:

        unset LD_LIBRARY_PATH
        source <installation directory of platfom SDK>/environment-setup-armv8-2a-qcom-linux
        $CC -o simple_camera simple_camera.c `pkg-config --cflags --libs gstreamer-1.0 gstreamer-audio-1.0 gstreamer-pbutils-1.0`
        Copy to clipboard
2. Run the following command to push the `simple_camera` binary to the
          device:

        scp ./simple_camera root@[ip-addr]:/opt/simple_cameraCopy to clipboard
3. Use the following commands to run `simple_camera` in the
          device:

        cd /opt/
        ./simple_camera
        Copy to clipboard

### Walkthrough

The GStreamer pipeline contains the basic building blocks for a media pipeline using [GstElement](https://gstreamer.freedesktop.org/documentation/gstreamer/gstelement.html?gi-language=c). In this example, the
          `qtiqmmfsrc`, `capsfilter`, `v4l2h264enc`,
          `h264parse`, `mp4mux`, and `filesink`
        elements are used to create a single video recording pipeline.

![](data:image/png;base64,UklGRgQdAABXRUJQVlA4TPccAAAv3gY2ACI8zP67ehuJ5ZRTumTp0iVLllO6ZMlSJUuXLr9SpUuWLlmyVOmSpcopXU7OMwLO+f9/59z/vffwUqPP93CjAzdH2QQEXMIEuDkHChMPTLGYJHClYqIoAQ401pOjw7fEncA1xI0yqMkzmk2TadgTqo2TuZnF5G/ADcZOTsQBKKwAGADA1rGCDw+HwWEwOCweFoPBYd9/WBwOD4fB4nBYLB4evs/9f4OB/W8mKXh4uDi4uPjHwcXFw2Jw8XCxGDxcPAwGi4PB4ODgfV/uM/2nBUmS5bapkREADSL6enr3sIcXRf3tWqpZri7ebTtLNJfVfbermYWHnXOjqayWS/8p/af0n9J/Sv8p/af0n9J/Sv9p7sXvCV4Fh4fsc8/v8o+6/xYcHnL43NO7Sv/Z45wYya7WTg8R1ZRFZEX65G2WklwPEdWERfSsopLQa+ji/rCcdmtJ32vUAe1hlp6Karoi+rs6gHR1AQbEffQPO3tXpC7o6/YQUc1ZdAAGog6YPm7Aepcg9IJ6soBkx0jxAVN6Yi2q2Qmwy7yrPRTT44rogCnESlRTFDH6oXPvYGqw6+Oea7Pjk43cNkP7JHkMcPbpm+GNA9E9v7Dm7xobyr1LKLQb4lhUbLoidEH7wVffEwYkyWOA7Ybo43ojwkFIaD/fLCo2RzFwbuEgQx8AfdhZO4TG1rxvZLT3eyIG0d6vRU36iET52Az15YHcN1fWGWNrbKdJJHj/zpV1eGHNKwWTHopqeiKQmtvvzSxOBVLt/WbG1qAoH5ugbuhxQzm9jzaMPY7Umg1IVJPUBR9jtLxAygYkqknq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j3Po0wLXRdHIsCyatOO/dUipOIjjJMH97lKIVb3ePYS1EMtfcE1AZ3OSXCG6yi+LYaLo5lrsR/mmO3OOYFG4wbPj8pzly1MCSwUl2MdwaTTfHcvfAP6yYowwDuNCx4fQfVsxFlkjgKLc4xTeWpf+U/jOixFHVRIKzqjDirHtNMripOK53rBAvCxLjLLeGIRYm3FXLBRF33WuSwFlFcb1jxXhZkBhn1XDD/MSCy+phP1kAmZ9YdllNzCdixmV+ERztmLNxd5cTseAyu2aGlXDGee+yUtNuocLVsUow8bis9LTjcMecXC7v8kggnNFt1SpWODxWDjas1XK+Y4V53nR3OItzFS32HKnSf0r/Kf2n9J/Sf0r/Kf2n9J/Sf3ans8d3FR72AK+Cw8Y39gCvjWGSPfir9J/Sf0r/Kf2n9J/Sf0r/Kf2n9J/iRpNZWfDI28+DD+/NZfWI6zdjAwA=)  

[gst_init](https://gstreamer.freedesktop.org/documentation/gstreamer/gst.html?gi-language=c#gst_init) must be the first GStreamer command. It
        initializes all internal GStreamer structures, checks what plug-ins are available, and
        executes any command line option.

    /* Initialize GStreamer */
     gst_init (&argc, &argv);
    Copy to clipboard

New elements can be created with [gst_element_factory_make](https://gstreamer.freedesktop.org/documentation/gstreamer/gstelementfactory.html?gi-language=c#gst_element_factory_make). The first parameter is the
        type of element to create and the second parameter is the name to give this instance.

     /* Create all elements */
      appctx.qtiqmmfsrc = gst_element_factory_make ("qtiqmmfsrc", "qtiqmmfsrc");
      appctx.x_raw = gst_element_factory_make ("capsfilter", "x_raw");
      appctx.v4l2h264enc = gst_element_factory_make ("v4l2h264enc", "v4l2h264enc");
      appctx.enc_queue = gst_element_factory_make ("queue", "enc_queue");
      appctx.h264parse = gst_element_factory_make ("h264parse", "h264parse");
      appctx.mp4mux = gst_element_factory_make ("mp4mux", "mp4mux");
      appctx.mux_queue = gst_element_factory_make ("queue", "mux_queue");
      appctx.filesink = gst_element_factory_make ("filesink", "filesink");
    Copy to clipboard

The pipeline can be created with [gst_pipeline_new](https://gstreamer.freedesktop.org/documentation/gstreamer/gstpipeline.html?gi-language=c#gst_pipeline_new). Created elements can then be added
        to the pipeline using [gst_bin_add_many](https://gstreamer.freedesktop.org/documentation/gstreamer/gstbin.html?gi-language=c#gst_bin_add_many).

     /* Create the pipeline */
      appctx.pipeline = gst_pipeline_new ("basic-recording");
    
      if (!appctx.pipeline || !appctx.qtiqmmfsrc || !appctx.x_raw ||
       !appctx.v4l2h264enc || !appctx.enc_queue || !appctx.h264parse ||
       !appctx.mp4mux || !appctx.mux_queue || !appctx.filesink) {
        g_printerr ("Failed to create pipeline or elements.\n");
        return -1;
      }
    
      /* Add the elements to the pipeline */
      gst_bin_add_many (GST_BIN(appctx.pipeline), appctx.qtiqmmfsrc, appctx.x_raw,
       appctx.v4l2h264enc, appctx.enc_queue, appctx.h264parse, appctx.mp4mux,
       appctx.mux_queue, appctx.filesink, NULL);
    Copy to clipboard

Caps (capabilities) are object describing media types. Here, a new [GstCaps](https://gstreamer.freedesktop.org/documentation/gstreamer/gstcaps.html?gi-language=c#GstCaps) (filtercaps) is created using [gst_caps_new_simple](https://gstreamer.freedesktop.org/documentation/gstreamer/gstcaps.html?gi-language=c#gst_caps_new_simple). This filtercaps describes the
          [qtiqmmfsrc pad configuration](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/qtiqmmfsrc.html).

     /* Configure stream caps */
        filtercaps = gst_caps_new_simple ("video/x-raw",
       "format", G_TYPE_STRING, "NV12",
       "width", G_TYPE_INT, 1280,
       "height", G_TYPE_INT, 720,
       "framerate", GST_TYPE_FRACTION, 30, 1,
       "compression", G_TYPE_STRING, "ubwc",
       "interlace-mode", G_TYPE_STRING, "progressive",
       "colorimetry", G_TYPE_STRING, "bt601",
       NULL);
      gst_caps_set_features (filtercaps, 0,
       gst_caps_features_new ("memory:GBM", NULL));
      g_object_set (G_OBJECT (appctx.x_raw), "caps", filtercaps, NULL);
      gst_caps_unref (filtercaps);
    Copy to clipboard

GStreamer elements are all a kind of [GObject](https://docs.gtk.org/gobject/#GObject-struct). Object properties are written to with [g_object_set](https://docs.gtk.org/gobject/#g-object-set) and read from with [g_object_get](https://docs.gtk.org/gobject/#g-object-get).

For more information on the following code snippet, see:
- [v4l2h264enc properties](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/v4l2h264enc.html)
- [filesink properties](https://gstreamer.freedesktop.org/documentation/coreelements/filesink.html?gi-language=c)

/* Set v4l2h264enc */
      g_object_set (G_OBJECT (appctx.v4l2h264enc), "capture-io-mode", 5, NULL);
      g_object_set (G_OBJECT (appctx.v4l2h264enc), "output-io-mode", 5, NULL);
      g_object_set (G_OBJECT (appctx.v4l2h264enc), "controls,video_bitrate", 5000000, NULL);
      g_object_set (G_OBJECT (appctx.v4l2h264enc), "video_bitrate_mode", 0, NULL);
      /* Set filesink */
      g_object_set (G_OBJECT (appctx.filesink), "location", FILE_SINK_LOCATION, NULL);
    Copy to clipboard

[gst_element_link_many](https://gstreamer.freedesktop.org/documentation/gstreamer/gstelement.html?gi-language=c#gst_element_link_many) links each element:

    /* Link elements */
      if (!gst_element_link_many (appctx.qtiqmmfsrc, appctx.x_raw,
       appctx.v4l2h264enc, appctx.enc_queue, appctx.h264parse, appctx.mp4mux,
       appctx.mux_queue, appctx.filesink, NULL)) {
        g_printerr ("Faile to link elements\n");
        gst_bin_remove_many (GST_BIN(appctx.pipeline), appctx.qtiqmmfsrc, appctx.x_raw,
         appctx.v4l2h264enc, appctx.enc_queue, appctx.h264parse, appctx.mp4mux,
         appctx.mux_queue, appctx.filesink, NULL);
        gst_object_unref (appctx.pipeline);
        return -1;
      }
    Copy to clipboard

g\_main\_loop\_new() initializes the main loop.
          gst\_pipeline\_get\_bus() gets the bus reference and registers the
        callback function for particular bus messages. Here, the
        state\_changed\_cb, error\_cb, and
          eos\_cb functions are set for the `state_changed`,
          `error`, and `end-of-stream` (EoS) bus messages.

The pipeline state is then set to `GST_STATE_PLAYING` and the camera stream
        starts.

    /* Initialize main loop */
      if ((appctx.mloop = g_main_loop_new (NULL, FALSE)) == NULL) {
        g_printerr ("ERROR: Failed to create Main loop!\n");
        destroy_pipeline(&appctx);
        return -1;
      }
    
      /* Retrieve reference of the pipeline bus */
      if ((bus = gst_pipeline_get_bus (GST_PIPELINE (appctx.pipeline))) == NULL) {
        g_printerr ("Failed to retrieve pipeline bus\n");
        g_main_loop_unref (appctx.mloop);
        destroy_pipeline(&appctx);
        return -1;
      }
    
      /* Connect watcher to bus signal */
      gst_bus_add_signal_watch (bus);
      g_signal_connect (bus, "message::state-changed",
       G_CALLBACK (state_changed_cb), appctx.pipeline);
      g_signal_connect (bus, "message::error", G_CALLBACK (error_cb), &appctx);
      g_signal_connect (bus, "message::eos", G_CALLBACK (eos_cb), &appctx);
      gst_object_unref (bus);
    
      /* Set pipeline state to PLAYING */
      gst_element_set_state (appctx.pipeline, GST_STATE_PLAYING);
    Copy to clipboard

The handler function is registered using g\_unix\_signal\_add(). If the
        pipeline process gets a `SIGINT` signal, then
          handle\_interrupt\_signal() is called. `Main_loop` will
        continue until getting a Ctrl+C interrupt signal.

After the interrupt signal is received, `main_loop` is exited, resources are
        released, and the pipeline is destroyed.

    /* Register interrupt handler for main_loop */
      interrupt_watch_id = g_unix_signal_add (SIGINT, handle_interrupt_signal, &appctx);
    
      /* Run mainloop */
    g_main_loop_run (appctx.mloop);
    
      /* Release/Free resources */
      gst_element_set_state (appctx.pipeline, GST_STATE_NULL);
      g_main_loop_unref (appctx.mloop);
      /* destroy pipeline */
      destroy_pipeline(&appctx);
    Copy to clipboard

## Samples

Source: [https://docs.qualcomm.com/doc/80-70015-17/topic/gstreamer_camera_application.html](https://docs.qualcomm.com/doc/80-70015-17/topic/gstreamer_camera_application.html)

Sample applications and use case examples demonstrate camera and multi-camera
                features.

The QIM SDK includes [GStreamer sample applications for camera](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/camera-sample-applications.html) as
            well as sample applications for [AI/ML and other multimedia applications](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/example-applications.html).

Note: Before using the sample applications, ensure that the installation
            prerequisites for gst-launch-1.0 and GStreamer plugins are met.

The [Gstreamer use case examples](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/multimedia-use-cases.html) listed below use
            gst-launch-1.0.

**Camera and video encode**

| Example | Description |
| --- | --- |
| [One stream – 1080p AVC RTSP from<br>                                    live source](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/one-stream-1080p-avc-rtsp-from-live-source.html) | <ul class="ul" id="id_pjy_wg2_wcc__d9e72"><br>                                    <li class="li">Single stream use case using single camera</li><br><br>                                    <li class="li">One 1080P stream video encoding</li><br><br>                                    <li class="li">1080P network streaming using RTSP</li><br><br>                                </ul> |
| [Three 1080p AVC streams from live<br>                                    source](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/three-1080p-avc-streams-from-live-source.html) | <ul class="ul" id="id_pjy_wg2_wcc__d9e94"><br>                                    <li class="li">Three stream use case using single camera</li><br><br>                                    <li class="li">Three 1080P streams video encoding</li><br><br>                                    <li class="li">Video file save for each streams</li><br><br>                                </ul> |
| [Three streams – 1080p AVC, 1080p<br>                                    HEVC, and 1080p YUV from live source](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/three-streams_1080p-avc-1080p-hevc-and-1080p-yuv-from-live-source.html) | <ul class="ul" id="id_pjy_wg2_wcc__d9e116"><br>                                    <li class="li">Three stream use case using single camera</li><br><br>                                    <li class="li">One 1080P stream video encoding in H264 format and video<br>                                        file save</li><br><br>                                    <li class="li">One 1080P stream video encoding in HEVC format and video<br>                                        file save</li><br><br>                                    <li class="li">One 1080P stream for display</li><br><br>                                </ul> |
| [Three streams – 1080p AVC MP4,<br>                                    1080p AVC MPEGTS, and 1080p AVC MP4 from live<br>                                source](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/three-streams-1080p-avc-mp4-1080p-avc-mpegts-and-1080p-avc-mp4-from-live-source.html) | <ul class="ul" id="id_pjy_wg2_wcc__d9e141"><br>                                    <li class="li">Three stream use case using single camera</li><br><br>                                    <li class="li">One 1080P stream video encoding in H264 format and video<br>                                        file save</li><br><br>                                    <li class="li">One 1080P stream video encoding in MPEGTS format and video<br>                                        file save</li><br><br>                                    <li class="li">One 1080P stream video encoding in H265 format and video<br>                                        file save</li><br><br>                                </ul> |
| [Three streams – 1080p AVC file<br>                                    save, 1080p AVC RTSP, and 1080p YUV from live<br>                                source](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/three_streams-1080p-avc-file-save-1080p-avc-rtsp-and-1080p-yuv-from-live-source.html) | <ul class="ul" id="id_pjy_wg2_wcc__d9e166"><br>                                    <li class="li">Three stream use case using single camera</li><br><br>                                    <li class="li">One 1080P stream video encoding in H264 format and video<br>                                        file save</li><br><br>                                    <li class="li">1080P network streaming using RTSP</li><br><br>                                    <li class="li">One 1080P stream for display</li><br><br>                                </ul> |
| [Three stream – 4k JPEG snapshot,<br>                                    1080p AVC MP4, 1080p YUV from live source](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/three-stream_4k_jpeg_snapshot_1080p_avc_mp4_1080p_yuv_from_live_source.html) | <ul class="ul" id="id_pjy_wg2_wcc__d9e192"><br>                                    <li class="li">Three stream use case using single camera</li><br><br>                                    <li class="li">One 1080P stream video encoding in H264 format and video<br>                                        file save</li><br><br>                                    <li class="li">One 4k snapshot stream for JPEG encoding</li><br><br>                                    <li class="li">One 1080P stream for display</li><br><br>                                </ul> |

**Multi-camera/multi-client use cases**

| Example | Description |
| --- | --- |
| [Two streams – both 720p—one from<br>                                    each camera with side-by-side stitching sent to<br>                                display](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/two-streams-both-720p-one-from-each-camera-with-side-by-side-stitching-sent-to-display.html) | <ul class="ul" id="id_pjy_wg2_wcc__d9e250"><br>                                    <li class="li">Two streams from two cameras - one stream from each<br>                                        camera</li><br><br>                                    <li class="li">Compose to single frame (side-by-side stitching) and sent to<br>                                        display</li><br><br>                                </ul> |
| [Two streams – both 720p—one from<br>                                    each camera with side-by-side stitching sent to encode for<br>                                    filesave and RTSP streaming](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/two-streams-both-720p-one-from-each-camera-with-side-by-side-stitching-sent-to-encode-for-filesave-and-rtsp-streaming.html) | <ul class="ul" id="id_pjy_wg2_wcc__d9e269"><br>                                    <li class="li">Two streams from two cameras - one stream from each<br>                                        camera</li><br><br>                                    <li class="li">Compose to single frame (side-by-side stitching)</li><br><br>                                    <li class="li">Divert to two streams - one for video file save and the<br>                                        other for network streaming using RTSP</li><br><br>                                </ul> |
| [Two streams – both 720p—one from<br>                                    each camera with picture-in-picture composition and sent to<br>                                    display](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/two-streams-both-720p-one-from-each-camera-with-picture-in-picture-composition-and-sent-to-display.html) | <ul class="ul" id="id_pjy_wg2_wcc__d9e291"><br>                                    <li class="li">Two streams from two cameras - one stream from each<br>                                        camera</li><br><br>                                    <li class="li">Compose to single frame (picture-in-picture composition) and<br>                                        sent to display</li><br><br>                                </ul> |
| [Two streams – both 720p—one from<br>                                    each camera with picture-in-picture composition sent to encode<br>                                    for filesave and RTSP streaming](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/two-streams-720p-one-camera-with-pip-composition-to-encode-filesave-rtsp-streaming.html) | <ul class="ul" id="id_pjy_wg2_wcc__d9e310"><br>                                    <li class="li">Two streams from two cameras - one stream from each<br>                                        camera</li><br><br>                                    <li class="li">Compose to single frame (picture-in-picture<br>                                        composition)</li><br><br>                                    <li class="li">Divert to two streams - one for video file save and the<br>                                        other for network streaming using RTSP</li><br><br>                                </ul> |
| [1080p to 1080p – Rotate<br>                                    (90/180/270)](https://docs.qualcomm.com/bundle/publicresource/topics/80-70015-50/1080p-to-1080p-rotate-90-180-270.html) | <ul class="ul" id="id_pjy_wg2_wcc__d9e332"><br>                                    <li class="li">Single stream use case using single camera</li><br><br>                                    <li class="li">Rotates the frame by 180 degrees and sent to display</li><br><br>                                </ul> |

Last Published: Oct 17, 2024

[Previous Topic
V4L2 Interface](https://docs.qualcomm.com/bundle/publicresource/80-70015-17/topics/v4l2_interface.md) [Next Topic
Advanced Camera Features](https://docs.qualcomm.com/bundle/publicresource/80-70015-17/topics/advanced_camera_features.md)