C++ RTP pipeline

horai ivo.hora at seznam.cz
Wed Mar 29 17:19:06 UTC 2017


Dear all,

I am very new to Gstreamer and I tried to reproduce my already working
pipeline from command line to C++. The pipeline compiles and runs fine, but
there is no output on my SPI TFT screen attached to Orange Pi, could anyone
help me finding a bug in my code or pointing me how to resolve it?

Best regards,

Sender pipeline:
gst-launch-1.0 v4l2src device=/dev/video0 !
video/x-raw,width=320,height=240,framerate=25/2 ! videoconvert !  x264enc !
rtph264pay ! udpsink host=192.168.1.3 port=1234

Receiver pipeline:
gst-launch-1.0 -v udpsrc port=1234 caps="application/x-rtp,
media=(string)video, clock-rate=(int)90000, encoding-name=(string)H264" !
rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! fbdevsink
device=/dev/fb8 sync=false

C++ receiver code modified thanks to excellent post
http://gstreamer-devel.966125.n4.nabble.com/C-code-for-rtp-h264-decoding-I-can-t-find-how-to-solve-the-error-Read-is-insteresting-td3242017.html

C++ receiver code:

#include <math.h>

#include <gst/gst.h>

/* the caps of the sender RTP stream. This is usually negotiated out of band
with
 * SDP or RTSP. */
#define VIDEO_CAPS
"application/x-rtp,media=(string)video,clock-rate=(int)90000,encoding-name=(string)H264"


#define VIDEO_DEPAY "rtph264depay"
#define VIDEO_DEC   "avdec_h264"
#define VIDEO_SINK  "fbdevsink"
#define VIDEO_PARSE "h264parse"


int main (int argc, char *argv[])
{
  GstElement *rtpbin, *rtpsrc, *rtcpsrc, *rtcpsink;
  GstElement *videodepay,
             *videodec,
             //*videores,
             *videoconv,
             *videosink,
  	*videoparse;	
  		

  GstElement *pipeline;
  GMainLoop *loop;
  GstCaps *caps;
  gboolean res;
  GstPadLinkReturn lres;
  GstPad *srcpad, *sinkpad;

  /* always init first */
  gst_init (&argc, &argv);

  /* the pipeline to hold everything */
  pipeline = gst_pipeline_new (NULL);
  g_assert (pipeline);

  /* the udp src and source we will use for RTP and RTCP */
  rtpsrc = gst_element_factory_make ("udpsrc", "rtpsrc");
  g_assert (rtpsrc);
  g_object_set (rtpsrc, "port", 1234, NULL);
  /* we need to set caps on the udpsrc for the RTP data */
  caps = gst_caps_from_string (VIDEO_CAPS);
  g_object_set (rtpsrc, "caps", caps, NULL);
  gst_caps_unref (caps);

  

  /* the depayloading and decoding */
  videodepay = gst_element_factory_make (VIDEO_DEPAY, "videodepay");
  g_assert (videodepay);
  videoparse= gst_element_factory_make (VIDEO_PARSE, "videoparse");
  g_assert (videoparse);
  videodec = gst_element_factory_make (VIDEO_DEC, "videodec");
  g_assert (videodec);
  /* the audio playback and format conversion */
  videoconv = gst_element_factory_make ("videoconvert", "videoconv");
  g_assert (videoconv);

  videosink = gst_element_factory_make (VIDEO_SINK, "videosink");
  g_assert (videosink);
g_object_set (videosink,"device", "/dev/fb8", NULL);
g_object_set (videosink, "sync", FALSE, NULL);


  /* add depayloading and playback to the pipeline and link */
  gst_bin_add_many (GST_BIN (pipeline), videodepay,videoparse, videodec,
videoconv, /*videores,*/ videosink, NULL);

  res = gst_element_link_many (videodepay, videoparse,videodec, videoconv,
/*videores,*/ videosink, NULL);
  g_assert (res == TRUE);


  /* set the pipeline to playing */
  g_print ("starting receiver pipeline\n");
  gst_element_set_state (pipeline, GST_STATE_PLAYING);

  /* we need to run a GLib main loop to get the messages */
  loop = g_main_loop_new (NULL, FALSE);
  g_main_loop_run (loop);

  g_print ("stopping receiver pipeline\n");
  gst_element_set_state (pipeline, GST_STATE_NULL);

  gst_object_unref (pipeline);

  return 0;

} 

Thank you





--
View this message in context: http://gstreamer-devel.966125.n4.nabble.com/C-RTP-pipeline-tp4682450.html
Sent from the GStreamer-devel mailing list archive at Nabble.com.


More information about the gstreamer-devel mailing list