Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Created TCP/SRT tunnel #504

Merged
merged 9 commits into from
May 2, 2019
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ endif()

message(STATUS "BUILD TYPE: ${CMAKE_BUILD_TYPE}")

getVarsWith(ENFORCE_ enforcers)
foreach(ef ${enforcers})
set (val ${${ef}})
if (NOT val STREQUAL "")
set(val =${val})
endif()
string(LENGTH ENFORCE_ pflen)
string(LENGTH ${ef} eflen)
math(EXPR alen ${eflen}-${pflen})
string(SUBSTRING ${ef} ${pflen} ${alen} ef)
message(STATUS "FORCED PP VARIABLE: ${ef}${val}")
add_definitions(-D${ef}${val})
endforeach()

# option defaults
# XXX CHANGE: Logging is enabled now by default,
# use ENABLE_LOGGING=NO in cmake or
Expand Down Expand Up @@ -691,8 +705,8 @@ macro(srt_make_application name)
target_link_libraries(${name} ${srt_link_library})
endmacro()

macro(srt_add_application name sources)
srt_add_program(${name} apps/${name}.cpp ${sources})
macro(srt_add_application name) # ARGN=sources...
srt_add_program(${name} apps/${name}.cpp ${ARGN})
srt_make_application(${name})
install(TARGETS ${name} RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
endmacro()
Expand Down Expand Up @@ -732,8 +746,10 @@ if (ENABLE_APPS)
# FIXME: with MINGW, it fails to build apps that require C++11
# https://github.com/Haivision/srt/issues/177
message(WARNING "On MinGW, some C++11 apps are blocked due to lacking proper C++11 headers for <thread>. FIX IF POSSIBLE.")
else()
else()
srt_add_application(srt-multiplex ${VIRTUAL_srtsupport})
srt_add_application(srt-tunnel ${VIRTUAL_srtsupport})
target_compile_definitions(srt-tunnel PUBLIC -DSRT_ENABLE_VERBOSE_LOCK)
endif()

if (ENABLE_TESTING)
Expand Down Expand Up @@ -764,7 +780,6 @@ if (ENABLE_APPS)
srt_add_testprogram(srt-test-live)
srt_make_application(srt-test-live)

# Still portability problem on Windows
srt_add_testprogram(srt-test-file)
srt_make_application(srt-test-file)

Expand Down
7 changes: 5 additions & 2 deletions apps/logsupport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ srt_logging::LogLevel::type SrtParseLogLevel(string level)
return LogLevel::type(i->second);
}

set<srt_logging::LogFA> SrtParseLogFA(string fa)
set<srt_logging::LogFA> SrtParseLogFA(string fa, set<string>* punknown)
{
using namespace srt_logging;

Expand Down Expand Up @@ -126,7 +126,10 @@ set<srt_logging::LogFA> SrtParseLogFA(string fa)
string* names_p = find(names, names + names_s, fa);
if ( names_p == names + names_s )
{
cerr << "ERROR: Invalid log functional area spec: '" << fa << "' - skipping\n";
if (punknown)
punknown->insert(fa); // If requested, add it back silently
else
cerr << "ERROR: Invalid log functional area spec: '" << fa << "' - skipping\n";
continue;
}

Expand Down
2 changes: 1 addition & 1 deletion apps/logsupport.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "../srtcore/logging_api.h"

srt_logging::LogLevel::type SrtParseLogLevel(std::string level);
std::set<srt_logging::LogFA> SrtParseLogFA(std::string fa);
std::set<srt_logging::LogFA> SrtParseLogFA(std::string fa, std::set<std::string>* punknown = nullptr);

SRT_API extern std::map<std::string, int> srt_level_names;

Expand Down
74 changes: 33 additions & 41 deletions apps/socketoptions.cpp
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -26,55 +26,47 @@ SocketOption::Mode SrtConfigurePre(SRTSOCKET socket, string host, map<string, st
vector<string> dummy;
vector<string>& fails = failures ? *failures : dummy;

if ( options.count("passphrase") )
SocketOption::Mode mode = SocketOption::CALLER;
if (host != "--") // for this value it will always return CALLER
maxsharabayko marked this conversation as resolved.
Show resolved Hide resolved
{
/*
// Insert default
if ( options.count("pbkeylen") == 0 )
string modestr = "default";

if ( options.count("mode") )
{
options["pbkeylen"] = "16"; // m_output_direction ? "16" : "0";
maxsharabayko marked this conversation as resolved.
Show resolved Hide resolved
modestr = options["mode"];
}
*/
}

SocketOption::Mode mode;
string modestr = "default";

if ( options.count("mode") )
{
modestr = options["mode"];
}

if ( modestr == "client" || modestr == "caller" )
{
mode = SocketOption::CALLER;
}
else if ( modestr == "server" || modestr == "listener" )
{
mode = SocketOption::LISTENER;
}
else if ( modestr == "default" )
{
// Use the following convention:
// 1. Server for source, Client for target
// 2. If host is empty, then always server.
if ( host == "" )
if ( modestr == "client" || modestr == "caller" )
{
mode = SocketOption::CALLER;
}
else if ( modestr == "server" || modestr == "listener" )
{
mode = SocketOption::LISTENER;
//else if ( !dir_output )
//mode = "server";
else
}
else if ( modestr == "default" )
{
// Host is given, so check also "adapter"
if ( options.count("adapter") )
mode = SocketOption::RENDEZVOUS;
// Use the following convention:
// 1. Server for source, Client for target
// 2. If host is empty, then always server.
if ( host == "" )
mode = SocketOption::LISTENER;
//else if ( !dir_output )
//mode = "server";
else
mode = SocketOption::CALLER;
{
// Host is given, so check also "adapter"
if ( options.count("adapter") )
mode = SocketOption::RENDEZVOUS;
else
mode = SocketOption::CALLER;
}
}
else
{
mode = SocketOption::FAILURE;
fails.push_back("mode");
}
}
else
{
mode = SocketOption::FAILURE;
fails.push_back("mode");
}

bool all_clear = true;
Expand Down
Loading