video server client application

metind metin.duman at arcelik.com
Wed May 21 01:08:15 PDT 2014


Dear all,

I am using gstream 0.36 version in ubuntu linux and wrote server and client
applications. I used for server part;
gst-launch videotestsrc ! ffmpegcolorspace ! vp8enc ! queue2 ! mux.
audiotestsrc ! audioconvert ! vorbisenc ! queue2 ! mux. webmmux name=mux
streamable=true ! tcpserversink port=9002
and for client part;
gst-launch tcpclientsrc host=192.168.32.134 port=9002 ! matroskademux name=d
d. ! queue2 ! vp8dec ! ffmpegcolorspace ! autovideosink d. ! queue2 !
vorbisdec ! audioconvert ! audioresample ! alsasink sync=true

Also i send the source codes. When i run server and client parts, i get an
error for client part as;
Running...
Error: Internal data flow error.
Returned, stopping playback
Deleting pipeline
I couldnt find any solution about it and dont understand where i do any
mistake. Could you pls help me about this subject.

/*********SERVER.C***********/
#define HOST	"192.168.32.134"
#define PORT 	9002

#include <gst/gst.h>
#include <glib.h>
 
static gboolean
bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{
  GMainLoop *loop = (GMainLoop *) data;
 
  switch (GST_MESSAGE_TYPE (msg)) {
 
    case GST_MESSAGE_EOS:
      g_print ("End of stream\n");
      g_main_loop_quit (loop);
      break;
 
    case GST_MESSAGE_ERROR: {
      gchar  *debug;
      GError *error;
 
      gst_message_parse_error (msg, &error, &debug);
      g_free (debug);
 
      g_printerr ("Error: %s\n", error->message);
      g_error_free (error);
 
      g_main_loop_quit (loop);
      break;
    }
    default:
      break;
  }
 
  return TRUE;
}
 
int
main (int argc, char *argv[])
{
  GMainLoop *loop;
 
  GstElement *pipeline, *videosrc, *colorspace, *videoenc,
    *videoq, *audiosrc, *conv, *audioenc, *audioq, *muxer, *sink;
 
  GstBus *bus;
 
  /* Initialisation */
  gst_init (&argc, &argv);
 
  loop = g_main_loop_new (NULL, FALSE);
 
  /* Check input arguments */
  if (argc != 2) {
    g_printerr ("Usage: %s <port number>\n", argv[0]);
    return -1;
  }
 
  /* Create gstreamer elements */
  pipeline = gst_pipeline_new ("audio-player");
  videosrc = gst_element_factory_make ("videotestsrc", "videosrc");
  colorspace = gst_element_factory_make ("ffmpegcolorspace", "colorspace");
  videoenc = gst_element_factory_make ("vp8enc", "videoenc");
  videoq = gst_element_factory_make ("queue2", "videoq");
  audiosrc = gst_element_factory_make ("audiotestsrc", "audiosrc");
  conv = gst_element_factory_make ("audioconvert", "converter");
  audioenc = gst_element_factory_make ("vorbisenc", "audioenc");
  audioq = gst_element_factory_make ("queue2", "audioq");
  muxer = gst_element_factory_make ("webmmux", "mux");
  sink = gst_element_factory_make ("tcpserversink", "sink");
 
  if (!pipeline || !videosrc || !colorspace || !videoenc
    || !videoq || !audiosrc || !conv || !audioenc || !audioq
    || !muxer || !sink) {
    g_printerr ("One element could not be created. Exiting.\n");
    return -1;
  }
 
  /* Set up the pipeline */
 
  /* we set the port number to the sink element */
  g_object_set (G_OBJECT (sink), "port", atoi(argv[1]),
    "host", /*"localhost"*/HOST, NULL);
 
  /* set the properties of other elements */
  //g_object_set (G_OBJECT (videosrc), "horizontal-speed", 1, NULL);
  //g_object_set (G_OBJECT (videosrc), "is-live", 1, NULL);
  //g_object_set (G_OBJECT (videoenc), "speed", 2, NULL);
  //g_object_set (G_OBJECT (audiosrc), "is-live", 1, NULL);
  g_object_set (G_OBJECT (muxer), "streamable", 1, NULL);
 
  /* we add a message handler */
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);
 
  /* we add all elements into the pipeline */
  gst_bin_add_many (GST_BIN (pipeline),
    videosrc, colorspace, videoenc, videoq, audiosrc, conv,
    audioenc, audioq, muxer, sink, NULL);
 
  /* we link the elements together */
  gst_element_link_many (videosrc, colorspace, videoenc,
    videoq, muxer, NULL);
  gst_element_link_many (audiosrc, conv, audioenc, audioq,
    muxer, NULL);
  gst_element_link(muxer, sink);
 
  /* Set the pipeline to "playing" state*/
  g_print ("Streaming to port: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);
 
  /* Iterate */
  g_print ("Running...\n");
  g_main_loop_run (loop);
 
  /* Out of the main loop, clean up nicely */
  g_print ("Returned, stopping playback\n");
  gst_element_set_state (pipeline, GST_STATE_NULL);
 
  g_print ("Deleting pipeline\n");
  gst_object_unref (GST_OBJECT (pipeline));
 
  return 0;
}


/************CLIENT.C**********/

#define HOST	"192.168.32.134"
#define PORT 	9002

#include <gst/gst.h>
#include <glib.h>
 
