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. RTSP协议建立服务器(该代码是C,但看看我的客户端端代码,看看它如何的API是相当直截了当) 我修改了代码的URL

  1. /* GStreamer
  2. * Copyright (C) 2008 Wim Taymans <wim.taymans at gmail.com>
  3. * Copyright (c) 2012 enthusiasticgeek <enthusiasticgeek@gmail.com>
  4. *
  5. * This library is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU Library General Public
  7. * License as published by the Free Software Foundation; either
  8. * version 2 of the License, or (at your option) any later version.
  9. *
  10. * This library is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  13. * Library General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU Library General Public
  16. * License along with this library; if not, write to the
  17. * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  18. * Boston, MA 02111-1307, USA.
  19. */
  20. //Edited by: enthusiasticgeek (c) 2012 for Stack Overflow Sept 11, 2012
  21. //###########################################################################
  22. //Important
  23. //###########################################################################
  24. //On ubuntu: sudo apt-get install libgstrtspserver-0.10-0 libgstrtspserver-0.10-dev
  25. //Play with VLC
  26. // CodeGo.net
  27. //video decode only: gst-launch -v rtspsrc location=" CodeGo.net ! rtph264depay ! ffdec_h264 ! autovideosink
  28. //audio and video:
  29. //gst-launch -v rtspsrc location=" CodeGo.net name=demux demux. ! queue ! rtph264depay ! ffdec_h264 ! ffmpegcolorspace ! autovideosink sync=false demux. ! queue ! rtppcmadepay ! alawdec ! autoaudiosink
  30. //###########################################################################
  31. #include <gst/gst.h>
  32. #include <gst/rtsp-server/rtsp-server.h>
  33. /* define this if you want the resource to only be available when using
  34. * user/admin as the password */
  35. #undef WITH_AUTH
  36. /* this timeout is periodically run to clean up the expired sessions from the
  37. * pool. This needs to be run explicitly currently but might be done
  38. * automatically as part of the mainloop. */
  39. static gboolean
  40. timeout (GstRTSPServer * server, gboolean ignored)
  41. {
  42. GstRTSPSessionPool *pool;
  43. pool = gst_rtsp_server_get_session_pool (server);
  44. gst_rtsp_session_pool_cleanup (pool);
  45. g_object_unref (pool);
  46. return TRUE;
  47. }
  48. int
  49. main (int argc, char *argv[])
  50. {
  51. GMainLoop *loop;
  52. GstRTSPServer *server;
  53. GstRTSPMediaMapping *mapping;
  54. GstRTSPMediaFactory *factory;
  55. #ifdef WITH_AUTH
  56. GstRTSPAuth *auth;
  57. gchar *basic;
  58. #endif
  59. gst_init (&argc, &argv);
  60. loop = g_main_loop_new (NULL, FALSE);
  61. /* create a server instance */
  62. server = gst_rtsp_server_new ();
  63. gst_rtsp_server_set_service(server,"8554"); //set the port #
  64. /* get the mapping for this server, every server has a default mapper object
  65. * that be used to map uri mount points to media factories */
  66. mapping = gst_rtsp_server_get_media_mapping (server);
  67. #ifdef WITH_AUTH
  68. /* make a new authentication manager. it can be added to control access to all
  69. * the factories on the server or on individual factories. */
  70. auth = gst_rtsp_auth_new ();
  71. basic = gst_rtsp_auth_make_basic ("user", "admin");
  72. gst_rtsp_auth_set_basic (auth, basic);
  73. g_free (basic);
  74. /* configure in the server */
  75. gst_rtsp_server_set_auth (server, auth);
  76. #endif
  77. /* make a media factory for a test stream. The default media factory can use
  78. * gst-launch syntax to create pipelines.
  79. * any launch line works as long as it contains elements named pay%d. Each
  80. * element with pay%d names will be a stream */
  81. factory = gst_rtsp_media_factory_new ();
  82. gst_rtsp_media_factory_set_launch (factory, "( "
  83. "videotestsrc ! video/x-raw-yuv,width=320,height=240,framerate=10/1 ! "
  84. "x264enc ! queue ! rtph264pay name=pay0 pt=96 ! audiotestsrc ! audio/x-raw-int,rate=8000 ! alawenc ! rtppcmapay name=pay1 pt=97 "")");
  85. /* attach the test factory to the /test url */
  86. gst_rtsp_media_mapping_add_factory (mapping, "/test", factory);
  87. /* don't need the ref to the mapper anymore */
  88. g_object_unref (mapping);
  89. /* attach the server to the default maincontext */
  90. if (gst_rtsp_server_attach (server, NULL) == 0)
  91. goto failed;
  92. /* add a timeout for the session cleanup */
  93. g_timeout_add_seconds (2, (GSourceFunc) timeout, server);
  94. /* start serving, this never stops */
  95. g_main_loop_run (loop);
  96. return 0;
  97. /* ERRORS */
  98. failed:
  99. {
  100. g_print ("failed to attach the server\n");
  101. return -1;
  102. }
  103. }

Makefile文件

  1. # Copyright (c) 2012 enthusiasticgeek
  2. # RTSP demo for Stack Overflow
  3. sample:
  4. 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

