Add dccp plugin. Fixes #542390.

Original commit message from CVS:
patch by: Leandro Melo de Sales <leandroal@gmail.com>
* configure.ac:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-bad-plugins-docs.sgml:
* docs/plugins/gst-plugins-bad-plugins-sections.txt:
* docs/plugins/gst-plugins-bad-plugins.args:
* docs/plugins/gst-plugins-bad-plugins.hierarchy:
* docs/plugins/gst-plugins-bad-plugins.interfaces:
* docs/plugins/gst-plugins-bad-plugins.prerequisites:
* docs/plugins/gst-plugins-bad-plugins.signals:
* docs/plugins/inspect/plugin-dccp.xml:
* gst/dccp/Makefile.am:
* gst/dccp/gstdccp.c:
* gst/dccp/gstdccp.h:
* gst/dccp/gstdccpclientsink.c:
* gst/dccp/gstdccpclientsink.h:
* gst/dccp/gstdccpclientsrc.c:
* gst/dccp/gstdccpclientsrc.h:
* gst/dccp/gstdccpplugin.c:
* gst/dccp/gstdccpserversink.c:
* gst/dccp/gstdccpserversink.h:
* gst/dccp/gstdccpserversrc.c:
* gst/dccp/gstdccpserversrc.h:
* tests/icles/dccp/README:
* tests/icles/dccp/call/README:
* tests/icles/dccp/call/DCCPClient.c:
* tests/icles/dccp/call/DCCPServer.c:
* tests/icles/dccp/file/DCCPClientSaveFile.c:
* tests/icles/dccp/file/DCCPServerSendFile.c:
* tests/icles/dccp/mic/DCCPClientPlayMic.c:
* tests/icles/dccp/mic/DCCPServerMic.c:
* tests/icles/dccp/mp3/DCCPClientPlayMP3.c:
* tests/icles/dccp/mp3/DCCPServerSendMP3.c:
* tests/icles/dccp/mp3Speex/DCCPClientPlaySpeexMP3.c:
* tests/icles/dccp/mp3Speex/DCCPServerSendSpeexMP3.c:
* tests/icles/dccp/mp3Stream/DCCPClientPlayMP3Stream.c:
* tests/icles/dccp/mp3Stream/DCCPServerSendMP3Stream.c:
Add dccp plugin. Fixes #542390.
This commit is contained in:
Leandro Melo de Sales 2008-08-21 13:22:38 +00:00 committed by Stefan Kost
parent fd66868120
commit 605482a1a8
38 changed files with 4619 additions and 128 deletions

View file

@ -1,3 +1,45 @@
2008-08-21 Stefan Kost <ensonic@users.sf.net>
patch by: Leandro Melo de Sales <leandroal@gmail.com>
* configure.ac:
* docs/plugins/Makefile.am:
* docs/plugins/gst-plugins-bad-plugins-docs.sgml:
* docs/plugins/gst-plugins-bad-plugins-sections.txt:
* docs/plugins/gst-plugins-bad-plugins.args:
* docs/plugins/gst-plugins-bad-plugins.hierarchy:
* docs/plugins/gst-plugins-bad-plugins.interfaces:
* docs/plugins/gst-plugins-bad-plugins.prerequisites:
* docs/plugins/gst-plugins-bad-plugins.signals:
* docs/plugins/inspect/plugin-dccp.xml:
* gst/dccp/Makefile.am:
* gst/dccp/gstdccp.c:
* gst/dccp/gstdccp.h:
* gst/dccp/gstdccpclientsink.c:
* gst/dccp/gstdccpclientsink.h:
* gst/dccp/gstdccpclientsrc.c:
* gst/dccp/gstdccpclientsrc.h:
* gst/dccp/gstdccpplugin.c:
* gst/dccp/gstdccpserversink.c:
* gst/dccp/gstdccpserversink.h:
* gst/dccp/gstdccpserversrc.c:
* gst/dccp/gstdccpserversrc.h:
* tests/icles/dccp/README:
* tests/icles/dccp/call/README:
* tests/icles/dccp/call/DCCPClient.c:
* tests/icles/dccp/call/DCCPServer.c:
* tests/icles/dccp/file/DCCPClientSaveFile.c:
* tests/icles/dccp/file/DCCPServerSendFile.c:
* tests/icles/dccp/mic/DCCPClientPlayMic.c:
* tests/icles/dccp/mic/DCCPServerMic.c:
* tests/icles/dccp/mp3/DCCPClientPlayMP3.c:
* tests/icles/dccp/mp3/DCCPServerSendMP3.c:
* tests/icles/dccp/mp3Speex/DCCPClientPlaySpeexMP3.c:
* tests/icles/dccp/mp3Speex/DCCPServerSendSpeexMP3.c:
* tests/icles/dccp/mp3Stream/DCCPClientPlayMP3Stream.c:
* tests/icles/dccp/mp3Stream/DCCPServerSendMP3Stream.c:
Add dccp plugin. Fixes #542390.
2008-08-20 Tim-Philipp Müller <tim at collabora co uk> 2008-08-20 Tim-Philipp Müller <tim at collabora co uk>
* configure.ac: * configure.ac:

2
common

@ -1 +1 @@
Subproject commit d70ca17ae6fbe6020996e4567275d5e14972ed45 Subproject commit 8d494854a6018336a80ece82ceb3df0033e2da9c

View file

@ -240,6 +240,7 @@ dnl these are all the gst plug-ins, compilable without additional libs
AG_GST_CHECK_PLUGIN(app) AG_GST_CHECK_PLUGIN(app)
AG_GST_CHECK_PLUGIN(bayer) AG_GST_CHECK_PLUGIN(bayer)
AG_GST_CHECK_PLUGIN(cdxaparse) AG_GST_CHECK_PLUGIN(cdxaparse)
AG_GST_CHECK_PLUGIN(dccp)
AG_GST_CHECK_PLUGIN(deinterlace) AG_GST_CHECK_PLUGIN(deinterlace)
AG_GST_CHECK_PLUGIN(deinterlace2) AG_GST_CHECK_PLUGIN(deinterlace2)
AG_GST_CHECK_PLUGIN(dvdspu) AG_GST_CHECK_PLUGIN(dvdspu)
@ -1249,6 +1250,7 @@ gst/Makefile
gst/app/Makefile gst/app/Makefile
gst/bayer/Makefile gst/bayer/Makefile
gst/cdxaparse/Makefile gst/cdxaparse/Makefile
gst/dccp/Makefile
gst/deinterlace/Makefile gst/deinterlace/Makefile
gst/deinterlace2/Makefile gst/deinterlace2/Makefile
gst/dvdspu/Makefile gst/dvdspu/Makefile

View file

@ -119,6 +119,10 @@ EXTRA_HFILES = \
$(top_srcdir)/ext/twolame/gsttwolame.h \ $(top_srcdir)/ext/twolame/gsttwolame.h \
$(top_srcdir)/ext/x264/gstx264enc.h \ $(top_srcdir)/ext/x264/gstx264enc.h \
$(top_srcdir)/gst/deinterlace/gstdeinterlace.h \ $(top_srcdir)/gst/deinterlace/gstdeinterlace.h \
$(top_srcdir)/gst/dccp/gstdccpclientsink.h \
$(top_srcdir)/gst/dccp/gstdccpclientsrc.h \
$(top_srcdir)/gst/dccp/gstdccpserversink.h \
$(top_srcdir)/gst/dccp/gstdccpserversrc.h \
$(top_srcdir)/gst/dvdspu/gstdvdspu.h \ $(top_srcdir)/gst/dvdspu/gstdvdspu.h \
$(top_srcdir)/gst/festival/gstfestival.h \ $(top_srcdir)/gst/festival/gstfestival.h \
$(top_srcdir)/gst/modplug/gstmodplug.h \ $(top_srcdir)/gst/modplug/gstmodplug.h \

View file

@ -18,6 +18,10 @@
<xi:include href="xml/element-audioparse.xml" /> <xi:include href="xml/element-audioparse.xml" />
<xi:include href="xml/element-celtdec.xml" /> <xi:include href="xml/element-celtdec.xml" />
<xi:include href="xml/element-celtenc.xml" /> <xi:include href="xml/element-celtenc.xml" />
<xi:include href="xml/element-dccpclientsink.xml" />
<xi:include href="xml/element-dccpclientsrc.xml" />
<xi:include href="xml/element-dccpserversink.xml" />
<xi:include href="xml/element-dccpserversrc.xml" />
<xi:include href="xml/element-deinterlace.xml" /> <xi:include href="xml/element-deinterlace.xml" />
<xi:include href="xml/element-dfbvideosink.xml" /> <xi:include href="xml/element-dfbvideosink.xml" />
<xi:include href="xml/element-dvbsrc.xml" /> <xi:include href="xml/element-dvbsrc.xml" />
@ -70,6 +74,7 @@
<xi:include href="xml/plugin-cdaudio.xml" /> <xi:include href="xml/plugin-cdaudio.xml" />
<xi:include href="xml/plugin-cdxaparse.xml" /> <xi:include href="xml/plugin-cdxaparse.xml" />
<xi:include href="xml/plugin-celt.xml" /> <xi:include href="xml/plugin-celt.xml" />
<xi:include href="xml/plugin-dccp.xml" />
<xi:include href="xml/plugin-dfbvideosink.xml" /> <xi:include href="xml/plugin-dfbvideosink.xml" />
<xi:include href="xml/plugin-dtsdec.xml" /> <xi:include href="xml/plugin-dtsdec.xml" />
<xi:include href="xml/plugin-dvbsrc.xml" /> <xi:include href="xml/plugin-dvbsrc.xml" />

View file

@ -96,6 +96,62 @@ GST_TYPE_DC1394
gst_dc1394_get_type gst_dc1394_get_type
</SECTION> </SECTION>
<SECTION>
<FILE>element-dccpclientsink</FILE>
<TITLE>dccpclientsink</TITLE>
GstDCCPClientSink
<SUBSECTION Standard>
GstDCCPClientSinkClass
GST_DCCP_CLIENT_SINK
GST_DCCP_CLIENT_SINK_CLASS
GST_IS_DCCP_CLIENT_SINK
GST_IS_DCCP_CLIENT_SINK_CLASS
GST_TYPE_DCCP_CLIENT_SINK
gst_dccp_client_sink_get_type
</SECTION>
<SECTION>
<FILE>element-dccpclientsrc</FILE>
<TITLE>dccpclientsrc</TITLE>
GstDCCPClientSrc
<SUBSECTION Standard>
GstDCCPClientSrcClass
GST_DCCP_CLIENT_SRC
GST_DCCP_CLIENT_SRC_CLASS
GST_IS_DCCP_CLIENT_SRC
GST_IS_DCCP_CLIENT_SRC_CLASS
GST_TYPE_DCCP_CLIENT_SRC
gst_dccp_client_src_get_type
</SECTION>
<SECTION>
<FILE>element-dccpserversink</FILE>
<TITLE>dccpserversink</TITLE>
GstDCCPServerSink
<SUBSECTION Standard>
GstDCCPServerSinkClass
GST_DCCP_SERVER_SINK
GST_DCCP_SERVER_SINK_CLASS
GST_IS_DCCP_SERVER_SINK
GST_IS_DCCP_SERVER_SINK_CLASS
GST_TYPE_DCCP_SERVER_SINK
gst_dccp_server_sink_get_type
</SECTION>
<SECTION>
<FILE>element-dccpserversrc</FILE>
<TITLE>dccpserversrc</TITLE>
GstDCCPServerSrc
<SUBSECTION Standard>
GstDCCPServerSrcClass
GST_DCCP_SERVER_SRC
GST_DCCP_SERVER_SRC_CLASS
GST_IS_DCCP_SERVER_SRC
GST_IS_DCCP_SERVER_SRC_CLASS
GST_TYPE_DCCP_SERVER_SRC
gst_dccp_server_src_get_type
</SECTION>
<SECTION> <SECTION>
<FILE>element-deinterlace</FILE> <FILE>element-deinterlace</FILE>
<TITLE>deinterlace</TITLE> <TITLE>deinterlace</TITLE>

View file

