Gstreamer-tips-picture-in-picture-compositing

Source: Internet
Author: User
Tags gstreamer

Http://www.oz9aec.net/index.php/gstreamer/347-more-gstreamer-tips-picture-in-picture-compositing

Http://blog.sina.com.cn/s/blog_5106eff101018lsu.html

1. The RTSP protocol establishes the server (the code is C, but look at my client-side code to see how the API is quite straightforward) I modified the code URL

/* GStreamer * Copyright (c) Taymans Wim <wim.taymans at gmail.com> * Copyright (c) Enthusiasticgeek <[ email protected]> * * This library was free software;  You can redistribute it and/or * modify it under the terms of the GNU Library general public * License as published by the Free software Foundation; either * Version 2 of the License, or (at your option) any later version. * * This library was distributed in the hope that it'll be useful, * but without any WARRANTY; Without even the implied warranty of * merchantability or FITNESS for A particular PURPOSE. See the GNU * Library general public License for more details. * * You should has received a copy of the GNU Library general public * License along with this Library; If not, write to the * Free Software Foundation, Inc., Temple Place-suite, * Boston, MA 02111-1307, USA. *///edited By:enthusiasticgeek (c) for Stack Overflow Sept 11, 2012//############################################# ##############################//important//######################################################################## ###//on ubuntu:sudo apt-get Install libgstrtspserver-0.10-0 libgstrtspserver-0.10-dev//play with VLC//CodeGo.net// Video decode Only:gst-launch-v rtspsrc location= "Codego.net! Rtph264depay! ffdec_h264! Autovideosink//audio and Video://gst-launch-v rtspsrc location= "Codego.net name=demux Demux. ! Queue! Rtph264depay! ffdec_h264! Ffmpegcolorspace! Autovideosink Sync=false Demux. ! Queue! Rtppcmadepay! Alawdec! autoaudiosink//########################################################################### #include <gst/ Gst.h> #include <gst/rtsp-server/rtsp-server.h>/* Define this if you want the resource for only being available when u Sing * user/admin as the password * * #undef with_auth/* This timeout was periodically run to clean up the expired sessions F Rom the * pool. This needs to is run explicitly currently but might is done * automatically as part of the Mainloop. */static gbooleantimeout (gstrtspserver * server, Gboolean ignored) {Gstrtspsessionpool *pool; pool = Gst_rtsp_server_get _session_pool (server); Gst_rtsp_session_pool_cleanup (pool); G_object_unref (pool); return TRUE;} Intmain (int argc, char *argv[]) {Gmainloop *loop; Gstrtspserver *server; Gstrtspmediamapping *mapping; Gstrtspmediafactory *factory; #ifdef with_auth Gstrtspauth *auth; Gchar *basic; #endif gst_init (&AMP;ARGC, &AMP;ARGV); loop = G_main_loop_new (NULL, FALSE); /* Create a server instance */server = Gst_rtsp_server_new (); Gst_rtsp_server_set_service (server, "8554"); Set the port #/* Get the mapping for this server, every server have a default mapper object * that is used to map URI mo UNT points to media factories */mapping = gst_rtsp_server_get_media_mapping (server), #ifdef with_auth/* Make a new authe Ntication Manager. It can be added-control access to all * The factories on the server or on individual factories. */auth = gst_rtsp_auth_new (); Basic =Gst_rtsp_auth_make_basic ("User", "admin"); Gst_rtsp_auth_set_basic (auth, Basic); G_free (Basic); /* Configure in the server */Gst_rtsp_server_set_auth (server, auth); #endif/* Make a media factory for a test stream. The default media factory can use * gst-launch syntax to create pipelines. * Any launch line works as long as it contains elements named pay%d. Each element with pay%d names would be a stream */factory = Gst_rtsp_media_factory_new (); Gst_rtsp_media_factory_set_launch (Factory, "(" "Videotestsrc! VIDEO/X-RAW-YUV,WIDTH=320,HEIGHT=240,FRAMERATE=10/1! "X264enc!" Queue! Rtph264pay name=pay0 pt=96! Audiotestsrc! audio/x-raw-int,rate=8000! Alawenc! Rtppcmapay name=pay1 pt=97 "") "); /* Attach the test factory to the/test URL */gst_rtsp_media_mapping_add_factory (mapping, "/test", factory); /* don ' t need the ref to the mapper anymore */g_object_unref (mapping); /* Attach the server to the default Maincontext */if (Gst_rtsp_server_attach (server, NULL) = = 0) gotO failed; /* Add a timeout for the session cleanup */G_timeout_add_seconds (2, (GSOURCEFUNC) timeout, server); /* Start serving, this never stops */G_main_loop_run (loop); return 0; /* ERRORS */failed: {g_print ("failed to attach the server\n"); return-1;}}

Makefile file

# Copyright (c) 2012 enthusiasticgeek# RTSP demo for Stack Overflowsample: gcc -Wall -I/usr/include/gstreamer-0.10 rtsp.c -o rtsp `pkg-config --libs --cflags gstreamer-0.10 gstreamer-rtsp-0.10` -lglib-2.0 -lgstrtspserver-0.10 -lgstreamer-0.10

Once you have built the binary, simply say it ./rtsp then open another tab in the terminal to test the following pipeline. Test the decoding pipeline. It works very well!

gst-launch -v rtspsrc location=" CodeGo.net  name=demux demux. ! queue ! rtph264depay ! ffdec_h264 ! ffmpegcolorspace ! autovideosink sync=false demux. ! queue ! rtppcmadepay ! alawdec ! autoaudiosink
Gst_rtsp_media_factory_set_launch (Factory,
"(VIDEOTESTSRC is-live=1!) X264enc! Rtph264pay name=pay0 pt=96) ");




Gstreamer-tips-picture-in-picture-compositing

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.