├── .gitignore ├── HISTORY.md ├── Makefile ├── README.md ├── media ├── small.3gp ├── small.flv ├── small.mp4 ├── small.ogv └── small.webm ├── static ├── GStreamer-1.0_usage.sh └── index.html └── tutorial ├── Makefile ├── basic-tutorial-1.c ├── basic-tutorial-2.c └── basic-tutorial-3.c /.gitignore: -------------------------------------------------------------------------------- 1 | 2 | *.exe 3 | 4 | tutorial/basic-tutorial-1 5 | tutorial/basic-tutorial-2 6 | tutorial/basic-tutorial-3 7 | -------------------------------------------------------------------------------- /HISTORY.md: -------------------------------------------------------------------------------- 1 | ## Learn to use 2 | 3 | 4 | ### Work History 5 | 6 | * 2019/05/06: 7 | - dowwnload and build the [GStreamer/gstreamer](https://github.com/GStreamer/gstreamer) - 1.17.1 8 | ``` 9 | $ ccget https://github.com/GStreamer/gstreamer 10 | $ ./autogen.sh 11 | $ ./configure 12 | $ make 13 | ``` 14 | - Configuration 15 | ``` 16 | Version : 1.17.0.1 17 | Source code location : . 18 | Prefix : /usr/local 19 | Compiler : gcc 20 | Package name : GStreamer git 21 | Package origin : Unknown package origin 22 | 23 | API Documentation : no 24 | 25 | Debug logging : yes 26 | Tracing subsystem hooks : yes 27 | Command-line parser : yes 28 | Option parsing in gst_init : yes 29 | Plugin registry : yes 30 | Plugin support : yes 31 | Static plugins : 32 | Unit testing support : yes 33 | PTP clock support : yes 34 | libunwind support : yes 35 | libdw support : yes <-- $ sudo apt install libdw-dev 36 | 37 | Debug : yes 38 | Profiling : no 39 | 40 | Building benchmarks : yes 41 | Building examples : yes 42 | Building test apps : yes 43 | Building tests that fail : no 44 | Building tools : yes 45 | ``` 46 | 47 | * 2018/05/04: 48 | - build and test some tutorial examples in GStreamer [Documentation](https://gstreamer.freedesktop.org/documentation/) 49 | 50 | 51 | ### Utility Shell 52 | ```sh 53 | $ type gst 54 | gst () 55 | { 56 | if [ $# = 0 ]; then 57 | echo "usage: $FUNCNAME "; 58 | return; 59 | fi; 60 | case $1 in 61 | info) 62 | v4l2-ctl --list-devices --list-ctrls --list-formats 63 | ;; 64 | list) 65 | pkg-config --list-all | grep --color=auto gst 66 | ;; 67 | play) 68 | gst-play-1.0 $2 69 | ;; 70 | search) 71 | gst-inspect-1.0 | grep --color=auto $2 72 | ;; 73 | version | v) 74 | gst-launch-1.0 --version 75 | ;; 76 | esac 77 | } 78 | ``` 79 | 80 | 81 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for gstreamer 1.0 3 | # 4 | PORT=5000 5 | SAMPLE=media/small.ogv 6 | 7 | GST_PLAY=gst-play-1.0 8 | GST_LAUNCH=gst-launch-1.0 9 | GST_INSPECT=gst-inspect-1.0 10 | GST_DISCOVER=gst-discoverer-1.0 11 | GST_DEVICE=gst-device-monitor-1.0 12 | #----------------------------------------------------------------------------------------- 13 | usage: 14 | @echo "make [pkg|video|gst|test|web]" 15 | #----------------------------------------------------------------------------------------- 16 | edit-history eh: 17 | vi HISTORY.md 18 | #----------------------------------------------------------------------------------------- 19 | package pkg p: 20 | @echo "make (pkg) [list|config|install|search]" 21 | 22 | pkg-list pl: 23 | ls /usr/lib/x86_64-linux-gnu/pkgconfig/gstreamer* 24 | ls /usr/lib/x86_64-linux-gnu/gstreamer* 25 | 26 | pkg-config pc: 27 | pkg-config --list-all | grep gstreamer 28 | 29 | pkg-install pi: 30 | sudo apt install libv4l-dev v4l-utils v4l2ucp 31 | sudo apt install -y \ 32 | gstreamer1.0-tools gstreamer1.0-nice \ 33 | gstreamer1.0-plugins-base gstreamer1.0-plugins-good \ 34 | gstreamer1.0-plugins-bad gstreamer1.0-plugins-ugly \ 35 | gstreamer1.0-libav libgstrtspserver-1.0-dev \ 36 | libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libgstreamer-plugins-bad1.0-dev \ 37 | libglib2.0-dev libsoup2.4-dev libjson-glib-dev 38 | sudo apt install ges1.0-tools 39 | 40 | pkg-search ps: 41 | apt search gst | grep gstreamer1.0 42 | 43 | pkg-list pl: 44 | dpkg -l gst* 45 | 46 | #----------------------------------------------------------------------------------------- 47 | video-device vd: 48 | v4l2-ctl --list-devices --list-ctrls --list-formats 49 | 50 | video-play vp: 51 | vlc udp://@0.0.0.0:$(PORT) & 52 | #----------------------------------------------------------------------------------------- 53 | gst s: 54 | @echo "make (gst:s) [device|view]" 55 | 56 | gst-device sd: 57 | $(GST_INSPECT) --print-all 58 | #$(GST_INSPECT) --print-plugin-auto-install-info 59 | #$(GST_INSPECT) mpegtsmux 60 | 61 | gst-view sv: 62 | @echo "make (gst-view:sv) [1|2]" 63 | sv1: 64 | $(GST_LAUNCH) playbin3 uri=v4l2:///dev/video0 65 | sv2: 66 | $(GST_LAUNCH) v4l2src device=/dev/video0 ! videoconvert ! autovideosink 67 | 68 | #----------------------------------------------------------------------------------------- 69 | test t: 70 | @echo "make (test) [discover|play|extract|stream|base]" 71 | 72 | test-discover td: 73 | $(GST_DISCOVER) $(SAMPLE) 74 | 75 | test-play tp: 76 | $(GST_PLAY) $(SAMPLE) 77 | 78 | test-extract te: 79 | -rm test.ac3 80 | $(GST_LAUNCH) -v filesrc location=$(SAMPLE) ! oggdemux ! vorbisdec ! avenc_ac3 bitrate=64000 ! filesink location=test.ac3 81 | $(GST_PLAY) test.ac3 82 | 83 | test-format tf: 84 | -rm test.mp4 85 | $(GST_LAUNCH) filesrc location=$(SAMPLE) ! oggdemux name=demux \ 86 | qtmux name=mux ! filesink location=test.mp4 \ 87 | demux. ! theoradec ! x264enc ! mux. \ 88 | demux. ! queue max-size-time=5000000000 max-size-buffers=10000 ! vorbisdec ! avenc_aac compliance=-2 ! mux. 89 | $(GST_PLAY) test.mp4 90 | 91 | test-stream ts: 92 | $(GST_LAUNCH) filesrc location=$(SAMPLE) ! oggdemux name=demux \ 93 | mpegtsmux name=mux alignment=7 ! udpsink host=127.0.0.1 port=$(PORT) buffer-size=10000000 \ 94 | demux. ! theoradec ! x264enc ! mux. \ 95 | demux. ! queue max-size-time=5000000000 max-size-buffers=10000 ! vorbisdec ! avenc_aac compliance=-2 ! mux. 96 | 97 | test-camera tc: 98 | @echo "make (test-camera) [1|2]" 99 | 100 | tc1: 101 | #gst-launch-1.0 v4l2src device=/dev/video0 ! 'video/x-raw,format=YUYV,width=320,height=240' \ 102 | #! x264enc pass=qual quantizer=20 tune=zerolatency ! rtph264pay ! udpsink host=127.0.0.1 port=$(PORT) 103 | $(GST_LAUNCH) -v v4l2src ! video/x-raw,width=640,height=480 \ 104 | ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=$(PORT) 105 | 106 | tc2: 107 | $(GST_LAUNCH) -v v4l2src ! video/x-raw,width=640,height=480 \ 108 | ! textoverlay text="Room A" valignment=top halignment=left font-desc="Sans, 22" \ 109 | ! videoconvert ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=$(PORT) 110 | 111 | test-recv tr: 112 | $(GST_LAUNCH) udpsrc port=$(PORT) ! "application/x-rtp,payload=127" ! rtph264depay ! ffdec_h264 ! xvimagesink sync=false 113 | 114 | test-test tt: 115 | $(GST_LAUNCH) -v udpsrc port=1234 ! fakesink dump=1 116 | $(GST_LAUNCH) -v audiotestsrc ! udpsink host=127.0.0.1 port=1234 117 | 118 | test-base tb: 119 | @echo "make (test-base) [1|2|3]" 120 | tb1: 121 | $(GST_LAUNCH) -v videotestsrc ! ximagesink 122 | tb2: 123 | $(GST_LAUNCH) -v videotestsrc ! x264enc ! mpegtsmux ! fakesink silent=false sync=true -v 124 | tb3: 125 | $(GST_INSPECT) mpegtsmux 126 | 127 | #----------------------------------------------------------------------------------------- 128 | send-recv sr: 129 | @echo "make (send-recv) [1|2|3]" 130 | 131 | sr1: # JPEG 132 | $(GST_LAUNCH) udpsrc port=$(PORT) ! application/x-rtp,encoding-name=JPEG,payload=26 ! rtpjpegdepay ! jpegdec ! autovideosink & 133 | $(GST_LAUNCH) -v v4l2src ! video/x-raw,width=640,height=480 ! videoconvert ! jpegenc \ 134 | ! rtpjpegpay ! udpsink host=127.0.0.1 port=$(PORT) 135 | 136 | sr2: # VP8 137 | $(GST_LAUNCH) udpsrc port=$(PORT) caps="application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)VP8-DRAFT-IETF-01, payload=(int)96, ssrc=(uint)2990747501, clock-base=(uint)275641083, seqnum-base=(uint)34810" ! rtpvp8depay ! vp8dec ! autovideosink & 138 | $(GST_LAUNCH) -v v4l2src ! video/x-raw,width=640,height=480 ! videoconvert ! vp8enc ! rtpvp8pay ! udpsink host=127.0.0.1 port=$(PORT) 139 | 140 | sr3: # MPEG-4 141 | $(GST_LAUNCH) udpsrc port=$(PORT) caps = "application/x-rtp\,\ media\=\(string\)video\,\ clock-rate\=\(int\)90000\,\ encoding-name\=\(string\)MP4V-ES\,\ profile-level-id\=\(string\)1\,\ config\=\(string\)000001b001000001b58913000001000000012000c48d8800cd3204709443000001b24c61766335362e312e30\,\ payload\=\(int\)96\,\ ssrc\=\(uint\)2873740600\,\ timestamp-offset\=\(uint\)391825150\,\ seqnum-offset\=\(uint\)2980" ! rtpmp4vdepay ! avdec_mpeg4 ! autovideosink & 142 | $(GST_LAUNCH) -v v4l2src ! video/x-raw,width=640,height=480 ! videoconvert ! avenc_mpeg4 ! rtpmp4vpay config-interval=3 ! udpsink host=127.0.0.1 port=$(PORT) 143 | 144 | sr4: # H.264 145 | $(GST_LAUNCH) udpsrc port=$(PORT) caps = "application/x-rtp\,\ media\=\(string\)video\,\ clock-rate\=\(int\)90000\,\ encoding-name\=\(string\)H264\,\ payload\=\(int\)96" ! rtph264depay ! avdec_h264 ! autovideosink & 146 | $(GST_LAUNCH) -v v4l2src ! video/x-raw,width=640,height=480 ! videoconvert ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=$(PORT) 147 | 148 | sr5: 149 | $(GST_LAUNCH) -v v4l2src ! video/x-raw,width=640,height=480 \ 150 | ! textoverlay text="Room A" valignment=top halignment=left font-desc="Sans, 22" \ 151 | ! videoconvert ! x264enc ! rtph264pay ! udpsink host=127.0.0.1 port=$(PORT) & 152 | $(GST_LAUNCH) -v v4l2src ! video/x-raw,width=640,height=480 ! videoconvert ! x264enc \ 153 | ! rtph264pay ! udpsink host=127.0.0.1 port=$(PORT) 154 | 155 | sr6: 156 | $(GST_LAUNCH) -vc udpsrc port=$(PORT) close-socket=false multicast-iface=false auto-multicast=true \ 157 | ! application/x-rtp, payload=96 ! rtpjitterbuffer ! rtph264depay ! avdec_h264 \ 158 | ! fpsdisplaysink sync=false async=false --verbose & 159 | $(GST_LAUNCH) -v v4l2src device=/dev/video0 \ 160 | ! video/x-raw,width=1280,height=720,type=video ! videoscale ! videoconvert ! x264enc tune=zerolatency \ 161 | ! rtph264pay ! udpsink host=127.0.0.1 port=$(PORT) --verbose 162 | 163 | 164 | sr7: # WebRTC 165 | gst-launch-1.0 webrtcbin bundle-policy=max-bundle name=sendrecv stun-server=stun://stun.l.google.com:19302 ! rtpopusdepay ! opusdec ! audioconvert ! autoaudiosink async=false & 166 | gst-launch-1.0 webrtcbin bundle-policy=max-bundle name=sendrecv stun-server=stun://stun.l.google.com:19302 audiotestsrc is-live=true wave=red-noise ! audioconvert ! audioresample ! queue ! opusenc ! rtpopuspay ! application/x-rtp,media=audio,encoding-name=OPUS,payload=97 ! sendrecv. 167 | 168 | rist: 169 | gst-launch-1.0 ristsrc address=0.0.0.0 port=5004 ! rtpmp2depay ! udpsink 170 | gst-play-1.0 "rist://0.0.0.0:5004?receiver-buffer=700" 171 | 172 | #----------------------------------------------------------------------------------------- 173 | web w: 174 | @echo "make (web) [sample]" 175 | 176 | web-sample ws: 177 | xdg-open http://4youngpadawans.com/gstreamer-real-life-examples/ 178 | 179 | clean: 180 | rm -f test.* 181 | #----------------------------------------------------------------------------------------- 182 | git g: 183 | @echo "make (git) [update|login|tag|status]" 184 | 185 | git-update gu: 186 | git add .gitignore *.md Makefile static/ media/ tutorial/ 187 | #git commit -m "initial commit" 188 | #git remote remove go.mod sse.go 189 | #git commit -m "add examples" 190 | git commit -m "update contents" 191 | git push 192 | 193 | git-login gl: 194 | git config --global user.email "sikang99@gmail.com" 195 | git config --global user.name "Stoney Kang" 196 | git config --global push.default matching 197 | #git config --global push.default simple 198 | git config credential.helper store 199 | 200 | git-tag gt: 201 | git tag v0.0.3 202 | git push --tags 203 | 204 | git-status gs: 205 | git status 206 | git log --oneline -5 207 | #----------------------------------------------------------------------------------------- 208 | 209 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## GStreamer Handling 2 | 3 | --- 4 | ## Farstream 5 | ### Information 6 | - [Farstream](https://www.freedesktop.org/wiki/Software/Farstream/) - Audio/Video Communications Framework] 7 | 8 | 9 | --- 10 | ## Gstreamer 11 | ### Information 12 | - [wiki/GStreamer](https://en.wikipedia.org/wiki/GStreamer) 13 | - [Gstreamer](https://gstreamer.freedesktop.org/) - [1.16](https://gstreamer.freedesktop.org/releases/1.16/), 1.15.2, [1.14](https://gstreamer.freedesktop.org/releases/1.14/) 14 | - [**Documentation**](https://gstreamer.freedesktop.org/documentation/): [gst-launch-1.0](https://gstreamer.freedesktop.org/documentation/tools/gst-launch.html) 15 | - [List of Elements and Plugins](https://gstreamer.freedesktop.org/documentation/plugins.html) 16 | - [gstreamer-1.16.0](http://www.linuxfromscratch.org/blfs/view/svn/multimedia/gstreamer10.html) 17 | - [Conference](https://gstconf.ubicast.tv/) 18 | - [Gstreamer real life examples](http://4youngpadawans.com/gstreamer-real-life-examples/) 19 | - [GstWebRTC 1.0 (1.14.4)](https://lazka.github.io/pgi-docs/GstWebRTC-1.0/index.html) 20 | - [VLC command-line help](https://wiki.videolan.org/VLC_command-line_help/) 21 | - [GStreamer-1.0 personal cheat sheet](https://gist.github.com/strezh/9114204) 22 | - [matthew1000/gstreamer-cheat-sheet](https://github.com/matthew1000/gstreamer-cheat-sheet) - Gstreamer command-line cheat sheet 23 | - Drone Software Development: [Video Streaming](https://theiotlearninginitiative.gitbook.io/bitol/virtual-drone-solution/features/video-streaming) 24 | - [GStreamer Optimized Multimedia Processing for Audio and Video](https://www.psirep.com/system/files/GStreamer%20Optimized%20Multimedia%20Processing%20for%20Audio%20and%20Video%20white%20paper.pdf) 25 | - [WebRTC Gstreamer Gateway](https://swmansion.com/webrtc) 26 | - [GStreamer forum](https://spectrum.chat/gstreamer?tab=posts) 27 | - [Intel Video and Audio for Linux](https://01.org/linuxmedia/quickstart/overview) 28 | - [RaspberryPiで高画質ライブ配信](http://dz.plala.jp/wiki/index.php/RaspberryPi%E3%81%A7%E9%AB%98%E7%94%BB%E8%B3%AA%E3%83%A9%E3%82%A4%E3%83%96%E9%85%8D%E4%BF%A1) 29 | - [GStreamer Technologies](https://developer.ridgerun.com/wiki/index.php?title=GStreamer_Technologies) 30 | - [Audio effects with G-Streamer](https://www.ittiam.com/wp-content/uploads/2017/12/Audio_Effects_with_G-Streamer.pdf) 31 | - Intel: [GStreamer - OpenVX Interoperability Sample](https://software.intel.com/en-us/sample-gstreamer-openvx-interoperability) 32 | - [Introduction to network streaming using GStreamer](https://developer.ridgerun.com/wiki/index.php/Introduction_to_network_streaming_using_GStreamer) 33 | - [Yocto/gstreamer/streaming](http://trac.gateworks.com/wiki/Yocto/gstreamer/streaming) 34 | - [**Raspberry PI RTSP Guide**](https://www.stev.org/post/raspberrypisimplertspserver) 35 | - Genie Doc: [GStreamer](https://genie.webierta.skn1.com/wiki/gstreamer) 36 | - [GStreamer on Gateworks SBCs](http://trac.gateworks.com/wiki/Yocto/gstreamer#gst-variable-rtsp-server) 37 | - TI: [Gstreamer Migration Guidelines](http://www.ti.com/lit/an/sprac14/sprac14.pdf), SPRAC14–April 2016 38 | - [Pitivi](http://www.pitivi.org/): [Planet](http://www.pitivi.org/planet/) - video editor based on GStreamer 39 | - [예제: Kinesis 비디오 스트림 생산자 SDK GStreamer 플러그인](https://docs.aws.amazon.com/ko_kr/kinesisvideostreams/latest/dg/examples-gstreamer-plugin.html) 40 | - [UAVcast-Pro](https://docs.uavmatrix.com/): [Camera](https://docs.uavmatrix.com/pages/Camera/) 41 | - H.264 GStreamer pipelines examples for non-VPU SoCs 42 | - [Part 1 playback](https://imxdev.gitlab.io/tutorials/H.264_GStreamer_pipelines_examples_for_non-VPU_SoCs-Part_1/) 43 | - [Part 2 stream](https://imxdev.gitlab.io/tutorials/H.264_GStreamer_pipelines_examples_for_non-VPU_SoCs-Part_2/) 44 | - Nvidia, [Accelerated GStreamer User Guide, Release 27.1](https://developer.download.nvidia.com/embedded/L4T/r27_Release_v1.0/Docs/Jetson_TX2_Accelerated_GStreamer_User_Guide_Release_27.1.pdf) 45 | 46 | 47 | ### Slides 48 | - 2018 [DeepStream SDK 2.0](http://on-demand.gputechconf.com/gtc-au/pdf/DeepStreamSDK-ettikan-sharing.pdf) 49 | - 2018 [Gstreamer pipeline on webOS OSE](https://gstreamer.freedesktop.org/data/events/gstreamer-conference/2018/Jimmy%20Ohn%20-%20GStreamer%20pipeline%20on%20webOS%20OSE%20Lightning%20Talk.pdf) 50 | - 2018 [GstCUDA: A GStreamer-CUDA interface solution](https://gstreamer.freedesktop.org/data/events/gstreamer-conference/2018/Jos%C3%A9%20Jim%C3%A9nez-Chavarr%C4%B1%CC%81a%20-%20GstCUDA:%20A%20GStreamer-CUDA%20interface%20solution%20(Lightning%20Talk).pdf) 51 | - 2018 [Accelerated Gstreamer User Guide](https://developer.download.nvidia.com/embedded/L4T/r31_Release_v1.0/Docs/Accelerated_GStreamer_User_Guide.pdf?w-FjfyCgri2qxmCtwnzhMhjK5emQaHGA2wLSyP-rmJrTQlNi1FETp93FpAAJAJxphtzSeBKHBE8_3a1lUp_SNgn1A7D4rqSCZ8JwmzRWO9Hn4tB2Hc5JUop-BroNDJLPAew402NKCFSPktA941zNnMKXOTKEEme-hmaka4EleJJH4NyY-pI) 52 | - 2018 [**NNStreamer: Neural Networks as GStreamer Filters**](https://www.researchgate.net/publication/329750345_NNStreamer_Neural_Networks_as_GStreamer_Filters) 53 | - 2017 [GStreamer Daemon - Building a media server under 30min](https://gstreamer.freedesktop.org/data/events/gstreamer-conference/2017/David%20Soto%20-%20GStreamer%20Daemon%20-%20Building%20a%20media%20server%20under%2030min.pdf) 54 | - 2010 [GStreamer Past Present - Future](https://docplayer.net/140104-Gstreamer-past-present-future.html) 55 | 56 | 57 | ### History 58 | - 2021/03/15 [**GStreamer 1.18 Release Notes**](https://gstreamer.freedesktop.org/releases/1.18/) - 1.18.4 59 | - 2019/09/22 [**GStreamer 1.16 Release Notes**](https://gstreamer.freedesktop.org/releases/1.16/) - 1.16.1 60 | - 2019/05/23 [How to Live Stream to YouTube With a Raspberry Pi](https://www.makeuseof.com/tag/live-stream-youtube-raspberry-pi/) 61 | - 2019/05/10 [GStreamer support for the RIST Specification](https://www.linuxtoday.com/infrastructure/gstreamer-support-for-the-rist-specification-190409145024.html) 62 | - 2019/04/04 [**A Guide to H.264 Streaming with Regards to FRC**](https://rianadon.github.io/blog/2019/04/04/guide-to-h264-streaming-frc.html) 63 | - 2019/04/04 [GStreamer buffer flow analyzer](https://www.collabora.com/news-and-blog/blog/2019/04/25/gstreamer-buffer-flow-analyzer/) 64 | - 2019/04/04 [GStreamer support for the RIST Specification](https://www.collabora.com/news-and-blog/news-and-events/gstreamer-support-for-the-rist-specification.html) 65 | - 2019/04/02 [Jetson Nano + Raspberry Pi Camera](https://www.jetsonhacks.com/2019/04/02/jetson-nano-raspberry-pi-camera/) 66 | - 2019/03/18 [Accelerated GStreamer User Guide - NVIDIA Developer](https://developer.nvidia.com/embedded/dlc/l4t-accelerated-gstreamer-guide-32-1) 67 | - 2019/02/02 [gstreamer 1.16 and beyond - FOSDEM 2019](https://fosdem.org/2019/schedule/event/media_gstreamer_1_16/attachments/slides/3027/export/events/attachments/media_gstreamer_1_16/slides/3027/FOSDEM_2019_OpenMedia_GStreamer_1_16_and_beyond.pdf) 68 | - 2019/01/29 [**Nnstreamer stream pipeline for arbitrary neural networks**](https://www.slideshare.net/NaverEngineering/nnstreamer-stream-pipeline-for-arbitrary-neural-networks) 69 | - 2019/01/23 [GStreamer WebRTC: A flexible solution to web-based media](https://opensource.com/article/19/1/gstreamer) 70 | - 2019/00/00 71 | - 2018/11/15 [Gstreamer webrtcbin working sample pipeline](https://stackoverflow.com/questions/53267038/gstreamer-webrtcbin-working-sample-pipeline) 72 | - 2018/10/27 [OpenVidu 2.6.0: Ionic support](https://medium.com/@openvidu/openvidu-2-6-0-ionic-support-33c395e59c45) 73 | - 2018/10/26 [GStreamer RTSP Raspberry Pi Camera](https://idle.run/rtsp-server-rpi-gstreamer) 74 | - 2018/10/18 [Raspberry Pi 3: RTSP Server 설정](https://imsoftpro.tistory.com/53) 75 | - 2018/08/05 [Streaming with gstreamer](http://patrickelectric.work/streaming_with_gstreamer/) 76 | - 2018/08/01 [**Object Detection in Live Video: Using The ODROID-XU4 With GStreamer**](https://magazine.odroid.com/article/object-detection-in-live-video-using-the-odroid-xu4-with-gstreamer/) 77 | - 2018/06/20 [gstreamerのsrtプラグインを1.12.x にバックポートする](https://qiita.com/tetsu_koba/items/c4a277b24c4b4a30afae) 78 | - 2018/06/12 [新しい映像伝送プロトコルSRTをgstreamerとVLCで試す](https://qiita.com/tetsu_koba/items/b12a6de83185a5267217) 79 | - 2018/05/07 [Optimizing opencv 3.4 in Raspberry Pi 3 using GStreamer](http://www.ebenezertechs.com/optimizing-opencv-3-4-in-raspberry-pi-3-using-gstreamer/) 80 | - 2018/05/01 [Liquidsoap – Gstreamer MPEGTS stream how to](https://www.autonarcosis.com/2018/05/01/liquidsoap-gstreamer-mpegts-stream-how-to/) 81 | - 2018/04/10 [A simple method of measuring audio latency](http://blog.nirbheek.in/2018/04/a-simple-method-of-measuring-audio.html) 82 | - 2018/04/01 [gstreamer로 실시간 스트리밍](https://kldp.org/node/159391) 83 | - 2018/02/03 [GStreamer has grown a WebRTC implementation](http://blog.nirbheek.in/2018/02/gstreamer-webrtc.html) 84 | - 2018/00/00 85 | - 2017/06/20 [Gstreamer 파이프라인 테스트](https://myserena.tistory.com/89) 86 | - 2015/12/25 [Play webcam using gstreamer](https://medium.com/@petehouston/play-webcam-using-gstreamer-9b7596e4e181) 87 | - 2014/06/05 [Videostreaming with Gstreamer](http://z25.org/static/_rd_/videostreaming_intro_plab/index.html) 88 | 89 | 90 | ### 국내 91 | - [Gstreamer 예기들](https://m.blog.naver.com/PostList.nhn?blogId=jedijaja&categoryNo=7&logCode=0&categoryName=Gstreamer%20%EC%98%88%EA%B8%B0%EB%93%A4) 92 | - [라즈베리파이와 gstreamer를 이용한 간단한 video audio 서버](https://m.blog.naver.com/jedijaja/221001104246) 93 | - [GStreamer RTP UDP 카메라 전송 명령](http://blog.naver.com/PostView.nhn?blogId=chandong83&logNo=221263551742) 94 | 95 | 96 | ### Stackoverflow 97 | - [GStreamer transcode audio to AAC](https://stackoverflow.com/questions/51963114/gstreamer-transcode-audio-to-aac) - RTSP to HLS 98 | - [Using Gstreamer to serve RTSP stream, working example sought](https://stackoverflow.com/questions/13744560/using-gstreamer-to-serve-rtsp-stream-working-example-sought) 99 | - [WebRTC stream getting stuck on limited network bandwidth](https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/issues/1083) 100 | 101 | 102 | ### Open Source 103 | - [**nnsuite/nnstreamer**](https://github.com/nnsuite/nnstreamer) 104 | - [OpenVisualCloud/SVT-AV1](https://github.com/OpenVisualCloud/SVT-AV1) 105 | - [**OpenVisualCloud/CDN-Transcode-Sample**](https://github.com/OpenVisualCloud/CDN-Transcode-Sample) - Media transcoding 106 | - [**opencv/gst-video-analytics**](https://github.com/opencv/gst-video-analytics) - a collection of GStreamer elements to enable CNN model based video analytics capabilities (such as object detection, classification, recognition) 107 | - [centricular/gstwebrtc-demos](https://github.com/centricular/gstwebrtc-demos) 108 | - [thaytan/gst-rpicamsrc](https://github.com/thaytan/gst-rpicamsrc) - GStreamer element for the Raspberry Pi camera module 109 | - [mrayy/mrayGStreamerUnity](https://github.com/mrayy/mrayGStreamerUnity) - GStreamer Integration with Unity using a Native plugin 110 | - [royrscb/Gstreamer-WebRTC-SFU](https://github.com/royrscb/Gstreamer-WebRTC-SFU) - SFU with WebRTC usign Gstreamer 111 | - [teltek/gst-plugin-ndi](https://github.com/teltek/gst-plugin-ndi) - GStreamer NDI Plugin for Linux 112 | - [rubenrua/GstreamerCodeSnippets](https://github.com/rubenrua/GstreamerCodeSnippets) - Gstreamer Code Snippets in C, Python and Shell (gst-launch) 113 | - [nnsuite/nnstreamer](https://github.com/nnsuite/nnstreamer) - Neural Network (NN) Streamer, Stream Processing Paradigm for Neural Network Apps/Devices 114 | - [agherzan/meta-raspberrypi](https://github.com/agherzan/meta-raspberrypi) - Yocto BSP layer for the Raspberry Pi boards 115 | - meta-raspberrypi/recipes-multimedia/gstreamer 116 | - [gohai/processing-glvideo](https://github.com/gohai/processing-glvideo) - Hardware accelerated video playback using GL textures for Processing on Raspberry Pi 117 | - [processing/processing](https://github.com/processing/processing) - Source code for the Processing Core and Development Environment (PDE) 118 | - [idlerun/rtsp-server-rpi-gstreamer](https://github.com/idlerun/rtsp-server-rpi-gstreamer) - 119 | - [ccrisan/motioneye](https://github.com/ccrisan/motioneye) 120 | - [**GStreamer**](https://github.com/GStreamer) - GStreamer GitHub mirrors 121 | - [GStreamer/gst-plugins-base/](https://github.com/GStreamer/gst-plugins-base/) - 'Base' GStreamer plugins and helper libraries 122 | - [GStreamer/gst-plugins-good/](https://github.com/GStreamer/gst-plugins-good/) - 'Good' GStreamer plugins and helper libraries 123 | - [GStreamer/gst-plugins-bad/](https://github.com/GStreamer/gst-plugins-bad/) - 'Bad' GStreamer plugins and helper libraries 124 | - [GStreamer/gst-rtsp-server](https://github.com/GStreamer/gst-rtsp-server) - RTSP server based on GStreamer 125 | - [RidgeRun](https://github.com/RidgeRun) - RidgeRun Embedded Solutions 126 | - [RidgeRun/gstd-1.x](https://github.com/RidgeRun/gstd-1.x) - GStreamer Daemon 127 | - [gitlab.aja.com/ntv2/gst](https://gitlab.aja.com/ntv2/gst) - gStreamer plugin for ntv2 cards 128 | - [**gitlab/gstreamer**](https://gitlab.freedesktop.org/gstreamer) - GStreamer open-source multimedia framework 129 | - [JetsonHacksNano/CSI-Camera](https://github.com/JetsonHacksNano/CSI-Camera) - Simple example of using a CSI-Camera (like the Raspberry Pi Version 2 camera) with the NVIDIA Jetson Nano Developer Kit 130 | - [notedit/rtmp-to-webrtc](https://github.com/notedit/rtmp-to-webrtc) - rtmp to webrtc (Chinese) 131 | - [wondershaper](https://github.com/magnific0/wondershaper) - Command-line utility for limiting an adapter's bandwidth 132 | 133 | 134 | ### Persons 135 | - [Nirbheek’s Rantings](http://blog.nirbheek.in/) 136 | 137 | ### Books 138 | - [GStreamer Plugin Writer’s Guide (1.10.1)](https://gstreamer.freedesktop.org/data/doc/gstreamer/head/pwg/pwg.pdf) 139 | - [GStreamer Application Development Manual (1.10.1)](https://gstreamer.freedesktop.org/data/doc/gstreamer/head/manual/manual.pdf) 140 | 141 | 142 | 143 | 144 | 145 | -------------------------------------------------------------------------------- /media/small.3gp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sikang99/gst-example/0d0c9d04fff483d99dc32270f5daea542a0ce691/media/small.3gp -------------------------------------------------------------------------------- /media/small.flv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sikang99/gst-example/0d0c9d04fff483d99dc32270f5daea542a0ce691/media/small.flv -------------------------------------------------------------------------------- /media/small.mp4: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sikang99/gst-example/0d0c9d04fff483d99dc32270f5daea542a0ce691/media/small.mp4 -------------------------------------------------------------------------------- /media/small.ogv: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sikang99/gst-example/0d0c9d04fff483d99dc32270f5daea542a0ce691/media/small.ogv -------------------------------------------------------------------------------- /media/small.webm: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/sikang99/gst-example/0d0c9d04fff483d99dc32270f5daea542a0ce691/media/small.webm -------------------------------------------------------------------------------- /static/GStreamer-1.0_usage.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # play YUV444 FULL HD file 4 | gst-launch-1.0 -v filesrc location=size_1920x1080.yuv ! \ 5 | videoparse width=1920 height=1080 framerate=25/1 format=GST_VIDEO_FORMAT_Y444 ! \ 6 | videoconvert ! \ 7 | autovideosink 8 | 9 | # play YUV422 FULL HD file 10 | gst-launch-1.0 -v filesrc location=size_1920x1080.yuv ! \ 11 | videoparse width=1920 height=1080 framerate=25/1 format=GST_VIDEO_FORMAT_Y42B ! \ 12 | videoconvert ! \ 13 | autovideosink 14 | 15 | # play YUV422 FULL HD file 16 | gst-launch-1.0 -v filesrc location=size_1920x1080.yuv ! \ 17 | videoparse width=1920 height=1080 framerate=25/1 format=GST_VIDEO_FORMAT_Y42B ! \ 18 | videoconvert ! \ 19 | autovideosink 20 | 21 | # make PNG from YUV420 22 | gst-launch-1.0 -v filesrc location=size_1920x1080.yuv ! \ 23 | videoparse width=1920 height=1080 framerate=25/1 format=GST_VIDEO_FORMAT_Y42B ! \ 24 | videoconvert ! \ 25 | pngenc ! multifilesink location=img%03d.png 26 | 27 | # play MP4 FULL HD file 28 | gst-launch-1.0 filesrc location=test.mp4 ! \ 29 | decodebin name=dec ! \ 30 | queue ! \ 31 | videoconvert ! \ 32 | autovideosink dec. ! \ 33 | queue ! \ 34 | audioconvert ! \ 35 | audioresample ! \ 36 | autoaudiosink 37 | 38 | # play MP3 39 | gst-launch-1.0 filesrc location=test.mp3 ! decodebin ! playsink 40 | 41 | # play OGG 42 | gst-launch-1.0 filesrc location=test.ogg ! decodebin ! playsink 43 | 44 | # play MP3 over UDP + RTP 45 | # sender: 46 | gst-launch-1.0 -v filesrc location=test.mp3 ! \ 47 | decodebin ! \ 48 | audioconvert ! \ 49 | rtpL16pay ! \ 50 | udpsink port=6969 host=192.168.1.42 51 | # receiver: 52 | gst-launch-1.0 -v udpsrc port=6969 \ 53 | caps="application/x-rtp, media=(string)audio, format=(string)S32LE, \ 54 | layout=(string)interleaved, clock-rate=(int)44100, channels=(int)2, payload=(int)0" ! \ 55 | rtpL16depay ! playsink 56 | 57 | #play webcam video over UDP with h264 coding 58 | #sender 59 | gst-launch-1.0 v4l2src ! \ 60 | 'video/x-raw, width=640, height=480, framerate=30/1' ! \ 61 | videoconvert ! \ 62 | x264enc pass=qual quantizer=20 tune=zerolatency ! \ 63 | rtph264pay ! \ 64 | udpsink host=192.168.1.140 port=1234 65 | #receiver 66 | gst-launch-1.0 udpsrc port=1234 ! \ 67 | "application/x-rtp, payload=127" ! \ 68 | rtph264depay ! \ 69 | avdec_h264 ! \ 70 | videoconvert ! \ 71 | xvimagesink sync=false 72 | 73 | #play RAW webcam video over UDP (+RTP) without any coding 74 | #sender 75 | gst-launch-1.0 -v v4l2src ! 'video/x-raw, width=(int)640, height=(int)480, framerate=10/1' ! \ 76 | videoconvert ! queue ! \ 77 | rtpvrawpay ! queue ! \ 78 | 79 | udpsink host=127.0.0.1 port=1234 80 | #receiver 81 | gst-launch-1.0 udpsrc port=1234 ! \ 82 | "application/x-rtp, media=(string)video, clock-rate=(int)90000, encoding-name=(string)RAW, \ 83 | sampling=(string)YCbCr-4:2:2, depth=(string)8, width=(string)640, height=(string)480, \ 84 | ssrc=(uint)1825678493, payload=(int)96, clock-base=(uint)4068866987, seqnum-base=(uint)24582" ! \ 85 | rtpvrawdepay ! queue ! videoconvert ! autovideosink 86 | 87 | #save RAW video from webcam to file 88 | gst-launch-1.0 -v v4l2src ! 'video/x-raw, width=(int)640, height=(int)480, framerate=10/1' ! videoconvert ! filesink location=out.yuv 89 | 90 | #play RAW video from file 91 | gst-launch-1.0 filesrc location=out.yuv ! videoparse width=640 height=480 format=GST_VIDEO_FORMAT_YUY2 ! videoconvert ! autovideosink 92 | 93 | # video flipping 94 | gst-launch-1.0 videotestsrc ! videoflip method=clockwise ! videoconvert ! ximagesink 95 | 96 | 97 | # rtmp to webrtc 98 | gst-launch-1.0 -v rtmpsrc location=rtmp://localhost/live/{stream} ! flvdemux ! h264parse ! \ 99 | rtph264pay config-interval=-1 pt={pt} ! udpsink host=127.0.0.1 port={port} 100 | 101 | 102 | -------------------------------------------------------------------------------- /static/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 |