@ -17000,12 +17000,12 @@
<ARG> <ARG>
<NAME>GstX264Enc::pass</NAME> <NAME>GstX264Enc::pass</NAME>
<TYPE>GstX264EncPass</TYPE> <TYPE>guint</TYPE>
<RANGE></RANGE> <RANGE><= 3</RANGE>
<FLAGS>rw</FLAGS> <FLAGS>rw</FLAGS>
<NICK>Encoding pass/type</NICK> <NICK>Pass</NICK>
<BLURB>Encoding pass/type.</BLURB> <BLURB>Pass of multipass encoding (0=single pass; 1=first pass, 2=middle pass, 3=last pass).</BLURB>
<DEFAULT>Constant Bitrate Encoding</DEFAULT> <DEFAULT>0</DEFAULT>
</ARG> </ARG>
<ARG> <ARG>
@ -17051,10 +17051,10 @@
<ARG> <ARG>
<NAME>GstX264Enc::threads</NAME> <NAME>GstX264Enc::threads</NAME>
<TYPE>guint</TYPE> <TYPE>guint</TYPE>
<RANGE><= 4</RANGE> <RANGE>[1,4]</RANGE>
<FLAGS>rw</FLAGS> <FLAGS>rw</FLAGS>
<NICK>Threads</NICK> <NICK>Threads</NICK>
<BLURB>Number of threads used by the codec (0 for automatic).</BLURB> <BLURB>Number of threads used by the codec.</BLURB>
<DEFAULT>1</DEFAULT> <DEFAULT>1</DEFAULT>
</ARG> </ARG>
@ -22020,7 +22020,7 @@
<FLAGS>rw</FLAGS> <FLAGS>rw</FLAGS>
<NICK>Method</NICK> <NICK>Method</NICK>
<BLURB>Deinterlace Method.</BLURB> <BLURB>Deinterlace Method.</BLURB>
<DEFAULT>Toms Motion Compensation</DEFAULT> <DEFAULT>Motion Adaptive: Motion Search</DEFAULT>
</ARG> </ARG>
<ARG> <ARG>
@ -22233,3 +22233,223 @@
<DEFAULT>NULL</DEFAULT> <DEFAULT>NULL</DEFAULT>
</ARG> </ARG>
<ARG>
<NAME>GstDCCPClientSrc::caps</NAME>
<TYPE>GstCaps*</TYPE>
<RANGE></RANGE>
<FLAGS>rw</FLAGS>
<NICK>Caps</NICK>
<BLURB>The caps of the source pad.</BLURB>
<DEFAULT></DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPClientSrc::ccid</NAME>
<TYPE>gint</TYPE>
<RANGE>>= 2</RANGE>
<FLAGS>rw</FLAGS>
<NICK>CCID</NICK>
<BLURB>The Congestion Control IDentified to be used.</BLURB>
<DEFAULT>2</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPClientSrc::close-socket</NAME>
<TYPE>gboolean</TYPE>
<RANGE></RANGE>
<FLAGS>rw</FLAGS>
<NICK>Close socket</NICK>
<BLURB>Close socket at the end of stream.</BLURB>
<DEFAULT>TRUE</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPClientSrc::host</NAME>
<TYPE>gchar*</TYPE>
<RANGE></RANGE>
<FLAGS>rw</FLAGS>
<NICK>Host</NICK>
<BLURB>The host IP address to receive packets from.</BLURB>
<DEFAULT>"127.0.0.1"</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPClientSrc::port</NAME>
<TYPE>gint</TYPE>
<RANGE>[0,65535]</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Port</NICK>
<BLURB>The port to receive the packets from, 0=allocate.</BLURB>
<DEFAULT>5001</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPClientSrc::sockfd</NAME>
<TYPE>gint</TYPE>
<RANGE>>= -1</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Socket fd</NICK>
<BLURB>The socket file descriptor.</BLURB>
<DEFAULT>-1</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPServerSink::ccid</NAME>
<TYPE>gint</TYPE>
<RANGE>>= 2</RANGE>
<FLAGS>rw</FLAGS>
<NICK>CCID</NICK>
<BLURB>The Congestion Control IDentified to be used.</BLURB>
<DEFAULT>2</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPServerSink::close-socket</NAME>
<TYPE>gboolean</TYPE>
<RANGE></RANGE>
<FLAGS>rw</FLAGS>
<NICK>Close</NICK>
<BLURB>Close socket at end of stream.</BLURB>
<DEFAULT>TRUE</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPServerSink::port</NAME>
<TYPE>gint</TYPE>
<RANGE>[0,65535]</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Port</NICK>
<BLURB>The port to receive the packets from, 0=allocate.</BLURB>
<DEFAULT>5001</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPServerSink::sockfd</NAME>
<TYPE>gint</TYPE>
<RANGE>>= -1</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Socket fd</NICK>
<BLURB>The client socket file descriptor.</BLURB>
<DEFAULT>-1</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPServerSink::wait-connections</NAME>
<TYPE>gboolean</TYPE>
<RANGE></RANGE>
<FLAGS>rw</FLAGS>
<NICK>Wait connections</NICK>
<BLURB>Wait for many client connections.</BLURB>
<DEFAULT>FALSE</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPClientSink::ccid</NAME>
<TYPE>gint</TYPE>
<RANGE>>= 2</RANGE>
<FLAGS>rw</FLAGS>
<NICK>CCID</NICK>
<BLURB>The Congestion Control IDentified to be used.</BLURB>
<DEFAULT>2</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPClientSink::close-socket</NAME>
<TYPE>gboolean</TYPE>
<RANGE></RANGE>
<FLAGS>rw</FLAGS>
<NICK>Close</NICK>
<BLURB>Close socket at end of stream.</BLURB>
<DEFAULT>TRUE</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPClientSink::host</NAME>
<TYPE>gchar*</TYPE>
<RANGE></RANGE>
<FLAGS>rw</FLAGS>
<NICK>Host</NICK>
<BLURB>The host IP address to send packets to.</BLURB>
<DEFAULT>"127.0.0.1"</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPClientSink::port</NAME>
<TYPE>gint</TYPE>
<RANGE>[0,65535]</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Port</NICK>
<BLURB>The port to receive the packets from, 0=allocate.</BLURB>
<DEFAULT>5001</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPClientSink::sockfd</NAME>
<TYPE>gint</TYPE>
<RANGE>>= -1</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Socket fd</NICK>
<BLURB>The socket file descriptor.</BLURB>
<DEFAULT>-1</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPServerSrc::caps</NAME>
<TYPE>GstCaps*</TYPE>
<RANGE></RANGE>
<FLAGS>rw</FLAGS>
<NICK>Caps</NICK>
<BLURB>The caps of the source pad.</BLURB>
<DEFAULT></DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPServerSrc::ccid</NAME>
<TYPE>gint</TYPE>
<RANGE>>= 2</RANGE>
<FLAGS>rw</FLAGS>
<NICK>CCID</NICK>
<BLURB>The Congestion Control IDentified to be used.</BLURB>
<DEFAULT>2</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPServerSrc::close-socket</NAME>
<TYPE>gboolean</TYPE>
<RANGE></RANGE>
<FLAGS>rw</FLAGS>
<NICK>Close socket</NICK>
<BLURB>Close socket at the end of stream.</BLURB>
<DEFAULT>TRUE</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPServerSrc::host</NAME>
<TYPE>gchar*</TYPE>
<RANGE></RANGE>
<FLAGS>rw</FLAGS>
<NICK>Host</NICK>
<BLURB>The hostname to listen as.</BLURB>
<DEFAULT>NULL</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPServerSrc::port</NAME>
<TYPE>gint</TYPE>
<RANGE>[0,65535]</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Port</NICK>
<BLURB>The port to receive the packets from, 0=allocate.</BLURB>
<DEFAULT>5001</DEFAULT>
</ARG>
<ARG>
<NAME>GstDCCPServerSrc::sockfd</NAME>
<TYPE>gint</TYPE>
<RANGE>>= -1</RANGE>
<FLAGS>rw</FLAGS>
<NICK>Socket fd</NICK>
<BLURB>The client socket file descriptor.</BLURB>
<DEFAULT>-1</DEFAULT>
</ARG>

View file

@ -11,109 +11,34 @@ GObject
GstElement GstElement
GstBin GstBin
GstPipeline GstPipeline
GstSDPDemux RsnDvdBin
GstRgVolume DvbBaseBin
GstRtpBin GstRtpBin
GstRtpClient GstRtpClient
DvbBaseBin GstRgVolume
GstCDXAParse GstSDPDemux
GstVcdParse GstX264Enc
GstBaseTransform GstBaseMetadata
GstDeinterlace GstMetadataDemux
GstIIR GstMetadataMux
GstBayer2RGB GstWildmidi
GstAudioFilter GstTimidity
GstStereo
GstBPMDetect
GstVideoCrop
GstRgAnalysis
GstRgLimiter
GstVideoFilter
GstVideoAnalyse
GstVideoDetect
GstVideoMark
GstSpeexResample
GstFestival
GstBaseSrc GstBaseSrc
GstAppSrc
GstPushSrc GstPushSrc
GstRfbSrc GstMythtvSrc
GstVCDSrc GstNeonhttpSrc
GstDvbSrc GstMMS
GstBaseAudioSrc GstBaseAudioSrc
GstJackAudioSrc
GstAudioSrc GstAudioSrc
GstOss4Source GstOss4Source
GstJackAudioSrc GstDvbSrc
GstMMS GstVCDSrc
GstNeonhttpSrc GstDCCPClientSrc
GstMythtvSrc GstDCCPServerSrc
GstRfbSrc
GstSFSrc GstSFSrc
GstBaseSink GstAppSrc
GstAppSink
GstVideoSink
GstGLImageSink
GstSDLVideoSink
GstBaseAudioSink
GstAudioSink
GstOss4Sink
GstNasSink
GstSDLAudioSink
GstJackAudioSink
GstFBDEVSink
AlsaSPDIFSink
GstSFSink
GstFreeze
GstFLVDemux
GstH264Parse
GstModPlug
GstInputSelector
GstOutputSelector
GstDVDSpu
GstNsfDec
GstSpeed
GstTtaParse
GstTtaDec
GstDeinterlace2
GstY4mEncode
GstNuvDemux
GstRealVideoDec
GstRealAudioDec
GstInterleave
GstDeinterleave
GstMveDemux
GstMveMux
GstVMncDec
MpegVideoParse
GstMpeg4VParse
GstRtpJitterBuffer
GstRtpPtDemux
GstRtpSession
GstRtpSsrcDemux
GstRawParse
GstVideoParse
GstAudioParse
MpegTSParse
GstSrtEnc
GstOss4Mixer
GstAmrwbDec
GstAmrwbParse
GstAmrwbEnc
GstBz2enc
GstBz2dec
GstCDAudio
GstDtsDec
GstFaac
GstFaad
GstGSMEnc
GstGSMDec
GstMpeg2enc
GstMplex
GstMusepackDec
GstTRM
GstPitch
GstSpcDec
GstXvidEnc
GstXvidDec
GstSignalProcessor GstSignalProcessor
ladspa-delay-5s ladspa-delay-5s
ladspa-amp-mono ladspa-amp-mono
@ -346,12 +271,91 @@ GObject
ladspa-mbeq ladspa-mbeq
ladspa-pitchScaleHQ ladspa-pitchScaleHQ
ladspa-imp ladspa-imp
GstTimidity GstXvidEnc
GstWildmidi GstXvidDec
GstBaseMetadata GstSpcDec
GstMetadataDemux GstPitch
GstMetadataMux GstBaseTransform
GstX264Enc GstAudioFilter
GstBPMDetect
GstStereo
GstSpeexResample
GstVideoFilter
GstVideoAnalyse
GstVideoDetect
GstVideoMark
GstRgAnalysis
GstRgLimiter
GstVideoCrop
GstBayer2RGB
GstIIR
GstDeinterlace
GstBaseSink
GstSFSink
GstVideoSink
GstSDLVideoSink
GstGLImageSink
GstBaseAudioSink
GstAudioSink
GstSDLAudioSink
GstNasSink
GstOss4Sink
GstJackAudioSink
AlsaSPDIFSink
GstFBDEVSink
GstDCCPServerSink
GstDCCPClientSink
GstAppSink
GstTRM
GstMusepackDec
GstMpeg2enc
GstGSMEnc
GstGSMDec
GstFaad
GstFaac
GstDtsDec
GstCDAudio
GstBz2enc
GstBz2dec
GstAmrwbDec
GstAmrwbParse
GstAmrwbEnc
GstOss4Mixer
GstSrtEnc
MpegTSParse
GstRawParse
GstVideoParse
GstAudioParse
GstRtpJitterBuffer
GstRtpPtDemux
GstRtpSession
GstRtpSsrcDemux
GstMpeg4VParse
MpegVideoParse
GstVMncDec
GstMveDemux
GstMveMux
GstInterleave
GstDeinterleave
GstRealVideoDec
GstRealAudioDec
GstNuvDemux
GstY4mEncode
GstDeinterlace2
GstTtaParse
GstTtaDec
GstSpeed
GstNsfDec
GstDVDSpu
GstInputSelector
GstOutputSelector
GstModPlug
GstH264Parse
GstFLVDemux
GstFreeze
GstFestival
GstCDXAParse
GstVcdParse
GstBus GstBus
GstTask GstTask
GstClock GstClock
@ -367,9 +371,9 @@ GInterface
GTypePlugin GTypePlugin
GstChildProxy GstChildProxy
GstURIHandler GstURIHandler
GstTagSetter
GstImplementsInterface GstImplementsInterface
GstXOverlay GstXOverlay
GstNavigation
GstPropertyProbe GstPropertyProbe
GstMixer GstMixer
GstNavigation
GstTagSetter

View file

@ -1,20 +1,21 @@
GstBin GstChildProxy GstBin GstChildProxy
GstPipeline GstChildProxy GstPipeline GstChildProxy
GstSDPDemux GstChildProxy RsnDvdBin GstChildProxy GstURIHandler
GstRgVolume GstChildProxy DvbBaseBin GstChildProxy GstURIHandler
GstRtpBin GstChildProxy GstRtpBin GstChildProxy
GstRtpClient GstChildProxy GstRtpClient GstChildProxy
DvbBaseBin GstChildProxy GstURIHandler GstRgVolume GstChildProxy
GstAppSrc GstURIHandler GstSDPDemux GstChildProxy
GstVCDSrc GstURIHandler
GstOss4Source GstImplementsInterface GstPropertyProbe GstMixer
GstMMS GstURIHandler
GstNeonhttpSrc GstURIHandler
GstMythtvSrc GstURIHandler
GstGLImageSink GstImplementsInterface GstXOverlay
GstSDLVideoSink GstImplementsInterface GstXOverlay GstNavigation
GstOss4Sink GstPropertyProbe
GstDeinterlace2 GstChildProxy
GstOss4Mixer GstImplementsInterface GstPropertyProbe GstMixer
GstCDAudio GstURIHandler
GstMetadataMux GstTagSetter GstMetadataMux GstTagSetter
GstMythtvSrc GstURIHandler
GstNeonhttpSrc GstURIHandler
GstMMS GstURIHandler
GstOss4Source GstImplementsInterface GstPropertyProbe GstMixer
GstVCDSrc GstURIHandler
GstAppSrc GstURIHandler
GstSDLVideoSink GstImplementsInterface GstXOverlay GstNavigation
GstGLImageSink GstImplementsInterface GstXOverlay
GstOss4Sink GstPropertyProbe
GstCDAudio GstURIHandler
GstOss4Mixer GstImplementsInterface GstPropertyProbe GstMixer
GstDeinterlace2 GstChildProxy

View file

@ -1,5 +1,5 @@
GstChildProxy GstObject GstChildProxy GstObject
GstTagSetter GstObject GstElement
GstImplementsInterface GstObject GstElement GstImplementsInterface GstObject GstElement
GstXOverlay GstObject GstImplementsInterface GstElement GstXOverlay GstObject GstImplementsInterface GstElement
GstMixer GstObject GstImplementsInterface GstElement GstMixer GstObject GstImplementsInterface GstElement
GstTagSetter GstObject GstElement

View file

@ -343,3 +343,35 @@ guint64 arg1
GstDivxEnc *gstdivxenc GstDivxEnc *gstdivxenc
</SIGNAL> </SIGNAL>
<SIGNAL>
<NAME>GstDCCPClientSrc::connected</NAME>
<RETURNS>void</RETURNS>
<FLAGS>f</FLAGS>
GstDCCPClientSrc *gstdccpclientsrc
gint arg1
</SIGNAL>
<SIGNAL>
<NAME>GstDCCPServerSink::connected</NAME>
<RETURNS>void</RETURNS>
<FLAGS>f</FLAGS>
GstDCCPServerSink *gstdccpserversink
gint arg1
</SIGNAL>
<SIGNAL>
<NAME>GstDCCPClientSink::connected</NAME>
<RETURNS>void</RETURNS>
<FLAGS>f</FLAGS>
GstDCCPClientSink *gstdccpclientsink
gint arg1
</SIGNAL>
<SIGNAL>
<NAME>GstDCCPServerSrc::connected</NAME>
<RETURNS>void</RETURNS>
<FLAGS>f</FLAGS>
GstDCCPServerSrc *gstdccpserversrc
gint arg1
</SIGNAL>

View file

@ -0,0 +1,73 @@
<plugin>
<name>dccp</name>
<description>transfer data over the network via DCCP.</description>
<filename>../../gst/dccp/.libs/libgstdccp.so</filename>
<basename>libgstdccp.so</basename>
<version>0.10.8.1</version>
<license>LGPL</license>
<source>gst-plugins-bad</source>
<package>DCCP</package>
<origin>http://garage.maemo.org/projects/ephone</origin>
<elements>
<element>
<name>dccpclientsink</name>
<longname>DCCP client sink</longname>
<class>Sink/Network</class>
<description>Send data as a client over the network via DCCP</description>
<author>E-Phone Team at Federal University of Campina Grande &lt;leandroal@gmail.com&gt;</author>
<pads>
<caps>
<name>sink</name>
<direction>sink</direction>
<presence>always</presence>
<details>ANY</details>
</caps>
</pads>
</element>
<element>
<name>dccpclientsrc</name>
<longname>DCCP client source</longname>
<class>Source/Network</class>
<description>Receive data as a client over the network via DCCP</description>
<author>E-Phone Team at Federal University of Campina Grande &lt;leandroal@gmail.com&gt;</author>
<pads>
<caps>
<name>src</name>
<direction>source</direction>
<presence>always</presence>
<details>ANY</details>
</caps>
</pads>
</element>
<element>
<name>dccpserversink</name>
<longname>DCCP server sink</longname>
<class>Sink/Network</class>
<description>Send data as a server over the network via DCCP</description>
<author>E-Phone Team at Federal University of Campina Grande &lt;leandroal@gmail.com&gt;</author>
<pads>
<caps>
<name>sink</name>
<direction>sink</direction>
<presence>always</presence>
<details>ANY</details>
</caps>
</pads>
</element>
<element>
<name>dccpserversrc</name>
<longname>DCCP server source</longname>
<class>Source/Network</class>
<description>Receive data as a server over the network via DCCP</description>
<author>E-Phone Team at Federal University of Campina Grande &lt;leandroal@gmail.com&gt;</author>
<pads>
<caps>
<name>src</name>
<direction>source</direction>
<presence>always</presence>
<details>ANY</details>
</caps>
</pads>
</element>
</elements>
</plugin>

