Help with new plugin develppment

pchaurasia pchaurasia at gameloreinc.com
Wed Sep 13 10:52:42 UTC 2017


Folks,

I am learning how to write plugin. I am following this simple example from -

https://github.com/kirankrishnappa/gst-template/tree/master/gst-plugin/src/gstmyfilter.c.

This is simple plugin which does output = input.

I am calling this plugin - in my code as follows -

#include "play.h"

void
play_uri (const gchar * uri)
{
  GstStateChangeReturn sret;
  GstElement *playbin;
  GstElement *audiosink;
  GstElement *videosink; 
  GstElement *plugin;
  GstMessage *msg = NULL;
  GstBus *bus;

  g_print ("Trying to play %s ...\n", uri);

  playbin = gst_element_factory_make ("playbin", "playbin");
  if (playbin == NULL)
    goto no_playbin;

  /* get playbin's bus - we'll watch it for messages */
  bus = gst_pipeline_get_bus (GST_PIPELINE (playbin));

  /* set audio sink */
  audiosink = gst_element_factory_make ("autoaudiosink", "audiosink");
  if (audiosink == NULL)
    goto no_autoaudiosink;
  g_object_set (playbin, "audio-sink", audiosink, NULL);


  /* set gsttransform - plugin */
  plugin = gst_element_factory_make ("myfilter", "transform");
  if (plugin == NULL)
    goto no_plugin;
  g_object_set (playbin, "video-sink", plugin, NULL);


#if TRY_NEW_PLUGIN
  /* set gsttransform - plugin */
  plugin = gst_element_factory_make ("myfilter", "transform");
  if (plugin == NULL)
    goto no_plugin;
  g_object_set (playbin, "video-sink", plugin, NULL);


  /* connect video  */
  videosink = gst_element_factory_make ("autovideosink", "videosink");
  if (videosink == NULL)
    goto no_autovideosink;
  g_object_set (plugin, "sink", videosink, NULL);
#else

  /* set video sink */
  videosink = gst_element_factory_make ("autovideosink", "videosink");
  if (videosink == NULL)
    goto no_autovideosink;
  g_object_set (playbin, "video-sink", videosink, NULL);
#endif

  /* set URI to play back */
  g_object_set (playbin, "uri", uri, NULL);

  /* and GO GO GO! */
  gst_element_set_state (GST_ELEMENT (playbin), GST_STATE_PLAYING);

  /* wait (blocks!) until state change either completes or fails */
  sret = gst_element_get_state (GST_ELEMENT (playbin), NULL, NULL, -1);

  switch (sret) {
    case GST_STATE_CHANGE_FAILURE:{
      msg = gst_bus_poll (bus, GST_MESSAGE_ERROR, 0);
      goto got_error_message;
    }
    case GST_STATE_CHANGE_SUCCESS:{
      GstMessage *msg;

      g_print ("Playing ...\n");

      while (1) {
        gint64 dur, pos;

        if (gst_element_query_duration (playbin, GST_FORMAT_TIME, &dur) &&
            gst_element_query_position (playbin, GST_FORMAT_TIME, &pos)) {
          g_print ("  %" GST_TIME_FORMAT " / %" GST_TIME_FORMAT "\n",
              GST_TIME_ARGS (pos), GST_TIME_ARGS (dur));
        }

        /* check if we finished or if there was an error,
         * but don't wait/block if neither is the case */
        msg = gst_bus_poll (bus, GST_MESSAGE_EOS | GST_MESSAGE_ERROR, 0);

        if (msg && GST_MESSAGE_TYPE (msg) == GST_MESSAGE_ERROR)
          goto got_error_message;

        if (msg && GST_MESSAGE_TYPE (msg) == GST_MESSAGE_EOS) {
          g_print ("Finished.\n");
          break;
        }

        /* sleep for one second */
        g_usleep (G_USEC_PER_SEC * 1);
      }
      break;
    }
    default:
      g_assert_not_reached ();
  }

  /* shut down and free everything */
  gst_element_set_state (playbin, GST_STATE_NULL);
  gst_object_unref (playbin);
  gst_object_unref (bus);
  return;

/* ERRORS */
got_error_message:
  {
    if (msg) {
      GError *err = NULL;
      gchar *dbg_str = NULL;

      gst_message_parse_error (msg, &err, &dbg_str);
      g_printerr ("FAILED to play %s: %s\n%s\n", uri, err->message,
          (dbg_str) ? dbg_str : "(no debugging information)");
      g_error_free (err);
      g_free (dbg_str);
      gst_message_unref (msg);
    } else {
      g_printerr ("FAILED to play %s: unknown error\n", uri);
    }

    /* shut down and free everything */
    gst_element_set_state (playbin, GST_STATE_NULL);
    gst_object_unref (playbin);
    gst_object_unref (bus);
    return;
  }

no_playbin:
  {
    g_error ("Could not create GStreamer 'playbin' element. "
        "Please install it");
    /* not reached, g_error aborts */
    return;
  }

no_autoaudiosink:
  {
    g_error ("Could not create GStreamer 'autoaudiosink' element. "
        "Please install it");
    /* not reached, g_error aborts */
    return;
  }

no_autovideosink:
  {
    g_error ("Could not create GStreamer 'autovideosink' element. "
        "Please install it");
    /* not reached, g_error aborts */
    return;
  }

no_plugin:
  {
    g_error ("Could not create GStreamer 'plugin' element. "
        "Please install it");
    /* not reached, g_error aborts */
    return;
  }


}

When I run my app - I see following messages with GST_DEBUG=3. Could someone
please help with what could be going wrong ?

When I have TRY_NEW_PLUGIN defined I get -


0:00:00.086549106 ESC[331m16680ESC[00m   0x7f740044f0 ESC[33;01mWARN  
ESC[00m ESC[00m                 omx gstomx.c:2836:plugin_init:ESC[00m Failed
to load configuration file: Valid key file could not be found in search dirs
(searched in:
/home/ubuntu/.config:/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg as
per GST_OMX_CONFIG_DIR environment variable, the xdg user config directory
(or XDG_CONFIG_HOME) and the system config directory (or XDG_CONFIG_DIRS)
0:00:00.094815536 ESC[331m16680ESC[00m   0x7f740044f0 ESC[32;01mFIXME 
ESC[00m ESC[00m        videodecoder
gstvideodecoder.c:946:gst_video_decoder_drain_out:<omx


When I do not define TRY_NEW_PLUGIN, then things work fine.

Thanks



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


More information about the gstreamer-devel mailing list