Sample WebM, Ogg, and MP4 Video Files for HTML5

4 | 5 | 12 | 13 |
14 | 15 | -------------------------------------------------------------------------------- /tutorial/Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile for gstreamer 3 | # 4 | FLAGS=`pkg-config --cflags --libs gstreamer-1.0` 5 | PROG=basic-tutorial-3 6 | 7 | .PHONEY: edit build run clean 8 | 9 | usage: 10 | @echo "make [edit|build|run|clean]" 11 | 12 | edit e: 13 | vi $(PROG).c 14 | 15 | build b: $(PROG).c 16 | gcc -o $(PROG) $(PROG).c $(FLAGS) 17 | 18 | run r: 19 | ./$(PROG) 20 | 21 | clean: 22 | rm -f $(PROG) 23 | 24 | -------------------------------------------------------------------------------- /tutorial/basic-tutorial-1.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int 4 | main (int argc, char *argv[]) 5 | { 6 | GstElement *pipeline; 7 | GstBus *bus; 8 | GstMessage *msg; 9 | 10 | /* Initialize GStreamer */ 11 | gst_init (&argc, &argv); 12 | 13 | /* Build the pipeline */ 14 | pipeline = 15 | gst_parse_launch 16 | ("playbin uri=https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm", 17 | NULL); 18 | 19 | /* Start playing */ 20 | gst_element_set_state (pipeline, GST_STATE_PLAYING); 21 | 22 | /* Wait until error or EOS */ 23 | bus = gst_element_get_bus (pipeline); 24 | msg = 25 | gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, 26 | GST_MESSAGE_ERROR | GST_MESSAGE_EOS); 27 | 28 | /* Free resources */ 29 | if (msg != NULL) 30 | gst_message_unref (msg); 31 | gst_object_unref (bus); 32 | gst_element_set_state (pipeline, GST_STATE_NULL); 33 | gst_object_unref (pipeline); 34 | 35 | return 0; 36 | } 37 | 38 | -------------------------------------------------------------------------------- /tutorial/basic-tutorial-2.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main(int argc, char *argv[]) { 4 | GstElement *pipeline, *source, *sink; 5 | GstBus *bus; 6 | GstMessage *msg; 7 | GstStateChangeReturn ret; 8 | 9 | /* Initialize GStreamer */ 10 | gst_init (&argc, &argv); 11 | 12 | /* Create the elements */ 13 | source = gst_element_factory_make ("videotestsrc", "source"); 14 | sink = gst_element_factory_make ("autovideosink", "sink"); 15 | 16 | /* Create the empty pipeline */ 17 | pipeline = gst_pipeline_new ("test-pipeline"); 18 | 19 | if (!pipeline || !source || !sink) { 20 | g_printerr ("Not all elements could be created.\n"); 21 | return -1; 22 | } 23 | 24 | /* Build the pipeline */ 25 | gst_bin_add_many (GST_BIN (pipeline), source, sink, NULL); 26 | if (gst_element_link (source, sink) != TRUE) { 27 | g_printerr ("Elements could not be linked.\n"); 28 | gst_object_unref (pipeline); 29 | return -1; 30 | } 31 | 32 | /* Modify the source's properties */ 33 | g_object_set (source, "pattern", 0, NULL); 34 | 35 | /* Start playing */ 36 | ret = gst_element_set_state (pipeline, GST_STATE_PLAYING); 37 | if (ret == GST_STATE_CHANGE_FAILURE) { 38 | g_printerr ("Unable to set the pipeline to the playing state.\n"); 39 | gst_object_unref (pipeline); 40 | return -1; 41 | } 42 | 43 | /* Wait until error or EOS */ 44 | bus = gst_element_get_bus (pipeline); 45 | msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, GST_MESSAGE_ERROR | GST_MESSAGE_EOS); 46 | 47 | /* Parse message */ 48 | if (msg != NULL) { 49 | GError *err; 50 | gchar *debug_info; 51 | 52 | switch (GST_MESSAGE_TYPE (msg)) { 53 | case GST_MESSAGE_ERROR: 54 | gst_message_parse_error (msg, &err, &debug_info); 55 | g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message); 56 | g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none"); 57 | g_clear_error (&err); 58 | g_free (debug_info); 59 | break; 60 | case GST_MESSAGE_EOS: 61 | g_print ("End-Of-Stream reached.\n"); 62 | break; 63 | default: 64 | /* We should not reach here because we only asked for ERRORs and EOS */ 65 | g_printerr ("Unexpected message received.\n"); 66 | break; 67 | } 68 | gst_message_unref (msg); 69 | } 70 | 71 | /* Free resources */ 72 | gst_object_unref (bus); 73 | gst_element_set_state (pipeline, GST_STATE_NULL); 74 | gst_object_unref (pipeline); 75 | return 0; 76 | } 77 | -------------------------------------------------------------------------------- /tutorial/basic-tutorial-3.c: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* Structure to contain all our information, so we can pass it to callbacks */ 4 | typedef struct _CustomData { 5 | GstElement *pipeline; 6 | GstElement *source; 7 | GstElement *convert; 8 | GstElement *sink; 9 | } CustomData; 10 | 11 | /* Handler for the pad-added signal */ 12 | static void pad_added_handler (GstElement *src, GstPad *pad, CustomData *data); 13 | 14 | int main(int argc, char *argv[]) { 15 | CustomData data; 16 | GstBus *bus; 17 | GstMessage *msg; 18 | GstStateChangeReturn ret; 19 | gboolean terminate = FALSE; 20 | 21 | /* Initialize GStreamer */ 22 | gst_init (&argc, &argv); 23 | 24 | /* Create the elements */ 25 | data.source = gst_element_factory_make ("uridecodebin", "source"); 26 | data.convert = gst_element_factory_make ("audioconvert", "convert"); 27 | data.sink = gst_element_factory_make ("autoaudiosink", "sink"); 28 | 29 | /* Create the empty pipeline */ 30 | data.pipeline = gst_pipeline_new ("test-pipeline"); 31 | 32 | if (!data.pipeline || !data.source || !data.convert || !data.sink) { 33 | g_printerr ("Not all elements could be created.\n"); 34 | return -1; 35 | } 36 | 37 | /* Build the pipeline. Note that we are NOT linking the source at this 38 | * point. We will do it later. */ 39 | gst_bin_add_many (GST_BIN (data.pipeline), data.source, data.convert , data.sink, NULL); 40 | if (!gst_element_link (data.convert, data.sink)) { 41 | g_printerr ("Elements could not be linked.\n"); 42 | gst_object_unref (data.pipeline); 43 | return -1; 44 | } 45 | 46 | /* Set the URI to play */ 47 | g_object_set (data.source, "uri", "https://www.freedesktop.org/software/gstreamer-sdk/data/media/sintel_trailer-480p.webm", NULL); 48 | 49 | /* Connect to the pad-added signal */ 50 | g_signal_connect (data.source, "pad-added", G_CALLBACK (pad_added_handler), &data); 51 | 52 | /* Start playing */ 53 | ret = gst_element_set_state (data.pipeline, GST_STATE_PLAYING); 54 | if (ret == GST_STATE_CHANGE_FAILURE) { 55 | g_printerr ("Unable to set the pipeline to the playing state.\n"); 56 | gst_object_unref (data.pipeline); 57 | return -1; 58 | } 59 | 60 | /* Listen to the bus */ 61 | bus = gst_element_get_bus (data.pipeline); 62 | do { 63 | msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE, 64 | GST_MESSAGE_STATE_CHANGED | GST_MESSAGE_ERROR | GST_MESSAGE_EOS); 65 | 66 | /* Parse message */ 67 | if (msg != NULL) { 68 | GError *err; 69 | gchar *debug_info; 70 | 71 | switch (GST_MESSAGE_TYPE (msg)) { 72 | case GST_MESSAGE_ERROR: 73 | gst_message_parse_error (msg, &err, &debug_info); 74 | g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message); 75 | g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none"); 76 | g_clear_error (&err); 77 | g_free (debug_info); 78 | terminate = TRUE; 79 | break; 80 | case GST_MESSAGE_EOS: 81 | g_print ("End-Of-Stream reached.\n"); 82 | terminate = TRUE; 83 | break; 84 | case GST_MESSAGE_STATE_CHANGED: 85 | /* We are only interested in state-changed messages from the pipeline */ 86 | if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data.pipeline)) { 87 | GstState old_state, new_state, pending_state; 88 | gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state); 89 | g_print ("Pipeline state changed from %s to %s:\n", 90 | gst_element_state_get_name (old_state), gst_element_state_get_name (new_state)); 91 | } 92 | break; 93 | default: 94 | /* We should not reach here */ 95 | g_printerr ("Unexpected message received.\n"); 96 | break; 97 | } 98 | gst_message_unref (msg); 99 | } 100 | } while (!terminate); 101 | 102 | /* Free resources */ 103 | gst_object_unref (bus); 104 | gst_element_set_state (data.pipeline, GST_STATE_NULL); 105 | gst_object_unref (data.pipeline); 106 | return 0; 107 | } 108 | 109 | /* This function will be called by the pad-added signal */ 110 | static void pad_added_handler (GstElement *src, GstPad *new_pad, CustomData *data) { 111 | GstPad *sink_pad = gst_element_get_static_pad (data->convert, "sink"); 112 | GstPadLinkReturn ret; 113 | GstCaps *new_pad_caps = NULL; 114 | GstStructure *new_pad_struct = NULL; 115 | const gchar *new_pad_type = NULL; 116 | 117 | g_print ("Received new pad '%s' from '%s':\n", GST_PAD_NAME (new_pad), GST_ELEMENT_NAME (src)); 118 | 119 | /* If our converter is already linked, we have nothing to do here */ 120 | if (gst_pad_is_linked (sink_pad)) { 121 | g_print ("We are already linked. Ignoring.\n"); 122 | goto exit; 123 | } 124 | 125 | /* Check the new pad's type */ 126 | new_pad_caps = gst_pad_get_current_caps (new_pad); 127 | new_pad_struct = gst_caps_get_structure (new_pad_caps, 0); 128 | new_pad_type = gst_structure_get_name (new_pad_struct); 129 | if (!g_str_has_prefix (new_pad_type, "audio/x-raw")) { 130 | g_print ("It has type '%s' which is not raw audio. Ignoring.\n", new_pad_type); 131 | goto exit; 132 | } 133 | 134 | /* Attempt the link */ 135 | ret = gst_pad_link (new_pad, sink_pad); 136 | if (GST_PAD_LINK_FAILED (ret)) { 137 | g_print ("Type is '%s' but link failed.\n", new_pad_type); 138 | } else { 139 | g_print ("Link succeeded (type '%s').\n", new_pad_type); 140 | } 141 | 142 | exit: 143 | /* Unreference the new pad's caps, if we got them */ 144 | if (new_pad_caps != NULL) 145 | gst_caps_unref (new_pad_caps); 146 | 147 | /* Unreference the sink pad */ 148 | gst_object_unref (sink_pad); 149 | } 150 | --------------------------------------------------------------------------------