36
gst/dccp/Makefile.am Normal file
View file

@ -0,0 +1,36 @@
# plugindir is set in configure
##############################################################################
# change libgstplugin.la to something more suitable, e.g. libmysomething.la #
##############################################################################
plugin_LTLIBRARIES = libgstdccp.la
##############################################################################
# for the next set of variables, rename the prefix if you renamed the .la, #
# e.g. libgstplugin_la_SOURCES => libmysomething_la_SOURCES #
# libgstplugin_la_CFLAGS => libmysomething_la_CFLAGS #
# libgstplugin_la_LIBADD => libmysomething_la_LIBADD #
# libgstplugin_la_LDFLAGS => libmysomething_la_LDFLAGS #
##############################################################################
# sources used to compile this plug-in
libgstdccp_la_SOURCES = gstdccpplugin.c \
gstdccp.c \
gstdccpserversink.c \
gstdccpserversrc.c \
gstdccpclientsink.c \
gstdccpclientsrc.c
# flags used to compile this plugin
# add other _CFLAGS and _LIBS as needed
libgstdccp_la_CFLAGS = $(GST_CFLAGS)
libgstdccp_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS)
libgstdccp_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS)
# headers we need but don't want installed
noinst_HEADERS = gstdccp.h \
gstdccpserversink.h \
gstdccpserversrc.h \
gstdccpclientsink.h \
gstdccpclientsrc.h

450
gst/dccp/gstdccp.c Normal file
View file

@ -0,0 +1,450 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "gstdccp.h"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <string.h>
/* Prototypes and definitions for private functions and not exported via gstdccp.h */
gint gst_dccp_socket_write (int socket, const void *buf, size_t count,
int packet_size);
gboolean gst_dccp_socket_connected (GstElement * element, int server_sock_fd);
struct sockaddr_in gst_dccp_create_sockaddr (GstElement * element, gchar * ip,
int port);
/* Resolves host to IP address
* @return a gchar pointer containing the ip address or NULL
*/
gchar *
gst_dccp_host_to_ip (GstElement * element, const gchar * host)
{
struct hostent *hostinfo;
char **addrs;
gchar *ip;
struct in_addr addr;
GST_DEBUG_OBJECT (element, "resolving host %s", host);
/* first check if it already is an IP address */
if (inet_aton (host, &addr)) {
ip = g_strdup (host);
GST_DEBUG_OBJECT (element, "resolved to IP %s", ip);
return ip;
}
/* perform a name lookup */
if (!(hostinfo = gethostbyname (host))) {
GST_ELEMENT_ERROR (element, RESOURCE, NOT_FOUND, (NULL),
("Could not find IP address for host \"%s\".", host));
return NULL;
}
if (hostinfo->h_addrtype != AF_INET) {
GST_ELEMENT_ERROR (element, RESOURCE, NOT_FOUND, (NULL),
("host \"%s\" is not an IP host", host));
return NULL;
}
addrs = hostinfo->h_addr_list;
/* There could be more than one IP address, but we just return the first */
ip = g_strdup (inet_ntoa (*(struct in_addr *) *addrs));
return ip;
}
/* Read a buffer from the given socket
* @returns:
* a GstBuffer from which data should be read
* or NULL, indicating a connection close or an error. Handle it with EOS.
*/
GstFlowReturn
gst_dccp_read_buffer (GstElement * this, int socket, GstBuffer ** buf)
{
fd_set testfds;
int maxfdp1;
int ret;
ssize_t bytes_read;
int readsize;
*buf = NULL;
/* do a blocking select on the socket */
FD_ZERO (&testfds);
FD_SET (socket, &testfds);
maxfdp1 = socket + 1;
/* no action (0) is also an error in our case */
if ((ret = select (maxfdp1, &testfds, NULL, NULL, 0)) <= 0) {
GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL),
("select failed: %s", g_strerror (errno)));
return GST_FLOW_ERROR;
}
/* ask how much is available for reading on the socket */
if ((ret = ioctl (socket, FIONREAD, &readsize)) < 0) {
GST_ELEMENT_ERROR (this, RESOURCE, READ, (NULL),
("read FIONREAD value failed: %s", g_strerror (errno)));
return GST_FLOW_ERROR;
}
if (readsize == 0) {
GST_DEBUG_OBJECT (this, "Got EOS on socket stream");
return GST_FLOW_UNEXPECTED;
}
*buf = gst_buffer_new_and_alloc (readsize);
bytes_read = read (socket, GST_BUFFER_DATA (*buf), readsize);
GST_LOG_OBJECT (this, "bytes read %d\n", bytes_read);
GST_LOG_OBJECT (this, "returning buffer of size %d", GST_BUFFER_SIZE (*buf));
return GST_FLOW_OK;
}
/* Create a new socket
* @return the socket file descriptor
*/
gint
gst_dccp_create_new_socket (GstElement * element)
{
int sock_fd;
if ((sock_fd = socket (AF_INET, SOCK_DCCP, IPPROTO_DCCP)) < 0) {
GST_ELEMENT_ERROR (element, RESOURCE, OPEN_READ, (NULL), GST_ERROR_SYSTEM);
}
return sock_fd;
}
/* Connect to a server
* @return true in case of successfull connection, false otherwise
*/
gboolean
gst_dccp_connect_to_server (GstElement * element, struct sockaddr_in server_sin,
int sock_fd)
{
GST_DEBUG_OBJECT (element, "connecting to server");
if (connect (sock_fd, (struct sockaddr *) &server_sin, sizeof (server_sin))) {
switch (errno) {
case ECONNREFUSED:
GST_ERROR_OBJECT (element, "Connection refused.");
return FALSE;
break;
default:
GST_ERROR_OBJECT (element, "Connection failed.");
return FALSE;
break;
}
}
return TRUE;
}
/* FIXME support only one client */
/*
* Accept connection on the server socket.
* @return the socket of the client connected to the server.
*/
gint
gst_dccp_server_wait_connections (GstElement * element, int server_sock_fd)
{
/* new client */
int client_sock_fd;
struct sockaddr_in client_address;
unsigned int client_address_len;
/* For some stupid reason, client_address and client_address_len has to be
* zeroed */
memset (&client_address, 0, sizeof (client_address));
client_address_len = 0;
if ((client_sock_fd =
accept (server_sock_fd, (struct sockaddr *) &client_address,
&client_address_len)) == -1) {
return -1;
}
/* to support multiple connection, fork here a new thread passing the
* client_sock_fd returned by accept function.
*/
GST_DEBUG_OBJECT (element, "added new client ip %s with fd %d",
inet_ntoa (client_address.sin_addr), client_sock_fd);
/* return the thread object, instead of the fd */
return client_sock_fd;
}
/*
* Bind a server address.
* @return true in success, false otherwise.
*/
gboolean
gst_dccp_bind_server_socket (GstElement * element, int server_sock_fd,
struct sockaddr_in server_sin)
{
int ret;
GST_DEBUG_OBJECT (element, "binding server socket to address");
ret = bind (server_sock_fd, (struct sockaddr *) &server_sin,
sizeof (server_sin));
if (ret) {
switch (errno) {
default:
GST_ELEMENT_ERROR (element, RESOURCE, OPEN_READ, (NULL),
("bind on port %d failed: %s", server_sin.sin_port,
g_strerror (errno)));
return FALSE;
break;
}
}
return TRUE;
}
gboolean
gst_dccp_listen_server_socket (GstElement * element, int server_sock_fd)
{
GST_DEBUG_OBJECT (element, "listening on server socket %d with queue of %d",
server_sock_fd, DCCP_BACKLOG);
if (listen (server_sock_fd, DCCP_BACKLOG) == -1) {
GST_ELEMENT_ERROR (element, RESOURCE, OPEN_READ, (NULL),
("Could not listen on server socket: %s", g_strerror (errno)));
return FALSE;
}
GST_DEBUG_OBJECT (element,
"listened on server socket %d, returning from connection setup",
server_sock_fd);
return TRUE;
}
/* FIXME */
gboolean
gst_dccp_socket_connected (GstElement * element, int server_sock_fd)
{
return FALSE;
}
/* Write buffer to given socket incrementally.
* Returns number of bytes written.
*/
gint
gst_dccp_socket_write (int socket, const void *buf, size_t size,
int packet_size)
{
size_t bytes_written = 0;
ssize_t wrote;
while (bytes_written < size) {
do {
wrote = write (socket, (const char *) buf + bytes_written,
MIN (packet_size, size - bytes_written));
} while (wrote == -1 && errno == EAGAIN);
/* TODO print the send error */
bytes_written += wrote;
}
if (bytes_written < 0)
GST_WARNING ("error while writing");
else
GST_LOG ("wrote %" G_GSIZE_FORMAT " bytes succesfully", bytes_written);
return bytes_written;
}
GstFlowReturn
gst_dccp_send_buffer (GstElement * this, GstBuffer * buffer, int client_sock_fd,
int packet_size)
{
size_t wrote;
gint size = 0;
guint8 *data;
size = GST_BUFFER_SIZE (buffer);
data = GST_BUFFER_DATA (buffer);
GST_LOG_OBJECT (this, "writing %d bytes\n", size);
if (packet_size < 0) {
GST_LOG_OBJECT (this, "error getting MTU\n");
return GST_FLOW_ERROR;
}
wrote = gst_dccp_socket_write (client_sock_fd, data, size, packet_size);
if (wrote != size) {
GST_DEBUG_OBJECT (this, ("Error while sending data"));
return GST_FLOW_ERROR;
}
return GST_FLOW_OK;
}
/*
* Create socket address.
* @return sockaddr_in.
*/
struct sockaddr_in
gst_dccp_create_sockaddr (GstElement * element, gchar * ip, int port)
{
struct sockaddr_in sin;
memset (&sin, 0, sizeof (sin));
sin.sin_family = AF_INET; /* network socket */
sin.sin_port = htons (port); /* on port */
sin.sin_addr.s_addr = inet_addr (ip); /* on host ip */
return sin;
}
gboolean
gst_dccp_make_address_reusable (GstElement * element, int sock_fd)
{
int ret = 1;
/* make address reusable */
if (setsockopt (sock_fd, SOL_SOCKET, SO_REUSEADDR,
(void *) &ret, sizeof (ret)) < 0) {
GST_ELEMENT_ERROR (element, RESOURCE, SETTINGS, (NULL),
("Could not setsockopt: %s", g_strerror (errno)));
return FALSE;
}
return TRUE;
}
/* DCCP socket specific stuffs */
gboolean
gst_dccp_set_ccid (GstElement * element, int sock_fd, uint8_t ccid)
{
uint8_t ccids[4]; /* for getting the available CCIDs, should be large enough */
socklen_t len = sizeof (ccids);
int i, ret;
gboolean ccid_supported = FALSE;
/*
* Determine which CCIDs are available on the host
*/
ret = getsockopt (sock_fd, SOL_DCCP, DCCP_SOCKOPT_AVAILABLE_CCIDS, &ccids,
&len);
if (ret < 0) {
GST_ERROR_OBJECT (element, "Can not determine available CCIDs");
return FALSE;
}
for (i = 0; i < sizeof (ccids); i++) {
if (ccid == ccids[i]) {
ccid_supported = TRUE;
}
}
if (!ccid_supported) {
GST_ERROR_OBJECT (element, "CCID specified is not supported");
return FALSE;
}
if (setsockopt (sock_fd, SOL_DCCP, DCCP_SOCKOPT_CCID, &ccid,
sizeof (ccid)) < 0) {
GST_ERROR_OBJECT (element, "Can not set CCID");
return FALSE;
}
return TRUE;
}
/*
* Get the current ccid of TX or RX half-connection. tx_or_rx parameter must be
* DCCP_SOCKOPT_TX_CCID or DCCP_SOCKOPT_RX_CCID.
* @return ccid or -1 on error or tx_or_rx not the correct option
*/
uint8_t
gst_dccp_get_ccid (GstElement * element, int sock_fd, int tx_or_rx)
{
uint8_t ccid;
socklen_t ccidlen;
int ret;
switch (tx_or_rx) {
case DCCP_SOCKOPT_TX_CCID:
case DCCP_SOCKOPT_RX_CCID:
break;
default:
return -1;
}
ccidlen = sizeof (ccid);
ret = getsockopt (sock_fd, SOL_DCCP, tx_or_rx, &ccid, &ccidlen);
if (ret < 0) {
GST_ERROR_OBJECT (element, "Can not determine available CCIDs");
return -1;
}
return ccid;
}
gint
gst_dccp_get_max_packet_size (GstElement * element, int sock)
{
int size;
socklen_t sizelen = sizeof (size);
if (getsockopt (sock, SOL_DCCP, DCCP_SOCKOPT_GET_CUR_MPS,
&size, &sizelen) < 0) {
GST_ELEMENT_ERROR (element, RESOURCE, SETTINGS, (NULL),
("Could not get current MTU %d: %s", errno, g_strerror (errno)));
return -1;
}
GST_DEBUG_OBJECT (element, "MTU: %d", size);
return size;
}
/* Still not used and need to be FIXED */
gboolean
gst_dccp_set_sock_windowsize (GstElement * element, int sock, int winSize,
gboolean inSend)
{
#ifdef SO_SNDBUF
int rc;
if (!inSend) {
/* receive buffer -- set
* note: results are verified after connect() or listen(),
* since some OS's don't show the corrected value until then. */
rc = setsockopt (sock, SOL_DCCP, SO_RCVBUF,
(char *) &winSize, sizeof (winSize));
GST_DEBUG_OBJECT (element, "set rcv sockbuf: %d\n", winSize);
} else {
/* send buffer -- set
* note: results are verified after connect() or listen(),
* since some OS's don't show the corrected value until then. */
rc = setsockopt (sock, SOL_DCCP, SO_SNDBUF,
(char *) &winSize, sizeof (winSize));
GST_DEBUG_OBJECT (element, "set snd sockbuf: %d\n", winSize);
}
if (rc < 0) {
GST_ELEMENT_ERROR (element, RESOURCE, SETTINGS, (NULL),
("Could not set window size %d: %s", errno, g_strerror (errno)));
return FALSE;
}
#endif /* SO_SNDBUF */
return TRUE;
}

96
gst/dccp/gstdccp.h Normal file
View file

