├── .gitignore ├── AUTHORS ├── COPYING ├── COPYING.LIB ├── ChangeLog ├── Makefile.am ├── NEWS ├── README ├── README.md ├── autogen.sh ├── configure.ac ├── gst-zeromq-vars.sh └── src ├── Makefile.am └── zeromq ├── Makefile.am ├── README ├── gstzmq.h ├── gstzmqplugin.c ├── gstzmqplugin.h ├── gstzmqsink.c ├── gstzmqsink.h ├── gstzmqsrc.c └── gstzmqsrc.h /.gitignore: -------------------------------------------------------------------------------- 1 | aclocal.m4 2 | autom4te.cache 3 | config.h* 4 | config.h.in 5 | config.log 6 | config.status 7 | config.guess 8 | config.sub 9 | config.rpath 10 | configure 11 | gst-zero.spec 12 | gstreamer-libs-uninstalled*.pc 13 | gstreamer-libs*.pc 14 | gstreamer-play-uninstalled*.pc 15 | gstreamer-play*.pc 16 | libtool 17 | stamp-h 18 | stamp-h.in 19 | stamp-h1 20 | gst-element-check-*.m4 21 | ltmain.sh 22 | missing 23 | mkinstalldirs 24 | compile 25 | install-sh 26 | depcomp 27 | autoregen.sh 28 | ABOUT-NLS 29 | /INSTALL 30 | _stdint.h 31 | 32 | gst-zeromq-*.tar* 33 | 34 | .deps 35 | .libs 36 | *.lo 37 | *.la 38 | *.o 39 | *~ 40 | *.bak 41 | /m4 42 | Makefile.in 43 | Makefile 44 | *.gir 45 | *.typelib 46 | *.gc?? 47 | 48 | tmp-orc.c 49 | gst*orc.h 50 | tests/check/orc 51 | 52 | Build 53 | *.user 54 | *.suo 55 | *.ipch 56 | *.sdf 57 | *.opensdf 58 | *.DS_Store 59 | 60 | /test-driver 61 | *.trs 62 | *.log 63 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Mark Howell 2 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 19yy 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License 307 | along with this program; if not, write to the Free Software 308 | Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 309 | 310 | 311 | Also add information on how to contact you by electronic and paper mail. 312 | 313 | If the program is interactive, make it output a short notice like this 314 | when it starts in an interactive mode: 315 | 316 | Gnomovision version 69, Copyright (C) 19yy name of author 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 318 | This is free software, and you are welcome to redistribute it 319 | under certain conditions; type `show c' for details. 320 | 321 | The hypothetical commands `show w' and `show c' should show the appropriate 322 | parts of the General Public License. Of course, the commands you use may 323 | be called something other than `show w' and `show c'; they could even be 324 | mouse-clicks or menu items--whatever suits your program. 325 | 326 | You should also get your employer (if you work as a programmer) or your 327 | school, if any, to sign a "copyright disclaimer" for the program, if 328 | necessary. Here is a sample; alter the names: 329 | 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 332 | 333 | , 1 April 1989 334 | Ty Coon, President of Vice 335 | 336 | This General Public License does not permit incorporating your program into 337 | proprietary programs. If your program is a subroutine library, you may 338 | consider it more useful to permit linking proprietary applications with the 339 | library. If this is what you want to do, use the GNU Library General 340 | Public License instead of this License. 341 | -------------------------------------------------------------------------------- /COPYING.LIB: -------------------------------------------------------------------------------- 1 | GNU LIBRARY GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1991 Free Software Foundation, Inc. 5 | 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the library GPL. It is 10 | numbered 2 because it goes with version 2 of the ordinary GPL.] 11 | 12 | Preamble 13 | 14 | The licenses for most software are designed to take away your 15 | freedom to share and change it. By contrast, the GNU General Public 16 | Licenses are intended to guarantee your freedom to share and change 17 | free software--to make sure the software is free for all its users. 18 | 19 | This license, the Library General Public License, applies to some 20 | specially designated Free Software Foundation software, and to any 21 | other libraries whose authors decide to use it. You can use it for 22 | your libraries, too. 23 | 24 | When we speak of free software, we are referring to freedom, not 25 | price. Our General Public Licenses are designed to make sure that you 26 | have the freedom to distribute copies of free software (and charge for 27 | this service if you wish), that you receive source code or can get it 28 | if you want it, that you can change the software or use pieces of it 29 | in new free programs; and that you know you can do these things. 30 | 31 | To protect your rights, we need to make restrictions that forbid 32 | anyone to deny you these rights or to ask you to surrender the rights. 33 | These restrictions translate to certain responsibilities for you if 34 | you distribute copies of the library, or if you modify it. 35 | 36 | For example, if you distribute copies of the library, whether gratis 37 | or for a fee, you must give the recipients all the rights that we gave 38 | you. You must make sure that they, too, receive or can get the source 39 | code. If you link a program with the library, you must provide 40 | complete object files to the recipients so that they can relink them 41 | with the library, after making changes to the library and recompiling 42 | it. And you must show them these terms so they know their rights. 43 | 44 | Our method of protecting your rights has two steps: (1) copyright 45 | the library, and (2) offer you this license which gives you legal 46 | permission to copy, distribute and/or modify the library. 47 | 48 | Also, for each distributor's protection, we want to make certain 49 | that everyone understands that there is no warranty for this free 50 | library. If the library is modified by someone else and passed on, we 51 | want its recipients to know that what they have is not the original 52 | version, so that any problems introduced by others will not reflect on 53 | the original authors' reputations. 54 | 55 | Finally, any free program is threatened constantly by software 56 | patents. We wish to avoid the danger that companies distributing free 57 | software will individually obtain patent licenses, thus in effect 58 | transforming the program into proprietary software. To prevent this, 59 | we have made it clear that any patent must be licensed for everyone's 60 | free use or not licensed at all. 61 | 62 | Most GNU software, including some libraries, is covered by the ordinary 63 | GNU General Public License, which was designed for utility programs. This 64 | license, the GNU Library General Public License, applies to certain 65 | designated libraries. This license is quite different from the ordinary 66 | one; be sure to read it in full, and don't assume that anything in it is 67 | the same as in the ordinary license. 68 | 69 | The reason we have a separate public license for some libraries is that 70 | they blur the distinction we usually make between modifying or adding to a 71 | program and simply using it. Linking a program with a library, without 72 | changing the library, is in some sense simply using the library, and is 73 | analogous to running a utility program or application program. However, in 74 | a textual and legal sense, the linked executable is a combined work, a 75 | derivative of the original library, and the ordinary General Public License 76 | treats it as such. 77 | 78 | Because of this blurred distinction, using the ordinary General 79 | Public License for libraries did not effectively promote software 80 | sharing, because most developers did not use the libraries. We 81 | concluded that weaker conditions might promote sharing better. 82 | 83 | However, unrestricted linking of non-free programs would deprive the 84 | users of those programs of all benefit from the free status of the 85 | libraries themselves. This Library General Public License is intended to 86 | permit developers of non-free programs to use free libraries, while 87 | preserving your freedom as a user of such programs to change the free 88 | libraries that are incorporated in them. (We have not seen how to achieve 89 | this as regards changes in header files, but we have achieved it as regards 90 | changes in the actual functions of the Library.) The hope is that this 91 | will lead to faster development of free libraries. 92 | 93 | The precise terms and conditions for copying, distribution and 94 | modification follow. Pay close attention to the difference between a 95 | "work based on the library" and a "work that uses the library". The 96 | former contains code derived from the library, while the latter only 97 | works together with the library. 98 | 99 | Note that it is possible for a library to be covered by the ordinary 100 | General Public License rather than by this special one. 101 | 102 | GNU LIBRARY GENERAL PUBLIC LICENSE 103 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 104 | 105 | 0. This License Agreement applies to any software library which 106 | contains a notice placed by the copyright holder or other authorized 107 | party saying it may be distributed under the terms of this Library 108 | General Public License (also called "this License"). Each licensee is 109 | addressed as "you". 110 | 111 | A "library" means a collection of software functions and/or data 112 | prepared so as to be conveniently linked with application programs 113 | (which use some of those functions and data) to form executables. 114 | 115 | The "Library", below, refers to any such software library or work 116 | which has been distributed under these terms. A "work based on the 117 | Library" means either the Library or any derivative work under 118 | copyright law: that is to say, a work containing the Library or a 119 | portion of it, either verbatim or with modifications and/or translated 120 | straightforwardly into another language. (Hereinafter, translation is 121 | included without limitation in the term "modification".) 122 | 123 | "Source code" for a work means the preferred form of the work for 124 | making modifications to it. For a library, complete source code means 125 | all the source code for all modules it contains, plus any associated 126 | interface definition files, plus the scripts used to control compilation 127 | and installation of the library. 128 | 129 | Activities other than copying, distribution and modification are not 130 | covered by this License; they are outside its scope. The act of 131 | running a program using the Library is not restricted, and output from 132 | such a program is covered only if its contents constitute a work based 133 | on the Library (independent of the use of the Library in a tool for 134 | writing it). Whether that is true depends on what the Library does 135 | and what the program that uses the Library does. 136 | 137 | 1. You may copy and distribute verbatim copies of the Library's 138 | complete source code as you receive it, in any medium, provided that 139 | you conspicuously and appropriately publish on each copy an 140 | appropriate copyright notice and disclaimer of warranty; keep intact 141 | all the notices that refer to this License and to the absence of any 142 | warranty; and distribute a copy of this License along with the 143 | Library. 144 | 145 | You may charge a fee for the physical act of transferring a copy, 146 | and you may at your option offer warranty protection in exchange for a 147 | fee. 148 | 149 | 2. You may modify your copy or copies of the Library or any portion 150 | of it, thus forming a work based on the Library, and copy and 151 | distribute such modifications or work under the terms of Section 1 152 | above, provided that you also meet all of these conditions: 153 | 154 | a) The modified work must itself be a software library. 155 | 156 | b) You must cause the files modified to carry prominent notices 157 | stating that you changed the files and the date of any change. 158 | 159 | c) You must cause the whole of the work to be licensed at no 160 | charge to all third parties under the terms of this License. 161 | 162 | d) If a facility in the modified Library refers to a function or a 163 | table of data to be supplied by an application program that uses 164 | the facility, other than as an argument passed when the facility 165 | is invoked, then you must make a good faith effort to ensure that, 166 | in the event an application does not supply such function or 167 | table, the facility still operates, and performs whatever part of 168 | its purpose remains meaningful. 169 | 170 | (For example, a function in a library to compute square roots has 171 | a purpose that is entirely well-defined independent of the 172 | application. Therefore, Subsection 2d requires that any 173 | application-supplied function or table used by this function must 174 | be optional: if the application does not supply it, the square 175 | root function must still compute square roots.) 176 | 177 | These requirements apply to the modified work as a whole. If 178 | identifiable sections of that work are not derived from the Library, 179 | and can be reasonably considered independent and separate works in 180 | themselves, then this License, and its terms, do not apply to those 181 | sections when you distribute them as separate works. But when you 182 | distribute the same sections as part of a whole which is a work based 183 | on the Library, the distribution of the whole must be on the terms of 184 | this License, whose permissions for other licensees extend to the 185 | entire whole, and thus to each and every part regardless of who wrote 186 | it. 187 | 188 | Thus, it is not the intent of this section to claim rights or contest 189 | your rights to work written entirely by you; rather, the intent is to 190 | exercise the right to control the distribution of derivative or 191 | collective works based on the Library. 192 | 193 | In addition, mere aggregation of another work not based on the Library 194 | with the Library (or with a work based on the Library) on a volume of 195 | a storage or distribution medium does not bring the other work under 196 | the scope of this License. 197 | 198 | 3. You may opt to apply the terms of the ordinary GNU General Public 199 | License instead of this License to a given copy of the Library. To do 200 | this, you must alter all the notices that refer to this License, so 201 | that they refer to the ordinary GNU General Public License, version 2, 202 | instead of to this License. (If a newer version than version 2 of the 203 | ordinary GNU General Public License has appeared, then you can specify 204 | that version instead if you wish.) Do not make any other change in 205 | these notices. 206 | 207 | Once this change is made in a given copy, it is irreversible for 208 | that copy, so the ordinary GNU General Public License applies to all 209 | subsequent copies and derivative works made from that copy. 210 | 211 | This option is useful when you wish to copy part of the code of 212 | the Library into a program that is not a library. 213 | 214 | 4. You may copy and distribute the Library (or a portion or 215 | derivative of it, under Section 2) in object code or executable form 216 | under the terms of Sections 1 and 2 above provided that you accompany 217 | it with the complete corresponding machine-readable source code, which 218 | must be distributed under the terms of Sections 1 and 2 above on a 219 | medium customarily used for software interchange. 220 | 221 | If distribution of object code is made by offering access to copy 222 | from a designated place, then offering equivalent access to copy the 223 | source code from the same place satisfies the requirement to 224 | distribute the source code, even though third parties are not 225 | compelled to copy the source along with the object code. 226 | 227 | 5. A program that contains no derivative of any portion of the 228 | Library, but is designed to work with the Library by being compiled or 229 | linked with it, is called a "work that uses the Library". Such a 230 | work, in isolation, is not a derivative work of the Library, and 231 | therefore falls outside the scope of this License. 232 | 233 | However, linking a "work that uses the Library" with the Library 234 | creates an executable that is a derivative of the Library (because it 235 | contains portions of the Library), rather than a "work that uses the 236 | library". The executable is therefore covered by this License. 237 | Section 6 states terms for distribution of such executables. 238 | 239 | When a "work that uses the Library" uses material from a header file 240 | that is part of the Library, the object code for the work may be a 241 | derivative work of the Library even though the source code is not. 242 | Whether this is true is especially significant if the work can be 243 | linked without the Library, or if the work is itself a library. The 244 | threshold for this to be true is not precisely defined by law. 245 | 246 | If such an object file uses only numerical parameters, data 247 | structure layouts and accessors, and small macros and small inline 248 | functions (ten lines or less in length), then the use of the object 249 | file is unrestricted, regardless of whether it is legally a derivative 250 | work. (Executables containing this object code plus portions of the 251 | Library will still fall under Section 6.) 252 | 253 | Otherwise, if the work is a derivative of the Library, you may 254 | distribute the object code for the work under the terms of Section 6. 255 | Any executables containing that work also fall under Section 6, 256 | whether or not they are linked directly with the Library itself. 257 | 258 | 6. As an exception to the Sections above, you may also compile or 259 | link a "work that uses the Library" with the Library to produce a 260 | work containing portions of the Library, and distribute that work 261 | under terms of your choice, provided that the terms permit 262 | modification of the work for the customer's own use and reverse 263 | engineering for debugging such modifications. 264 | 265 | You must give prominent notice with each copy of the work that the 266 | Library is used in it and that the Library and its use are covered by 267 | this License. You must supply a copy of this License. If the work 268 | during execution displays copyright notices, you must include the 269 | copyright notice for the Library among them, as well as a reference 270 | directing the user to the copy of this License. Also, you must do one 271 | of these things: 272 | 273 | a) Accompany the work with the complete corresponding 274 | machine-readable source code for the Library including whatever 275 | changes were used in the work (which must be distributed under 276 | Sections 1 and 2 above); and, if the work is an executable linked 277 | with the Library, with the complete machine-readable "work that 278 | uses the Library", as object code and/or source code, so that the 279 | user can modify the Library and then relink to produce a modified 280 | executable containing the modified Library. (It is understood 281 | that the user who changes the contents of definitions files in the 282 | Library will not necessarily be able to recompile the application 283 | to use the modified definitions.) 284 | 285 | b) Accompany the work with a written offer, valid for at 286 | least three years, to give the same user the materials 287 | specified in Subsection 6a, above, for a charge no more 288 | than the cost of performing this distribution. 289 | 290 | c) If distribution of the work is made by offering access to copy 291 | from a designated place, offer equivalent access to copy the above 292 | specified materials from the same place. 293 | 294 | d) Verify that the user has already received a copy of these 295 | materials or that you have already sent this user a copy. 296 | 297 | For an executable, the required form of the "work that uses the 298 | Library" must include any data and utility programs needed for 299 | reproducing the executable from it. However, as a special exception, 300 | the source code distributed need not include anything that is normally 301 | distributed (in either source or binary form) with the major 302 | components (compiler, kernel, and so on) of the operating system on 303 | which the executable runs, unless that component itself accompanies 304 | the executable. 305 | 306 | It may happen that this requirement contradicts the license 307 | restrictions of other proprietary libraries that do not normally 308 | accompany the operating system. Such a contradiction means you cannot 309 | use both them and the Library together in an executable that you 310 | distribute. 311 | 312 | 7. You may place library facilities that are a work based on the 313 | Library side-by-side in a single library together with other library 314 | facilities not covered by this License, and distribute such a combined 315 | library, provided that the separate distribution of the work based on 316 | the Library and of the other library facilities is otherwise 317 | permitted, and provided that you do these two things: 318 | 319 | a) Accompany the combined library with a copy of the same work 320 | based on the Library, uncombined with any other library 321 | facilities. This must be distributed under the terms of the 322 | Sections above. 323 | 324 | b) Give prominent notice with the combined library of the fact 325 | that part of it is a work based on the Library, and explaining 326 | where to find the accompanying uncombined form of the same work. 327 | 328 | 8. You may not copy, modify, sublicense, link with, or distribute 329 | the Library except as expressly provided under this License. Any 330 | attempt otherwise to copy, modify, sublicense, link with, or 331 | distribute the Library is void, and will automatically terminate your 332 | rights under this License. However, parties who have received copies, 333 | or rights, from you under this License will not have their licenses 334 | terminated so long as such parties remain in full compliance. 335 | 336 | 9. You are not required to accept this License, since you have not 337 | signed it. However, nothing else grants you permission to modify or 338 | distribute the Library or its derivative works. These actions are 339 | prohibited by law if you do not accept this License. Therefore, by 340 | modifying or distributing the Library (or any work based on the 341 | Library), you indicate your acceptance of this License to do so, and 342 | all its terms and conditions for copying, distributing or modifying 343 | the Library or works based on it. 344 | 345 | 10. Each time you redistribute the Library (or any work based on the 346 | Library), the recipient automatically receives a license from the 347 | original licensor to copy, distribute, link with or modify the Library 348 | subject to these terms and conditions. You may not impose any further 349 | restrictions on the recipients' exercise of the rights granted herein. 350 | You are not responsible for enforcing compliance by third parties to 351 | this License. 352 | 353 | 11. If, as a consequence of a court judgment or allegation of patent 354 | infringement or for any other reason (not limited to patent issues), 355 | conditions are imposed on you (whether by court order, agreement or 356 | otherwise) that contradict the conditions of this License, they do not 357 | excuse you from the conditions of this License. If you cannot 358 | distribute so as to satisfy simultaneously your obligations under this 359 | License and any other pertinent obligations, then as a consequence you 360 | may not distribute the Library at all. For example, if a patent 361 | license would not permit royalty-free redistribution of the Library by 362 | all those who receive copies directly or indirectly through you, then 363 | the only way you could satisfy both it and this License would be to 364 | refrain entirely from distribution of the Library. 365 | 366 | If any portion of this section is held invalid or unenforceable under any 367 | particular circumstance, the balance of the section is intended to apply, 368 | and the section as a whole is intended to apply in other circumstances. 369 | 370 | It is not the purpose of this section to induce you to infringe any 371 | patents or other property right claims or to contest validity of any 372 | such claims; this section has the sole purpose of protecting the 373 | integrity of the free software distribution system which is 374 | implemented by public license practices. Many people have made 375 | generous contributions to the wide range of software distributed 376 | through that system in reliance on consistent application of that 377 | system; it is up to the author/donor to decide if he or she is willing 378 | to distribute software through any other system and a licensee cannot 379 | impose that choice. 380 | 381 | This section is intended to make thoroughly clear what is believed to 382 | be a consequence of the rest of this License. 383 | 384 | 12. If the distribution and/or use of the Library is restricted in 385 | certain countries either by patents or by copyrighted interfaces, the 386 | original copyright holder who places the Library under this License may add 387 | an explicit geographical distribution limitation excluding those countries, 388 | so that distribution is permitted only in or among countries not thus 389 | excluded. In such case, this License incorporates the limitation as if 390 | written in the body of this License. 391 | 392 | 13. The Free Software Foundation may publish revised and/or new 393 | versions of the Library General Public License from time to time. 394 | Such new versions will be similar in spirit to the present version, 395 | but may differ in detail to address new problems or concerns. 396 | 397 | Each version is given a distinguishing version number. If the Library 398 | specifies a version number of this License which applies to it and 399 | "any later version", you have the option of following the terms and 400 | conditions either of that version or of any later version published by 401 | the Free Software Foundation. If the Library does not specify a 402 | license version number, you may choose any version ever published by 403 | the Free Software Foundation. 404 | 405 | 14. If you wish to incorporate parts of the Library into other free 406 | programs whose distribution conditions are incompatible with these, 407 | write to the author to ask for permission. For software which is 408 | copyrighted by the Free Software Foundation, write to the Free 409 | Software Foundation; we sometimes make exceptions for this. Our 410 | decision will be guided by the two goals of preserving the free status 411 | of all derivatives of our free software and of promoting the sharing 412 | and reuse of software generally. 413 | 414 | NO WARRANTY 415 | 416 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 417 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 418 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 419 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 420 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 421 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 422 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 423 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 424 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 425 | 426 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 427 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 428 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 429 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 430 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 431 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 432 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 433 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 434 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 435 | DAMAGES. 436 | 437 | END OF TERMS AND CONDITIONS 438 | 439 | Appendix: How to Apply These Terms to Your New Libraries 440 | 441 | If you develop a new library, and you want it to be of the greatest 442 | possible use to the public, we recommend making it free software that 443 | everyone can redistribute and change. You can do so by permitting 444 | redistribution under these terms (or, alternatively, under the terms of the 445 | ordinary General Public License). 446 | 447 | To apply these terms, attach the following notices to the library. It is 448 | safest to attach them to the start of each source file to most effectively 449 | convey the exclusion of warranty; and each file should have at least the 450 | "copyright" line and a pointer to where the full notice is found. 451 | 452 | 453 | Copyright (C) 454 | 455 | This library is free software; you can redistribute it and/or 456 | modify it under the terms of the GNU Library General Public 457 | License as published by the Free Software Foundation; either 458 | version 2 of the License, or (at your option) any later version. 459 | 460 | This library is distributed in the hope that it will be useful, 461 | but WITHOUT ANY WARRANTY; without even the implied warranty of 462 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 463 | Library General Public License for more details. 464 | 465 | You should have received a copy of the GNU Library General Public 466 | License along with this library; if not, write to the Free 467 | Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. 468 | 469 | Also add information on how to contact you by electronic and paper mail. 470 | 471 | You should also get your employer (if you work as a programmer) or your 472 | school, if any, to sign a "copyright disclaimer" for the library, if 473 | necessary. Here is a sample; alter the names: 474 | 475 | Yoyodyne, Inc., hereby disclaims all copyright interest in the 476 | library `Frob' (a library for tweaking knobs) written by James Random Hacker. 477 | 478 | , 1 April 1990 479 | Ty Coon, President of Vice 480 | 481 | That's all there is to it! 482 | -------------------------------------------------------------------------------- /ChangeLog: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjhowell/gst-zeromq/75cf2dd90e6b0077e71a1ed2ac6850f366287ecc/ChangeLog -------------------------------------------------------------------------------- /Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = src 2 | 3 | EXTRA_DIST = autogen.sh AUTHORS COPYING NEWS README ChangeLog 4 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | Nothing much yet. 2 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjhowell/gst-zeromq/75cf2dd90e6b0077e71a1ed2ac6850f366287ecc/README -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gst-zeromq 2 | 3 | ## Introduction 4 | 5 | gst-zeromq provides [GStreamer](http://gstreamer.freedesktop.org) elements for moving data with [ZeroMQ](http://zeromq.org). 6 | 7 | Specifically, it supports ZeroMQ PUB/SUB sockets via a sink (zmqsink) which provides a PUB endpoint, and a source (zmqsrc) that uses a SUB socket to connect to a PUB. 8 | 9 | Other ZeroMQ topologies may be implemented in the future. 10 | 11 | gst-zeromq is written in C for GStreamer 1.x, using the usual GStreamer GLib C idiom. 12 | 13 | It has been developed and tested with: 14 | 15 | * Ubuntu Trusty Tahr (14.04) 16 | * GStreamer 1.2.4 packages available on Trusty (but any 1.x should work) 17 | * ZeroMQ 4.1.1 (but any version back to 2.2.0 should work) 18 | 19 | Git repo at http://github.com/mjhowell/gst-zeromq 20 | 21 | ## Required packages (for Ubuntu, as of Mar 2018) 22 | Install the required packages as: 23 | ``` 24 | $ sudo apt-get install dh-autoreconf libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libzmq3-dev 25 | ``` 26 | 27 | ## Build It 28 | 29 | On Ubuntu, you'll need at least build-essential and libgstreamer1.0-dev installed. Then, to build: 30 | 31 | $ ./autogen.sh 32 | 33 | $ make 34 | 35 | The libs will be built in src/zeromq/.libs. To test them in place without installing, run the gst-zeromq-vars script: 36 | 37 | $ . gst-zeromq-vars.sh 38 | 39 | Now see if GStreamer can find the libs and catalog the elements: 40 | 41 | $ gst-inspect-1.0 zmqsrc 42 | 43 | You should see something like this: 44 | 45 | ``` 46 | Factory Details: 47 | Rank none (0) 48 | Long-name ZeroMQ source 49 | Klass Source/Network 50 | Description Receive data on ZeroMQ SUB socket 51 | 52 | ... 53 | 54 | is-live : If true, act as a live source 55 | flags: readable, writable 56 | Boolean. Default: true 57 | do-timestamp : Apply current stream time to buffers 58 | flags: readable, writable 59 | Boolean. Default: false 60 | endpoint : ZeroMQ endpoint from which to receive buffers 61 | flags: readable, writable 62 | String. Default: "tcp://localhost:5556" 63 | bind : If true, bind to the endpoint (be the "server") 64 | flags: readable, writable 65 | Boolean. Default: false 66 | 67 | ``` 68 | 69 | ## Try It 70 | 71 | ### With stdin/stdout 72 | 73 | In one terminal, start a "server": 74 | 75 | $ gst-launch-1.0 fdsrc fd=0 ! zmqsink 76 | 77 | In another terminal, start a "client": 78 | 79 | $ gst-launch-1.0 zmqsrc ! fdsink fd=1 80 | 81 | When you type in a line of text at the server and hit Enter, the text will show at the client. 82 | 83 | Stop each side with Ctrl-C. 84 | 85 | ### With Video 86 | 87 | In one terminal, start a "server": 88 | 89 | $ gst-launch-1.0 videotestsrc ! video/x-raw, format=I420, width=640, height=480, framerate=30/1 ! zmqsink 90 | 91 | In another terminal, start a "client": 92 | 93 | $ gst-launch-1.0 zmqsrc ! video/x-raw, format=I420, width=640, height=480, framerate=30/1 ! autovideosink 94 | 95 | Note caps are specified here because this is two separate pipelines with no cap negotiation happening between them. 96 | 97 | ### ZeroMQ PUB/SUB in action 98 | 99 | With ZeroMQ PUB/SUB, multiple SUBs can connect to one PUB. PUBs and SUBs can come and go at will, and reconnect automatically. 100 | 101 | Let's start a server (which provides a PUB endpoint): 102 | 103 | $ gst-launch-1.0 videotestsrc ! video/x-raw, format=I420, width=640, height=480, framerate=30/1 ! zmqsink 104 | 105 | Then in two separate terminals, start two clients (which SUB to the server's PUB): 106 | 107 | $ gst-launch-1.0 zmqsrc ! video/x-raw, format=I420, width=640, height=480, framerate=30/1 ! autovideosink 108 | 109 | and 110 | 111 | $ gst-launch-1.0 zmqsrc ! video/x-raw, format=I420, width=640, height=480, framerate=30/1 ! autovideosink 112 | 113 | Stop and restart a client. It will start to play again. 114 | 115 | Stop and restart the server. Both clients will stop playing, then reconnect and start playing again. 116 | 117 | You can start and stop the server and clients in any order, and they will connect and play. You can connect any number of clients (SUBs) to the server's PUB, within the limitations of your system. 118 | 119 | Servers and clients can be on different systems as long as the PUB endpoint is reachable by clients over the network, just change the endpoint from the default. Multiple streams can be served on the same system by changing the endpoint's port number or protocol type. See the [ZeroMQ](http://zeromq.org) docs for more information about endpoints and protocols. 120 | 121 | ## License 122 | 123 | This project uses the GNU LGPL. See COPYING and COPYING.LIB. 124 | 125 | ## TODO 126 | * move zmq context into class (one context for all instances)? 127 | * destroy zmq context on release 128 | * fix src getting stuck in create() after stopping pipeline. 129 | * zero copy possible, rather than memcpy() between mapped GstBuffer and zmq_msg_t? 130 | * correct reset behavior... works OK in gst-launch cmdline but not in apps. 131 | -------------------------------------------------------------------------------- /autogen.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # you can either set the environment variables AUTOCONF, AUTOHEADER, AUTOMAKE, 3 | # ACLOCAL, AUTOPOINT and/or LIBTOOLIZE to the right versions, or leave them 4 | # unset and get the defaults 5 | 6 | autoreconf --verbose --force --install --make || { 7 | echo 'autogen.sh failed'; 8 | exit 1; 9 | } 10 | 11 | ./configure || { 12 | echo 'configure failed'; 13 | exit 1; 14 | } 15 | 16 | echo 17 | echo "Now type 'make' to compile this module." 18 | echo 19 | -------------------------------------------------------------------------------- /configure.ac: -------------------------------------------------------------------------------- 1 | dnl required version of autoconf 2 | AC_PREREQ([2.53]) 3 | 4 | dnl TODO: fill in your package name and package version here 5 | AC_INIT([gst-zeromq],[1.0.0]) 6 | 7 | dnl required versions of gstreamer and plugins-base 8 | GST_REQUIRED=1.0.0 9 | GSTPB_REQUIRED=1.0.0 10 | 11 | AC_CONFIG_SRCDIR([src/zeromq/gstzmqsrc.c]) 12 | AC_CONFIG_HEADERS([config.h]) 13 | 14 | dnl required version of automake 15 | AM_INIT_AUTOMAKE([1.10]) 16 | 17 | dnl enable mainainer mode by default 18 | AM_MAINTAINER_MODE([enable]) 19 | 20 | dnl check for tools (compiler etc.) 21 | AC_PROG_CC 22 | 23 | dnl required version of libtool 24 | LT_PREREQ([2.2.6]) 25 | LT_INIT 26 | 27 | dnl give error and exit if we don't have pkgconfig 28 | AC_CHECK_PROG(HAVE_PKGCONFIG, pkg-config, [ ], [ 29 | AC_MSG_ERROR([You need to have pkg-config installed!]) 30 | ]) 31 | 32 | dnl set license and copyright notice 33 | GST_LICENSE="LGPL" 34 | AC_DEFINE_UNQUOTED(GST_LICENSE, "$GST_LICENSE", [GStreamer license]) 35 | AC_SUBST(GST_LICENSE) 36 | 37 | dnl Check for the required version of GStreamer core (and gst-plugins-base) 38 | dnl This will export GST_CFLAGS and GST_LIBS variables for use in Makefile.am 39 | dnl 40 | dnl If you need libraries from gst-plugins-base here, also add: 41 | dnl for libgstaudio-1.0: gstreamer-audio-1.0 >= $GST_REQUIRED 42 | dnl for libgstvideo-1.0: gstreamer-video-1.0 >= $GST_REQUIRED 43 | dnl for libgsttag-1.0: gstreamer-tag-1.0 >= $GST_REQUIRED 44 | dnl for libgstpbutils-1.0: gstreamer-pbutils-1.0 >= $GST_REQUIRED 45 | dnl for libgstfft-1.0: gstreamer-fft-1.0 >= $GST_REQUIRED 46 | dnl for libgstinterfaces-1.0: gstreamer-interfaces-1.0 >= $GST_REQUIRED 47 | dnl for libgstrtp-1.0: gstreamer-rtp-1.0 >= $GST_REQUIRED 48 | dnl for libgstrtsp-1.0: gstreamer-rtsp-1.0 >= $GST_REQUIRED 49 | dnl etc. 50 | PKG_CHECK_MODULES(GST, [ 51 | gstreamer-1.0 >= $GST_REQUIRED 52 | gstreamer-base-1.0 >= $GST_REQUIRED 53 | gstreamer-controller-1.0 >= $GST_REQUIRED 54 | ], [ 55 | AC_SUBST(GST_CFLAGS) 56 | AC_SUBST(GST_LIBS) 57 | ], [ 58 | AC_MSG_ERROR([ 59 | You need to install or upgrade the GStreamer development 60 | packages on your system. On debian-based systems these are 61 | libgstreamer1.0-dev and libgstreamer-plugins-base1.0-dev. 62 | on RPM-based systems gstreamer1.0-devel, libgstreamer1.0-devel 63 | or similar. The minimum version required is $GST_REQUIRED. 64 | ]) 65 | ]) 66 | 67 | PKG_CHECK_MODULES(ZMQ, [libzmq >= 2.2.0],, 68 | [AC_MSG_ERROR([Cannot find required package for libzmq. Note, pkg-config is required due to specified version >= 2.2.0]) 69 | ]) 70 | 71 | dnl check if compiler understands -Wall (if yes, add -Wall to GST_CFLAGS) 72 | AC_MSG_CHECKING([to see if compiler understands -Wall]) 73 | save_CFLAGS="$CFLAGS" 74 | CFLAGS="$CFLAGS -Wall" 75 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ ], [ ])], [ 76 | GST_CFLAGS="$GST_CFLAGS -Wall" 77 | AC_MSG_RESULT([yes]) 78 | ], [ 79 | AC_MSG_RESULT([no]) 80 | ]) 81 | 82 | dnl set the plugindir where plugins should be installed (for src/Makefile.am) 83 | if test "x${prefix}" = "x$HOME"; then 84 | plugindir="$HOME/.gstreamer-1.0/plugins" 85 | else 86 | plugindir="\$(libdir)/gstreamer-1.0" 87 | fi 88 | AC_SUBST(plugindir) 89 | 90 | dnl set proper LDFLAGS for plugins 91 | GST_PLUGIN_LDFLAGS='-module -avoid-version -export-symbols-regex [_]*\(gst_\|Gst\|GST_\).*' 92 | AC_SUBST(GST_PLUGIN_LDFLAGS) 93 | 94 | AC_CONFIG_FILES([Makefile src/Makefile src/zeromq/Makefile]) 95 | AC_OUTPUT 96 | 97 | -------------------------------------------------------------------------------- /gst-zeromq-vars.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | SCRIPT_PATH="${BASH_SOURCE[0]}"; 4 | if ([ -h "${SCRIPT_PATH}" ]) then 5 | while([ -h "${SCRIPT_PATH}" ]) do SCRIPT_PATH=`readlink "${SCRIPT_PATH}"`; done 6 | fi 7 | pushd . > /dev/null 8 | cd `dirname ${SCRIPT_PATH}` > /dev/null 9 | SCRIPT_PATH=`pwd`; 10 | popd > /dev/null 11 | 12 | echo script path is $SCRIPT_PATH 13 | 14 | export GST_PLUGIN_PATH_1_0=$GST_PLUGIN_PATH_1_0:$SCRIPT_PATH/src/zeromq/.libs: 15 | 16 | -------------------------------------------------------------------------------- /src/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = zeromq 2 | -------------------------------------------------------------------------------- /src/zeromq/Makefile.am: -------------------------------------------------------------------------------- 1 | plugin_LTLIBRARIES = libgstzmq.la 2 | 3 | libgstzmq_la_SOURCES = \ 4 | gstzmqplugin.c \ 5 | gstzmqsrc.c \ 6 | gstzmqsink.c 7 | 8 | libgstzmq_la_CFLAGS = $(GST_CFLAGS) $(ZMQ_CFLAGS) 9 | libgstzmq_la_LDFLAGS = $(GST_PLUGIN_LDFLAGS) 10 | libgstzmq_la_LIBADD = $(GST_BASE_LIBS) $(GST_LIBS) $(ZMQ_LIBS) 11 | libgstzmq_la_LIBTOOLFLAGS = $(GST_PLUGIN_LIBTOOLFLAGS) 12 | 13 | noinst_HEADERS = \ 14 | gstzmqsrc.h \ 15 | gstzmqsink.h \ 16 | gstzmq.h 17 | 18 | CLEANFILES = $(BUILT_SOURCES) 19 | -------------------------------------------------------------------------------- /src/zeromq/README: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjhowell/gst-zeromq/75cf2dd90e6b0077e71a1ed2ac6850f366287ecc/src/zeromq/README -------------------------------------------------------------------------------- /src/zeromq/gstzmq.h: -------------------------------------------------------------------------------- 1 | #ifndef __GST_ZMQ_H_ 2 | #define __GST_ZMQ_H_ 3 | 4 | #include 5 | #include 6 | 7 | #define ZMQ_DEFAULT_BIND_SRC FALSE 8 | #define ZMQ_DEFAULT_BIND_SINK TRUE 9 | 10 | #define ZMQ_DEFAULT_ENDPOINT_SERVER "tcp://*:5556" 11 | #define ZMQ_DEFAULT_ENDPOINT_CLIENT "tcp://localhost:5556" 12 | 13 | #endif // __GST_ZMQ_H_ 14 | -------------------------------------------------------------------------------- /src/zeromq/gstzmqplugin.c: -------------------------------------------------------------------------------- 1 | /* GStreamer 2 | * Copyright (C) <1999> Erik Walthinsen 3 | * Copyright (C) <2015> Mark J. Howell 4 | * 5 | * This library is free software; you can redistribute it and/or 6 | * modify it under the terms of the GNU Library General Public 7 | * License as published by the Free Software Foundation; either 8 | * version 2 of the License, or (at your option) any later version. 9 | * 10 | * This library is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 | * Library General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU Library General Public 16 | * License along with this library; if not, write to the 17 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 18 | * Boston, MA 02110-1301, USA. 19 | */ 20 | 21 | #ifdef HAVE_CONFIG_H 22 | #include "config.h" 23 | #endif 24 | 25 | #include "gstzmqsrc.h" 26 | #include "gstzmqsink.h" 27 | 28 | GST_DEBUG_CATEGORY (zmq_debug); 29 | 30 | static gboolean 31 | plugin_init (GstPlugin * plugin) 32 | { 33 | if (!gst_element_register (plugin, "zmqsrc", GST_RANK_NONE, GST_TYPE_ZMQ_SRC)) 34 | return FALSE; 35 | 36 | if (!gst_element_register (plugin, "zmqsink", GST_RANK_NONE, 37 | GST_TYPE_ZMQ_SINK)) 38 | return FALSE; 39 | 40 | GST_DEBUG_CATEGORY_INIT (zmq_debug, "zmq", 0, "ZeroMQ calls"); 41 | 42 | return TRUE; 43 | } 44 | 45 | GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, 46 | GST_VERSION_MINOR, 47 | zmq, 48 | "Transfer data via ZeroMQ", 49 | plugin_init, VERSION, GST_LICENSE, "gst-zeromq", 50 | "http://github.com/mjhowell/gst-zeromq") 51 | -------------------------------------------------------------------------------- /src/zeromq/gstzmqplugin.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mjhowell/gst-zeromq/75cf2dd90e6b0077e71a1ed2ac6850f366287ecc/src/zeromq/gstzmqplugin.h -------------------------------------------------------------------------------- /src/zeromq/gstzmqsink.c: -------------------------------------------------------------------------------- 1 | /* GStreamer 2 | * Copyright (C) <1999> Erik Walthinsen 3 | * Copyright (C) <2004> Thomas Vander Stichele 4 | * Copyright (C) <2015> Mark J. Howell 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | /** 23 | * SECTION:element-zmqsink 24 | * @see_also: #zmqsrc 25 | * 26 | * 27 | * Example launch line 28 | * |[ 29 | * # server: 30 | * gst-launch-1.0 fdsrc fd=0 ! zmqsink 31 | * # client: 32 | * gst-launch-1.0 zmqsrc ! fdsink fd=1 33 | * ]| everything you type in the server is shown on the client 34 | * 35 | */ 36 | 37 | #include 38 | #include // for memcpy 39 | 40 | #ifdef HAVE_CONFIG_H 41 | #include "config.h" 42 | #endif 43 | 44 | #include "gstzmq.h" 45 | #include "gstzmqsink.h" 46 | 47 | GST_DEBUG_CATEGORY_STATIC (zmqsink_debug); 48 | #define GST_CAT_DEFAULT (zmqsink_debug) 49 | 50 | static GstStaticPadTemplate sinktemplate = GST_STATIC_PAD_TEMPLATE ("sink", 51 | GST_PAD_SINK, 52 | GST_PAD_ALWAYS, 53 | GST_STATIC_CAPS_ANY); 54 | 55 | enum 56 | { 57 | PROP_0, 58 | PROP_ENDPOINT, 59 | PROP_BIND 60 | }; 61 | 62 | static void gst_zmq_sink_finalize (GObject * gobject); 63 | 64 | static void gst_zmq_sink_set_property (GObject * object, guint prop_id, 65 | const GValue * value, GParamSpec * pspec); 66 | static void gst_zmq_sink_get_property (GObject * object, guint prop_id, 67 | GValue * value, GParamSpec * pspec); 68 | 69 | static gboolean gst_zmq_sink_start (GstBaseSink * sink); 70 | static gboolean gst_zmq_sink_stop (GstBaseSink * sink); 71 | static GstFlowReturn gst_zmq_sink_render (GstBaseSink * sink, 72 | GstBuffer * buffer); 73 | 74 | #define gst_zmq_sink_parent_class parent_class 75 | G_DEFINE_TYPE (GstZmqSink, gst_zmq_sink, GST_TYPE_BASE_SINK); 76 | 77 | static void 78 | gst_zmq_sink_class_init (GstZmqSinkClass * klass) 79 | { 80 | GST_DEBUG ("zmqsink class init"); 81 | 82 | GObjectClass *gobject_class; 83 | GstElementClass *gstelement_class; 84 | GstBaseSinkClass *gstbasesink_class; 85 | 86 | gobject_class = (GObjectClass *) klass; 87 | gstelement_class = (GstElementClass *) klass; 88 | gstbasesink_class = (GstBaseSinkClass *) klass; 89 | 90 | gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_zmq_sink_set_property); 91 | gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_zmq_sink_get_property); 92 | gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_zmq_sink_finalize); 93 | 94 | g_object_class_install_property (gobject_class, PROP_ENDPOINT, 95 | g_param_spec_string ("endpoint", "Endpoint", 96 | "ZeroMQ endpoint through which to send buffers", 97 | ZMQ_DEFAULT_ENDPOINT_SERVER, 98 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 99 | 100 | g_object_class_install_property (gobject_class, PROP_BIND, 101 | g_param_spec_boolean ("bind", "Bind", 102 | "If true, bind to the endpoint (be the \"server\")", 103 | ZMQ_DEFAULT_BIND_SINK, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 104 | 105 | gst_element_class_add_pad_template (gstelement_class, 106 | gst_static_pad_template_get (&sinktemplate)); 107 | 108 | gst_element_class_set_static_metadata (gstelement_class, 109 | "ZeroMQ sink", "Sink/Network", 110 | "Send data on ZeroMQ PUB socket", 111 | "Mark J. Howell "); 112 | 113 | gstbasesink_class->start = GST_DEBUG_FUNCPTR (gst_zmq_sink_start); 114 | gstbasesink_class->stop = GST_DEBUG_FUNCPTR (gst_zmq_sink_stop); 115 | gstbasesink_class->render = GST_DEBUG_FUNCPTR (gst_zmq_sink_render); 116 | 117 | GST_DEBUG_CATEGORY_INIT (zmqsink_debug, "zmqsink", 0, "ZeroMQ Sink"); 118 | } 119 | 120 | static void 121 | gst_zmq_sink_init (GstZmqSink * this) 122 | { 123 | this->endpoint = g_strdup (ZMQ_DEFAULT_ENDPOINT_SERVER); 124 | this->bind = ZMQ_DEFAULT_BIND_SINK; 125 | this->context = zmq_ctx_new (); 126 | } 127 | 128 | static void 129 | gst_zmq_sink_finalize (GObject * gobject) 130 | { 131 | GstZmqSink *this = GST_ZMQ_SINK (gobject); 132 | zmq_ctx_destroy (this->context); 133 | G_OBJECT_CLASS (parent_class)->finalize (gobject); 134 | } 135 | 136 | static void 137 | gst_zmq_sink_set_property (GObject * object, guint prop_id, 138 | const GValue * value, GParamSpec * pspec) 139 | { 140 | GstZmqSink *sink; 141 | 142 | sink = GST_ZMQ_SINK (object); 143 | 144 | switch (prop_id) { 145 | case PROP_ENDPOINT: 146 | if (!g_value_get_string (value)) { 147 | g_warning ("endpoint property cannot be NULL"); 148 | break; 149 | } 150 | if (sink->endpoint) { 151 | g_free (sink->endpoint); 152 | } 153 | sink->endpoint = g_strdup (g_value_get_string (value)); 154 | break; 155 | case PROP_BIND: 156 | sink->bind = g_value_get_boolean (value); 157 | break; 158 | 159 | default: 160 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 161 | break; 162 | } 163 | } 164 | 165 | static void 166 | gst_zmq_sink_get_property (GObject * object, guint prop_id, 167 | GValue * value, GParamSpec * pspec) 168 | { 169 | GstZmqSink *sink; 170 | 171 | sink = GST_ZMQ_SINK (object); 172 | 173 | switch (prop_id) { 174 | case PROP_ENDPOINT: 175 | g_value_set_string (value, sink->endpoint); 176 | break; 177 | case PROP_BIND: 178 | g_value_set_boolean (value, sink->bind); 179 | break; 180 | default: 181 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 182 | break; 183 | } 184 | } 185 | 186 | static GstFlowReturn 187 | gst_zmq_sink_render (GstBaseSink * basesink, GstBuffer * buffer) 188 | { 189 | 190 | GstFlowReturn retval = GST_FLOW_OK; 191 | 192 | GstZmqSink *sink; 193 | GstMapInfo map; 194 | 195 | sink = GST_ZMQ_SINK (basesink); 196 | 197 | gst_buffer_map (buffer, &map, GST_MAP_READ); 198 | 199 | GST_DEBUG_OBJECT (sink, "publishing %" G_GSIZE_FORMAT " bytes", map.size); 200 | 201 | if (map.size > 0 && map.data != NULL) { 202 | zmq_msg_t msg; 203 | int rc = zmq_msg_init_size (&msg, map.size); 204 | if (rc) { 205 | GST_ELEMENT_ERROR (sink, RESOURCE, FAILED, 206 | ("zmq_msg_init_size() failed with error code %d [%s]", errno, 207 | zmq_strerror (errno)), NULL); 208 | retval = GST_FLOW_ERROR; 209 | } else { 210 | memcpy (zmq_msg_data (&msg), map.data, map.size); 211 | 212 | rc = zmq_msg_send (&msg, sink->socket, 0); 213 | if (rc != map.size) { 214 | GST_ELEMENT_ERROR (sink, RESOURCE, WRITE, 215 | ("zmq_msg_send() failed with error code %d [%s]", errno, 216 | zmq_strerror (errno)), NULL); 217 | zmq_msg_close (&msg); 218 | retval = GST_FLOW_ERROR; 219 | } 220 | } 221 | } 222 | 223 | gst_buffer_unmap (buffer, &map); 224 | 225 | return retval; 226 | 227 | } 228 | 229 | static gboolean 230 | gst_zmq_sink_start (GstBaseSink * basesink) 231 | { 232 | gboolean retval = TRUE; 233 | 234 | GstZmqSink *sink; 235 | 236 | sink = GST_ZMQ_SINK (basesink); 237 | 238 | int rc; 239 | 240 | GST_DEBUG_OBJECT (sink, "starting"); 241 | 242 | sink->socket = zmq_socket (sink->context, ZMQ_PUB); 243 | if (!sink->socket) { 244 | GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_READ_WRITE, 245 | ("zmq_socket() failed with error code %d [%s]", errno, 246 | zmq_strerror (errno)), NULL); 247 | } else { 248 | if (sink->bind) { 249 | GST_DEBUG ("binding to endpoint %s", sink->endpoint); 250 | rc = zmq_bind (sink->socket, sink->endpoint); 251 | if (rc) { 252 | GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_READ_WRITE, 253 | ("zmq_bind() to endpoint \"%s\" failed with error code %d [%s]", 254 | sink->endpoint, errno, zmq_strerror (errno)), NULL); 255 | retval = FALSE; 256 | } 257 | } else { 258 | GST_DEBUG ("connecting to endpoint %s", sink->endpoint); 259 | rc = zmq_connect (sink->socket, sink->endpoint); 260 | if (rc) { 261 | GST_ELEMENT_ERROR (sink, RESOURCE, OPEN_READ_WRITE, 262 | ("zmq_connect() to endpoint \"%s\" failed with error code %d [%s]", 263 | sink->endpoint, errno, zmq_strerror (errno)), NULL); 264 | retval = FALSE; 265 | } 266 | } 267 | } 268 | 269 | return retval; 270 | } 271 | 272 | static gboolean 273 | gst_zmq_sink_stop (GstBaseSink * basesink) 274 | { 275 | gboolean retval = TRUE; 276 | 277 | GstZmqSink *sink; 278 | 279 | sink = GST_ZMQ_SINK (basesink); 280 | 281 | GST_DEBUG_OBJECT (sink, "stopping"); 282 | 283 | int rc = zmq_close (sink->socket); 284 | 285 | if (rc) { 286 | GST_ELEMENT_WARNING (sink, RESOURCE, CLOSE, 287 | ("zmq_close() failed with error code %d [%s]", errno, strerror (errno)), 288 | NULL); 289 | retval = FALSE; 290 | } 291 | 292 | return retval; 293 | } 294 | -------------------------------------------------------------------------------- /src/zeromq/gstzmqsink.h: -------------------------------------------------------------------------------- 1 | /* GStreamer 2 | * Copyright (C) <1999> Erik Walthinsen 3 | * Copyright (C) <2004> Thomas Vander Stichele 4 | * Copyright (C) <2015> Mark J. Howell 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifndef __GST_ZMQ_SINK_H__ 24 | #define __GST_ZMQ_SINK_H__ 25 | 26 | 27 | #include 28 | #include 29 | 30 | G_BEGIN_DECLS 31 | 32 | #define GST_TYPE_ZMQ_SINK \ 33 | (gst_zmq_sink_get_type()) 34 | #define GST_ZMQ_SINK(obj) \ 35 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ZMQ_SINK,GstZmqSink)) 36 | #define GST_ZMQ_SINK_CLASS(klass) \ 37 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ZMQ_SINK,GstZmqSinkClass)) 38 | #define GST_IS_ZMQ_SINK(obj) \ 39 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ZMQ_SINK)) 40 | #define GST_IS_ZMQ_SINK_CLASS(klass) \ 41 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ZMQ_SINK)) 42 | 43 | typedef struct _GstZmqSink GstZmqSink; 44 | typedef struct _GstZmqSinkClass GstZmqSinkClass; 45 | 46 | typedef enum { 47 | GST_ZMQ_SINK_OPEN = (GST_ELEMENT_FLAG_LAST << 0), 48 | 49 | GST_ZMQ_SINK_FLAG_LAST = (GST_ELEMENT_FLAG_LAST << 2) 50 | } GstZmqSinkFlags; 51 | 52 | struct _GstZmqSink { 53 | GstBaseSink parent; 54 | 55 | // properties 56 | gchar *endpoint; 57 | gboolean bind; 58 | 59 | // zmq stuff 60 | void *context; 61 | void *socket; 62 | }; 63 | 64 | struct _GstZmqSinkClass { 65 | GstBaseSinkClass parent_class; 66 | }; 67 | 68 | GType gst_zmq_sink_get_type (void); 69 | 70 | G_END_DECLS 71 | 72 | #endif /* __GST_ZMQ_SINK_H__ */ 73 | -------------------------------------------------------------------------------- /src/zeromq/gstzmqsrc.c: -------------------------------------------------------------------------------- 1 | /* GStreamer 2 | * Copyright (C) <1999> Erik Walthinsen 3 | * Copyright (C) <2004> Thomas Vander Stichele 4 | * Copyright (C) <2011> Collabora Ltd. 5 | * Author: Sebastian Dröge 6 | * Copyright (C) <2015> Mark J. Howell 7 | * 8 | * This library is free software; you can redistribute it and/or 9 | * modify it under the terms of the GNU Library General Public 10 | * License as published by the Free Software Foundation; either 11 | * version 2 of the License, or (at your option) any later version. 12 | * 13 | * This library is distributed in the hope that it will be useful, 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 16 | * Library General Public License for more details. 17 | * 18 | * You should have received a copy of the GNU Library General Public 19 | * License along with this library; if not, write to the 20 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 21 | * Boston, MA 02110-1301, USA. 22 | */ 23 | 24 | /** 25 | * SECTION:element-zmqsrc 26 | * @see_also: #zmqsink 27 | * 28 | * 29 | * Example launch line 30 | * |[ 31 | * # server: 32 | * gst-launch-1.0 fdsrc fd=0 ! zmqsink 33 | * # client: 34 | * gst-launch-1.0 zmqsrc ! fdsink fd=1 35 | * ]| everything you type in the server is shown on the client 36 | * 37 | */ 38 | 39 | #include 40 | #include // for memcpy 41 | 42 | #ifdef HAVE_CONFIG_H 43 | #include "config.h" 44 | #endif 45 | 46 | #include "gstzmq.h" 47 | #include "gstzmqsrc.h" 48 | 49 | GST_DEBUG_CATEGORY_STATIC (zmqsrc_debug); 50 | #define GST_CAT_DEFAULT zmqsrc_debug 51 | 52 | static GstStaticPadTemplate srctemplate = GST_STATIC_PAD_TEMPLATE ("src", 53 | GST_PAD_SRC, 54 | GST_PAD_ALWAYS, 55 | GST_STATIC_CAPS_ANY); 56 | 57 | enum 58 | { 59 | PROP_0, 60 | PROP_ENDPOINT, 61 | PROP_BIND, 62 | PROP_IS_LIVE 63 | }; 64 | 65 | #define gst_zmq_src_parent_class parent_class 66 | G_DEFINE_TYPE (GstZmqSrc, gst_zmq_src, GST_TYPE_PUSH_SRC); 67 | 68 | static void gst_zmq_src_finalize (GObject * gobject); 69 | 70 | static GstCaps *gst_zmq_src_getcaps (GstBaseSrc * psrc, GstCaps * filter); 71 | 72 | static GstFlowReturn gst_zmq_src_create (GstPushSrc * psrc, 73 | GstBuffer ** outbuf); 74 | static gboolean gst_zmq_src_stop (GstBaseSrc * bsrc); 75 | static gboolean gst_zmq_src_start (GstBaseSrc * bsrc); 76 | static GstStateChangeReturn gst_zmq_src_change_state (GstElement * element, 77 | GstStateChange transition); 78 | 79 | static void gst_zmq_src_set_property (GObject * object, guint prop_id, 80 | const GValue * value, GParamSpec * pspec); 81 | static void gst_zmq_src_get_property (GObject * object, guint prop_id, 82 | GValue * value, GParamSpec * pspec); 83 | 84 | static void 85 | gst_zmq_src_class_init (GstZmqSrcClass * klass) 86 | { 87 | GObjectClass *gobject_class; 88 | GstElementClass *gstelement_class; 89 | GstBaseSrcClass *gstbasesrc_class; 90 | GstPushSrcClass *gstpush_src_class; 91 | 92 | gobject_class = (GObjectClass *) klass; 93 | gstelement_class = (GstElementClass *) klass; 94 | gstbasesrc_class = (GstBaseSrcClass *) klass; 95 | gstpush_src_class = (GstPushSrcClass *) klass; 96 | 97 | gobject_class->set_property = GST_DEBUG_FUNCPTR (gst_zmq_src_set_property); 98 | gobject_class->get_property = GST_DEBUG_FUNCPTR (gst_zmq_src_get_property); 99 | gobject_class->finalize = GST_DEBUG_FUNCPTR (gst_zmq_src_finalize); 100 | 101 | g_object_class_install_property (gobject_class, PROP_ENDPOINT, 102 | g_param_spec_string ("endpoint", "Endpoint", 103 | "ZeroMQ endpoint from which to receive buffers", 104 | ZMQ_DEFAULT_ENDPOINT_CLIENT, 105 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 106 | g_object_class_install_property (gobject_class, PROP_BIND, 107 | g_param_spec_boolean ("bind", "Bind", 108 | "If true, bind to the endpoint (be the \"server\")", 109 | ZMQ_DEFAULT_BIND_SRC, G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 110 | g_object_class_install_property (gobject_class, PROP_IS_LIVE, 111 | g_param_spec_boolean ("is-live", "Is this a live source", 112 | "True if the element cannot produce data in PAUSED", TRUE, 113 | G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); 114 | 115 | gst_element_class_add_pad_template (gstelement_class, 116 | gst_static_pad_template_get (&srctemplate)); 117 | 118 | gst_element_class_set_static_metadata (gstelement_class, 119 | "ZeroMQ source", "Source/Network", 120 | "Receive data on ZeroMQ SUB socket", 121 | "Mark J. Howell "); 122 | 123 | gstelement_class->change_state = GST_DEBUG_FUNCPTR (gst_zmq_src_change_state); 124 | 125 | gstbasesrc_class->get_caps = GST_DEBUG_FUNCPTR (gst_zmq_src_getcaps); 126 | gstbasesrc_class->start = GST_DEBUG_FUNCPTR (gst_zmq_src_start); 127 | gstbasesrc_class->stop = GST_DEBUG_FUNCPTR (gst_zmq_src_stop); 128 | 129 | gstpush_src_class->create = GST_DEBUG_FUNCPTR (gst_zmq_src_create); 130 | 131 | GST_DEBUG_CATEGORY_INIT (zmqsrc_debug, "zmqsrc", 0, "ZeroMQ Source"); 132 | } 133 | 134 | static void 135 | gst_zmq_src_init (GstZmqSrc * this) 136 | { 137 | this->endpoint = g_strdup (ZMQ_DEFAULT_ENDPOINT_CLIENT); 138 | this->bind = ZMQ_DEFAULT_BIND_SRC; 139 | this->context = zmq_ctx_new (); 140 | } 141 | 142 | static void 143 | gst_zmq_src_finalize (GObject * gobject) 144 | { 145 | GstZmqSrc *this = GST_ZMQ_SRC (gobject); 146 | zmq_ctx_destroy (this->context); 147 | G_OBJECT_CLASS (parent_class)->finalize (gobject); 148 | } 149 | 150 | static GstCaps * 151 | gst_zmq_src_getcaps (GstBaseSrc * bsrc, GstCaps * filter) 152 | { 153 | GstZmqSrc *src; 154 | GstCaps *caps = NULL; 155 | 156 | src = GST_ZMQ_SRC (bsrc); 157 | 158 | caps = (filter ? gst_caps_ref (filter) : gst_caps_new_any ()); 159 | 160 | GST_DEBUG_OBJECT (src, "returning caps %" GST_PTR_FORMAT, caps); 161 | g_assert (GST_IS_CAPS (caps)); 162 | return caps; 163 | } 164 | 165 | static GstFlowReturn 166 | gst_zmq_src_create (GstPushSrc * psrc, GstBuffer ** outbuf) 167 | { 168 | GstZmqSrc *src; 169 | GstFlowReturn retval = GST_FLOW_OK; 170 | GstMapInfo map; 171 | 172 | src = GST_ZMQ_SRC (psrc); 173 | 174 | GST_LOG_OBJECT (src, "was asked for a buffer"); 175 | 176 | zmq_msg_t msg; 177 | int rc = zmq_msg_init (&msg); 178 | if (rc) { 179 | GST_ELEMENT_ERROR (src, RESOURCE, FAILED, 180 | ("zmq_msg_init() failed with error code %d [%s]", errno, 181 | zmq_strerror (errno)), NULL); 182 | retval = GST_FLOW_ERROR; 183 | goto done; 184 | } 185 | 186 | while (1) { 187 | rc = zmq_msg_recv (&msg, src->socket, 0); 188 | if ((rc < 0) && (EAGAIN == errno)) { 189 | GST_LOG_OBJECT (src, "No message available on socket"); 190 | continue; 191 | } else { 192 | break; 193 | } 194 | } 195 | 196 | if (rc < 0) { 197 | if (ENOTSOCK == errno) { 198 | GST_DEBUG_OBJECT (src, "Connection closed"); 199 | retval = GST_FLOW_EOS; 200 | /* } else if (EAGAIN == errno) { 201 | GST_LOG_OBJECT (src, "No message available on socket"); 202 | g_print("w");*/ 203 | } else { 204 | GST_ELEMENT_ERROR (src, RESOURCE, READ, 205 | ("zmq_msg_recv() failed with error code %d [%s]", errno, 206 | zmq_strerror (errno)), NULL); 207 | retval = GST_FLOW_ERROR; 208 | } 209 | *outbuf = NULL; 210 | zmq_msg_close (&msg); 211 | goto done; 212 | } 213 | size_t msg_size = zmq_msg_size (&msg); 214 | 215 | *outbuf = gst_buffer_new_and_alloc (msg_size); 216 | gst_buffer_map (*outbuf, &map, GST_MAP_READWRITE); 217 | 218 | memcpy (map.data, zmq_msg_data (&msg), msg_size); 219 | 220 | gst_buffer_unmap (*outbuf, &map); 221 | 222 | zmq_msg_close (&msg); 223 | 224 | GST_LOG_OBJECT (src, "delivered a buffer of size %" G_GSIZE_FORMAT " bytes", 225 | msg_size); 226 | done: 227 | return retval; 228 | } 229 | 230 | static void 231 | gst_zmq_src_set_property (GObject * object, guint prop_id, 232 | const GValue * value, GParamSpec * pspec) 233 | { 234 | GstZmqSrc *zmqsrc = GST_ZMQ_SRC (object); 235 | 236 | switch (prop_id) { 237 | case PROP_ENDPOINT: 238 | if (!g_value_get_string (value)) { 239 | g_warning ("endpoint property cannot be NULL"); 240 | break; 241 | } 242 | g_free (zmqsrc->endpoint); 243 | zmqsrc->endpoint = g_strdup (g_value_get_string (value)); 244 | break; 245 | case PROP_BIND: 246 | zmqsrc->bind = g_value_get_boolean (value); 247 | break; 248 | case PROP_IS_LIVE: 249 | gst_base_src_set_live (GST_BASE_SRC (object), 250 | g_value_get_boolean (value)); 251 | break; 252 | 253 | default: 254 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 255 | break; 256 | } 257 | } 258 | 259 | static void 260 | gst_zmq_src_get_property (GObject * object, guint prop_id, 261 | GValue * value, GParamSpec * pspec) 262 | { 263 | GstZmqSrc *zmqsrc = GST_ZMQ_SRC (object); 264 | 265 | switch (prop_id) { 266 | case PROP_ENDPOINT: 267 | g_value_set_string (value, zmqsrc->endpoint); 268 | break; 269 | case PROP_BIND: 270 | g_value_set_boolean (value, zmqsrc->bind); 271 | break; 272 | case PROP_IS_LIVE: 273 | g_value_set_boolean (value, gst_base_src_is_live (GST_BASE_SRC (object))); 274 | break; 275 | default: 276 | G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); 277 | break; 278 | } 279 | } 280 | 281 | static gboolean 282 | gst_zmq_src_start (GstBaseSrc * bsrc) 283 | { 284 | GstZmqSrc *src = GST_ZMQ_SRC (bsrc); 285 | 286 | GST_DEBUG_OBJECT (src, "starting"); 287 | 288 | return TRUE; 289 | } 290 | 291 | static gboolean 292 | gst_zmq_src_stop (GstBaseSrc * bsrc) 293 | { 294 | GstZmqSrc *src; 295 | 296 | src = GST_ZMQ_SRC (bsrc); 297 | 298 | GST_DEBUG_OBJECT (src, "stopping"); 299 | 300 | return TRUE; 301 | } 302 | 303 | static gboolean 304 | gst_zmq_src_open (GstZmqSrc * src) 305 | { 306 | 307 | gboolean retval = TRUE; 308 | 309 | int rc; 310 | 311 | src->socket = zmq_socket (src->context, ZMQ_SUB); 312 | if (!src->socket) { 313 | GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE, 314 | ("zmq_socket() failed with error code %d [%s]", errno, 315 | zmq_strerror (errno)), NULL); 316 | retval = FALSE; 317 | } 318 | 319 | if (retval) { 320 | if (src->bind) { 321 | GST_DEBUG ("binding to endpoint %s", src->endpoint); 322 | rc = zmq_bind (src->socket, src->endpoint); 323 | if (rc) { 324 | GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE, 325 | ("zmq_bind() to endpoint \"%s\" failed with error code %d [%s]", 326 | src->endpoint, errno, zmq_strerror (errno)), NULL); 327 | retval = FALSE; 328 | } 329 | } else { 330 | GST_DEBUG ("connecting to endpoint %s", src->endpoint); 331 | rc = zmq_connect (src->socket, src->endpoint); 332 | if (rc) { 333 | GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE, 334 | ("zmq_connect() to endpoint \"%s\" failed with error code %d [%s]", 335 | src->endpoint, errno, zmq_strerror (errno)), NULL); 336 | retval = FALSE; 337 | } 338 | } 339 | } 340 | 341 | if (retval) { 342 | rc = zmq_setsockopt (src->socket, ZMQ_SUBSCRIBE, "", 0); 343 | if (rc) { 344 | GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE, 345 | ("zmq_setsockopt() failed with error code %d [%s]", errno, 346 | zmq_strerror (errno)), NULL); 347 | retval = FALSE; 348 | } 349 | } 350 | 351 | if (retval) { 352 | int timeout_ms = 1000; 353 | rc = zmq_setsockopt (src->socket, ZMQ_RCVTIMEO, &timeout_ms, 354 | sizeof (timeout_ms)); 355 | if (rc) { 356 | GST_ELEMENT_ERROR (src, RESOURCE, OPEN_READ_WRITE, 357 | ("zmq_setsockopt() failed with error code %d [%s]", errno, 358 | zmq_strerror (errno)), NULL); 359 | retval = FALSE; 360 | } 361 | } 362 | 363 | return retval; 364 | } 365 | 366 | static gboolean 367 | gst_zmq_src_close (GstZmqSrc * src) 368 | { 369 | 370 | gboolean retval = TRUE; 371 | 372 | int rc = zmq_close (src->socket); 373 | 374 | if (rc) { 375 | GST_ELEMENT_WARNING (src, RESOURCE, CLOSE, 376 | ("zmq_close() failed with error code %d [%s]", errno, strerror (errno)), 377 | NULL); 378 | retval = FALSE; 379 | } 380 | 381 | return retval; 382 | } 383 | 384 | static GstStateChangeReturn 385 | gst_zmq_src_change_state (GstElement * element, GstStateChange transition) 386 | { 387 | GstZmqSrc *src; 388 | GstStateChangeReturn result; 389 | 390 | src = GST_ZMQ_SRC (element); 391 | 392 | switch (transition) { 393 | case GST_STATE_CHANGE_NULL_TO_READY: 394 | if (!gst_zmq_src_open (src)) 395 | goto open_failed; 396 | break; 397 | default: 398 | break; 399 | } 400 | if ((result = 401 | GST_ELEMENT_CLASS (parent_class)->change_state (element, 402 | transition)) == GST_STATE_CHANGE_FAILURE) 403 | goto failure; 404 | 405 | switch (transition) { 406 | case GST_STATE_CHANGE_READY_TO_NULL: 407 | gst_zmq_src_close (src); 408 | break; 409 | default: 410 | break; 411 | } 412 | return result; 413 | /* ERRORS */ 414 | open_failed: 415 | { 416 | GST_DEBUG_OBJECT (src, "failed to open socket"); 417 | return GST_STATE_CHANGE_FAILURE; 418 | } 419 | failure: 420 | { 421 | GST_DEBUG_OBJECT (src, "parent failed state change"); 422 | return result; 423 | } 424 | } 425 | -------------------------------------------------------------------------------- /src/zeromq/gstzmqsrc.h: -------------------------------------------------------------------------------- 1 | /* GStreamer 2 | * Copyright (C) <1999> Erik Walthinsen 3 | * Copyright (C) <2004> Thomas Vander Stichele 4 | * Copyright (C) <2015> Mark J. Howell 5 | * 6 | * This library is free software; you can redistribute it and/or 7 | * modify it under the terms of the GNU Library General Public 8 | * License as published by the Free Software Foundation; either 9 | * version 2 of the License, or (at your option) any later version. 10 | * 11 | * This library is distributed in the hope that it will be useful, 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 | * Library General Public License for more details. 15 | * 16 | * You should have received a copy of the GNU Library General Public 17 | * License along with this library; if not, write to the 18 | * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, 19 | * Boston, MA 02110-1301, USA. 20 | */ 21 | 22 | 23 | #ifndef __GST_ZMQ_SRC_H__ 24 | #define __GST_ZMQ_SRC_H__ 25 | 26 | #include 27 | #include 28 | 29 | //#include 30 | 31 | G_BEGIN_DECLS 32 | 33 | #define GST_TYPE_ZMQ_SRC \ 34 | (gst_zmq_src_get_type()) 35 | #define GST_ZMQ_SRC(obj) \ 36 | (G_TYPE_CHECK_INSTANCE_CAST((obj),GST_TYPE_ZMQ_SRC,GstZmqSrc)) 37 | #define GST_ZMQ_SRC_CLASS(klass) \ 38 | (G_TYPE_CHECK_CLASS_CAST((klass),GST_TYPE_ZMQ_SRC,GstZmqSrcClass)) 39 | #define GST_IS_ZMQ_SRC(obj) \ 40 | (G_TYPE_CHECK_INSTANCE_TYPE((obj),GST_TYPE_ZMQ_SRC)) 41 | #define GST_IS_ZMQ_SRC_CLASS(klass) \ 42 | (G_TYPE_CHECK_CLASS_TYPE((klass),GST_TYPE_ZMQ_SRC)) 43 | 44 | typedef struct _GstZmqSrc GstZmqSrc; 45 | typedef struct _GstZmqSrcClass GstZmqSrcClass; 46 | 47 | typedef enum { 48 | GST_ZMQ_SRC_OPEN = (GST_BASE_SRC_FLAG_LAST << 0), 49 | 50 | GST_ZMQ_SRC_FLAG_LAST = (GST_BASE_SRC_FLAG_LAST << 2) 51 | } GstZmqSrcFlags; 52 | 53 | struct _GstZmqSrc { 54 | GstPushSrc element; 55 | 56 | // properties 57 | gchar *endpoint; 58 | gboolean bind; 59 | 60 | // zmq stuff 61 | void *context; 62 | void *socket; 63 | 64 | //GCancellable *cancellable; 65 | }; 66 | 67 | struct _GstZmqSrcClass { 68 | GstPushSrcClass parent_class; 69 | }; 70 | 71 | GType gst_zmq_src_get_type (void); 72 | 73 | G_END_DECLS 74 | 75 | #endif /* __GST_ZMQ_SRC_H__ */ 76 | --------------------------------------------------------------------------------