一旦你建立了二进制,简单来说它./rtsp然后打开另一个选项卡中的终端测试以下的pipeline。 测试解码流水线。它工作得很好!

  1. gst-launch -v rtspsrc location=" CodeGo.net name=demux demux. ! queue ! rtph264depay ! ffdec_h264 ! ffmpegcolorspace ! autovideosink sync=false demux. ! queue ! rtppcmadepay ! alawdec ! autoaudiosink

  2.  gst_rtsp_media_factory_set_launch (factory,
          "( videotestsrc is-live=1 ! x264enc ! rtph264pay name=pay0 pt=96 )");
  3.  

gstreamer-tips-picture-in-picture-compositing的更多相关文章

  1. A Complete Guide to the <Picture> Element

    If you’ve ever struggled building responsive websites, this post is for you. It’s part of a series o ...

  2. 【20190305】CSS-响应式图片:srcset+sizes,picture,svg

    响应式图片可以根据不同的设备屏幕大小从而选择加载不同的图片,从而节省带宽.实现响应式图片有三种方法:srcset+sizes属性.picture标签.svg 1. srcset+sizes srcse ...

  3. error C2011: “Picture”:“struct”类型重定义

    今天引用外来库时出现问题,也许是版本问题. 错误如下: .....\oursun\cincludes\quickdraw.h(309): error C2011: “Picture”:“struct” ...

  4. gstreamer应用笔记

    gstreamer官网 https://gstreamer.freedesktop.org/ 应用手册 https://gstreamer.freedesktop.org/documentation/ ...

  5. iPad 多任务 Spilt View & Size Class

    iPad 多任务 Spilt View & Size Class 一.多任务简介 iOS 9 以后iPad新增了多任务的支持,主要形式有三种: Slide Over (侧边快捷打开) Spil ...

  6. SpringMVC处理multipart请求.

    一.简述 multipart格式的数据会将一个表单拆分为多个部分(part),每个部分对应一个输入域.在一般的表单输入域中,它所对应的部分中会放置文本型数据,但是如果上传文件的话,它所对应的部分可以是 ...

  7. puppeteer(五)chrome启动参数列表API

    List of Chromium Command Line Switches https://peter.sh/experiments/chromium-command-line-switches/ ...

  8. CEF 支持的命令行参数

    参考:https://peter.sh/experiments/chromium-command-line-switches/ List of Chromium Command Line Switch ...

  9. OpenCV 数字验证码识别

    更新后代码下载链接在此! !! 点我下载 本文针对OpenCv入门人士.由于我也不是专门做图像的,仅仅是为了完毕一次模式识别的小作业. 主要完毕的功能就是自己主动识别图片中的数字.图片包含正常图片,有 ...

  10. java web学习笔记-jsp篇

    1.java web简介 1.1静态页面与动态页面   表现形式 所需技术 静态网页 网页内容固定,不会更新 html,css 动态网页 网页内容由程序动态显示,自动更新 html,css,DB,ja ...

随机推荐

  1. 简单介绍一下vue2.0

    Vue Vue是用于构建用户界面的渐进框架.作者尤雨熙特别强调它与其他的框架不同,Vue是渐进式的框架,可以逐步采用,不必一下就通过框架去重构项目. 另外Vue的核心库只专注于视图层,这样就更容易与其 ...

  2. plsql programming 12 集合(忽略, 个人感觉用不到)

    关联数组, 嵌套表, varray 个人并不推荐使用集合, 因为操作有别于普通字段. 集合中每一个元素的数据类型都是相同的, 因此这些元素都是同质的(同质元素) 这一章的内容先忽略吧, 因为个人感觉用 ...

  3. [转]Netbeans IDE默认UTF-8编码

    NetBeans是一款优秀的开源集成开发环境,可以用于Java,C/C++,PHP等语言的开发.同时它也是一个可扩展的开发平台,可以通过插件来扩展官方版本没有的功能. NetBeans有一个很弱智的地 ...

  4. Python Theano 一键安装

    Download Anaconda Anaconda is a completely free Python distribution (including for commercial use an ...

  5. Consul1 在window7安装

    1.从下载地址:https://www.consul.io/downloads.html下载解压到某一地方.以本机为例:既解压到D:/tool下 2.  将consul.exe文件所在的文件路径添加到 ...

  6. 关于 JavaScript 学习 —— 好的博客或者网站推荐

    作者:Tw93链接:https://www.zhihu.com/question/19651401/answer/46211739来源:知乎著作权归作者所有.商业转载请联系作者获得授权,非商业转载请注 ...

  7. redis string底层数据结构sds

    redis的string没有采用c语言的字符串数组而采用自定义的数据结构SDS(simple dynamic string)设计 len 为字符串的实际长度  在redis中获取字符串的key长度的时 ...

  8. UIWebView加载ANSI格式的txt文件出现乱码问题解决

    //若为txt文档    if([encodedString hasSuffix:@".txt"]){                        NSData* Data = ...

  9. tomcat访问日志分析

    常使用web服务器的朋友大都了解,一般的web server有两部分日志: 一是运行中的日志,它主要记录运行的一些信息,尤其是一些异常错误日志信息 二是访问日志信息,它记录的访问的时间,IP,访问的资 ...

  10. 《从零开始学Swift》学习笔记(Day 3)——Swift 2.0之后增加的关键字

    Swift 2.0学习笔记(Day 3)——Swift 2.0之后增加的关键字 原创文章,欢迎转载.转载请注明:关东升的博客 看了之前的学习笔记知道了什么是关键字,现在提示各位在Swift 2.0之后 ...