@ -0,0 +1,96 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_DCCP_H__
#define __GST_DCCP_H__
#include <gst/gst.h>
#include <gst/base/gstadapter.h>
#include <sys/socket.h>
#include <netinet/in.h> /* sockaddr_in */
/* DCCP socket general options */
#define DCCP_BACKLOG 5
#ifndef SOCK_DCCP
#define SOCK_DCCP 6
#endif
#ifndef IPPROTO_DCCP
#define IPPROTO_DCCP 33
#endif
#ifndef SOL_DCCP
#define SOL_DCCP 269
#endif
/* dccp socket specific options */
#define DCCP_SOCKOPT_PACKET_SIZE 1 /* XXX deprecated, without effect */
#define DCCP_SOCKOPT_SERVICE 2
#define DCCP_SOCKOPT_CHANGE_L 3
#define DCCP_SOCKOPT_CHANGE_R 4
#define DCCP_SOCKOPT_GET_CUR_MPS 5
#define DCCP_SOCKOPT_SERVER_TIMEWAIT 6
#define DCCP_SOCKOPT_SEND_CSCOV 10
#define DCCP_SOCKOPT_RECV_CSCOV 11
#define DCCP_SOCKOPT_AVAILABLE_CCIDS 12
#define DCCP_SOCKOPT_CCID 13
#define DCCP_SOCKOPT_TX_CCID 14
#define DCCP_SOCKOPT_RX_CCID 15
#define DCCP_SOCKOPT_CCID_RX_INFO 128
#define DCCP_SOCKOPT_CCID_TX_INFO 192
/* Default parameters for the gst dccp element property */
#define DCCP_DEFAULT_PORT 5001
#define DCCP_DEFAULT_SOCK_FD -1
#define DCCP_DEFAULT_CLIENT_SOCK_FD -1
#define DCCP_DEFAULT_CLOSED TRUE
#define DCCP_DEFAULT_WAIT_CONNECTIONS FALSE
#define DCCP_DEFAULT_HOST "127.0.0.1"
#define DCCP_DEFAULT_CCID 2
#define DCCP_DELTA 100
gchar *gst_dccp_host_to_ip (GstElement * element, const gchar * host);
GstFlowReturn gst_dccp_read_buffer (GstElement * this, int socket,
GstBuffer ** buf);
gint gst_dccp_create_new_socket (GstElement * element);
gboolean gst_dccp_connect_to_server (GstElement * element,
struct sockaddr_in server_sin,
int sock_fd);
gint gst_dccp_server_wait_connections (GstElement * element, int server_sock_fd);
gboolean gst_dccp_bind_server_socket (GstElement * element, int server_sock_fd,
struct sockaddr_in server_sin);
gboolean gst_dccp_listen_server_socket (GstElement * element, int server_sock_fd);
gboolean gst_dccp_set_ccid (GstElement * element, int sock_fd, uint8_t ccid);
gint gst_dccp_get_max_packet_size(GstElement * element, int sock);
GstFlowReturn gst_dccp_send_buffer (GstElement * element, GstBuffer * buffer,
int client_sock_fd, int packet_size);
gboolean gst_dccp_make_address_reusable (GstElement * element, int sock_fd);
gboolean gst_dccp_set_sock_windowsize(GstElement * element, int sock, int winSize,
gboolean inSend);
#endif /* __GST_DCCP_H__ */

View file

