forked from Haivision/srt
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Roman Diouskine
committed
Apr 21, 2017
0 parents
commit bdeb5d2
Showing
85 changed files
with
33,365 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
## License | ||
|
||
By contributing code to the [SRT project](https://github.com/Haivision/srt/), you agree to license your contribution under the [LGPLv2.1 License](COPYING). | ||
|
||
## Issues | ||
|
||
Open a GitHub issue for anything you find or any questions you have. | ||
|
||
## Comments | ||
|
||
Comment on any GitHub issue, open or closed. The only guidelines here are to be friendly and welcoming. If you see that a question has been asked and you think you know the answer, don't wait! | ||
|
||
## Pull Requests | ||
|
||
Submit a pull request at any time, whether an issue has been created or not. It may be helpful to discuss your goals in an issue first, though many things can best be shown with code. | ||
|
||
## Code Style | ||
|
||
Please follow existing style. | ||
|
||
## Attribution | ||
|
||
This contributing guide is adapted from [VVV's guide](https://github.com/Varying-Vagrant-Vagrants/VVV/blob/develop/.github/CONTRIBUTING.md). | ||
|
||
## Developer's Certificate of Origin 1.1 | ||
|
||
By making a contribution to this project, I certify that: | ||
|
||
* (a) The contribution was created in whole or in part by me and I | ||
have the right to submit it under the open source license | ||
indicated in the file; or | ||
|
||
* (b) The contribution is based upon previous work that, to the best | ||
of my knowledge, is covered under an appropriate open source | ||
license and I have the right under that license to submit that | ||
work with modifications, whether created in whole or in part | ||
by me, under the same open source license (unless I am | ||
permitted to submit under a different license), as indicated | ||
in the file; or | ||
|
||
* (c) The contribution was provided directly to me by some other | ||
person who certified (a), (b) or (c) and I have not modified | ||
it. | ||
|
||
* (d) I understand and agree that this project and the contribution | ||
are public and that a record of the contribution (including all | ||
personal information I submit with it, including my sign-off) is | ||
maintained indefinitely and may be redistributed consistent with | ||
this project or the open source license(s) involved. |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
REQUIREMENTS: | ||
============ | ||
|
||
* cmake (as build system) | ||
* OpenSSL | ||
* Pthreads (for POSIX systems it's builtin, for Windows there's a library) | ||
|
||
For Linux: | ||
========== | ||
|
||
Install cmake and openssl-devel (or similar name) package. For pthreads | ||
there should be -lpthreads linker flag added. | ||
|
||
## Ubunut 14 | ||
``` | ||
sudo apt-get update | ||
sudo apt-get upgrade | ||
sudo apt-get install tclsh pkg-config cmake libssl-dev build-essential | ||
./configure | ||
make | ||
``` | ||
## CentOS 7 | ||
``` | ||
sudo yum update | ||
sudo yum install tcl pkgconfig openssl-devel cmake gcc gcc-c++ make automake | ||
./configure | ||
make | ||
``` | ||
|
||
For Mac (Darwin, iOS): | ||
===================== | ||
|
||
Install cmake and openssl with development files from "brew". Note that the | ||
system version of OpenSSL is inappropriate, although you should be able to | ||
use any newer version compiled from sources, if you prefer. | ||
|
||
For Windows: | ||
============ | ||
|
||
1. Install cmake for Windows. The CMake GUI will help you configure the project. | ||
Note that some variables must be provided explicitly. These are the default | ||
recommended values (required until some solution for running the `configure` | ||
script in Windows can be found): | ||
|
||
WITH_OPENSSL_INCLUDEDIR=C:/OpenSSL-Win64/include | ||
WITH_OPENSSL_LIBDIR=C:/OpenSSL-win64/lib/VC/static | ||
WITH_OPENSSL_LIBRARIES=libeay32MT.lib ssleay32MT.lib | ||
WITH_PTHREAD_INCLUDEDIR=C:/pthread-win32/include | ||
WITH_PTHREAD_LDFLAGS=C:/pthread-win32/lib/pthread_lib.lib | ||
|
||
|
||
2. Please download and install OpenSSL for Windows. | ||
|
||
The 64-bit devel package can be downloaded from here: | ||
|
||
http://slproweb.com/download/Win64OpenSSL-1_0_2a.exe | ||
|
||
It's expected to be installed in `C:\OpenSSL-Win64` (see the above variables). | ||
|
||
|
||
3. Compile and install Pthreads for Windows from this submodule: | ||
|
||
submodules/pthread-win32 | ||
|
||
Please follow the steps: | ||
|
||
a. Using Visual Studio 2013, please open this file: | ||
|
||
pthread_lib.2013.vcxproj | ||
|
||
b. Make sure to select configuration: `Release` and `x64`. | ||
|
||
c. Make sure that the `pthread_lib` project will be built. | ||
|
||
d. After building, find the `pthread_lib.lib` file (directory is probably: `bin\x64_MSVC2013.Release`). | ||
Copy this file to `C:\pthread-win32\lib` (or whatever other location you configured in variables). | ||
|
||
e. Copy include files to `C:\pthread-win32\include` - the following ones: | ||
|
||
pthread.h | ||
sched.h | ||
semaphore.h | ||
|
||
(They are in the toplevel directory, there are actually no meaningful subdirs here) | ||
(NOTE: the win32 is part of the project name. It will become 32 or 64 depending on selection) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../udt4/app |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
/* | ||
* SRT - Secure, Reliable, Transport | ||
* Copyright (c) 2017 Haivision Systems Inc. | ||
* | ||
* This library is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 2.1 of the License, or (at your option) any later version. | ||
* | ||
* This library is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this library; If not, see <http://www.gnu.org/licenses/> | ||
*/ | ||
|
||
|
||
#if WIN32 | ||
|
||
// Keep this below commented out. | ||
// This is for a case when you need cpp debugging on Windows. | ||
//#ifdef _WINSOCKAPI_ | ||
//#error "You include <winsock.h> somewhere, remove it. It causes conflicts" | ||
//#endif | ||
|
||
#include <winsock2.h> | ||
#include <windows.h> | ||
#include <ws2tcpip.h> | ||
// WIN32 API does not have sleep() and usleep(), Although MINGW does. | ||
#ifdef __MINGW32__ | ||
#include <unistd.h> | ||
#else | ||
extern "C" inline int sleep(int seconds) { Sleep(seconds * 1000); return 0; } | ||
#endif | ||
#else | ||
#include <netdb.h> | ||
#include <sys/socket.h> | ||
#include <netinet/in.h> | ||
#include <arpa/inet.h> | ||
#include <unistd.h> | ||
#endif | ||
|
||
#include <string> | ||
|
||
// NOTE: MINGW currently does not include support for inet_pton(). See | ||
// http://mingw.5.n7.nabble.com/Win32API-request-for-new-functions-td22029.html | ||
// Even if it did support inet_pton(), it is only available on Windows Vista | ||
// and later. Since we need to support WindowsXP and later in ORTHRUS. Many | ||
// customers still use it, we will need to implement using something like | ||
// WSAStringToAddress() which is available on Windows95 and later. | ||
// Support for IPv6 was added on WindowsXP SP1. | ||
// Header: winsock2.h | ||
// Implementation: ws2_32.dll | ||
// See: | ||
// https://msdn.microsoft.com/en-us/library/windows/desktop/ms742214(v=vs.85).aspx | ||
// http://www.winsocketdotnetworkprogramming.com/winsock2programming/winsock2advancedInternet3b.html | ||
#ifdef __MINGW32__ | ||
static inline int inet_pton(int af, const char * src, void * dst) | ||
{ | ||
struct sockaddr_storage ss; | ||
int ssSize = sizeof(ss); | ||
char srcCopy[INET6_ADDRSTRLEN + 1]; | ||
|
||
ZeroMemory(&ss, sizeof(ss)); | ||
|
||
// work around stupid non-const API | ||
strncpy(srcCopy, src, INET6_ADDRSTRLEN + 1); | ||
srcCopy[INET6_ADDRSTRLEN] = '\0'; | ||
|
||
if (WSAStringToAddress( | ||
srcCopy, af, NULL, (struct sockaddr *)&ss, &ssSize) != 0) | ||
{ | ||
return 0; | ||
} | ||
|
||
switch (af) | ||
{ | ||
case AF_INET : | ||
{ | ||
*(struct in_addr *)dst = ((struct sockaddr_in *)&ss)->sin_addr; | ||
return 1; | ||
} | ||
case AF_INET6 : | ||
{ | ||
*(struct in6_addr *)dst = ((struct sockaddr_in6 *)&ss)->sin6_addr; | ||
return 1; | ||
} | ||
default : | ||
{ | ||
// No-Op | ||
} | ||
} | ||
|
||
return 0; | ||
} | ||
#endif // __MINGW__ | ||
|
||
inline sockaddr_in CreateAddrInet(const std::string& name, unsigned short port) | ||
{ | ||
sockaddr_in sa; | ||
memset(&sa, 0, sizeof sa); | ||
sa.sin_family = AF_INET; | ||
sa.sin_port = htons(port); | ||
|
||
if ( name != "" ) | ||
{ | ||
if ( inet_pton(AF_INET, name.c_str(), &sa.sin_addr) == 1 ) | ||
return sa; | ||
|
||
// XXX RACY!!! Use getaddrinfo() instead. Check portability. | ||
// Windows/Linux declare it. | ||
// See: | ||
// http://www.winsocketdotnetworkprogramming.com/winsock2programming/winsock2advancedInternet3b.html | ||
hostent* he = gethostbyname(name.c_str()); | ||
if ( !he || he->h_addrtype != AF_INET ) | ||
throw std::invalid_argument("SrtSource: host not found: " + name); | ||
|
||
sa.sin_addr = *(in_addr*)he->h_addr_list[0]; | ||
} | ||
|
||
return sa; | ||
} |
Oops, something went wrong.