├── .gitignore ├── COPYING ├── COPYING.LESSER ├── Makefile.head ├── Makefile.tail ├── README.md ├── config-example-ubuntu.linux-64bit ├── config-example.linux-64bit ├── genMakefiles ├── inih ├── INIReader.cpp ├── INIReader.hh ├── LICENSE.txt ├── ini.c └── ini.h └── live555ProxyServerEx.cpp /.gitignore: -------------------------------------------------------------------------------- 1 | Makefile 2 | *.o 3 | *.exe 4 | live555ProxyServerEx 5 | config.* 6 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /COPYING.LESSER: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /Makefile.head: -------------------------------------------------------------------------------- 1 | ##### Change the following for your environment: 2 | -------------------------------------------------------------------------------- /Makefile.tail: -------------------------------------------------------------------------------- 1 | ##### End of variables to change 2 | 3 | PROXY_SERVER = live555ProxyServerEx$(EXE) 4 | 5 | PREFIX = /usr/local 6 | ALL = $(PROXY_SERVER) 7 | all: $(ALL) 8 | 9 | .$(C).$(OBJ): 10 | $(C_COMPILER) -c $(C_FLAGS) $< 11 | .$(CPP).$(OBJ): 12 | $(CPLUSPLUS_COMPILER) -c $(CPLUSPLUS_FLAGS) $< 13 | 14 | PROXY_SERVER_OBJ = live555ProxyServerEx.$(OBJ) 15 | 16 | libliveMedia_LIB_SUFFIX = $(LIB_SUFFIX) 17 | libBasicUsageEnvironment_LIB_SUFFIX = $(LIB_SUFFIX) 18 | libUsageEnvironment_LIB_SUFFIX = $(LIB_SUFFIX) 19 | libgroupsock_LIB_SUFFIX = $(LIB_SUFFIX) 20 | 21 | USAGE_ENVIRONMENT_LIB = $(LIBRARIES_DIR)/libUsageEnvironment.$(libUsageEnvironment_LIB_SUFFIX) 22 | BASIC_USAGE_ENVIRONMENT_LIB = $(LIBRARIES_DIR)/libBasicUsageEnvironment.$(libBasicUsageEnvironment_LIB_SUFFIX) 23 | LIVEMEDIA_LIB = $(LIBRARIES_DIR)/libliveMedia.$(libliveMedia_LIB_SUFFIX) 24 | GROUPSOCK_LIB = $(LIBRARIES_DIR)/libgroupsock.$(libgroupsock_LIB_SUFFIX) 25 | LOCAL_LIBS = $(LIVEMEDIA_LIB) $(GROUPSOCK_LIB) \ 26 | $(BASIC_USAGE_ENVIRONMENT_LIB) $(USAGE_ENVIRONMENT_LIB) 27 | LIBS = $(LOCAL_LIBS) 28 | 29 | inih/ini.$(OBJ): 30 | $(CPLUSPLUS_COMPILER) -c $(CPLUSPLUS_FLAGS) inih/ini.$(C) -o inih/ini.$(OBJ) 31 | 32 | inih/INIReader.$(OBJ): 33 | $(CPLUSPLUS_COMPILER) -c $(CPLUSPLUS_FLAGS) inih/INIReader.$(CPP) -o inih/INIReader.$(OBJ) 34 | 35 | live555ProxyServerEx$(EXE): inih/ini.$(OBJ) inih/INIReader.$(OBJ) $(PROXY_SERVER_OBJ) 36 | $(LINK)$@ $(CONSOLE_LINK_OPTS) inih/ini.$(OBJ) inih/INIReader.$(OBJ) $(PROXY_SERVER_OBJ) $(LIBS) 37 | 38 | clean: 39 | -rm -rf *.$(OBJ) */*.$(OBJ) $(ALL) core *.core *~ include/*~ 40 | 41 | install: $(PROXY_SERVER) 42 | install -d $(DESTDIR)$(PREFIX)/bin 43 | install -m 755 $(PROXY_SERVER) $(DESTDIR)$(PREFIX)/bin 44 | 45 | ##### Any additional, platform-specific rules come here: 46 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # live555ProxyServerEx 2 | 3 | This is improved version of [LIVE555 Proxy Server](http://www.live555.com/proxyServer/) 4 | that supports configuration files. 5 | 6 | The "LIVE555 Proxy Server" is a unicast RTSP server - built from the 7 | ["LIVE555 Streaming Media" software](http://www.live555.com/liveMedia/) - that 8 | acts as a 'proxy' for one or more 'back-end' unicast or multicast RTSP/RTP 9 | streams (i.e., served by other server(s)). 10 | 11 | The key feature of a proxy server is that it reads each 'back-end' stream only 12 | once, regardless of how many separate clients are streaming from the proxy 13 | server. This makes the proxy server ideal, for example, for streaming from 14 | a RTSP-enabled video camera (which might not be able to handle more than 15 | one connection at a time). 16 | 17 | --> [RTSP client1] 18 | [back-end RTSP/RTP stream] --> [LIVE555 Proxy Server] --> [RTSP client2] 19 | ... 20 | --> [RTSP clientN] 21 | 22 | For more information see [the official documentation](http://www.live555.com/proxyServer/). 23 | 24 | 25 | ## Build instructions 26 | 27 | (only `linux-64bit` is supported now) 28 | 29 | - Install latest version of vanilla LIVE555: 30 | 31 | - Debian/Ubuntu: `sudo apt-get install livemedia-utils liblivemedia-dev` 32 | - Arch Linux: `sudo pacman -S live-media` 33 | - from source (`2018.09.10` was tested): 34 | - build using the official documentation: 35 | http://www.live555.com/liveMedia/#config-unix 36 | - install `*.a` libraries using `sudo make install` (you can put custom 37 | `DESTDIR` in your live555 config file (not proxy config file!) or use 38 | something like `checkinstall`) 39 | - put `LIBRARIES_DIR = /usr/local/lib` to your config file 40 | - use `LIB_SUFFIX = a` in your config file 41 | 42 | Make sure the development files (e.g. `/usr/include/liveMedia` or 43 | `/usr/local/include/liveMedia`) are available 44 | 45 | - Copy `config-example.linux-64bit` to `config.linux-64bit` and edit it. You 46 | may want to replace `LIBRARIES_DIR` and `INCLUDES_PREFIX` or change 47 | the compiler (see also example for Ubuntu 18.04 with gcc: 48 | `config-example-ubuntu.linux-64bit`) 49 | 50 | - Use `LIB_SUFFIX = a` for static linking 51 | - Use `LIB_SUFFIX = so` for dynamic linking 52 | 53 | - Generate Makefile using `./genMakefiles linux-64bit` 54 | 55 | - `make` 56 | 57 | - Then `live555ProxyServerEx` executable file will be available 58 | 59 | 60 | ## Configuration file 61 | 62 | While you can use command-line arguments as with vanilla live555ProxyServer, 63 | you also can create a configuration file and load it using `-c config.cfg` 64 | option. It has INI format. 65 | 66 | `[general]` section describes global options: 67 | 68 | - `verbosity`: `0` is default, `1` is equivalent to `-v`, `2` is equivalent 69 | to `-V`; 70 | 71 | - `stream_rtp_over_tcp` (boolean) is equivalent to `-t`; 72 | 73 | - `try_standard_port_numbers` (boolean): if `1` (default), then proxy server 74 | tries to use port 554 or 8554 if `rtsp_server_port` failed; 75 | 76 | - `server_tunneling_over_http` (boolean): if `1` (default), then proxy creates 77 | a HTTP server for RTSP-over-HTTP tunneling; 78 | 79 | - `server_tunneling_over_http_port` (0..65535): if `0` (default), then proxy 80 | tries to use port 80, 8000 or 8080 for RTSP-over-HTTP tunneling; a non-zero 81 | value means the use of a specific port; 82 | 83 | - `rtsp_server_port` (1..65535, default 554) is equivalent to `-p`; 84 | 85 | - `register_requests` (boolean) is equivalent to `-R`; 86 | 87 | - `username_for_register` and `password_for_register` are equivalent 88 | to `-U username password`; 89 | 90 | - `single_stream_name`: name of the stream if there is only one proxied URL 91 | (default `proxyStream`); 92 | 93 | - `multiple_stream_name`: names of the streams if there are multiple proxied 94 | URLs, must have `%d` for stream number (default `proxyStream-%d`); 95 | 96 | - `out_packet_max_size` (unsigned integer): changes 97 | `OutPacketBuffer::maxSize` value. If you see something like 98 | `The total received frame size exceeds the client's buffer size` or 99 | `The input frame data was too large for our buffer size`, you can try 100 | to increase this value (default is 2000000 — 2 megabytes). 101 | 102 | `[auth]` section is a list of usernames and passwords. If this is not empty, 103 | then proxy server will require authentication. Example: 104 | 105 | [auth] 106 | username = admin 107 | password = 123456 108 | 109 | username = alice 110 | password = 777bob777 111 | 112 | `[streams]` section is a list of proxied streams. Every stream must have URL 113 | and stream name. Example: 114 | 115 | [streams] 116 | url = rtsp://192.168.69.100:554/onvif1 117 | name = office 118 | 119 | url = rtsp://10.0.2.66:38888/h264_ulaw.sdp 120 | name = android_ipwebcam 121 | 122 | These streams will be proxied as `rtsp://[proxy_ip]:[proxy_port]/office` and 123 | `rtsp://[proxy_ip]:[proxy_port]/android_ipwebcam`. 124 | 125 | `[streamparams]` section has additional options for `[streams]` section. These 126 | options does not affect other config files or command-line arguments: 127 | 128 | - `username` and `password` are used for connection to proxied streams; 129 | 130 | - `tunnel_over_http_port` is equivalent to `-T`. 131 | 132 | `-u` and `-T` command-line options affects only command-line streams. 133 | 134 | `[include]` allows you to use multiple config files. They will be loaded 135 | in the specified order. Example: 136 | 137 | [include] 138 | path = proxyserver.d/auth.cfg 139 | path = proxyserver.d/office.cfg 140 | path = proxyserver.d/android_ipwebcam.cfg 141 | 142 | Configuration in the files that were read later has higher priority. (Note 143 | that `[auth]` sections will be merged and `[streamparams]` section affects 144 | only current file.) 145 | 146 | Command-line arguments have higher priority than any config files. 147 | -------------------------------------------------------------------------------- /config-example-ubuntu.linux-64bit: -------------------------------------------------------------------------------- 1 | # Ubuntu 18.04 example config (dynamic linking) 2 | # sudo apt-get install build-essential livemedia-utils liblivemedia-dev 3 | 4 | LIBRARIES_DIR = /usr/lib/x86_64-linux-gnu/ 5 | INCLUDES_PREFIX = /usr/include 6 | INCLUDES = -I$(INCLUDES_PREFIX)/UsageEnvironment -I$(INCLUDES_PREFIX)/groupsock -I$(INCLUDES_PREFIX)/liveMedia -I$(INCLUDES_PREFIX)/BasicUsageEnvironment 7 | COMPILE_OPTS = $(INCLUDES) -m64 -fPIC -I. -O2 -DSOCKLEN_T=socklen_t -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 8 | C = c 9 | C_COMPILER = gcc 10 | C_FLAGS = $(COMPILE_OPTS) 11 | CPP = cpp 12 | CPLUSPLUS_COMPILER = g++ 13 | CPLUSPLUS_FLAGS = $(COMPILE_OPTS) -Wall -Wno-deprecated -DBSD=1 14 | OBJ = o 15 | LINK = g++ -o 16 | LINK_OPTS = -L. 17 | CONSOLE_LINK_OPTS = $(LINK_OPTS) 18 | LIB_SUFFIX = so 19 | EXE = 20 | DESTDIR = 21 | -------------------------------------------------------------------------------- /config-example.linux-64bit: -------------------------------------------------------------------------------- 1 | LIBRARIES_DIR = /usr/lib 2 | INCLUDES_PREFIX = /usr/include 3 | INCLUDES = -I$(INCLUDES_PREFIX)/UsageEnvironment -I$(INCLUDES_PREFIX)/groupsock -I$(INCLUDES_PREFIX)/liveMedia -I$(INCLUDES_PREFIX)/BasicUsageEnvironment 4 | COMPILE_OPTS = $(INCLUDES) -m64 -fPIC -I. -O2 -DSOCKLEN_T=socklen_t -D_LARGEFILE_SOURCE=1 -D_FILE_OFFSET_BITS=64 5 | C = c 6 | C_COMPILER = cc 7 | C_FLAGS = $(COMPILE_OPTS) 8 | CPP = cpp 9 | CPLUSPLUS_COMPILER = c++ 10 | CPLUSPLUS_FLAGS = $(COMPILE_OPTS) -Wall -Wno-deprecated -DBSD=1 11 | OBJ = o 12 | LINK = c++ -o 13 | LINK_OPTS = -L. 14 | CONSOLE_LINK_OPTS = $(LINK_OPTS) 15 | LIB_SUFFIX = a 16 | EXE = 17 | DESTDIR = 18 | -------------------------------------------------------------------------------- /genMakefiles: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | usage() { 4 | echo "Usage: $0 " 5 | exit 1 6 | } 7 | 8 | if [ $# -ne 1 ] 9 | then 10 | usage $* 11 | fi 12 | 13 | platform=$1 14 | 15 | /bin/rm -f Makefile 16 | cat Makefile.head config.$platform Makefile.tail > Makefile 17 | chmod a-w Makefile 18 | -------------------------------------------------------------------------------- /inih/INIReader.cpp: -------------------------------------------------------------------------------- 1 | // Read an INI file into easy-to-access name/value pairs. 2 | 3 | // inih and INIReader are released under the New BSD license (see LICENSE.txt). 4 | // Go to the project home page for more info: 5 | // 6 | // https://github.com/benhoyt/inih 7 | 8 | #include 9 | #include 10 | #include 11 | #include "ini.h" 12 | #include "INIReader.hh" 13 | 14 | using std::string; 15 | 16 | INIReader::INIReader(const string& filename) 17 | { 18 | _error = ini_parse(filename.c_str(), ValueHandler, this); 19 | } 20 | 21 | int INIReader::ParseError() const 22 | { 23 | return _error; 24 | } 25 | 26 | string INIReader::Get(const string& section, const string& name, const string& default_value) const 27 | { 28 | string key = MakeKey(section, name); 29 | // Use _values.find() here instead of _values.at() to support pre C++11 compilers 30 | return _values.count(key) ? _values.find(key)->second : default_value; 31 | } 32 | 33 | long INIReader::GetInteger(const string& section, const string& name, long default_value) const 34 | { 35 | string valstr = Get(section, name, ""); 36 | const char* value = valstr.c_str(); 37 | char* end; 38 | // This parses "1234" (decimal) and also "0x4D2" (hex) 39 | long n = strtol(value, &end, 0); 40 | return end > value ? n : default_value; 41 | } 42 | 43 | double INIReader::GetReal(const string& section, const string& name, double default_value) const 44 | { 45 | string valstr = Get(section, name, ""); 46 | const char* value = valstr.c_str(); 47 | char* end; 48 | double n = strtod(value, &end); 49 | return end > value ? n : default_value; 50 | } 51 | 52 | bool INIReader::GetBoolean(const string& section, const string& name, bool default_value) const 53 | { 54 | string valstr = Get(section, name, ""); 55 | // Convert to lower case to make string comparisons case-insensitive 56 | std::transform(valstr.begin(), valstr.end(), valstr.begin(), ::tolower); 57 | if (valstr == "true" || valstr == "yes" || valstr == "on" || valstr == "1") 58 | return true; 59 | else if (valstr == "false" || valstr == "no" || valstr == "off" || valstr == "0") 60 | return false; 61 | else 62 | return default_value; 63 | } 64 | 65 | string INIReader::MakeKey(const string& section, const string& name) 66 | { 67 | string key = section + "=" + name; 68 | // Convert to lower case to make section/name lookups case-insensitive 69 | std::transform(key.begin(), key.end(), key.begin(), ::tolower); 70 | return key; 71 | } 72 | 73 | int INIReader::ValueHandler(void* user, const char* section, const char* name, 74 | const char* value) 75 | { 76 | INIReader* reader = (INIReader*)user; 77 | string key = MakeKey(section, name); 78 | if (reader->_values[key].size() > 0) 79 | reader->_values[key] += "\n"; 80 | reader->_values[key] += value; 81 | return 1; 82 | } 83 | -------------------------------------------------------------------------------- /inih/INIReader.hh: -------------------------------------------------------------------------------- 1 | // Read an INI file into easy-to-access name/value pairs. 2 | 3 | // inih and INIReader are released under the New BSD license (see LICENSE.txt). 4 | // Go to the project home page for more info: 5 | // 6 | // https://github.com/benhoyt/inih 7 | 8 | #ifndef __INIREADER_H__ 9 | #define __INIREADER_H__ 10 | 11 | #include 12 | #include 13 | 14 | // Read an INI file into easy-to-access name/value pairs. (Note that I've gone 15 | // for simplicity here rather than speed, but it should be pretty decent.) 16 | class INIReader 17 | { 18 | public: 19 | // Construct INIReader and parse given filename. See ini.h for more info 20 | // about the parsing. 21 | INIReader(const std::string& filename); 22 | 23 | // Return the result of ini_parse(), i.e., 0 on success, line number of 24 | // first error on parse error, or -1 on file open error. 25 | int ParseError() const; 26 | 27 | // Get a string value from INI file, returning default_value if not found. 28 | std::string Get(const std::string& section, const std::string& name, 29 | const std::string& default_value) const; 30 | 31 | // Get an integer (long) value from INI file, returning default_value if 32 | // not found or not a valid integer (decimal "1234", "-1234", or hex "0x4d2"). 33 | long GetInteger(const std::string& section, const std::string& name, long default_value) const; 34 | 35 | // Get a real (floating point double) value from INI file, returning 36 | // default_value if not found or not a valid floating point value 37 | // according to strtod(). 38 | double GetReal(const std::string& section, const std::string& name, double default_value) const; 39 | 40 | // Get a boolean value from INI file, returning default_value if not found or if 41 | // not a valid true/false value. Valid true values are "true", "yes", "on", "1", 42 | // and valid false values are "false", "no", "off", "0" (not case sensitive). 43 | bool GetBoolean(const std::string& section, const std::string& name, bool default_value) const; 44 | 45 | private: 46 | int _error; 47 | std::map _values; 48 | static std::string MakeKey(const std::string& section, const std::string& name); 49 | static int ValueHandler(void* user, const char* section, const char* name, 50 | const char* value); 51 | }; 52 | 53 | #endif // __INIREADER_H__ 54 | -------------------------------------------------------------------------------- /inih/LICENSE.txt: -------------------------------------------------------------------------------- 1 | 2 | The "inih" library is distributed under the New BSD license: 3 | 4 | Copyright (c) 2009, Ben Hoyt 5 | All rights reserved. 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of Ben Hoyt nor the names of its contributors 15 | may be used to endorse or promote products derived from this software 16 | without specific prior written permission. 17 | 18 | THIS SOFTWARE IS PROVIDED BY BEN HOYT ''AS IS'' AND ANY 19 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 20 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 21 | DISCLAIMED. IN NO EVENT SHALL BEN HOYT BE LIABLE FOR ANY 22 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 23 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 24 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 25 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 27 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 | -------------------------------------------------------------------------------- /inih/ini.c: -------------------------------------------------------------------------------- 1 | /* inih -- simple .INI file parser 2 | 3 | inih is released under the New BSD license (see LICENSE.txt). Go to the project 4 | home page for more info: 5 | 6 | https://github.com/benhoyt/inih 7 | 8 | */ 9 | 10 | #if defined(_MSC_VER) && !defined(_CRT_SECURE_NO_WARNINGS) 11 | #define _CRT_SECURE_NO_WARNINGS 12 | #endif 13 | 14 | #include 15 | #include 16 | #include 17 | 18 | #include "ini.h" 19 | 20 | #if !INI_USE_STACK 21 | #include 22 | #endif 23 | 24 | #define MAX_SECTION 50 25 | #define MAX_NAME 50 26 | 27 | /* Used by ini_parse_string() to keep track of string parsing state. */ 28 | typedef struct { 29 | const char* ptr; 30 | size_t num_left; 31 | } ini_parse_string_ctx; 32 | 33 | /* Strip whitespace chars off end of given string, in place. Return s. */ 34 | static char* rstrip(char* s) 35 | { 36 | char* p = s + strlen(s); 37 | while (p > s && isspace((unsigned char)(*--p))) 38 | *p = '\0'; 39 | return s; 40 | } 41 | 42 | /* Return pointer to first non-whitespace char in given string. */ 43 | static char* lskip(const char* s) 44 | { 45 | while (*s && isspace((unsigned char)(*s))) 46 | s++; 47 | return (char*)s; 48 | } 49 | 50 | /* Return pointer to first char (of chars) or inline comment in given string, 51 | or pointer to null at end of string if neither found. Inline comment must 52 | be prefixed by a whitespace character to register as a comment. */ 53 | static char* find_chars_or_comment(const char* s, const char* chars) 54 | { 55 | #if INI_ALLOW_INLINE_COMMENTS 56 | int was_space = 0; 57 | while (*s && (!chars || !strchr(chars, *s)) && 58 | !(was_space && strchr(INI_INLINE_COMMENT_PREFIXES, *s))) { 59 | was_space = isspace((unsigned char)(*s)); 60 | s++; 61 | } 62 | #else 63 | while (*s && (!chars || !strchr(chars, *s))) { 64 | s++; 65 | } 66 | #endif 67 | return (char*)s; 68 | } 69 | 70 | /* Version of strncpy that ensures dest (size bytes) is null-terminated. */ 71 | static char* strncpy0(char* dest, const char* src, size_t size) 72 | { 73 | strncpy(dest, src, size); 74 | dest[size - 1] = '\0'; 75 | return dest; 76 | } 77 | 78 | /* See documentation in header file. */ 79 | int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, 80 | void* user) 81 | { 82 | /* Uses a fair bit of stack (use heap instead if you need to) */ 83 | #if INI_USE_STACK 84 | char line[INI_MAX_LINE]; 85 | int max_line = INI_MAX_LINE; 86 | #else 87 | char* line; 88 | int max_line = INI_INITIAL_ALLOC; 89 | #endif 90 | #if INI_ALLOW_REALLOC 91 | char* new_line; 92 | int offset; 93 | #endif 94 | char section[MAX_SECTION] = ""; 95 | char prev_name[MAX_NAME] = ""; 96 | 97 | char* start; 98 | char* end; 99 | char* name; 100 | char* value; 101 | int lineno = 0; 102 | int error = 0; 103 | 104 | #if !INI_USE_STACK 105 | line = (char*)malloc(INI_INITIAL_ALLOC); 106 | if (!line) { 107 | return -2; 108 | } 109 | #endif 110 | 111 | #if INI_HANDLER_LINENO 112 | #define HANDLER(u, s, n, v) handler(u, s, n, v, lineno) 113 | #else 114 | #define HANDLER(u, s, n, v) handler(u, s, n, v) 115 | #endif 116 | 117 | /* Scan through stream line by line */ 118 | while (reader(line, max_line, stream) != NULL) { 119 | #if INI_ALLOW_REALLOC 120 | offset = strlen(line); 121 | while (offset == max_line - 1 && line[offset - 1] != '\n') { 122 | max_line *= 2; 123 | if (max_line > INI_MAX_LINE) 124 | max_line = INI_MAX_LINE; 125 | new_line = realloc(line, max_line); 126 | if (!new_line) { 127 | free(line); 128 | return -2; 129 | } 130 | line = new_line; 131 | if (reader(line + offset, max_line - offset, stream) == NULL) 132 | break; 133 | if (max_line >= INI_MAX_LINE) 134 | break; 135 | offset += strlen(line + offset); 136 | } 137 | #endif 138 | 139 | lineno++; 140 | 141 | start = line; 142 | #if INI_ALLOW_BOM 143 | if (lineno == 1 && (unsigned char)start[0] == 0xEF && 144 | (unsigned char)start[1] == 0xBB && 145 | (unsigned char)start[2] == 0xBF) { 146 | start += 3; 147 | } 148 | #endif 149 | start = lskip(rstrip(start)); 150 | 151 | if (*start == ';' || *start == '#') { 152 | /* Per Python configparser, allow both ; and # comments at the 153 | start of a line */ 154 | } 155 | #if INI_ALLOW_MULTILINE 156 | else if (*prev_name && *start && start > line) { 157 | /* Non-blank line with leading whitespace, treat as continuation 158 | of previous name's value (as per Python configparser). */ 159 | if (!HANDLER(user, section, prev_name, start) && !error) 160 | error = lineno; 161 | } 162 | #endif 163 | else if (*start == '[') { 164 | /* A "[section]" line */ 165 | end = find_chars_or_comment(start + 1, "]"); 166 | if (*end == ']') { 167 | *end = '\0'; 168 | strncpy0(section, start + 1, sizeof(section)); 169 | *prev_name = '\0'; 170 | } 171 | else if (!error) { 172 | /* No ']' found on section line */ 173 | error = lineno; 174 | } 175 | } 176 | else if (*start) { 177 | /* Not a comment, must be a name[=:]value pair */ 178 | end = find_chars_or_comment(start, "=:"); 179 | if (*end == '=' || *end == ':') { 180 | *end = '\0'; 181 | name = rstrip(start); 182 | value = end + 1; 183 | #if INI_ALLOW_INLINE_COMMENTS 184 | end = find_chars_or_comment(value, NULL); 185 | if (*end) 186 | *end = '\0'; 187 | #endif 188 | value = lskip(value); 189 | rstrip(value); 190 | 191 | /* Valid name[=:]value pair found, call handler */ 192 | strncpy0(prev_name, name, sizeof(prev_name)); 193 | if (!HANDLER(user, section, name, value) && !error) 194 | error = lineno; 195 | } 196 | else if (!error) { 197 | /* No '=' or ':' found on name[=:]value line */ 198 | error = lineno; 199 | } 200 | } 201 | 202 | #if INI_STOP_ON_FIRST_ERROR 203 | if (error) 204 | break; 205 | #endif 206 | } 207 | 208 | #if !INI_USE_STACK 209 | free(line); 210 | #endif 211 | 212 | return error; 213 | } 214 | 215 | /* See documentation in header file. */ 216 | int ini_parse_file(FILE* file, ini_handler handler, void* user) 217 | { 218 | return ini_parse_stream((ini_reader)fgets, file, handler, user); 219 | } 220 | 221 | /* See documentation in header file. */ 222 | int ini_parse(const char* filename, ini_handler handler, void* user) 223 | { 224 | FILE* file; 225 | int error; 226 | 227 | file = fopen(filename, "r"); 228 | if (!file) 229 | return -1; 230 | error = ini_parse_file(file, handler, user); 231 | fclose(file); 232 | return error; 233 | } 234 | 235 | /* An ini_reader function to read the next line from a string buffer. This 236 | is the fgets() equivalent used by ini_parse_string(). */ 237 | static char* ini_reader_string(char* str, int num, void* stream) { 238 | ini_parse_string_ctx* ctx = (ini_parse_string_ctx*)stream; 239 | const char* ctx_ptr = ctx->ptr; 240 | size_t ctx_num_left = ctx->num_left; 241 | char* strp = str; 242 | char c; 243 | 244 | if (ctx_num_left == 0 || num < 2) 245 | return NULL; 246 | 247 | while (num > 1 && ctx_num_left != 0) { 248 | c = *ctx_ptr++; 249 | ctx_num_left--; 250 | *strp++ = c; 251 | if (c == '\n') 252 | break; 253 | num--; 254 | } 255 | 256 | *strp = '\0'; 257 | ctx->ptr = ctx_ptr; 258 | ctx->num_left = ctx_num_left; 259 | return str; 260 | } 261 | 262 | /* See documentation in header file. */ 263 | int ini_parse_string(const char* string, ini_handler handler, void* user) { 264 | ini_parse_string_ctx ctx; 265 | 266 | ctx.ptr = string; 267 | ctx.num_left = strlen(string); 268 | return ini_parse_stream((ini_reader)ini_reader_string, &ctx, handler, 269 | user); 270 | } 271 | -------------------------------------------------------------------------------- /inih/ini.h: -------------------------------------------------------------------------------- 1 | /* inih -- simple .INI file parser 2 | 3 | inih is released under the New BSD license (see LICENSE.txt). Go to the project 4 | home page for more info: 5 | 6 | https://github.com/benhoyt/inih 7 | 8 | */ 9 | 10 | #ifndef __INI_H__ 11 | #define __INI_H__ 12 | 13 | /* Make this header file easier to include in C++ code */ 14 | #ifdef __cplusplus 15 | extern "C" { 16 | #endif 17 | 18 | #include 19 | 20 | /* Nonzero if ini_handler callback should accept lineno parameter. */ 21 | #ifndef INI_HANDLER_LINENO 22 | #define INI_HANDLER_LINENO 0 23 | #endif 24 | 25 | /* Typedef for prototype of handler function. */ 26 | #if INI_HANDLER_LINENO 27 | typedef int (*ini_handler)(void* user, const char* section, 28 | const char* name, const char* value, 29 | int lineno); 30 | #else 31 | typedef int (*ini_handler)(void* user, const char* section, 32 | const char* name, const char* value); 33 | #endif 34 | 35 | /* Typedef for prototype of fgets-style reader function. */ 36 | typedef char* (*ini_reader)(char* str, int num, void* stream); 37 | 38 | /* Parse given INI-style file. May have [section]s, name=value pairs 39 | (whitespace stripped), and comments starting with ';' (semicolon). Section 40 | is "" if name=value pair parsed before any section heading. name:value 41 | pairs are also supported as a concession to Python's configparser. 42 | 43 | For each name=value pair parsed, call handler function with given user 44 | pointer as well as section, name, and value (data only valid for duration 45 | of handler call). Handler should return nonzero on success, zero on error. 46 | 47 | Returns 0 on success, line number of first error on parse error (doesn't 48 | stop on first error), -1 on file open error, or -2 on memory allocation 49 | error (only when INI_USE_STACK is zero). 50 | */ 51 | int ini_parse(const char* filename, ini_handler handler, void* user); 52 | 53 | /* Same as ini_parse(), but takes a FILE* instead of filename. This doesn't 54 | close the file when it's finished -- the caller must do that. */ 55 | int ini_parse_file(FILE* file, ini_handler handler, void* user); 56 | 57 | /* Same as ini_parse(), but takes an ini_reader function pointer instead of 58 | filename. Used for implementing custom or string-based I/O (see also 59 | ini_parse_string). */ 60 | int ini_parse_stream(ini_reader reader, void* stream, ini_handler handler, 61 | void* user); 62 | 63 | /* Same as ini_parse(), but takes a zero-terminated string with the INI data 64 | instead of a file. Useful for parsing INI data from a network socket or 65 | already in memory. */ 66 | int ini_parse_string(const char* string, ini_handler handler, void* user); 67 | 68 | /* Nonzero to allow multi-line value parsing, in the style of Python's 69 | configparser. If allowed, ini_parse() will call the handler with the same 70 | name for each subsequent line parsed. */ 71 | #ifndef INI_ALLOW_MULTILINE 72 | #define INI_ALLOW_MULTILINE 1 73 | #endif 74 | 75 | /* Nonzero to allow a UTF-8 BOM sequence (0xEF 0xBB 0xBF) at the start of 76 | the file. See http://code.google.com/p/inih/issues/detail?id=21 */ 77 | #ifndef INI_ALLOW_BOM 78 | #define INI_ALLOW_BOM 1 79 | #endif 80 | 81 | /* Nonzero to allow inline comments (with valid inline comment characters 82 | specified by INI_INLINE_COMMENT_PREFIXES). Set to 0 to turn off and match 83 | Python 3.2+ configparser behaviour. */ 84 | #ifndef INI_ALLOW_INLINE_COMMENTS 85 | #define INI_ALLOW_INLINE_COMMENTS 1 86 | #endif 87 | #ifndef INI_INLINE_COMMENT_PREFIXES 88 | #define INI_INLINE_COMMENT_PREFIXES ";" 89 | #endif 90 | 91 | /* Nonzero to use stack for line buffer, zero to use heap (malloc/free). */ 92 | #ifndef INI_USE_STACK 93 | #define INI_USE_STACK 1 94 | #endif 95 | 96 | /* Maximum line length for any line in INI file (stack or heap). Note that 97 | this must be 3 more than the longest line (due to '\r', '\n', and '\0'). */ 98 | #ifndef INI_MAX_LINE 99 | #define INI_MAX_LINE 200 100 | #endif 101 | 102 | /* Nonzero to allow heap line buffer to grow via realloc(), zero for a 103 | fixed-size buffer of INI_MAX_LINE bytes. Only applies if INI_USE_STACK is 104 | zero. */ 105 | #ifndef INI_ALLOW_REALLOC 106 | #define INI_ALLOW_REALLOC 0 107 | #endif 108 | 109 | /* Initial size in bytes for heap line buffer. Only applies if INI_USE_STACK 110 | is zero. */ 111 | #ifndef INI_INITIAL_ALLOC 112 | #define INI_INITIAL_ALLOC 200 113 | #endif 114 | 115 | /* Stop parsing on first error (default is to keep parsing). */ 116 | #ifndef INI_STOP_ON_FIRST_ERROR 117 | #define INI_STOP_ON_FIRST_ERROR 0 118 | #endif 119 | 120 | #ifdef __cplusplus 121 | } 122 | #endif 123 | 124 | #endif /* __INI_H__ */ 125 | -------------------------------------------------------------------------------- /live555ProxyServerEx.cpp: -------------------------------------------------------------------------------- 1 | /********** 2 | This library is free software; you can redistribute it and/or modify it under 3 | the terms of the GNU Lesser General Public License as published by the 4 | Free Software Foundation; either version 3 of the License, or (at your 5 | option) any later version. (See .) 6 | 7 | This library is distributed in the hope that it will be useful, but WITHOUT 8 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 9 | FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 10 | more details. 11 | 12 | You should have received a copy of the GNU Lesser General Public License 13 | along with this library; if not, write to the Free Software Foundation, Inc., 14 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 15 | **********/ 16 | // Copyright (c) 1996-2018, Live Networks, Inc. 17 | // Copyright (c) 2018 andreymal 18 | // All rights reserved 19 | 20 | // LIVE555 Proxy Server Ex 21 | // main program 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | #include 28 | #include "liveMedia.hh" 29 | #include "BasicUsageEnvironment.hh" 30 | #include "inih/INIReader.hh" 31 | 32 | struct ProxyStream { 33 | std::string proxiedURL; 34 | std::string streamName; 35 | std::string username; 36 | std::string password; 37 | portNumBits tunnelOverHTTPPortNum; 38 | }; 39 | 40 | char const* progName; 41 | UsageEnvironment* env; 42 | UserAuthenticationDatabase* authDB = NULL; 43 | UserAuthenticationDatabase* authDBForREGISTER = NULL; 44 | 45 | std::vector streams; 46 | std::vector streamNames; // for collision detection 47 | 48 | // Global configuration 49 | int verbosityLevel = 0; 50 | Boolean streamRTPOverTCP = False; 51 | Boolean tryStandardPortNumbers = True; 52 | Boolean serverTunnelingOverHTTP = True; 53 | portNumBits serverTunnelingOverHTTPPortNum = 0; // It tries 80, 8000 or 8080 by default 54 | portNumBits rtspServerPortNum = 554; 55 | Boolean proxyREGISTERRequests = False; 56 | std::string usernameForREGISTER; 57 | std::string passwordForREGISTER; 58 | std::string singleStreamNameTemplate("proxyStream"); 59 | std::string multipleStreamNameTemplate("proxyStream-%d"); 60 | unsigned outPacketMaxSize = 2000000; // bytes 61 | 62 | // Configuration for command-line streams 63 | std::string username; 64 | std::string password; 65 | portNumBits tunnelOverHTTPPortNum = 0; 66 | 67 | 68 | bool includeConfig(const char* path); 69 | bool loadINIFile(const char* inifile); 70 | 71 | 72 | static RTSPServer* createRTSPServer(Port port) { 73 | if (proxyREGISTERRequests) { 74 | return RTSPServerWithREGISTERProxying::createNew( 75 | *env, port, authDB, authDBForREGISTER, 65, 76 | streamRTPOverTCP, verbosityLevel, 77 | username.length() > 0 ? username.c_str() : NULL, 78 | password.length() > 0 ? password.c_str() : NULL); 79 | } else { 80 | return RTSPServer::createNew(*env, port, authDB); 81 | } 82 | } 83 | 84 | void usage() { 85 | *env << "Usage: " << progName 86 | << " [-c ]" 87 | << " [-v|-V]" 88 | << " [-t|-T ]" 89 | << " [-p ]" 90 | << " [-u ]" 91 | << " [-R] [-U ]" 92 | << " ... \n"; 93 | exit(1); 94 | } 95 | 96 | 97 | char* findConfigPath(int argc, char** argv) { 98 | int pos = 1; 99 | 100 | while (pos < argc) { 101 | // Process initial command-line options (beginning with "-"), 102 | // but find only path to configuration file 103 | char* const opt = argv[pos]; 104 | if (opt[0] != '-') break; // the remaining parameters are assumed to be "rtsp://" URLs 105 | 106 | switch (opt[1]) { 107 | case 'c': { // path to configuration file 108 | if (pos + 1 >= argc) { 109 | usage(); 110 | return NULL; 111 | } 112 | return argv[pos + 1]; 113 | } 114 | 115 | // Skip options that use few command-line arguments 116 | case 'T': { 117 | ++pos; 118 | break; 119 | } 120 | 121 | case 'p': { 122 | ++pos; 123 | break; 124 | } 125 | 126 | case 'u': { 127 | pos += 2; 128 | break; 129 | } 130 | 131 | case 'U': { 132 | pos += 2; 133 | break; 134 | } 135 | 136 | // Skip any other options 137 | default: { 138 | break; 139 | } 140 | } 141 | 142 | ++pos; 143 | } 144 | 145 | return NULL; 146 | } 147 | 148 | 149 | bool includeConfig(const char* path) { 150 | struct stat st; 151 | if (stat(path, &st) != 0) { 152 | *env << "Path \"" << path << "\" not found\n"; 153 | return false; 154 | } 155 | 156 | if (S_ISDIR(st.st_mode)) { 157 | *env << "Config directories are not supported\n"; 158 | return false; 159 | } 160 | 161 | return loadINIFile(path); 162 | } 163 | 164 | 165 | bool loadINIFile(const char* inifile) { 166 | INIReader reader(inifile); 167 | if (reader.ParseError() != 0) { 168 | return false; 169 | } 170 | 171 | // Global configuration variables 172 | verbosityLevel = reader.GetInteger("general", "verbosity", verbosityLevel); 173 | streamRTPOverTCP = reader.GetBoolean("general", "stream_rtp_over_tcp", streamRTPOverTCP); 174 | tryStandardPortNumbers = reader.GetBoolean("general", "try_standard_port_numbers", tryStandardPortNumbers); 175 | serverTunnelingOverHTTP = reader.GetBoolean("general", "server_tunneling_over_http", serverTunnelingOverHTTP); 176 | serverTunnelingOverHTTPPortNum = reader.GetInteger("general", "server_tunneling_over_http_port", serverTunnelingOverHTTPPortNum); 177 | rtspServerPortNum = reader.GetInteger("general", "rtsp_server_port", rtspServerPortNum); 178 | proxyREGISTERRequests = reader.GetBoolean("general", "register_requests", proxyREGISTERRequests); 179 | usernameForREGISTER = reader.Get("general", "username_for_register", usernameForREGISTER); 180 | passwordForREGISTER = reader.Get("general", "password_for_register", passwordForREGISTER); 181 | singleStreamNameTemplate = reader.Get("general", "single_stream_name", singleStreamNameTemplate); 182 | // TODO: %d should be validated here 183 | multipleStreamNameTemplate = reader.Get("general", "multiple_stream_name", multipleStreamNameTemplate); 184 | 185 | int outPacketMaxSizeTmp = reader.GetInteger("general", "out_packet_max_size", 0); 186 | if (outPacketMaxSizeTmp < 0) { 187 | *env << "Invalid out_packet_max_size\n"; 188 | return false; 189 | } 190 | if (outPacketMaxSizeTmp > 0) { 191 | outPacketMaxSize = outPacketMaxSizeTmp; 192 | } 193 | 194 | // Variables that affects only current streams 195 | std::string streamUsername = reader.Get("streamparams", "username", ""); 196 | std::string streamPassword = reader.Get("streamparams", "password", ""); 197 | portNumBits streamTunnelOverHTTPPortNum = 198 | (portNumBits) reader.GetInteger("streamparams", "tunnel_over_http_port", 0); 199 | 200 | // Parse proxied streams from "streams" section 201 | std::string urls = reader.Get("streams", "url", ""); 202 | std::string names = reader.Get("streams", "name", ""); 203 | std::stringstream ss1(urls); 204 | std::stringstream ss2(names); 205 | std::string url; 206 | std::string streamName; 207 | 208 | while (std::getline(ss1, url, '\n') && std::getline(ss2, streamName, '\n')) { 209 | // Ensure that there are no collision with previous streams 210 | if (std::find(streamNames.begin(), streamNames.end(), streamName) != streamNames.end()) { 211 | *env << "Conflict: stream name " << streamName.c_str() << " is already used\n"; 212 | return false; 213 | } 214 | 215 | ProxyStream stream; 216 | stream.proxiedURL = url; 217 | stream.streamName = streamName; 218 | stream.username = streamUsername; 219 | stream.password = streamPassword; 220 | stream.tunnelOverHTTPPortNum = streamTunnelOverHTTPPortNum; 221 | streams.push_back(stream); 222 | streamNames.push_back(streamName); 223 | } 224 | 225 | // Client access control to the RTSP server 226 | std::string usernames = reader.Get("auth", "username", ""); 227 | std::string passwords = reader.Get("auth", "password", ""); 228 | std::stringstream ss3(usernames); 229 | std::stringstream ss4(passwords); 230 | std::string authUsername; 231 | std::string authPassword; 232 | 233 | while (std::getline(ss3, authUsername, '\n') && std::getline(ss4, authPassword, '\n')) { 234 | if (authUsername.length() > 0 && authPassword.length() > 0) { 235 | if (authDB == NULL) { 236 | authDB = new UserAuthenticationDatabase; 237 | } 238 | authDB->addUserRecord(authUsername.c_str(), authPassword.c_str()); 239 | } 240 | } 241 | 242 | // Get list of config files for recursive loading 243 | std::string includes = reader.Get("include", "path", ""); 244 | 245 | std::stringstream ss(includes); 246 | std::string nextinifile; 247 | 248 | // TODO: prevent infinite recursion 249 | while(std::getline(ss, nextinifile, '\n')){ 250 | if (nextinifile.length() > 0) { 251 | if (!includeConfig(nextinifile.c_str())) { 252 | return false; 253 | } 254 | } 255 | } 256 | 257 | return true; 258 | } 259 | 260 | 261 | int parseArgs(int argc, char** argv) { 262 | int pos = 1; 263 | 264 | while (pos < argc) { 265 | // Process initial command-line options (beginning with "-"): 266 | char* const opt = argv[pos]; 267 | if (opt[0] != '-') break; // the remaining parameters are assumed to be "rtsp://" URLs 268 | 269 | switch (opt[1]) { 270 | case 'c': { // already parsed by findConfigPath function; just skip it 271 | ++pos; 272 | break; 273 | } 274 | 275 | case 'v': { // verbose output 276 | verbosityLevel = 1; 277 | break; 278 | } 279 | 280 | case 'V': { // more verbose output 281 | verbosityLevel = 2; 282 | break; 283 | } 284 | 285 | case 't': { 286 | // Stream RTP and RTCP over the TCP 'control' connection. 287 | // (This is for the 'back end' (i.e., proxied) stream only.) 288 | streamRTPOverTCP = True; 289 | break; 290 | } 291 | 292 | case 'T': { 293 | // stream RTP and RTCP over a HTTP connection 294 | if (pos + 1 < argc && argv[pos + 1][0] != '-') { 295 | // The next argument is the HTTP server port number: 296 | if (sscanf(argv[pos + 1], "%hu", &tunnelOverHTTPPortNum) == 1 297 | && tunnelOverHTTPPortNum > 0) { 298 | ++pos; 299 | break; 300 | } 301 | } 302 | 303 | // If we get here, the option was specified incorrectly: 304 | return -1; 305 | } 306 | 307 | case 'p': { 308 | // specify a rtsp server port number 309 | if (pos + 1 < argc && argv[pos + 1][0] != '-') { 310 | // The next argument is the rtsp server port number: 311 | if (sscanf(argv[pos + 1], "%hu", &rtspServerPortNum) == 1 312 | && rtspServerPortNum > 0) { 313 | ++pos; 314 | break; 315 | } 316 | } 317 | 318 | // If we get here, the option was specified incorrectly: 319 | usage(); 320 | break; 321 | } 322 | 323 | case 'u': { // specify a username and password (to be used if the 'back end' (i.e., proxied) stream requires authentication) 324 | if (pos + 2 >= argc) return -1; // there's no argv[pos + 2] (for the "password") 325 | username = std::string(argv[pos + 1]); 326 | password = std::string(argv[pos + 2]); 327 | pos += 2; 328 | break; 329 | } 330 | 331 | case 'U': { // specify a username and password to use to authenticate incoming "REGISTER" commands 332 | if (pos + 2 >= argc) return -1; // there's no argv[pos + 2] (for the "password") 333 | usernameForREGISTER = std::string(argv[pos + 1]); 334 | passwordForREGISTER = std::string(argv[pos + 2]); 335 | 336 | if (authDBForREGISTER == NULL) authDBForREGISTER = new UserAuthenticationDatabase; 337 | authDBForREGISTER->addUserRecord(usernameForREGISTER.c_str(), passwordForREGISTER.c_str()); 338 | pos += 2; 339 | break; 340 | } 341 | 342 | case 'R': { // Handle incoming "REGISTER" requests by proxying the specified stream: 343 | proxyREGISTERRequests = True; 344 | break; 345 | } 346 | 347 | default: { 348 | return -1; 349 | } 350 | } 351 | 352 | ++pos; 353 | } 354 | 355 | return pos; 356 | } 357 | 358 | 359 | bool parseURLs(int argc, char** argv, int urlsStartPos) { 360 | int i = 1; 361 | 362 | while (urlsStartPos < argc) { 363 | char streamName[127]; 364 | 365 | if (i == 1 && urlsStartPos == argc - 1) { 366 | sprintf(streamName, "%s", singleStreamNameTemplate.c_str()); // there's just one stream; give it this name 367 | } else { 368 | sprintf(streamName, multipleStreamNameTemplate.c_str(), i); // there's more than one stream; distinguish them by name 369 | } 370 | 371 | std::string cppStreamName(streamName); 372 | 373 | // Ensure that there are no collisions with streams from config files 374 | if (std::find(streamNames.begin(), streamNames.end(), cppStreamName) != streamNames.end()) { 375 | *env << "Conflict: stream name " << streamName << " is already used\n"; 376 | return false; 377 | } 378 | 379 | ProxyStream stream; 380 | stream.proxiedURL = std::string(argv[urlsStartPos]); 381 | stream.streamName = cppStreamName; 382 | stream.username = username; 383 | stream.password = password; 384 | stream.tunnelOverHTTPPortNum = tunnelOverHTTPPortNum; 385 | streams.push_back(stream); 386 | streamNames.push_back(cppStreamName); 387 | 388 | ++urlsStartPos; 389 | ++i; 390 | } 391 | 392 | return true; 393 | } 394 | 395 | 396 | int main(int argc, char** argv) { 397 | 398 | // Begin by setting up our usage environment: 399 | TaskScheduler* scheduler = BasicTaskScheduler::createNew(); 400 | env = BasicUsageEnvironment::createNew(*scheduler); 401 | 402 | *env << "LIVE555 Proxy Server Ex\n" 403 | << "\t(LIVE555 Streaming Media library version " 404 | << LIVEMEDIA_LIBRARY_VERSION_STRING 405 | << "; licensed under the GNU LGPL)\n\n"; 406 | 407 | // Check command-line arguments: optional parameters, then one or more rtsp:// URLs (of streams to be proxied): 408 | progName = argv[0]; 409 | if (argc < 2) usage(); 410 | 411 | // Config file has low priority, so it should be loaded first 412 | char *inifile = findConfigPath(argc, argv); 413 | if (inifile != NULL) { 414 | if (!includeConfig(inifile)) { 415 | *env << "Cannot parse config files\n"; 416 | return 1; 417 | } 418 | } 419 | 420 | // Command line parameters have high priority, parse it after config file 421 | int urlsStartPos = parseArgs(argc, argv); 422 | if (urlsStartPos < 1) { 423 | usage(); 424 | } 425 | 426 | // Parse URLs from command line arguments 427 | if (!parseURLs(argc, argv, urlsStartPos)) { 428 | return 1; 429 | } 430 | 431 | if (streams.size() < 1 && !proxyREGISTERRequests) { 432 | usage(); 433 | } 434 | 435 | std::vector::iterator it; 436 | 437 | // Make sure that the remaining arguments appear to be "rtsp://" URLs: 438 | for(it = streams.begin(); it != streams.end(); ++it) { 439 | if ((*it).proxiedURL.find("rtsp://") != 0) { 440 | *env << "Invalid URL " << (*it).proxiedURL.c_str() << "\n"; 441 | return 1; 442 | } 443 | 444 | if (streamRTPOverTCP) { 445 | if ((*it).tunnelOverHTTPPortNum > 0) { 446 | *env << "Invalid configuration for " << (*it).proxiedURL.c_str() << ": the -t and -T options cannot both be used!\n"; 447 | return 1; 448 | } else { 449 | (*it).tunnelOverHTTPPortNum = (portNumBits)(~0); // hack to tell "ProxyServerMediaSession" to stream over TCP, but not using HTTP 450 | } 451 | } 452 | } 453 | 454 | // Do some additional checking for invalid command-line argument combinations: 455 | if (authDBForREGISTER != NULL && !proxyREGISTERRequests) { 456 | *env << "The '-U ' option can be used only with -R\n"; 457 | usage(); 458 | } 459 | 460 | // This option allows to increase the maximum size of video frames that we can 'proxy' without truncation. 461 | // (Such frames are unreasonably large; the back-end servers should really not be sending frames this large!) 462 | OutPacketBuffer::maxSize = outPacketMaxSize; // bytes 463 | 464 | // Create the RTSP server. Try first with the configured port number, 465 | // and then with the default port number (554) if different, 466 | // and then with the alternative port number (8554): 467 | RTSPServer* rtspServer; 468 | rtspServer = createRTSPServer(rtspServerPortNum); 469 | if (rtspServer == NULL && tryStandardPortNumbers && rtspServerPortNum != 554) { 470 | *env << "Unable to create a RTSP server with port number " << rtspServerPortNum << ": " << env->getResultMsg() << "\n"; 471 | *env << "Trying instead with the standard port numbers (554 and 8554)...\n"; 472 | 473 | rtspServerPortNum = 554; 474 | rtspServer = createRTSPServer(rtspServerPortNum); 475 | } 476 | if (rtspServer == NULL && tryStandardPortNumbers) { 477 | rtspServerPortNum = 8554; 478 | rtspServer = createRTSPServer(rtspServerPortNum); 479 | } 480 | if (rtspServer == NULL) { 481 | *env << "Failed to create RTSP server: " << env->getResultMsg() << "\n"; 482 | exit(1); 483 | } 484 | 485 | // Create a proxy for each "rtsp://" URL specified on the command line: 486 | for(it = streams.begin(); it != streams.end(); ++it) { 487 | ServerMediaSession* sms 488 | = ProxyServerMediaSession::createNew(*env, rtspServer, 489 | (*it).proxiedURL.c_str(), 490 | (*it).streamName.c_str(), 491 | (*it).username.length() > 0 ? (*it).username.c_str() : NULL, 492 | (*it).password.length() > 0 ? (*it).password.c_str() : NULL, 493 | (*it).tunnelOverHTTPPortNum, verbosityLevel); 494 | rtspServer->addServerMediaSession(sms); 495 | 496 | char* proxyStreamURL = rtspServer->rtspURL(sms); 497 | *env << "RTSP stream, proxying the stream \"" << (*it).proxiedURL.c_str() << "\"\n"; 498 | *env << "\tPlay this stream using the URL: " << proxyStreamURL << "\n"; 499 | delete[] proxyStreamURL; 500 | } 501 | 502 | if (proxyREGISTERRequests) { 503 | *env << "(We handle incoming \"REGISTER\" requests on port " << rtspServerPortNum << ")\n"; 504 | } 505 | 506 | // Also, attempt to create a HTTP server for RTSP-over-HTTP tunneling. 507 | // Try first with the default HTTP port (80), and then with the alternative HTTP 508 | // port numbers (8000 and 8080). 509 | if (serverTunnelingOverHTTP) { 510 | Boolean success; 511 | 512 | if (serverTunnelingOverHTTPPortNum == 0) { 513 | success = (rtspServer->setUpTunnelingOverHTTP(80) || rtspServer->setUpTunnelingOverHTTP(8000) || rtspServer->setUpTunnelingOverHTTP(8080)); 514 | } else { 515 | success = rtspServer->setUpTunnelingOverHTTP(serverTunnelingOverHTTPPortNum); 516 | } 517 | 518 | if (success) { 519 | *env << "\n(We use port " << rtspServer->httpServerPortNum() << " for optional RTSP-over-HTTP tunneling.)\n"; 520 | } else { 521 | *env << "\n(RTSP-over-HTTP tunneling is not available.)\n"; 522 | } 523 | } else { 524 | *env << "\n(RTSP-over-HTTP tunneling is disabled.)\n"; 525 | } 526 | 527 | // Now, enter the event loop: 528 | env->taskScheduler().doEventLoop(); // does not return 529 | 530 | return 0; // only to prevent compiler warning 531 | } 532 | --------------------------------------------------------------------------------