@ -0,0 +1,322 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:element-dccpclientsink
* @see_also: dccpserversrc, dccpclientsrc, dccpserversink
*
* This element connect to a DCCP server and send data to it.
* <ulink url="http://www.linuxfoundation.org/en/Net:DCCP">DCCP</ulink> (Datagram
* Congestion Control Protocol) is a Transport Layer protocol like
* TCP and UDP.
*
* <refsect2>
* <title>Example pipeline</title>
* <para>
* |[
* gst-launch -v filesrc location=music.mp3 ! mp3parse ! dccpclientsink host=localhost port=9011 ccid=2
* ]| Client
* |[
* gst-launch -v dccpserversrc port=9011 ccid=2 ! decodebin ! alsasink
* ]| Server
*
* This example pipeline will send a MP3 stream to the server using DCCP.
* The server will decode the MP3 and play it.
* Run the server pipeline first than the client pipeline.
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstdccpclientsink.h"
#include "gstdccp.h"
#include <string.h> /* memset */
#include <unistd.h>
#include <arpa/inet.h>
#include <fcntl.h>
/* signals */
enum
{
SIGNAL_CONNECTED,
LAST_SIGNAL
};
/* properties */
enum
{
PROP_0,
PROP_PORT,
PROP_HOST,
PROP_SOCK_FD,
PROP_CCID,
PROP_CLOSE_FD
};
static gboolean gst_dccp_client_sink_stop (GstBaseSink * bsink);
static gboolean gst_dccp_client_sink_start (GstBaseSink * bsink);
static GstFlowReturn gst_dccp_client_sink_render (GstBaseSink * bsink,
GstBuffer * buf);
GST_DEBUG_CATEGORY_STATIC (dccpclientsink_debug);
static const GstElementDetails gst_dccp_client_sink_details =
GST_ELEMENT_DETAILS ("DCCP client sink",
"Sink/Network",
"Send data as a client over the network via DCCP",
"E-Phone Team at Federal University of Campina Grande <leandroal@gmail.com>");
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
GST_BOILERPLATE (GstDCCPClientSink, gst_dccp_client_sink, GstBaseSink,
GST_TYPE_BASE_SINK);
static guint gst_dccp_client_sink_signals[LAST_SIGNAL] = { 0 };
static GstFlowReturn
gst_dccp_client_sink_render (GstBaseSink * bsink, GstBuffer * buf)
{
GstDCCPClientSink *sink = GST_DCCP_CLIENT_SINK (bsink);
return gst_dccp_send_buffer (GST_ELEMENT (sink), buf, sink->sock_fd,
sink->pksize);
}
/*
* Set the value of a property for the client sink.
*/
static void
gst_dccp_client_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstDCCPClientSink *sink = GST_DCCP_CLIENT_SINK (object);
switch (prop_id) {
case PROP_PORT:
sink->port = g_value_get_int (value);
break;
case PROP_SOCK_FD:
sink->sock_fd = g_value_get_int (value);
break;
case PROP_HOST:
if (!g_value_get_string (value)) {
g_warning ("host property cannot be NULL");
break;
}
g_free (sink->host);
sink->host = g_strdup (g_value_get_string (value));
break;
case PROP_CLOSE_FD:
sink->closed = g_value_get_boolean (value);
break;
case PROP_CCID:
sink->ccid = g_value_get_int (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/*
* Get a given property value for the client sink.
*/
static void
gst_dccp_client_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstDCCPClientSink *sink = GST_DCCP_CLIENT_SINK (object);
switch (prop_id) {
case PROP_PORT:
g_value_set_int (value, sink->port);
break;
case PROP_SOCK_FD:
g_value_set_int (value, sink->sock_fd);
break;
case PROP_HOST:
g_value_set_string (value, sink->host);
break;
case PROP_CLOSE_FD:
g_value_set_boolean (value, sink->closed);
break;
case PROP_CCID:
g_value_set_int (value, sink->ccid);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
gst_dccp_client_sink_start (GstBaseSink * bsink)
{
GstDCCPClientSink *sink = GST_DCCP_CLIENT_SINK (bsink);
if (sink->sock_fd == DCCP_DEFAULT_SOCK_FD) {
gchar *ip = NULL;
/* look up name if we need to */
if (!(ip = gst_dccp_host_to_ip (GST_ELEMENT (sink), sink->host))) {
GST_ERROR_OBJECT (sink, "cannot resolve hostname");
gst_dccp_client_sink_stop (GST_BASE_SINK (sink));
return FALSE;
}
/* name the server socket */
memset (&sink->server_sin, 0, sizeof (sink->server_sin));
sink->server_sin.sin_family = AF_INET; /* network socket */
sink->server_sin.sin_port = htons (sink->port); /* on port */
sink->server_sin.sin_addr.s_addr = inet_addr (ip); /* on host ip */
g_free (ip);
/* create socket */
if ((sink->sock_fd = gst_dccp_create_new_socket (GST_ELEMENT (sink))) < 0) {
return FALSE;
}
if (!gst_dccp_set_ccid (GST_ELEMENT (sink), sink->sock_fd, sink->ccid)) {
gst_dccp_client_sink_stop (GST_BASE_SINK (sink));
return FALSE;
}
if (!gst_dccp_connect_to_server (GST_ELEMENT (sink), sink->server_sin,
sink->sock_fd)) {
gst_dccp_client_sink_stop (GST_BASE_SINK (sink));
return FALSE;
}
/* the socket is connected */
g_signal_emit (sink, gst_dccp_client_sink_signals[SIGNAL_CONNECTED], 0,
sink->sock_fd);
}
sink->pksize =
gst_dccp_get_max_packet_size (GST_ELEMENT (sink), sink->sock_fd);
return TRUE;
}
static void
gst_dccp_client_sink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sinktemplate));
gst_element_class_set_details (element_class, &gst_dccp_client_sink_details);
}
static void
gst_dccp_client_sink_init (GstDCCPClientSink * this,
GstDCCPClientSinkClass * g_class)
{
this->port = DCCP_DEFAULT_PORT;
this->host = g_strdup (DCCP_DEFAULT_HOST);
this->sock_fd = DCCP_DEFAULT_SOCK_FD;
this->closed = DCCP_DEFAULT_CLOSED;
this->ccid = DCCP_DEFAULT_CCID;
}
static gboolean
gst_dccp_client_sink_stop (GstBaseSink * bsink)
{
GstDCCPClientSink *sink;
sink = GST_DCCP_CLIENT_SINK (bsink);
if (sink->sock_fd != -1 && sink->closed) {
GST_DEBUG_OBJECT (sink, "closing socket");
close (sink->sock_fd);
sink->sock_fd = -1;
}
return TRUE;
}
/*
* Define the gst class, callbacks, etc.
*/
static void
gst_dccp_client_sink_class_init (GstDCCPClientSinkClass * klass)
{
GObjectClass *gobject_class;
GstBaseSinkClass *gstbasesink_class;
gobject_class = (GObjectClass *) klass;
gstbasesink_class = (GstBaseSinkClass *) klass;
gobject_class->set_property = gst_dccp_client_sink_set_property;
gobject_class->get_property = gst_dccp_client_sink_get_property;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PORT,
g_param_spec_int ("port", "Port",
"The port to receive the packets from, 0=allocate", 0, G_MAXUINT16,
DCCP_DEFAULT_PORT, G_PARAM_READWRITE));
/* FIXME property server_ip */
g_object_class_install_property (gobject_class, PROP_HOST,
g_param_spec_string ("host", "Host",
"The host IP address to send packets to", DCCP_DEFAULT_HOST,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_SOCK_FD,
g_param_spec_int ("sockfd", "Socket fd",
"The socket file descriptor", -1, G_MAXINT,
DCCP_DEFAULT_SOCK_FD, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CLOSE_FD,
g_param_spec_boolean ("close-socket", "Close",
"Close socket at end of stream",
DCCP_DEFAULT_CLOSED, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CCID,
g_param_spec_int ("ccid", "CCID",
"The Congestion Control IDentified to be used", 2, G_MAXINT,
DCCP_DEFAULT_CCID, G_PARAM_READWRITE));
/* signals */
/**
* GstDccpClientSink::connected:
* @sink: the gstdccpclientsink instance
* @fd: the connected socket fd
*
* Sign that the element has connected, return the fd of the socket.
*/
gst_dccp_client_sink_signals[SIGNAL_CONNECTED] =
g_signal_new ("connected", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GstDCCPClientSinkClass, connected), NULL, NULL,
gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
gstbasesink_class->start = gst_dccp_client_sink_start;
gstbasesink_class->stop = gst_dccp_client_sink_stop;
gstbasesink_class->render = gst_dccp_client_sink_render;
GST_DEBUG_CATEGORY_INIT (dccpclientsink_debug, "dccpclientsink", 0,
"DCCP Client Sink");
}

View file

@ -0,0 +1,81 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_DCCP_CLIENT_SINK_H__
#define __GST_DCCP_CLIENT_SINK_H__
#include <gst/gst.h>
#include <gst/base/gstbasesink.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
#include <netdb.h> /* sockaddr_in */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h> /* sockaddr_in */
#include <unistd.h>
#define GST_TYPE_DCCP_CLIENT_SINK \
(gst_dccp_client_sink_get_type())
#define GST_DCCP_CLIENT_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DCCP_CLIENT_SINK,GstDCCPClientSink))
#define GST_DCCP_CLIENT_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DCCP_CLIENT_SINK,GstDCCPClientSinkClass))
#define GST_IS_DCCP_CLIENT_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DCCP_CLIENT_SINK))
#define GST_IS_DCCP_CLIENT_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DCCP_CLIENT_SINK))
typedef struct _GstDCCPClientSink GstDCCPClientSink;
typedef struct _GstDCCPClientSinkClass GstDCCPClientSinkClass;
struct _GstDCCPClientSink
{
GstBaseSink element;
/* server information */
int port;
gchar *host;
struct sockaddr_in server_sin;
/* socket */
int sock_fd;
gboolean closed;
int pksize;
GstCaps *caps;
uint8_t ccid;
};
struct _GstDCCPClientSinkClass
{
GstBaseSinkClass parent_class;
/* signals */
void (*connected) (GstElement *sink, gint fd);
};
GType gst_dccp_client_sink_get_type (void);
G_END_DECLS
#endif /* __GST_DCCP_CLIENT_SRC_H__ */

398
gst/dccp/gstdccpclientsrc.c Normal file
View file

@ -0,0 +1,398 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:element-dccpclientsrc
* @see_also: dccpclientsink, dccpserversink, dccpserversrc
*
* This element connect to a DCCP server and send data to it.
* <ulink url="http://www.linuxfoundation.org/en/Net:DCCP">DCCP</ulink> (Datagram
* Congestion Control Protocol) is a Transport Layer protocol like
* TCP and UDP.
*
* <refsect2>
* <title>Example pipeline</title>
* <para>
* |[
* gst-launch -v dccpclientsrc host=localhost port=9011 ccid=2 ! decodebin ! alsasink
* ]| Client
* |[
* gst-launch -v filesrc location=music.mp3 ! mp3parse ! dccpserversink port=9011 ccid=2
* ]| Server
*
* This example pipeline will send a MP3 stream to the client using DCCP.
* The client will decode the MP3 and play it. Run the server pipeline
* first than the client pipeline. If you want, you can run more than one dccpclientsrc
* to connect to the same server (see wait-connections property at dccpserversink).
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstdccpclientsrc.h"
#include "gstdccp.h"
#include <string.h> /* memset */
#include <unistd.h>
#include <arpa/inet.h>
#include <fcntl.h>
#define DCCP_DEFAULT_CAPS NULL
/* signals */
enum
{
SIGNAL_CONNECTED,
LAST_SIGNAL
};
/* properties */
enum
{
PROP_0,
PROP_PORT,
PROP_HOST,
PROP_SOCK_FD,
PROP_CLOSED,
PROP_CCID,
PROP_CAPS
};
static gboolean gst_dccp_client_src_stop (GstBaseSrc * bsrc);
GST_DEBUG_CATEGORY_STATIC (dccpclientsrc_debug);
static const GstElementDetails gst_dccp_client_src_details =
GST_ELEMENT_DETAILS ("DCCP client source",
"Source/Network",
"Receive data as a client over the network via DCCP",
"E-Phone Team at Federal University of Campina Grande <leandroal@gmail.com>");
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
GST_BOILERPLATE (GstDCCPClientSrc, gst_dccp_client_src, GstPushSrc,
GST_TYPE_PUSH_SRC);
static guint gst_dccp_client_src_signals[LAST_SIGNAL] = { 0 };
static GstFlowReturn
gst_dccp_client_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
{
GstDCCPClientSrc *src;
GstFlowReturn ret = GST_FLOW_OK;
src = GST_DCCP_CLIENT_SRC (psrc);
GST_LOG_OBJECT (src, "reading a buffer");
ret = gst_dccp_read_buffer (GST_ELEMENT (src), src->sock_fd, outbuf);
if (ret == GST_FLOW_OK) {
GST_LOG_OBJECT (src,
"Returning buffer from _get of size %d, ts %"
GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT
", offset %" G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT,
GST_BUFFER_SIZE (*outbuf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (*outbuf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (*outbuf)),
GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf));
if (!gst_caps_is_equal (src->caps, GST_CAPS_ANY)) {
gst_buffer_set_caps (*outbuf, src->caps);
}
}
return ret;
}
/*
* Set the value of a property for the client src.
*/
static void
gst_dccp_client_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstDCCPClientSrc *src = GST_DCCP_CLIENT_SRC (object);
switch (prop_id) {
case PROP_PORT:
src->port = g_value_get_int (value);
break;
case PROP_HOST:
if (!g_value_get_string (value)) {
g_warning ("host property cannot be NULL");
break;
}
g_free (src->host);
src->host = g_strdup (g_value_get_string (value));
break;
case PROP_SOCK_FD:
src->sock_fd = g_value_get_int (value);
break;
case PROP_CLOSED:
src->closed = g_value_get_boolean (value);
break;
case PROP_CCID:
src->ccid = g_value_get_int (value);
break;
case PROP_CAPS:
{
const GstCaps *new_caps_val = gst_value_get_caps (value);
GstCaps *new_caps;
GstCaps *old_caps;
if (new_caps_val == NULL) {
new_caps = gst_caps_new_any ();
} else {
new_caps = gst_caps_copy (new_caps_val);
}
old_caps = src->caps;
src->caps = new_caps;
if (old_caps)
gst_caps_unref (old_caps);
gst_pad_set_caps (GST_BASE_SRC (src)->srcpad, new_caps);
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/*
* Get a given property value for the client src.
*/
static void
gst_dccp_client_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstDCCPClientSrc *src = GST_DCCP_CLIENT_SRC (object);
switch (prop_id) {
case PROP_PORT:
g_value_set_int (value, src->port);
break;
case PROP_HOST:
g_value_set_string (value, src->host);
break;
case PROP_SOCK_FD:
g_value_set_int (value, src->sock_fd);
break;
case PROP_CLOSED:
g_value_set_boolean (value, src->closed);
break;
case PROP_CCID:
g_value_set_int (value, src->ccid);
break;
case PROP_CAPS:
gst_value_set_caps (value, src->caps);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
gst_dccp_client_src_start (GstBaseSrc * bsrc)
{
GstDCCPClientSrc *src = GST_DCCP_CLIENT_SRC (bsrc);
if (src->sock_fd == DCCP_DEFAULT_SOCK_FD) {
gchar *ip = NULL;
/* look up name if we need to */
if (!(ip = gst_dccp_host_to_ip (GST_ELEMENT (src), src->host))) {
GST_ERROR_OBJECT (src, "cannot resolve hostname");
gst_dccp_client_src_stop (GST_BASE_SRC (src));
return FALSE;
}
/* name the server socket */
memset (&src->server_sin, 0, sizeof (src->server_sin));
src->server_sin.sin_family = AF_INET; /* network socket */
src->server_sin.sin_port = htons (src->port); /* on port */
src->server_sin.sin_addr.s_addr = inet_addr (ip); /* on host ip */
g_free (ip);
/* create socket */
if ((src->sock_fd = gst_dccp_create_new_socket (GST_ELEMENT (src))) < 0) {
return FALSE;
}
if (!gst_dccp_set_ccid (GST_ELEMENT (src), src->sock_fd, src->ccid)) {
gst_dccp_client_src_stop (GST_BASE_SRC (src));
return FALSE;
}
if (!gst_dccp_connect_to_server (GST_ELEMENT (src), src->server_sin,
src->sock_fd)) {
gst_dccp_client_src_stop (GST_BASE_SRC (src));
return FALSE;
}
/* the socket is connected */
g_signal_emit (src, gst_dccp_client_src_signals[SIGNAL_CONNECTED], 0,
src->sock_fd);
}
return TRUE;
}
static void
gst_dccp_client_src_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&srctemplate));
gst_element_class_set_details (element_class, &gst_dccp_client_src_details);
}
static void
gst_dccp_client_src_init (GstDCCPClientSrc * this,
GstDCCPClientSrcClass * g_class)
{
this->port = DCCP_DEFAULT_PORT;
this->host = g_strdup (DCCP_DEFAULT_HOST);
this->sock_fd = DCCP_DEFAULT_SOCK_FD;
this->closed = DCCP_DEFAULT_CLOSED;
this->ccid = DCCP_DEFAULT_CCID;
this->caps = NULL;
gst_base_src_set_format (GST_BASE_SRC (this), GST_FORMAT_TIME);
/* Checking if the version of the gstreamer is bigger that 0.10.15 */
#if ((GST_VERSION_MAJOR > 0) || \
(GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR > 10) || \
(GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR == 10 && GST_VERSION_MICRO >= 15))
gst_base_src_set_do_timestamp (GST_BASE_SRC (this), TRUE);
#endif
/* FIXME is this correct? */
gst_base_src_set_live (GST_BASE_SRC (this), TRUE);
}
static void
gst_dccp_client_src_finalize (GObject * gobject)
{
GstDCCPClientSrc *this = GST_DCCP_CLIENT_SRC (gobject);
if (this->caps) {
gst_caps_unref (this->caps);
this->caps = NULL;
}
g_free (this->host);
G_OBJECT_CLASS (parent_class)->finalize (gobject);
}
static gboolean
gst_dccp_client_src_stop (GstBaseSrc * bsrc)
{
GstDCCPClientSrc *src;
src = GST_DCCP_CLIENT_SRC (bsrc);
if (src->sock_fd != -1 && src->closed) {
GST_DEBUG_OBJECT (src, "closing socket");
close (src->sock_fd);
src->sock_fd = -1;
}
return TRUE;
}
/*
* Define the gst class, callbacks, etc.
*/
static void
gst_dccp_client_src_class_init (GstDCCPClientSrcClass * klass)
{
GObjectClass *gobject_class;
GstBaseSrcClass *gstbasesrc_class;
GstPushSrcClass *gstpush_src_class;
gobject_class = (GObjectClass *) klass;
gstbasesrc_class = (GstBaseSrcClass *) klass;
gstpush_src_class = (GstPushSrcClass *) klass;
gobject_class->set_property = gst_dccp_client_src_set_property;
gobject_class->get_property = gst_dccp_client_src_get_property;
gobject_class->finalize = gst_dccp_client_src_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PORT,
g_param_spec_int ("port", "Port",
"The port to receive the packets from, 0=allocate", 0, G_MAXUINT16,
DCCP_DEFAULT_PORT, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_HOST,
g_param_spec_string ("host", "Host",
"The host IP address to receive packets from", DCCP_DEFAULT_HOST,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_SOCK_FD,
g_param_spec_int ("sockfd", "Socket fd",
"The socket file descriptor", -1, G_MAXINT, DCCP_DEFAULT_SOCK_FD,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CLOSED,
g_param_spec_boolean ("close-socket", "Close socket",
"Close socket at the end of stream", DCCP_DEFAULT_CLOSED,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CAPS,
g_param_spec_boxed ("caps", "Caps",
"The caps of the source pad", GST_TYPE_CAPS, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CCID,
g_param_spec_int ("ccid", "CCID",
"The Congestion Control IDentified to be used", 2, G_MAXINT,
DCCP_DEFAULT_CCID, G_PARAM_READWRITE));
/* signals */
/**
* GstDccpClientSrc::connected:
* @src: the gstdccpclientsrc instance
* @fd: the connected socket fd
*
* Reports that the element has connected, giving the fd of the socket
*/
gst_dccp_client_src_signals[SIGNAL_CONNECTED] =
g_signal_new ("connected", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GstDCCPClientSrcClass, connected), NULL, NULL,
gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
gstbasesrc_class->start = gst_dccp_client_src_start;
gstbasesrc_class->stop = gst_dccp_client_src_stop;
gstpush_src_class->create = gst_dccp_client_src_create;
GST_DEBUG_CATEGORY_INIT (dccpclientsrc_debug, "dccpclientsrc", 0,
"DCCP Client Source");
}

View file

@ -0,0 +1,77 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_DCCP_CLIENT_SRC_H__
#define __GST_DCCP_CLIENT_SRC_H__
#include <gst/gst.h>
#include <gst/base/gstpushsrc.h>
#include <gst/base/gstbasesrc.h>
G_BEGIN_DECLS
#include <netdb.h> /* sockaddr_in */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h> /* sockaddr_in */
#include <unistd.h>
#define GST_TYPE_DCCP_CLIENT_SRC \
(gst_dccp_client_src_get_type())
#define GST_DCCP_CLIENT_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DCCP_CLIENT_SRC,GstDCCPClientSrc))
#define GST_DCCP_CLIENT_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DCCP_CLIENT_SRC,GstDCCPClientSrcClass))
#define GST_IS_DCCP_CLIENT_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DCCP_CLIENT_SRC))
#define GST_IS_DCCP_CLIENT_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DCCP_CLIENT_SRC))
typedef struct _GstDCCPClientSrc GstDCCPClientSrc;
typedef struct _GstDCCPClientSrcClass GstDCCPClientSrcClass;
struct _GstDCCPClientSrc {
GstPushSrc element;
/* server information */
int port;
gchar *host;
struct sockaddr_in server_sin;
/* socket */
int sock_fd;
gboolean closed;
GstCaps *caps;
uint8_t ccid;
};
struct _GstDCCPClientSrcClass {
GstPushSrcClass parent_class;
/* signals */
void (*connected) (GstElement *src, gint fd);
};
GType gst_dccp_client_src_get_type (void);
G_END_DECLS
#endif /* __GST_DCCP_CLIENT_SRC_H__ */

60
gst/dccp/gstdccpplugin.c Normal file
View file

@ -0,0 +1,60 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstdccpclientsrc.h"
#include "gstdccpserversink.h"
#include "gstdccpclientsink.h"
#include "gstdccpserversrc.h"
GST_DEBUG_CATEGORY (dccp_debug);
static gboolean
plugin_init (GstPlugin * plugin)
{
if (!gst_element_register (plugin, "dccpclientsrc", GST_RANK_NONE,
GST_TYPE_DCCP_CLIENT_SRC))
return FALSE;
if (!gst_element_register (plugin, "dccpserversink", GST_RANK_NONE,
GST_TYPE_DCCP_SERVER_SINK))
return FALSE;
if (!gst_element_register (plugin, "dccpclientsink", GST_RANK_NONE,
GST_TYPE_DCCP_CLIENT_SINK))
return FALSE;
if (!gst_element_register (plugin, "dccpserversrc", GST_RANK_NONE,
GST_TYPE_DCCP_SERVER_SRC))
return FALSE;
GST_DEBUG_CATEGORY_INIT (dccp_debug, "dccp", 0, "DCCP calls");
return TRUE;
}
GST_PLUGIN_DEFINE (GST_VERSION_MAJOR,
GST_VERSION_MINOR,
"dccp",
"transfer data over the network via DCCP.",
plugin_init, VERSION, GST_LICENSE, "DCCP",
"http://garage.maemo.org/projects/ephone")

View file

@ -0,0 +1,435 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:element-dccpserversink
* @see_also: dccpclientsink, dccpclientsrc, dccpserversrc
*
* This element wait for connections from clients and send data to them.
* <ulink url="http://www.linuxfoundation.org/en/Net:DCCP">DCCP</ulink> (Datagram
* Congestion Control Protocol) is a Transport Layer protocol like
* TCP and UDP.
*
* <refsect2>
* <title>Example pipeline</title>
* <para>
* |[
* gst-launch -v dccpclientsrc host=localhost port=9011 ccid=2 ! decodebin ! alsasink
* ]| Client
* |[
* gst-launch -v filesrc location=music.mp3 ! mp3parse ! dccpserversink port=9011 ccid=2
* ]| Server
*
* This example pipeline will send a MP3 stream to the client using DCCP.
* The client will decode the MP3 and play it. Run the server pipeline
* first than the client pipeline. If you want, you can run more than one dccpclientsrc
* to connect to the same server (see wait-connections property at dccpserversink).
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstdccpserversink.h"
#include "gstdccp.h"
#include <string.h> /* memset */
#include <unistd.h>
#include <arpa/inet.h>
#include <fcntl.h>
/* signals */
enum
{
SIGNAL_CONNECTED,
LAST_SIGNAL
};
/* properties */
enum
{
PROP_0,
PROP_PORT,
PROP_CLIENT_SOCK_FD,
PROP_CCID,
PROP_CLOSED,
PROP_WAIT_CONNECTIONS
};
pthread_mutex_t lock = PTHREAD_MUTEX_INITIALIZER;
static gboolean gst_dccp_server_sink_stop (GstBaseSink * bsink);
GST_DEBUG_CATEGORY_STATIC (dccpserversink_debug);
static const GstElementDetails gst_dccp_server_sink_details =
GST_ELEMENT_DETAILS ("DCCP server sink",
"Sink/Network",
"Send data as a server over the network via DCCP",
"E-Phone Team at Federal University of Campina Grande <leandroal@gmail.com>");
static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink",
GST_PAD_SINK,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
GST_BOILERPLATE (GstDCCPServerSink, gst_dccp_server_sink, GstBaseSink,
GST_TYPE_BASE_SINK);
static guint gst_dccp_server_sink_signals[LAST_SIGNAL] = { 0 };
static Client *
gst_dccp_server_create_client (GstElement * element, int socket)
{
Client *client = (Client *) g_malloc (sizeof (Client));
client->socket = socket;
client->pksize = gst_dccp_get_max_packet_size (element, client->socket);
client->flow_status = GST_FLOW_OK;
/* the socket is connected */
g_signal_emit (element, gst_dccp_server_sink_signals[SIGNAL_CONNECTED], 0,
socket);
return client;
}
static void *
gst_dccp_server_accept_new_clients (void *arg)
{
GstDCCPServerSink *sink = (GstDCCPServerSink *) arg;
int newsockfd;
Client *client;
while (1) {
newsockfd =
gst_dccp_server_wait_connections (GST_ELEMENT (sink), sink->sock_fd);
client = gst_dccp_server_create_client (GST_ELEMENT (sink), newsockfd);
pthread_mutex_lock (&lock);
sink->clients = g_list_append (sink->clients, client);
pthread_mutex_unlock (&lock);
}
}
static void *
gst_dccp_server_send_buffer (void *arg)
{
Client *client = (Client *) arg;
GstDCCPServerSink *sink = client->server;
GstBuffer *buf = client->buf;
int client_sock_fd = client->socket;
int pksize = client->pksize;
if (gst_dccp_send_buffer (GST_ELEMENT (sink), buf, client_sock_fd,
pksize) == GST_FLOW_ERROR) {
client->flow_status = GST_FLOW_ERROR;
}
return NULL;
}
/* Remove clients with problems to send */
static void *
gst_dccp_server_delete_dead_clients (void *arg)
{
GstDCCPServerSink *sink = (GstDCCPServerSink *) arg;
int i;
GList *tmp = NULL;
pthread_mutex_lock (&lock);
for (i = 0; i < g_list_length (sink->clients); i++) {
Client *client = (Client *) g_list_nth_data (sink->clients, i);
if (client->flow_status == GST_FLOW_OK) {
tmp = g_list_append (tmp, client);
} else {
close (client->socket);
g_free (client);
}
}
g_list_free (sink->clients);
sink->clients = tmp;
pthread_mutex_unlock (&lock);
return 0;
}
static void
gst_dccp_server_sink_init (GstDCCPServerSink * this,
GstDCCPServerSinkClass * g_class)
{
this->port = DCCP_DEFAULT_PORT;
this->sock_fd = DCCP_DEFAULT_SOCK_FD;
this->client_sock_fd = DCCP_DEFAULT_CLIENT_SOCK_FD;
this->closed = DCCP_DEFAULT_CLOSED;
this->ccid = DCCP_DEFAULT_CCID;
this->wait_connections = DCCP_DEFAULT_WAIT_CONNECTIONS;
this->clients = NULL;
}
static gboolean
gst_dccp_server_sink_start (GstBaseSink * bsink)
{
GstDCCPServerSink *sink = GST_DCCP_SERVER_SINK (bsink);
int ret = 1;
Client *client;
/* create socket */
if ((sink->sock_fd = gst_dccp_create_new_socket (GST_ELEMENT (sink))) < 0) {
return FALSE;
}
/* make address reusable */
if (setsockopt (sink->sock_fd, SOL_SOCKET, SO_REUSEADDR,
(void *) &ret, sizeof (ret)) < 0) {
GST_ELEMENT_ERROR (sink, RESOURCE, SETTINGS, (NULL),
("Could not setsockopt: %s", g_strerror (errno)));
return FALSE;
}
/* name the server socket */
memset (&sink->server_sin, 0, sizeof (sink->server_sin));
sink->server_sin.sin_family = AF_INET; /* network socket */
sink->server_sin.sin_port = htons (sink->port); /* on port */
sink->server_sin.sin_addr.s_addr = htonl (INADDR_ANY); /* for hosts */
if (!gst_dccp_bind_server_socket (GST_ELEMENT (sink), sink->sock_fd,
sink->server_sin)) {
return FALSE;
}
if (!gst_dccp_set_ccid (GST_ELEMENT (sink), sink->sock_fd, sink->ccid)) {
return FALSE;
}
if (!gst_dccp_listen_server_socket (GST_ELEMENT (sink), sink->sock_fd)) {
return FALSE;
}
if (sink->client_sock_fd == DCCP_DEFAULT_CLIENT_SOCK_FD) {
sink->client_sock_fd =
gst_dccp_server_wait_connections (GST_ELEMENT (sink), sink->sock_fd);
}
if (sink->client_sock_fd == -1) {
return FALSE;
}
client =
gst_dccp_server_create_client (GST_ELEMENT (sink), sink->client_sock_fd);
sink->clients = g_list_append (sink->clients, client);
pthread_mutex_init (&lock, NULL);
if (sink->wait_connections == TRUE) {
pthread_create (&accept_thread_id, NULL, gst_dccp_server_accept_new_clients,
sink);
pthread_detach (accept_thread_id);
}
return TRUE;
}
static GstFlowReturn
gst_dccp_server_sink_render (GstBaseSink * bsink, GstBuffer * buf)
{
GstDCCPServerSink *sink = GST_DCCP_SERVER_SINK (bsink);
pthread_t thread_id;
int i;
pthread_mutex_lock (&lock);
for (i = 0; i < g_list_length (sink->clients); i++) {
Client *client = (Client *) g_list_nth_data (sink->clients, i);
client->buf = buf;
client->server = sink;
if (client->flow_status == GST_FLOW_OK) {
pthread_create (&thread_id, NULL, gst_dccp_server_send_buffer,
(void *) client);
pthread_detach (thread_id);
} else {
pthread_create (&thread_id, NULL, gst_dccp_server_delete_dead_clients,
(void *) sink);
pthread_detach (thread_id);
}
}
pthread_mutex_unlock (&lock);
return GST_FLOW_OK;
}
static gboolean
gst_dccp_server_sink_stop (GstBaseSink * bsink)
{
GstDCCPServerSink *sink;
int i;
sink = GST_DCCP_SERVER_SINK (bsink);
if (sink->wait_connections == TRUE) {
pthread_cancel (accept_thread_id);
}
if (sink->sock_fd != -1 && sink->closed == TRUE) {
GST_DEBUG_OBJECT (sink, "closing socket");
close (sink->sock_fd);
sink->sock_fd = -1;
}
pthread_mutex_lock (&lock);
for (i = 0; i < g_list_length (sink->clients); i++) {
Client *client = (Client *) g_list_nth_data (sink->clients, i);
close (client->socket);
g_free (client);
}
pthread_mutex_unlock (&lock);
return TRUE;
}
static void
gst_dccp_server_sink_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&sinktemplate));
gst_element_class_set_details (element_class, &gst_dccp_server_sink_details);
}
/*
* Set the value of a property for the server sink.
*/
static void
gst_dccp_server_sink_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstDCCPServerSink *sink = GST_DCCP_SERVER_SINK (object);
switch (prop_id) {
case PROP_PORT:
sink->port = g_value_get_int (value);
break;
case PROP_CLIENT_SOCK_FD:
sink->client_sock_fd = g_value_get_int (value);
break;
case PROP_CLOSED:
sink->closed = g_value_get_boolean (value);
break;
case PROP_WAIT_CONNECTIONS:
sink->wait_connections = g_value_get_boolean (value);
break;
case PROP_CCID:
sink->ccid = g_value_get_int (value);
break;
default:
break;
}
}
static void
gst_dccp_server_sink_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstDCCPServerSink *sink = GST_DCCP_SERVER_SINK (object);
switch (prop_id) {
case PROP_PORT:
g_value_set_int (value, sink->port);
break;
case PROP_CLIENT_SOCK_FD:
g_value_set_int (value, sink->client_sock_fd);
break;
case PROP_CLOSED:
g_value_set_boolean (value, sink->closed);
break;
case PROP_WAIT_CONNECTIONS:
g_value_set_boolean (value, sink->wait_connections);
break;
case PROP_CCID:
g_value_set_int (value, sink->ccid);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static void
gst_dccp_server_sink_class_init (GstDCCPServerSinkClass * klass)
{
GObjectClass *gobject_class;
GstBaseSinkClass *gstbasesink_class;
gobject_class = (GObjectClass *) klass;
gstbasesink_class = (GstBaseSinkClass *) klass;
gobject_class->set_property = gst_dccp_server_sink_set_property;
gobject_class->get_property = gst_dccp_server_sink_get_property;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PORT,
g_param_spec_int ("port", "Port",
"The port to receive the packets from, 0=allocate", 0, G_MAXUINT16,
DCCP_DEFAULT_PORT, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CLIENT_SOCK_FD,
g_param_spec_int ("sockfd", "Socket fd",
"The client socket file descriptor", -1, G_MAXINT,
DCCP_DEFAULT_CLIENT_SOCK_FD, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CLOSED,
g_param_spec_boolean ("close-socket", "Close",
"Close socket at end of stream",
DCCP_DEFAULT_CLOSED, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CCID,
g_param_spec_int ("ccid", "CCID",
"The Congestion Control IDentified to be used", 2, G_MAXINT,
DCCP_DEFAULT_CCID, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_WAIT_CONNECTIONS,
g_param_spec_boolean ("wait-connections", "Wait connections",
"Wait for many client connections",
DCCP_DEFAULT_WAIT_CONNECTIONS, G_PARAM_READWRITE));
/* signals */
/**
* GstDccpServerSink::connected:
* @src: the gstdccpserversink instance
* @fd: the connected socket fd
*
* Reports that the element has connected, giving the fd of the socket
*/
gst_dccp_server_sink_signals[SIGNAL_CONNECTED] =
g_signal_new ("connected", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GstDCCPServerSinkClass, connected), NULL, NULL,
gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
gstbasesink_class->start = gst_dccp_server_sink_start;
gstbasesink_class->stop = gst_dccp_server_sink_stop;
gstbasesink_class->render = gst_dccp_server_sink_render;
GST_DEBUG_CATEGORY_INIT (dccpserversink_debug, "dccpserversink", 0,
"DCCP Server Sink");
}

View file

@ -0,0 +1,96 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_DCCP_SERVER_SINK_H__
#define __GST_DCCP_SERVER_SINK_H__
#include <gst/gst.h>
#include <gst/base/gstbasesink.h>
#include <gst/base/gstadapter.h>
G_BEGIN_DECLS
#include <netdb.h> /* sockaddr_in */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h> /* sockaddr_in */
#include <unistd.h>
#include <pthread.h>
#define GST_TYPE_DCCP_SERVER_SINK \
(gst_dccp_server_sink_get_type())
#define GST_DCCP_SERVER_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DCCP_SERVER_SINK,GstDCCPServerSink))
#define GST_DCCP_SERVER_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DCCP_SERVER_SINK,GstDCCPServerSinkClass))
#define GST_IS_DCCP_SERVER_SINK(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DCCP_SERVER_SINK))
#define GST_IS_DCCP_SERVER_SINK_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DCCP_SERVER_SINK))
typedef struct _GstDCCPServerSink GstDCCPServerSink;
typedef struct _GstDCCPServerSinkClass GstDCCPServerSinkClass;
typedef struct _Client Client;
struct _Client
{
GstDCCPServerSink *server;
GstBuffer * buf;
int socket;
int pksize;
GstFlowReturn flow_status;
};
pthread_t accept_thread_id;
struct _GstDCCPServerSink
{
GstBaseSink element;
/* server information */
int port;
struct sockaddr_in server_sin;
/* socket */
int sock_fd;
/* multiple clients */
GList *clients;
/* properties */
int client_sock_fd;
uint8_t ccid;
gboolean wait_connections;
gboolean closed;
};
struct _GstDCCPServerSinkClass
{
GstBaseSinkClass parent_class;
/* signals */
void (*connected) (GstElement *sink, gint fd);
};
GType gst_dccp_server_sink_get_type (void);
G_END_DECLS
#endif /* __GST_DCCP_SERVER_SINK_H__ */

403
gst/dccp/gstdccpserversrc.c Normal file
View file

@ -0,0 +1,403 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
/**
* SECTION:element-dccpserversrc
* @see_also: dccpclientsink, dccpclientsrc, dccpserversink
*
* This element wait for connection from a client and receive data.
* <ulink url="http://www.linuxfoundation.org/en/Net:DCCP">DCCP</ulink> (Datagram
* Congestion Control Protocol) is a Transport Layer protocol like
* TCP and UDP.
*
* <refsect2>
* <title>Example pipeline</title>
* <para>
* |[
* gst-launch -v filesrc location=music.mp3 ! mp3parse ! dccpclientsink host=localhost port=9011 ccid=2
* ]| Client
* |[
* gst-launch -v dccpserversrc port=9011 ccid=2 ! decodebin ! alsasink
* ]| Server
*
* This example pipeline will send a MP3 stream to the server using DCCP.
* The server will decode the MP3 and play it.
* Run the server pipeline first than the client pipeline.
* </para>
* </refsect2>
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstdccpserversrc.h"
#include "gstdccp.h"
#include <string.h> /* memset */
#include <unistd.h>
#include <arpa/inet.h>
#include <fcntl.h>
#define DCCP_DEFAULT_CAPS NULL
#define DCCP_DEFAULT_LISTEN_HOST NULL /* listen on all interfaces */
/* signals */
enum
{
SIGNAL_CONNECTED,
LAST_SIGNAL
};
/* properties */
enum
{
PROP_0,
PROP_PORT,
PROP_HOST,
PROP_CLIENT_SOCK_FD,
PROP_CLOSED,
PROP_CCID,
PROP_CAPS
};
static gboolean gst_dccp_server_src_stop (GstBaseSrc * bsrc);
GST_DEBUG_CATEGORY_STATIC (dccpserversrc_debug);
static const GstElementDetails gst_dccp_server_src_details =
GST_ELEMENT_DETAILS ("DCCP server source",
"Source/Network",
"Receive data as a server over the network via DCCP",
"E-Phone Team at Federal University of Campina Grande <leandroal@gmail.com>");
static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src",
GST_PAD_SRC,
GST_PAD_ALWAYS,
GST_STATIC_CAPS_ANY);
GST_BOILERPLATE (GstDCCPServerSrc, gst_dccp_server_src, GstPushSrc,
GST_TYPE_PUSH_SRC);
static guint gst_dccp_server_src_signals[LAST_SIGNAL] = { 0 };
static GstFlowReturn
gst_dccp_server_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
{
GstDCCPServerSrc *src;
GstFlowReturn ret = GST_FLOW_OK;
src = GST_DCCP_SERVER_SRC (psrc);
GST_LOG_OBJECT (src, "reading a buffer");
ret = gst_dccp_read_buffer (GST_ELEMENT (src), src->client_sock_fd, outbuf);
if (ret == GST_FLOW_OK) {
GST_LOG_OBJECT (src,
"Returning buffer from _get of size %d, ts %"
GST_TIME_FORMAT ", dur %" GST_TIME_FORMAT
", offset %" G_GINT64_FORMAT ", offset_end %" G_GINT64_FORMAT,
GST_BUFFER_SIZE (*outbuf),
GST_TIME_ARGS (GST_BUFFER_TIMESTAMP (*outbuf)),
GST_TIME_ARGS (GST_BUFFER_DURATION (*outbuf)),
GST_BUFFER_OFFSET (*outbuf), GST_BUFFER_OFFSET_END (*outbuf));
if (!gst_caps_is_equal (src->caps, GST_CAPS_ANY)) {
gst_buffer_set_caps (*outbuf, src->caps);
}
}
return ret;
}
/*
* Set the value of a property for the server src.
*/
static void
gst_dccp_server_src_set_property (GObject * object, guint prop_id,
const GValue * value, GParamSpec * pspec)
{
GstDCCPServerSrc *src = GST_DCCP_SERVER_SRC (object);
switch (prop_id) {
case PROP_HOST:
if (!g_value_get_string (value)) {
g_warning ("host property cannot be NULL");
break;
}
g_free (src->host);
src->host = g_strdup (g_value_get_string (value));
break;
case PROP_PORT:
src->port = g_value_get_int (value);
break;
case PROP_CLIENT_SOCK_FD:
src->client_sock_fd = g_value_get_int (value);
break;
case PROP_CLOSED:
src->closed = g_value_get_boolean (value);
break;
case PROP_CCID:
src->ccid = g_value_get_int (value);
break;
case PROP_CAPS:
{
const GstCaps *new_caps_val = gst_value_get_caps (value);
GstCaps *new_caps;
GstCaps *old_caps;
if (new_caps_val == NULL) {
new_caps = gst_caps_new_any ();
} else {
new_caps = gst_caps_copy (new_caps_val);
}
old_caps = src->caps;
src->caps = new_caps;
if (old_caps) {
gst_caps_unref (old_caps);
}
gst_pad_set_caps (GST_BASE_SRC (src)->srcpad, new_caps);
break;
}
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
/*
* Get a given property value for the server src.
*/
static void
gst_dccp_server_src_get_property (GObject * object, guint prop_id,
GValue * value, GParamSpec * pspec)
{
GstDCCPServerSrc *src = GST_DCCP_SERVER_SRC (object);
switch (prop_id) {
case PROP_HOST:
g_value_set_string (value, src->host);
break;
case PROP_PORT:
g_value_set_int (value, src->port);
break;
case PROP_CLIENT_SOCK_FD:
g_value_set_int (value, src->client_sock_fd);
break;
case PROP_CLOSED:
g_value_set_boolean (value, src->closed);
break;
case PROP_CAPS:
gst_value_set_caps (value, src->caps);
break;
case PROP_CCID:
g_value_set_int (value, src->ccid);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
break;
}
}
static gboolean
gst_dccp_server_src_start (GstBaseSrc * bsrc)
{
GstDCCPServerSrc *src = GST_DCCP_SERVER_SRC (bsrc);
if (src->client_sock_fd == DCCP_DEFAULT_CLIENT_SOCK_FD) {
/* create socket */
if ((src->sock_fd = gst_dccp_create_new_socket (GST_ELEMENT (src))) < 0) {
return FALSE;
}
gst_dccp_make_address_reusable (GST_ELEMENT (src), src->sock_fd);
/* name the server socket */
memset (&src->server_sin, 0, sizeof (src->server_sin));
src->server_sin.sin_family = AF_INET; /* network socket */
src->server_sin.sin_port = htons (src->port); /* on port */
src->server_sin.sin_addr.s_addr = htonl (INADDR_ANY); /* for hosts */
if (!gst_dccp_bind_server_socket (GST_ELEMENT (src), src->sock_fd,
src->server_sin)) {
return FALSE;
}
if (!gst_dccp_set_ccid (GST_ELEMENT (src), src->sock_fd, src->ccid)) {
return FALSE;
}
if (!gst_dccp_listen_server_socket (GST_ELEMENT (src), src->sock_fd)) {
return FALSE;
}
src->client_sock_fd = gst_dccp_server_wait_connections (GST_ELEMENT (src),
src->sock_fd);
if (src->client_sock_fd == -1) {
return FALSE;
}
/* the socket is connected */
g_signal_emit (src, gst_dccp_server_src_signals[SIGNAL_CONNECTED], 0,
src->client_sock_fd);
}
return TRUE;
}
static void
gst_dccp_server_src_base_init (gpointer g_class)
{
GstElementClass *element_class = GST_ELEMENT_CLASS (g_class);
gst_element_class_add_pad_template (element_class,
gst_static_pad_template_get (&srctemplate));
gst_element_class_set_details (element_class, &gst_dccp_server_src_details);
}
static void
gst_dccp_server_src_init (GstDCCPServerSrc * this,
GstDCCPServerSrcClass * g_class)
{
this->port = DCCP_DEFAULT_PORT;
this->host = g_strdup (DCCP_DEFAULT_HOST);
this->sock_fd = DCCP_DEFAULT_SOCK_FD;
this->client_sock_fd = DCCP_DEFAULT_CLIENT_SOCK_FD;
this->closed = DCCP_DEFAULT_CLOSED;
this->ccid = DCCP_DEFAULT_CCID;
this->caps = DCCP_DEFAULT_CAPS;
gst_base_src_set_format (GST_BASE_SRC (this), GST_FORMAT_TIME);
/* Checking if the version of the gstreamer is bigger that 0.10.15 */
#if ((GST_VERSION_MAJOR > 0) || \
(GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR > 10) || \
(GST_VERSION_MAJOR == 0 && GST_VERSION_MINOR == 10 && GST_VERSION_MICRO >= 15))
gst_base_src_set_do_timestamp (GST_BASE_SRC (this), TRUE);
#endif
/* FIXME is this correct? */
gst_base_src_set_live (GST_BASE_SRC (this), TRUE);
}
static void
gst_dccp_server_src_finalize (GObject * gobject)
{
GstDCCPServerSrc *this = GST_DCCP_SERVER_SRC (gobject);
if (this->caps) {
gst_caps_unref (this->caps);
this->caps = NULL;
}
g_free (this->host);
G_OBJECT_CLASS (parent_class)->finalize (gobject);
}
static gboolean
gst_dccp_server_src_stop (GstBaseSrc * bsrc)
{
GstDCCPServerSrc *src;
src = GST_DCCP_SERVER_SRC (bsrc);
if (src->sock_fd != -1 && src->closed == TRUE) {
GST_DEBUG_OBJECT (src, "closing socket");
close (src->sock_fd);
src->sock_fd = -1;
}
return TRUE;
}
static void
gst_dccp_server_src_class_init (GstDCCPServerSrcClass * klass)
{
GObjectClass *gobject_class;
GstBaseSrcClass *gstbasesrc_class;
GstPushSrcClass *gstpush_src_class;
gobject_class = (GObjectClass *) klass;
gstbasesrc_class = (GstBaseSrcClass *) klass;
gstpush_src_class = (GstPushSrcClass *) klass;
gobject_class->set_property = gst_dccp_server_src_set_property;
gobject_class->get_property = gst_dccp_server_src_get_property;
gobject_class->finalize = gst_dccp_server_src_finalize;
g_object_class_install_property (G_OBJECT_CLASS (klass), PROP_PORT,
g_param_spec_int ("port", "Port",
"The port to receive the packets from, 0=allocate", 0, G_MAXUINT16,
DCCP_DEFAULT_PORT, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_HOST,
g_param_spec_string ("host", "Host", "The hostname to listen as",
DCCP_DEFAULT_LISTEN_HOST, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CLIENT_SOCK_FD,
g_param_spec_int ("sockfd", "Socket fd",
"The client socket file descriptor", -1, G_MAXINT,
DCCP_DEFAULT_CLIENT_SOCK_FD, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CLOSED,
g_param_spec_boolean ("close-socket", "Close socket",
"Close socket at the end of stream", DCCP_DEFAULT_CLOSED,
G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CCID,
g_param_spec_int ("ccid", "CCID",
"The Congestion Control IDentified to be used", 2, G_MAXINT,
DCCP_DEFAULT_CCID, G_PARAM_READWRITE));
g_object_class_install_property (gobject_class, PROP_CAPS,
g_param_spec_boxed ("caps", "Caps",
"The caps of the source pad", GST_TYPE_CAPS, G_PARAM_READWRITE));
/* signals */
/**
* GstDccpServerSrc::connected:
* @src: the gstdccpserversrc instance
* @fd: the connected socket fd
*
* Reports that the element has connected, giving the fd of the socket
*/
gst_dccp_server_src_signals[SIGNAL_CONNECTED] =
g_signal_new ("connected", G_TYPE_FROM_CLASS (klass), G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GstDCCPServerSrcClass, connected), NULL, NULL,
gst_marshal_VOID__INT, G_TYPE_NONE, 1, G_TYPE_INT);
gstbasesrc_class->start = gst_dccp_server_src_start;
gstbasesrc_class->stop = gst_dccp_server_src_stop;
gstpush_src_class->create = gst_dccp_server_src_create;
GST_DEBUG_CATEGORY_INIT (dccpserversrc_debug, "dccpserversrc", 0,
"DCCP Server Source");
}

View file

@ -0,0 +1,94 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __GST_DCCP_SERVER_SRC_H__
#define __GST_DCCP_SERVER_SRC_H__
#include <gst/gst.h>
#include <gst/base/gstpushsrc.h>
#include <gst/base/gstbasesrc.h>
G_BEGIN_DECLS
#include <netdb.h> /* sockaddr_in */
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h> /* sockaddr_in */
#include <unistd.h>
#define GST_TYPE_DCCP_SERVER_SRC \
(gst_dccp_server_src_get_type())
#define GST_DCCP_SERVER_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_DCCP_SERVER_SRC,GstDCCPServerSrc))
#define GST_DCCP_SERVER_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_DCCP_SERVER_SRC,GstDCCPServerSrcClass))
#define GST_IS_DCCP_SERVER_SRC(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_DCCP_SERVER_SRC))
#define GST_IS_DCCP_SERVER_SRC_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_DCCP_SERVER_SRC))
typedef struct _GstDCCPServerSrc GstDCCPServerSrc;
typedef struct _GstDCCPServerSrcClass GstDCCPServerSrcClass;
struct _GstDCCPServerSrc
{
GstPushSrc element;
/* server information */
int port;
gchar *host;
struct sockaddr_in server_sin;
/* socket */
int sock_fd;
gboolean closed;
GstCaps *caps;
uint8_t ccid;
/* single client */
int client_sock_fd;
};
struct _GstDCCPServerSrcClass
{
GstPushSrcClass parent_class;
/* signals */
void (*connected) (GstElement *src, gint fd);
};
GType gst_dccp_server_src_get_type (void);
G_END_DECLS
#endif /* __GST_DCCP_SERVER_SRC_H__ */

52
tests/icles/dccp/README Normal file
View file

@ -0,0 +1,52 @@
Applications
If you want to compile the applications you will need to run this command-line:
gcc -Wall $(pkg-config --cflags --libs gstreamer-0.10) <applicationName>.c -o <applicationName>
To run:
./<applicationName>
Command-line
###### Pipe to transmit a file #
* Server:
gst-launch -v filesrc location=file ! dccpserversink port=9011 ccid=2
* Client:
gst-launch -v dccpclientsrc host=localhost port=9011 ccid=2 ! filesink location=fileDist
###### Pipe to transmit from the microphone #
* Server:
gst-launch -v alsasrc ! dccpserversink port=9011 ccid=2
* Client:
gst-launch -v dccpclientsrc host=localhost port=9011 ccid=2 caps="audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)32, rate=(int)44100, channels=(int)2" ! alsasink
###### Pipe to transmit a MP3 #
* Server:
gst-launch -v filesrc location=music.mp3 ! mad ! dccpserversink port=9011 ccid=2
* Client:
gst-launch -v dccpclientsrc host=localhost port=9011 ccid=2 caps="audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)32, rate=(int)44100, channels=(int)2" ! alsasink
###### Pipe to stream a MP3 #
* Server:
gst-launch -v filesrc location=music.mp3 ! mp3parse ! dccpserversink port=9011 ccid=2
* Client:
gst-launch -v dccpclientsrc host=localhost port=9011 ccid=2 ! decodebin ! alsasink
-- We also tested with mpg123, to use it: mpg123 dccp://localhost:9011
###### Pipe to transmit a MP3 with dccp, speex and rtp #
* Server:
gst-launch -v filesrc location=music.mp3 ! mad ! audioconvert ! capsfilter caps="audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)1" ! speexenc ! rtpspeexpay ! dccpserversink port=9011 ccid=2
* Client:
gst-launch -v dccpclientsrc host=localhost port=9011 ccid=2 caps="application/x-rtp, media=(string)audio, payload=(int)110, clock-rate=(int)44100, encoding-name=(string)SPEEX, ssrc=(guint)152981653, clock-base=(guint)1553719649, seqnum-base=(guint)3680, encoding-params=(string)1" ! rtpspeexdepay ! speexdec ! alsasink

View file

@ -0,0 +1,151 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End-of-stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
void
start_dccpserversink_pipe (GstElement * object, gint socket, gpointer data)
{
GstElement *dccpserversink = (GstElement *) data;
g_object_set (G_OBJECT (dccpserversink), "sockfd", socket, NULL);
g_print ("Setting pipelinesink to PLAYING\n");
GstElement *pipelinesink =
(GstElement *) gst_element_get_parent (dccpserversink);
gst_element_set_state (pipelinesink, GST_STATE_PLAYING);
}
int
main (int argc, char *argv[])
{
GstElement *pipelinesink, *alsasrc, *dccpserversink;
GstElement *pipelinesrc, *alsasink, *dccpclientsrc;
GMainLoop *loop;
GstBus *bus;
GstCaps *caps;
/* initialize GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* check input arguments */
if (argc != 2) {
g_print ("%s\n", "see usage: serverHost");
return -1;
}
/* create elements */
pipelinesink = gst_pipeline_new ("audio-sender");
alsasrc = gst_element_factory_make ("alsasrc", "alsa-source");
dccpserversink = gst_element_factory_make ("dccpserversink", "server-sink");
pipelinesrc = gst_pipeline_new ("audio-receiver");
alsasink = gst_element_factory_make ("alsasink", "alsa-sink");
dccpclientsrc = gst_element_factory_make ("dccpclientsrc", "client-source");
if (!pipelinesink || !alsasrc || !dccpserversink || !pipelinesrc || !alsasink
|| !dccpclientsrc) {
g_print ("One element could not be created\n");
return -1;
}
caps =
gst_caps_from_string
("audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)32, rate=(int)44100, channels=(int)2");
g_object_set (G_OBJECT (dccpclientsrc), "caps", caps, NULL);
g_object_set (G_OBJECT (dccpclientsrc), "host", argv[1], NULL);
/*g_object_set (G_OBJECT (dccpclientsrc), "ccid", 3, NULL);
g_object_set (G_OBJECT (dccpserversink), "ccid", 3, NULL); */
bus = gst_pipeline_get_bus (GST_PIPELINE (pipelinesink));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipelinesrc));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* put all elements in a bin */
gst_bin_add_many (GST_BIN (pipelinesink), alsasrc, dccpserversink, NULL);
gst_element_link_many (alsasrc, dccpserversink, NULL);
gst_bin_add_many (GST_BIN (pipelinesrc), dccpclientsrc, alsasink, NULL);
gst_element_link (dccpclientsrc, alsasink);
g_signal_connect (dccpclientsrc, "connected",
(GCallback) start_dccpserversink_pipe, dccpserversink);
/* Now set to playing and iterate. */
g_print ("Setting pipelinesrc to PLAYING\n");
gst_element_set_state (pipelinesrc, GST_STATE_PLAYING);
g_print ("Running\n");
g_main_loop_run (loop);
/* clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipelinesink, GST_STATE_NULL);
g_print ("Deleting pipelinesink\n");
gst_object_unref (GST_OBJECT (pipelinesink));
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipelinesrc, GST_STATE_NULL);
g_print ("Deleting pipelinesrc\n");
gst_object_unref (GST_OBJECT (pipelinesrc));
return 0;
}

View file

@ -0,0 +1,144 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End-of-stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
void
start_dccpclientsrc_pipe (GstElement * object, gint socket, gpointer data)
{
GstElement *dccpclientsrc = (GstElement *) data;
g_object_set (G_OBJECT (dccpclientsrc), "sockfd", socket, NULL);
g_print ("Setting pipelinesrc to PLAYING\n");
GstElement *pipelinesrc =
(GstElement *) gst_element_get_parent (dccpclientsrc);
gst_element_set_state (pipelinesrc, GST_STATE_PLAYING);
}
int
main (int argc, char *argv[])
{
GstElement *pipelinesink, *alsasrc, *dccpserversink;
GstElement *pipelinesrc, *alsasink, *dccpclientsrc;
GMainLoop *loop;
GstBus *bus;
GstCaps *caps;
/* initialize GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* create elements */
pipelinesink = gst_pipeline_new ("audio-sender");
alsasrc = gst_element_factory_make ("alsasrc", "alsa-source");
dccpserversink = gst_element_factory_make ("dccpserversink", "server-sink");
pipelinesrc = gst_pipeline_new ("audio-receiver");
alsasink = gst_element_factory_make ("alsasink", "alsa-sink");
dccpclientsrc = gst_element_factory_make ("dccpclientsrc", "client-source");
if (!pipelinesink || !alsasrc || !dccpserversink || !pipelinesrc || !alsasink
|| !dccpclientsrc) {
g_print ("One element could not be created\n");
return -1;
}
caps =
gst_caps_from_string
("audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)32, rate=(int)44100, channels=(int)2");
g_object_set (G_OBJECT (dccpclientsrc), "caps", caps, NULL);
/*g_object_set (G_OBJECT (dccpclientsrc), "ccid", 3, NULL);
g_object_set (G_OBJECT (dccpserversink), "ccid", 3, NULL); */
bus = gst_pipeline_get_bus (GST_PIPELINE (pipelinesink));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipelinesrc));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* put all elements in a bin */
gst_bin_add_many (GST_BIN (pipelinesink), alsasrc, dccpserversink, NULL);
gst_element_link_many (alsasrc, dccpserversink, NULL);
gst_bin_add_many (GST_BIN (pipelinesrc), dccpclientsrc, alsasink, NULL);
gst_element_link (dccpclientsrc, alsasink);
g_signal_connect (dccpserversink, "connected",
(GCallback) start_dccpclientsrc_pipe, dccpclientsrc);
/* Now set to playing and iterate. */
g_print ("Setting pipelinesink to PLAYING\n");
gst_element_set_state (pipelinesink, GST_STATE_PLAYING);
g_print ("Running\n");
g_main_loop_run (loop);
/* clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipelinesink, GST_STATE_NULL);
g_print ("Deleting pipelinesink\n");
gst_object_unref (GST_OBJECT (pipelinesink));
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipelinesrc, GST_STATE_NULL);
g_print ("Deleting pipelinesrc\n");
gst_object_unref (GST_OBJECT (pipelinesrc));
return 0;
}

View file

@ -0,0 +1 @@
This application tests the socket sharing.

View file

@ -0,0 +1,113 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End-of-stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
int
main (int argc, char *argv[])
{
GMainLoop *loop;
GstBus *bus;
GstElement *pipeline, *filesink, *dccpclientsrc;
/* initialize GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* check input arguments */
if (argc != 4) {
g_print ("%s\n", "see usage: serverHost serverPort location");
return -1;
}
/* create elements */
pipeline = gst_pipeline_new ("audio-sender");
filesink = gst_element_factory_make ("filesink", "file-sink");
dccpclientsrc = gst_element_factory_make ("dccpclientsrc", "client-source");
if (!pipeline || !filesink || !dccpclientsrc) {
g_print ("One element could not be created\n");
return -1;
}
g_object_set (G_OBJECT (dccpclientsrc), "host", argv[1], NULL);
g_object_set (G_OBJECT (dccpclientsrc), "port", atoi (argv[2]), NULL);
/*g_object_set (G_OBJECT (dccpclientsrc), "ccid", 3, NULL); */
g_object_set (G_OBJECT (filesink), "location", argv[3], NULL);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* put all elements in a bin */
gst_bin_add_many (GST_BIN (pipeline), dccpclientsrc, filesink, NULL);
gst_element_link (dccpclientsrc, filesink);
/* Now set to playing and iterate. */
g_print ("Setting to PLAYING\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running\n");
g_main_loop_run (loop);
/* clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}

View file

@ -0,0 +1,112 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End-of-stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
int
main (int argc, char *argv[])
{
GMainLoop *loop;
GstBus *bus;
GstElement *pipeline, *filesrc, *dccpserversink;
/* initialize GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* check input arguments */
if (argc != 3) {
g_print ("%s\n", "see usage: port mp3Location");
return -1;
}
/* create elements */
pipeline = gst_pipeline_new ("audio-sender");
filesrc = gst_element_factory_make ("filesrc", "file-source");
dccpserversink = gst_element_factory_make ("dccpserversink", "server-sink");
if (!pipeline || !filesrc || !dccpserversink) {
g_print ("One element could not be created\n");
return -1;
}
g_object_set (G_OBJECT (dccpserversink), "port", atoi (argv[1]), NULL);
/*g_object_set (G_OBJECT (dccpserversink), "ccid", 3, NULL); */
g_object_set (G_OBJECT (filesrc), "location", argv[2], NULL);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* put all elements in a bin */
gst_bin_add_many (GST_BIN (pipeline), filesrc, dccpserversink, NULL);
gst_element_link_many (filesrc, dccpserversink, NULL);
/* Now set to playing and iterate. */
g_print ("Setting to PLAYING\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running\n");
g_main_loop_run (loop);
/* clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}

View file

@ -0,0 +1,116 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End-of-stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
int
main (int argc, char *argv[])
{
GMainLoop *loop;
GstBus *bus;
GstElement *pipeline, *alsasink, *dccpclientsrc;
GstCaps *caps;
/* initialize GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* check input arguments */
if (argc != 3) {
g_print ("%s\n", "see usage: serverHost serverPort");
return -1;
}
/* create elements */
pipeline = gst_pipeline_new ("audio-receiver");
alsasink = gst_element_factory_make ("alsasink", "alsa-sink");
dccpclientsrc = gst_element_factory_make ("dccpclientsrc", "client-source");
if (!pipeline || !alsasink || !dccpclientsrc) {
g_print ("One element could not be created\n");
return -1;
}
caps =
gst_caps_from_string
("audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)32, rate=(int)44100, channels=(int)2");
g_object_set (G_OBJECT (dccpclientsrc), "caps", caps, NULL);
g_object_set (G_OBJECT (dccpclientsrc), "host", argv[1], NULL);
g_object_set (G_OBJECT (dccpclientsrc), "port", atoi (argv[2]), NULL);
/*g_object_set (G_OBJECT (dccpclientsrc), "ccid", 3, NULL); */
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* put all elements in a bin */
gst_bin_add_many (GST_BIN (pipeline), dccpclientsrc, alsasink, NULL);
gst_element_link (dccpclientsrc, alsasink);
/* Now set to playing and iterate. */
g_print ("Setting to PLAYING\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running\n");
g_main_loop_run (loop);
/* clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}

View file

@ -0,0 +1,111 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End-of-stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
int
main (int argc, char *argv[])
{
GMainLoop *loop;
GstBus *bus;
GstElement *pipeline, *alsasrc, *dccpserversink;
/* initialize GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* check input arguments */
if (argc != 2) {
g_print ("%s\n", "see usage: port");
return -1;
}
/* create elements */
pipeline = gst_pipeline_new ("audio-sender");
alsasrc = gst_element_factory_make ("alsasrc", "alsa-source");
dccpserversink = gst_element_factory_make ("dccpserversink", "server-sink");
if (!pipeline || !alsasrc || !dccpserversink) {
g_print ("One element could not be created\n");
return -1;
}
g_object_set (G_OBJECT (dccpserversink), "port", atoi (argv[1]), NULL);
/*g_object_set (G_OBJECT (dccpserversink), "ccid", 3, NULL); */
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* put all elements in a bin */
gst_bin_add_many (GST_BIN (pipeline), alsasrc, dccpserversink, NULL);
gst_element_link_many (alsasrc, dccpserversink, NULL);
/* Now set to playing and iterate. */
g_print ("Setting to PLAYING\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running\n");
g_main_loop_run (loop);
/* clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}

View file

@ -0,0 +1,117 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End-of-stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
int
main (int argc, char *argv[])
{
GMainLoop *loop;
GstBus *bus;
GstElement *pipeline, *alsasink, *dccpclientsrc;
GstCaps *caps;
/* initialize GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* check input arguments */
if (argc != 3) {
g_print ("%s\n", "see usage: serverHost serverPort");
return -1;
}
/* create elements */
pipeline = gst_pipeline_new ("audio-sender");
alsasink = gst_element_factory_make ("alsasink", "alsa-sink");
dccpclientsrc = gst_element_factory_make ("dccpclientsrc", "client-source");
if (!pipeline || !alsasink || !dccpclientsrc) {
g_print ("One element could not be created\n");
return -1;
}
caps =
gst_caps_from_string
("audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)32, depth=(int)32, rate=(int)44100, channels=(int)2");
g_object_set (G_OBJECT (dccpclientsrc), "caps", caps, NULL);
gst_object_unref (caps);
g_object_set (G_OBJECT (dccpclientsrc), "host", argv[1], NULL);
g_object_set (G_OBJECT (dccpclientsrc), "port", atoi (argv[2]), NULL);
/*g_object_set (G_OBJECT (dccpclientsrc), "ccid", 2, NULL); */
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* put all elements in a bin */
gst_bin_add_many (GST_BIN (pipeline), dccpclientsrc, alsasink, NULL);
gst_element_link_many (dccpclientsrc, alsasink, NULL);
/* Now set to playing and iterate. */
g_print ("Setting to PLAYING\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running\n");
g_main_loop_run (loop);
/* clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}

View file

@ -0,0 +1,113 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End-of-stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
int
main (int argc, char *argv[])
{
GMainLoop *loop;
GstBus *bus;
GstElement *pipeline, *filesrc, *dccpserversink, *mad;
/* initialize GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* check input arguments */
if (argc != 3) {
g_print ("%s\n", "see usage: port mp3Location");
return -1;
}
/* create elements */
pipeline = gst_pipeline_new ("audio-sender");
filesrc = gst_element_factory_make ("filesrc", "file-source");
mad = gst_element_factory_make ("mad", "mad");
dccpserversink = gst_element_factory_make ("dccpserversink", "server-sink");
if (!pipeline || !filesrc || !dccpserversink || !mad) {
g_print ("One element could not be created\n");
return -1;
}
g_object_set (G_OBJECT (dccpserversink), "port", atoi (argv[1]), NULL);
/*g_object_set (G_OBJECT (dccpserversink), "ccid", 2, NULL); */
g_object_set (G_OBJECT (filesrc), "location", argv[2], NULL);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* put all elements in a bin */
gst_bin_add_many (GST_BIN (pipeline), filesrc, mad, dccpserversink, NULL);
gst_element_link_many (filesrc, mad, dccpserversink, NULL);
/* Now set to playing and iterate. */
g_print ("Setting to PLAYING\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running\n");
g_main_loop_run (loop);
/* clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}

View file

@ -0,0 +1,120 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End-of-stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
int
main (int argc, char *argv[])
{
GMainLoop *loop;
GstBus *bus;
GstElement *pipeline, *alsasink, *rtpspeexdepay, *speexdec, *dccpclientsrc;
GstCaps *caps;
/* initialize GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* check input arguments */
if (argc != 3) {
g_print ("%s\n", "see usage: serverHost serverPort");
return -1;
}
/* create elements */
pipeline = gst_pipeline_new ("audio-sender");
alsasink = gst_element_factory_make ("alsasink", "alsa-sink");
rtpspeexdepay = gst_element_factory_make ("rtpspeexdepay", "rtpspeexdepay");
speexdec = gst_element_factory_make ("speexdec", "speexdec");
dccpclientsrc = gst_element_factory_make ("dccpclientsrc", "client-source");
if (!pipeline || !alsasink || !rtpspeexdepay || !speexdec || !dccpclientsrc) {
g_print ("One element could not be created\n");
return -1;
}
caps =
gst_caps_from_string
("application/x-rtp, media=(string)audio, payload=(int)110, clock-rate=(int)44100, encoding-name=(string)SPEEX, ssrc=(guint)152981653, clock-base=(guint)1553719649, seqnum-base=(guint)3680, encoding-params=(string)1");
g_object_set (G_OBJECT (dccpclientsrc), "caps", caps, NULL);
gst_object_unref (caps);
g_object_set (G_OBJECT (dccpclientsrc), "host", argv[1], NULL);
g_object_set (G_OBJECT (dccpclientsrc), "port", atoi (argv[2]), NULL);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* put all elements in a bin */
gst_bin_add_many (GST_BIN (pipeline), dccpclientsrc, rtpspeexdepay, speexdec,
alsasink, NULL);
gst_element_link_many (dccpclientsrc, rtpspeexdepay, speexdec, alsasink,
NULL);
/* Now set to playing and iterate. */
g_print ("Setting to PLAYING\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running\n");
g_main_loop_run (loop);
/* clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}

View file

@ -0,0 +1,128 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End-of-stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
int
main (int argc, char *argv[])
{
GMainLoop *loop;
GstBus *bus;
GstElement *pipeline, *filesrc, *mad, *audioconvert, *capsfilter, *speexenc,
*rtpspeexpay, *dccpserversink;
GstCaps *caps;
/* initialize GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* check input arguments */
if (argc != 3) {
g_print ("%s\n", "see usage: port mp3Location");
return -1;
}
/* create elements */
pipeline = gst_pipeline_new ("audio-sender");
filesrc = gst_element_factory_make ("filesrc", "file-source");
mad = gst_element_factory_make ("mad", "mad");
audioconvert = gst_element_factory_make ("audioconvert", "audioconvert");
capsfilter = gst_element_factory_make ("capsfilter", "capsfilter");
speexenc = gst_element_factory_make ("speexenc", "speexenc");
rtpspeexpay = gst_element_factory_make ("rtpspeexpay", "rtpspeexpay");
dccpserversink = gst_element_factory_make ("dccpserversink", "server-sink");
if (!pipeline || !filesrc || !dccpserversink || !mad || !audioconvert
|| !capsfilter || !speexenc || !rtpspeexpay) {
g_print ("One element could not be created\n");
return -1;
}
g_object_set (G_OBJECT (dccpserversink), "port", atoi (argv[1]), NULL);
g_object_set (G_OBJECT (filesrc), "location", argv[2], NULL);
caps =
gst_caps_from_string
("audio/x-raw-int, endianness=(int)1234, signed=(boolean)true, width=(int)16, depth=(int)16, rate=(int)44100, channels=(int)1");
g_object_set (G_OBJECT (capsfilter), "caps", caps, NULL);
gst_object_unref (caps);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* put all elements in a bin */
gst_bin_add_many (GST_BIN (pipeline), filesrc, mad, audioconvert, capsfilter,
speexenc, rtpspeexpay, dccpserversink, NULL);
gst_element_link_many (filesrc, mad, audioconvert, capsfilter, speexenc,
rtpspeexpay, dccpserversink, NULL);
/* Now set to playing and iterate. */
g_print ("Setting to PLAYING\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running\n");
g_main_loop_run (loop);
/* clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}

View file

@ -0,0 +1,113 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End-of-stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
int
main (int argc, char *argv[])
{
GMainLoop *loop;
GstBus *bus;
GstElement *pipeline, *alsasink, *mad, *audioconvert, *dccpclientsrc;
/* initialize GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* check input arguments */
if (argc != 3) {
g_print ("%s\n", "see usage: serverHost serverPort");
return -1;
}
/* create elements */
pipeline = gst_pipeline_new ("audio-sender");
dccpclientsrc = gst_element_factory_make ("dccpclientsrc", "client-source");
mad = gst_element_factory_make ("mad", "mad");
audioconvert = gst_element_factory_make ("audioconvert", "audioconvert");
alsasink = gst_element_factory_make ("alsasink", "alsa-sink");
if (!pipeline || !alsasink || !mad || !audioconvert || !dccpclientsrc) {
g_print ("One element could not be created\n");
return -1;
}
g_object_set (G_OBJECT (dccpclientsrc), "host", argv[1], NULL);
g_object_set (G_OBJECT (dccpclientsrc), "port", atoi (argv[2]), NULL);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* put all elements in a bin */
gst_bin_add_many (GST_BIN (pipeline), dccpclientsrc, mad, audioconvert,
alsasink, NULL);
gst_element_link_many (dccpclientsrc, mad, audioconvert, alsasink, NULL);
/* Now set to playing and iterate. */
g_print ("Setting to PLAYING\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running\n");
g_main_loop_run (loop);
/* clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}

View file

@ -0,0 +1,113 @@
/* GStreamer
* Copyright (C) <2007> Leandro Melo de Sales <leandroal@gmail.com>
*
* This library is 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 is distributed in the hope that it will 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 have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <gst/gst.h>
static gboolean
bus_call (GstBus * bus, GstMessage * msg, gpointer data)
{
GMainLoop *loop = (GMainLoop *) data;
switch (GST_MESSAGE_TYPE (msg)) {
case GST_MESSAGE_EOS:
g_print ("End-of-stream\n");
g_main_loop_quit (loop);
break;
case GST_MESSAGE_ERROR:{
gchar *debug;
GError *err;
gst_message_parse_error (msg, &err, &debug);
g_free (debug);
g_print ("Error: %s\n", err->message);
g_error_free (err);
g_main_loop_quit (loop);
break;
}
default:
break;
}
return TRUE;
}
int
main (int argc, char *argv[])
{
GMainLoop *loop;
GstBus *bus;
GstElement *pipeline, *filesrc, *mp3parse, *dccpserversink;
/* initialize GStreamer */
gst_init (&argc, &argv);
loop = g_main_loop_new (NULL, FALSE);
/* check input arguments */
if (argc != 3) {
g_print ("%s\n", "see usage: port mp3Location");
return -1;
}
/* create elements */
pipeline = gst_pipeline_new ("audio-sender"); /* create pipeline with the name audio-sender */
filesrc = gst_element_factory_make ("filesrc", "file-source"); /* create filesrc element with the name file-source */
mp3parse = gst_element_factory_make ("mp3parse", "mp3parse");
dccpserversink = gst_element_factory_make ("dccpserversink", "server-sink");
if (!pipeline || !filesrc || !mp3parse || !dccpserversink) {
g_print ("One element could not be created\n");
return -1;
}
g_object_set (G_OBJECT (dccpserversink), "port", atoi (argv[1]), NULL);
g_object_set (G_OBJECT (filesrc), "location", argv[2], NULL);
bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
gst_bus_add_watch (bus, bus_call, loop);
gst_object_unref (bus);
/* put all elements in a bin */
gst_bin_add_many (GST_BIN (pipeline), filesrc, mp3parse, dccpserversink,
NULL);
/* Link the elements at the pipeline */
gst_element_link_many (filesrc, mp3parse, dccpserversink, NULL);
/* Now set to playing and iterate. */
g_print ("Setting to PLAYING\n");
gst_element_set_state (pipeline, GST_STATE_PLAYING);
g_print ("Running\n");
g_main_loop_run (loop);
/* clean up nicely */
g_print ("Returned, stopping playback\n");
gst_element_set_state (pipeline, GST_STATE_NULL);
g_print ("Deleting pipeline\n");
gst_object_unref (GST_OBJECT (pipeline));
return 0;
}