Writing a streamer application which generates UYVY frames.

Nick.Adamson at gdlsuk.com Nick.Adamson at gdlsuk.com
Mon Dec 7 08:47:03 PST 2015


Hi All.
I'm new to this list and GStreamer and would like some advice please.
I've been reading the GStreamer guide from http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/index.html and have written a couple of basic applications which have worked OK.

What I'd like to do is update my application, which currently reads a file and plays it, to give me access to a UYVY frame for each frame of the video.

See below for code snippets I'm using, which is mostly based on the playsink example given in chapter 20 of the guide, http://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/html/section-components-playsink.html.

I've come across the video converter element which is able to output UYVY formatted video however I'm unsure how to link this in to my pipeline as it's using a dynamic sink. The documentation for the videoconverter is here: http://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-videoconvert.html
I've read this a number of times but am unsure how to link the extra element in and how to set the sink pad to be a UYVY format.

Once I've converted the video how do I get access to the frames? Is there a sink I can use to send the frames in to the application space or do I need to get access to the buffer? If so how?

Not that it should matter but I'm developing in c++ on windows.
Code:
... snip ...
// Globals
GstElement *pipeline, *sink;

static void cb_pad_added (GstElement *dec,      GstPad *pad,     gpointer data)
{
  GstCaps *caps;
  GstStructure *str;
  const gchar *name;
  GstPadTemplate *templ;
  GstElementClass *klass;

  // check media type
  caps = gst_pad_query_caps (pad, NULL);
  str = gst_caps_get_structure (caps, 0);
  name = gst_structure_get_name (str);
  klass = GST_ELEMENT_GET_CLASS (sink);
  if (g_str_has_prefix (name, "audio"))
  {
    templ = gst_element_class_get_pad_template (klass, "audio_sink");
  }
  else if (g_str_has_prefix (name, "video"))
  {
    templ = gst_element_class_get_pad_template (klass, "video_sink");
  }
  else if (g_str_has_prefix (name, "text"))
  {
    templ = gst_element_class_get_pad_template (klass, "text_sink");
  }
  else
  {
    templ = NULL;
  }
  if (templ)
  {
    GstPad *sinkpad;
    sinkpad = gst_element_request_pad (sink, templ, NULL, NULL);
    if (!gst_pad_is_linked (sinkpad))
    {
      gst_pad_link (pad, sinkpad);
    }
    gst_object_unref (sinkpad);
  }
}

int main(int argc, char** argv)
{
.... snipped ....

  // initialise gstreamer and get version information.
  const gchar *nano_str;
  guint major, minor, micro, nano;
  gst_init(&argc, &argv);

  // get the version of gstreamer.
  gst_version(&major, &minor, &micro, &nano);
  if (nano == 1)
  {
    nano_str = "(CVS)";
  }
  else if (nano == 2)
  {
    nano_str = "(Prerelease)";
  }
  else
  { nano_str = "";
  }
  char cVersion[256];
  sprintf(cVersion, "This program is linked against GStreamer %d.%d.%d %s",
    major, minor, micro, nano_str);
  print( cVersion );

  GMainLoop *loop;
  GstElement *dec;
  GstBus *bus;
  loop = g_main_loop_new (NULL, FALSE);

  // setup
  pipeline = gst_pipeline_new ("pipeline");
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);

  dec = gst_element_factory_make ("uridecodebin", "source");
  g_object_set (G_OBJECT (dec), "uri", argv[1],
    NULL);
  g_signal_connect (dec, "pad-added", G_CALLBACK (cb_pad_added), NULL);

  // create audio output
  sink = gst_element_factory_make ("playsink", "sink");
  gst_util_set_object_arg (G_OBJECT (sink), "flags",
    "soft-colorbalance+soft-volume+vis+text+audio+video");
  gst_bin_add_many (GST_BIN (pipeline), dec, sink, NULL);

  // run
  gst_element_set_state (pipeline, GST_STATE_PLAYING);
  g_main_loop_run (loop);

  // cleanup
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref (GST_OBJECT (pipeline));

  print("all done.");
  fclose( gLogFile );
  gLogFile = NULL;
  return 0;
}
... end of code. ...

Thanks for any ideas and sorry for all the noddy questions.
Nick.
Nick Adamson
Software Engineer

------------------------------------------------------------------------------

This email and any files attached are intended for the addressee and may contain information of a confidential nature. If you are not the intended recipient, be aware that this email was sent to you in error and you should not disclose, distribute, print, copy or make other use of this email or its attachments. Such actions, in fact, may be unlawful. In compliance with the various Regulations and Acts, General Dynamics United Kingdom Limited reserves the right to monitor (and examine for viruses) all emails and email attachments, both inbound and outbound. Email communications and their attachments may not be secure or error- or virus-free and the company does not accept liability or responsibility for such matters or the consequences thereof. General Dynamics United Kingdom Limited, Registered Office: 21 Holborn Viaduct, London EC1A 2DY. Registered in England and Wales No: 1911653.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/gstreamer-devel/attachments/20151207/53fe820d/attachment-0001.html>


More information about the gstreamer-devel mailing list