static gboolean
bus_call (GstBus *bus, GstMessage *msg, gpointer data)
{
  GMainLoop *loop = (GMainLoop *) data;
 
  switch (GST_MESSAGE_TYPE (msg)) {
 
    case GST_MESSAGE_EOS:
      g_print ("End of stream\n");
      g_main_loop_quit (loop);
      break;
 
    case GST_MESSAGE_ERROR: {
      gchar  *debug;
      GError *error;
 
      gst_message_parse_error (msg, &error, &debug);
      g_free (debug);
 
      g_printerr ("Error: %s\n", error->message);
      g_error_free (error);
 
      g_main_loop_quit (loop);
      break;
    }
    default:
      break;
  }
 
  return TRUE;
}
 
int
main (int argc, char *argv[])
{
  GMainLoop *loop;
 
  GstElement *pipeline,  *colorspace, *videodec,
    *videoq,  *conv, *audiodec, *audioq, *demuxer,
*source,*sink,*resample,*videosink;
 
  GstBus *bus;
 
  /* Initialisation */
  gst_init (&argc, &argv);
 
  loop = g_main_loop_new (NULL, FALSE);
 
  /* Check input arguments */
  if (argc != 2) {
    g_printerr ("Usage: %s <port number>\n", argv[0]);
    return -1;
  }
 


  /* Create gstreamer elements */
  pipeline = gst_pipeline_new ("audio-player");
  if (!pipeline)
   {
    g_printerr ("pipeline could not be created. Exiting.\n");
    return -1;
    }
  colorspace = gst_element_factory_make ("ffmpegcolorspace", "colorspace");
   if (!colorspace)
   {
    g_printerr ("colorspace could not be created. Exiting.\n");
    return -1;
    }
  videodec = gst_element_factory_make ("vp8dec", "videodec");
  if (!videodec)
   {
    g_printerr ("videodec could not be created. Exiting.\n");
    return -1;
    }
  videoq = gst_element_factory_make ("queue2", "videoq");
  if (!videoq)
   {
    g_printerr ("videoq could not be created. Exiting.\n");
    return -1;
    }
  conv = gst_element_factory_make ("audioconvert", "converter");
  if (!conv)
   {
    g_printerr ("conv could not be created. Exiting.\n");
    return -1;
    }
  audiodec = gst_element_factory_make ("vorbisdec", "audiodec");
  if (!audiodec)
   {
    g_printerr ("audiodec could not be created. Exiting.\n");
    return -1;
    }
  audioq = gst_element_factory_make ("queue2", "audioq");
  if (!audioq)
   {
    g_printerr ("audioq could not be created. Exiting.\n");
    return -1;
    }
  demuxer = gst_element_factory_make ("matroskademux", "demux");
  if (!demuxer)
   {
    g_printerr ("demuxer could not be created. Exiting.\n");
    return -1;
    }
  source = gst_element_factory_make ("tcpclientsrc", "source");
  if (!source)
   {
    g_printerr ("source could not be created. Exiting.\n");
    return -1;
    }
  resample = gst_element_factory_make ("audioresample", "resample");
  if (!resample)
   {
    g_printerr ("resample could not be created. Exiting.\n");
    return -1;
    }
  sink = gst_element_factory_make ("alsasink", "sink");
  if (!sink)
   {
    g_printerr ("sink could not be created. Exiting.\n");
    return -1;
    }
  videosink = gst_element_factory_make ("autovideosink", "videosink");
  if (!videosink)
   {
    g_printerr ("videosink could not be created. Exiting.\n");
    return -1;
    }
 /* 
 if (!pipeline || !colorspace || !videodec
    || !videoq || !conv || !audiodec || !audioq
    || !demuxer || !sink || !source || !resample || !videosink) {
    g_printerr ("One element could not be created. Exiting.\n");
    return -1;
  }*/
 
  /* Set up the pipeline */
 
  /* we set the port number to the sink element */
  g_object_set (G_OBJECT (source), "port", atoi(argv[1]),
    "host", /*"localhost"*/HOST, NULL);
 
  /* set the properties of other elements */
  //g_object_set (G_OBJECT (videosrc), "horizontal-speed", 1, NULL);
  //g_object_set (G_OBJECT (videosrc), "is-live", 1, NULL);
  //g_object_set (G_OBJECT (videoenc), "speed", 2, NULL);
  //g_object_set (G_OBJECT (audiosrc), "is-live", 1, NULL);
  //g_object_set (G_OBJECT (muxer), "streamable", 1, NULL);
 
  /* we add a message handler */
  bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
  gst_bus_add_watch (bus, bus_call, loop);
  gst_object_unref (bus);
 
  /* we add all elements into the pipeline */
  gst_bin_add_many (GST_BIN (pipeline),
    colorspace, videodec, videoq, conv,
    audiodec, audioq, demuxer, source,sink,resample, NULL);
 

  /* we link the elements together */
  gst_element_link(source, demuxer);
  gst_element_link_many (demuxer,videoq,videodec, colorspace,
videosink,NULL);
  gst_element_link_many (demuxer, audioq,audiodec, conv, resample,sink,
NULL);
  
 
  /* Set the pipeline to "playing" state*/
  g_print ("Streaming to port: %s\n", argv[1]);
  gst_element_set_state (pipeline, GST_STATE_PLAYING);
 
  /* Iterate */
  g_print ("Running...\n");
  g_main_loop_run (loop);
 
  /* Out of the main loop, clean up nicely */
  g_print ("Returned, stopping playback\n");
  gst_element_set_state (pipeline, GST_STATE_NULL);
 
  g_print ("Deleting pipeline\n");
  gst_object_unref (GST_OBJECT (pipeline));
 
  return 0;
}



--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/video-server-client-application-tp4667066.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list