Facing some problem in implementing c code for video streaming

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Facing some problem in implementing c code for video streaming

Puneeth
Hi All,

     I m implementing below pipeline to c code but facing some errors so kindly help me to resolve this

     gst-launch $1 gstrtpbin latency=100 name=rtpbin gst-sh-mobile-camera-enc \
cntl_file=/usr/share/libshcodecs/k264-v4l2-vga-stream.ctl preview=1 ! identity sync=true ! \
'video/x-h264,width=640,height=480,framerate=30/1' ! \
 queue max-size-buffers=150 ! rtph264pay ! identity sync=true ! queue ! rtpbin.send_rtp_sink_0 \
 rtpbin.send_rtp_src_0 ! udpsink host=172.16.10.71 port=5000 \
 rtpbin.send_rtcp_src_0 ! udpsink host=172.16.10.71 port=5001 sync=true async=false \
 udpsrc port=5005 ! rtpbin.recv_rtcp_sink_0 \

Code for the above pipeline

#include <string.h>
#include <math.h>
#include <gstreamer-0.10/gst/gst.h>

/* change this to send the RTP data and RTCP to another host */
#define DEST_HOST "172.16.10.71"

/* #define AUDIO_SRC  "alsasrc" */
#define VIDEO_SRC  "gst-sh-mobile-camera-enc"

/* the encoder and payloader elements */
#define VIDEO_PAY  "rtph264pay"

int main (int argc, char *argv[])
{
  GstElement *pipeline;
  GMainLoop *loop;

  GstElement *videosrc, *identity,*capsfilter,*videoqueue,*videorate,*videoconv;
  GstElement *videotee,*previewconv, *preview,*videopay,*rtpqueue, *identity1;
  GstElement *rtpbin, *v_rtpsink, *v_rtcpsink, *v_rtcpsrc;

  gboolean res;
  GstPadLinkReturn lres;
  GstPad *srcpad, *sinkpad;
  GstCaps *caps;

  /* always init first */
  gst_init (&argc, &argv);
  loop = g_main_loop_new (NULL, FALSE);
 /* the pipeline to hold everything */
  pipeline = gst_pipeline_new(NULL);
  g_assert (pipeline);

  /* the audio capture and format conversion */
  videosrc = gst_element_factory_make (VIDEO_SRC, "videosrc");
  g_assert (videosrc);
  identity = gst_element_factory_make ("identity", "identity");
  g_assert (identity);
  videoqueue = gst_element_factory_make ("queue", "videoqueue");
  g_assert (videoqueue);
  capsfilter = gst_element_factory_make ("capsfilter", "capsfilter");
  g_assert (capsfilter);
  videorate = gst_element_factory_make("videorate", "videorate");
  g_assert (videorate);
  videoconv = gst_element_factory_make("ffmpegcolorspace", "videoconv");
  g_assert (videoconv);
  rtpqueue = gst_element_factory_make ("queue", "rtpqueue");
  g_assert (rtpqueue);
  videopay = gst_element_factory_make (VIDEO_PAY, "videopay");
  g_assert (videopay);
  identity1 = gst_element_factory_make ("identity", "identity1");
  g_assert (identity);
  /* add capture and payloading to the pipeline and link */
  gst_bin_add_many(GST_BIN (pipeline),videosrc,identity,capsfilter,videoqueue,videorate,videoconv,videopay,identity1,rtpqueue, NULL);

  caps=gst_caps_from_string("video/x-h264,width=640,height=480,framerate=30/1");
  g_object_set (videosrc, "cntl_file", argv[1],NULL);
  g_object_set (identity, "sync", TRUE, NULL);
  g_object_set (videoqueue,"max-size-buffers",150, NULL);
 g_object_set (capsfilter, "caps", caps, NULL);

 // res = gst_element_link_many(videosrc,identity,capsfilter,videoqueue,videorate,videopay,identity1,rtpqueue,NULL);
  res=gst_element_link(videosrc,identity);
  g_assert (res);
  res=gst_element_link(identity,capsfilter);
  g_assert (res);
  res=gst_element_link(capsfilter,videoqueue);
  g_assert (res);
  res=gst_element_link(videoqueue,videopay);
  g_assert (res);
  res=gst_element_link(videopay,identity1);
  g_assert (res);
  res=gst_element_link(identity1,rtpqueue);
  g_assert (res);

  rtpbin = gst_element_factory_make ("gstrtpbin", "rtpbin");
  g_assert (rtpbin);

  gst_bin_add (GST_BIN (pipeline), rtpbin);
 /* the udp sinks and source we will use for RTP and RTCP */
  v_rtpsink = gst_element_factory_make("udpsink", "rtpsink");
  g_assert (v_rtpsink);
  g_object_set (v_rtpsink, "port", 5000, "host", DEST_HOST, NULL);

  v_rtcpsink = gst_element_factory_make("udpsink", "rtcpsink");
  g_assert (v_rtcpsink);
  g_object_set (v_rtcpsink, "port", 5001, "host", DEST_HOST, NULL);
  /* no need for synchronisation or preroll on the RTCP sink */
  g_object_set (v_rtcpsink, "async", FALSE, "sync", FALSE, NULL);

  v_rtcpsrc = gst_element_factory_make("udpsrc", "rtcpsrc");
  g_assert (v_rtcpsrc);
  g_object_set (v_rtcpsrc, "port", 5005, NULL);

  gst_bin_add_many (GST_BIN (pipeline), v_rtpsink, v_rtcpsink, v_rtcpsrc, NULL);

  /* now link all to the rtpbin, start by getting an RTP sinkpad for session 0 */
  srcpad = gst_element_get_static_pad(videopay, "src");
  sinkpad = gst_element_request_pad(rtpbin, "send_rtp_sink_%d", NULL, NULL);
 // srcpad = gst_element_get_request_pad (videosendtee, "src%d");
  lres = gst_pad_link(srcpad, sinkpad);
  g_assert (lres == GST_PAD_LINK_OK);
  gst_object_unref (srcpad);

  /* get the RTP srcpad that was created when we requested the sinkpad above and
   * link it to the rtpsink sinkpad*/
  srcpad = gst_element_get_request_pad(rtpbin, "send_rtp_src_%d");
  sinkpad = gst_element_get_static_pad(v_rtpsink, "sink");
 lres = gst_pad_link (srcpad, sinkpad);
  g_assert (lres == GST_PAD_LINK_OK);
  gst_object_unref (srcpad);
  gst_object_unref (sinkpad);

  /* get an RTCP srcpad for sending RTCP to the receiver */
  srcpad = gst_element_get_request_pad(rtpbin, "send_rtcp_src_%d");
  sinkpad = gst_element_get_static_pad(v_rtcpsink, "sink");
  lres = gst_pad_link (srcpad, sinkpad);
  g_assert (lres == GST_PAD_LINK_OK);
  gst_object_unref (sinkpad);

  /* we also want to receive RTCP, request an RTCP sinkpad for session 0 and
   * link it to the srcpad of the udpsrc for RTCP */
  srcpad = gst_element_get_static_pad(v_rtcpsrc, "src");
  sinkpad = gst_element_get_request_pad(rtpbin, "recv_rtcp_sink_%d");
  lres = gst_pad_link (srcpad, sinkpad);
  g_assert (lres == GST_PAD_LINK_OK);
  gst_object_unref (srcpad);

  g_print ("starting sender pipeline\n");
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* we need to run a GLib main loop to get the messages */
  g_main_loop_run (loop);
  gst_element_set_state (pipeline, GST_STATE_NULL);
  gst_object_unref(GST_OBJECT(pipeline));

  return 0;
}

The errors i m getting on SH7724 Renesas board is below, i would really appreciate for ur help. Thanks in advance.
0:00:00.758878548   588   0x412340 WARN            multiudpsink gstmultiudpsink.c:1094:gst_multiudpsink_add_in
ternal:<GstUDPSink@0x4f8078> getaddrinfo lookup error?
0:00:00.760340421   588   0x412340 WARN            multiudpsink gstmultiudpsink.c:1160:gst_multiudpsink_remove
:<rtpsink> client at host localhost, port 4951 not found
0:00:00.761303292   588   0x412340 WARN            multiudpsink gstmultiudpsink.c:1094:gst_multiudpsink_add_in
ternal:<rtpsink> getaddrinfo lookup error?
0:00:00.761717912   588   0x412340 WARN            multiudpsink gstmultiudpsink.c:1160:gst_multiudpsink_remove
:<rtpsink> client at host localhost, port 5000 not found
0:00:00.764049344   588   0x412340 WARN            multiudpsink gstmultiudpsink.c:1094:gst_multiudpsink_add_in
ternal:<GstUDPSink@0x4f83e0> getaddrinfo lookup error?
0:00:00.764764921   588   0x412340 WARN            multiudpsink gstmultiudpsink.c:1160:gst_multiudpsink_remove
:<rtcpsink> client at host localhost, port 4951 not found
0:00:00.765625265   588   0x412340 WARN            multiudpsink gstmultiudpsink.c:1094:gst_multiudpsink_add_in
ternal:<rtcpsink> getaddrinfo lookup error?
0:00:00.766040556   588   0x412340 WARN            multiudpsink gstmultiudpsink.c:1160:gst_multiudpsink_remove
:<rtcpsink> client at host localhost, port 5001 not found
Segmentation fault