Skip to content
This repository has been archived by the owner on Jul 21, 2020. It is now read-only.

Commit

Permalink
fixed issue with rr dns that resulted in connections going to one ing…
Browse files Browse the repository at this point in the history
…ets while media went to another
  • Loading branch information
sslivins committed Aug 21, 2016
1 parent 02b0f4c commit 97ca138
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 24 deletions.
48 changes: 30 additions & 18 deletions build_scripts/build_tachyon_windows_vs.bat
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
REM check for cef binary
REM check for dependencies (ffmpeg, etc)
SET build_config=Release
SET obs_version=1.2.11
SET obs_version=1.2.14
SET cef_binary_dir=C:\beam\cef_binary
SET cef_release_dir=C:\beam\obs-browser-1.22
SET coredeps=C:\beam\tachyon_deps
SET QTDIR64=C:\Qt\5.6\msvc2015_64
SET QTDIR32=C:\Qt\5.6\msvc2015
SET PATH=%PATH%;C:\Program Files (x86)\MSBuild\14.0\Bin;C:\Program Files (x86)\CMake\bin
SET DepsPath32=%coredeps%\win32
SET DepsPath64=%coredeps%\win64
SET FFmpegPath64=%coredeps%\win64
SET x264Path64=%coredeps%\win64
SET curlPath64=%coredeps%\win64
SET build32=
SET build64=
SET package=
if "%1" == "all" (
SET build32=true
SET build64=true
SET package=true
)
if "%1" == "win64" (
SET build64=true
)
echo "building CEF browser plugin"
REM call python automate-git.py --download-dir=../.. --branch=2623 --x64-build
REM SET cef_root_dir=%cd%\cef
pushd .
cd ..
call git submodule update --init
cd ..
REM windows 64 bit binary: https://cefbuilds.com/#branch_2623
REM pushd .
REM cd %cef_binary_dir%
REM mkdir build
REM cd build
REM cmake -G "Visual Studio 14 2015 Win64" ..
REM msbuild /p:Configuration=%build_config%,Platform=x64 ALL_BUILD.vcxproj || exit /b
REM current CEF plugin expects this one folder down
REM copy libcef_dll\%build_config%\libcef_dll_wrapper.lib libcef_dll\
REM popd
echo "building libftl"
call git clone https://github.com/WatchBeam/ftl-sdk.git
cd ftl-sdk
Expand All @@ -39,8 +37,22 @@ SET ftl_lib_dir=%cd%\%build_config%\ftl.lib
SET ftl_inc_dir=%cd%\..\libftl
popd
REM cmake -G "Visual Studio 14 2015 Win64" -DOBS_VERSION_OVERRIDE=%obs_version% -DFTLSDK_LIB=%ftl_lib_dir% -DFTLSDK_INCLUDE_DIR=%ftl_inc_dir% -DCEF_ROOT_DIR=%cef_binary_dir% -DCOPY_DEPENDENCIES=true ..
cmake -G "Visual Studio 14 2015 Win64" -DOBS_VERSION_OVERRIDE=%obs_version% -DFTLSDK_LIB=%ftl_lib_dir% -DFTLSDK_INCLUDE_DIR=%ftl_inc_dir% -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true ..
call msbuild /t:Rebuild /p:Configuration=%build_config%,Platform=x64 ALL_BUILD.vcxproj || exit /b
REM cmake -G "Visual Studio 14 2015 Win64" -DOBS_VERSION_OVERRIDE=%obs_version% -DFTLSDK_LIB=%ftl_lib_dir% -DFTLSDK_INCLUDE_DIR=%ftl_inc_dir% -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true ..
REM call msbuild /p:Configuration=%build_config%,Platform=x64 ALL_BUILD.vcxproj || exit /b
REM cmake -G "Visual Studio 14 2015" -DOBS_VERSION_OVERRIDE=%obs_version% -DFTLSDK_LIB=%ftl_lib_dir% -DFTLSDK_INCLUDE_DIR=%ftl_inc_dir% -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true ..
REM call msbuild /p:Configuration=%build_config% ALL_BUILD.vcxproj || exit /b
if defined build64 (
rmdir CMakeFiles /s /q
del CMakeCache.txt
cmake -G "Visual Studio 14 2015 Win64" -DOBS_VERSION_OVERRIDE=%obs_version% -DFTLSDK_LIB=%ftl_lib_dir% -DFTLSDK_INCLUDE_DIR=%ftl_inc_dir% -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true ..
call msbuild /p:Configuration=%build_config%,Platform=x64 ALL_BUILD.vcxproj || exit /b
)
if defined build32 (
rmdir CMakeFiles /s /q
del CMakeCache.txt
cmake -G "Visual Studio 14 2015" -DOBS_VERSION_OVERRIDE=%obs_version% -DFTLSDK_LIB=%ftl_lib_dir% -DFTLSDK_INCLUDE_DIR=%ftl_inc_dir% -DCOPIED_DEPENDENCIES=false -DCOPY_DEPENDENCIES=true ..
call msbuild /p:Configuration=%build_config% ALL_BUILD.vcxproj
)
echo "Building FTL-Express"
pushd .
cd ..\..
Expand Down
8 changes: 7 additions & 1 deletion build_scripts/tachyon_windows_installer.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
; HM NIS Edit Wizard helper defines
!define PRODUCT_NAME "Tachyon"
!define DEFAULT_INST_DIR "$PROGRAMFILES\${PRODUCT_NAME}"
!define PRODUCT_VERSION "1.2.11"
!define PRODUCT_VERSION "1.2.14"
!define PRODUCT_PUBLISHER "Beam Interactive"
!define PRODUCT_WEB_SITE "http://beam.pro"
!define PRODUCT_DIR_REGKEY "Software\Microsoft\Windows\CurrentVersion\App Paths\tachyon64.exe"
Expand Down Expand Up @@ -614,6 +614,9 @@ Section "data" SEC04
File "rundir\Release\data\obs-plugins\win-capture\get-graphics-offsets64.exe"
File "rundir\Release\data\obs-plugins\win-capture\graphics-hook64.dll"
File "rundir\Release\data\obs-plugins\win-capture\inject-helper64.exe"
File "rundir\Release\data\obs-plugins\win-capture\get-graphics-offsets32.exe"
File "rundir\Release\data\obs-plugins\win-capture\graphics-hook32.dll"
File "rundir\Release\data\obs-plugins\win-capture\inject-helper32.exe"
SetOutPath "$INSTDIR\data\obs-plugins\win-capture\locale"
File "rundir\Release\data\obs-plugins\win-capture\locale\ar-SA.ini"
File "rundir\Release\data\obs-plugins\win-capture\locale\ca-ES.ini"
Expand Down Expand Up @@ -1112,6 +1115,9 @@ Section Uninstall
Delete "$INSTDIR\data\obs-plugins\win-capture\inject-helper64.exe"
Delete "$INSTDIR\data\obs-plugins\win-capture\graphics-hook64.dll"
Delete "$INSTDIR\data\obs-plugins\win-capture\get-graphics-offsets64.exe"
Delete "$INSTDIR\data\obs-plugins\win-capture\inject-helper32.exe"
Delete "$INSTDIR\data\obs-plugins\win-capture\graphics-hook32.dll"
Delete "$INSTDIR\data\obs-plugins\win-capture\get-graphics-offsets32.exe"
Delete "$INSTDIR\data\obs-plugins\text-freetype2\text_default.effect"
Delete "$INSTDIR\data\obs-plugins\text-freetype2\locale\zh-TW.ini"
Delete "$INSTDIR\data\obs-plugins\text-freetype2\locale\zh-CN.ini"
Expand Down
44 changes: 39 additions & 5 deletions plugins/obs-ffmpeg/obs-ffmpeg-output.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@
#include <ftl/ftl.h>

#ifdef _WIN32
#include <winsock2.h>
#include <ws2tcpip.h>
#pragma comment(lib, "ws2_32.lib")
#include <windows.h>
#include <process.h>
#include <Shellapi.h>
Expand Down Expand Up @@ -66,6 +69,7 @@ struct ffmpeg_cfg {

/* FTL specific fields */
const char *ingest_location;
char ingest_ip[20];
uint32_t channel_id;
char stream_key[2048];
uint32_t audio_ssrc;
Expand Down Expand Up @@ -180,10 +184,39 @@ int map_ftl_error_to_obs_error(int status) {
return ftl_to_obs_error_code;
}

static int lookup_ingest_ip(const char *ingest_location, char *ingest_ip){
struct hostent *remoteHost;
struct in_addr addr;
int retval = -1;
ingest_ip[0] = '\0';

remoteHost = gethostbyname(ingest_location);

if(remoteHost) {
int i = 0;
if (remoteHost->h_addrtype == AF_INET)
{
while (remoteHost->h_addr_list[i] != 0) {
addr.s_addr = *(u_long *) remoteHost->h_addr_list[i++];
blog(LOG_INFO, "IP Address #%d of ingest is: %s\n", i, inet_ntoa(addr));

/*only use the first ip found*/
if(strlen(ingest_ip) == 0){
strcpy(ingest_ip, inet_ntoa(addr));
retval = 0;
}
}
}
}

return retval;
}

ftl_status_t attempt_ftl_connection(struct ffmpeg_output *output, struct ffmpeg_cfg config)
{
ftl_status_t status_code;


/* Use Charon to autheticate and configure muxer settings */
ftl_init();
ftl_register_log_handler(log_libftl_messages);
Expand All @@ -192,9 +225,9 @@ ftl_status_t attempt_ftl_connection(struct ffmpeg_output *output, struct ffmpeg_
if (status_code != FTL_SUCCESS) {
blog(LOG_WARNING, "Failed to initialize stream configuration: errno %d\n", status_code);
return OBS_OUTPUT_ERROR;
}
}

ftl_set_ingest_location(output->stream_config, config.ingest_location);
ftl_set_ingest_location(output->stream_config, config.ingest_ip);
ftl_set_authetication_key(output->stream_config, config.channel_id, config.stream_key);

#ifdef _FTL_USE_H264
Expand Down Expand Up @@ -1176,6 +1209,7 @@ static int try_connect(struct ffmpeg_output *output)
settings = obs_output_get_settings(output->output);
memset(&config, 0, sizeof(config));
config.ingest_location = get_string_or_null(settings, "url");
lookup_ingest_ip(config.ingest_location, config.ingest_ip);
config.format_name = get_string_or_null(settings, "format_name");
config.format_mime_type = get_string_or_null(settings,
"format_mime_type");
Expand All @@ -1189,7 +1223,7 @@ static int try_connect(struct ffmpeg_output *output)
full_streamkey = get_string_or_null(settings, "ftl_stream_key");

/* Build the RTP command line */
if (config.ingest_location == NULL) {
if (config.ingest_location == NULL || strlen(config.ingest_ip) == 0) {
blog(LOG_WARNING, "ingest location blank");
return OBS_OUTPUT_ERROR;
}
Expand Down Expand Up @@ -1305,7 +1339,7 @@ static int try_connect(struct ffmpeg_output *output)
/* Glue together the ingest URL */

#ifdef _WIN32
swprintf(ftl_ingest_arg, sizeof(ftl_ingest_arg)/sizeof(wchar_t), L"-rtpingestaddr=%hs:8082", config.ingest_location);
swprintf(ftl_ingest_arg, sizeof(ftl_ingest_arg)/sizeof(wchar_t), L"-rtpingestaddr=%hs:8082", config.ingest_ip);
blog(LOG_WARNING, "FTL ingest args are: %S\n", ftl_ingest_arg);
ZeroMemory( &output->ShExecInfo, sizeof(output->ShExecInfo) );
output->ShExecInfo.cbSize = sizeof(SHELLEXECUTEINFO);
Expand All @@ -1320,7 +1354,7 @@ static int try_connect(struct ffmpeg_output *output)
ShellExecuteEx(&output->ShExecInfo);
SetPriorityClass(output->ShExecInfo.hProcess, HIGH_PRIORITY_CLASS);
#else
snprintf(ftl_ingest_arg, sizeof(ftl_ingest_arg), "-rtpingestaddr=%s:8082", config.ingest_location);
snprintf(ftl_ingest_arg, sizeof(ftl_ingest_arg), "-rtpingestaddr=%s:8082", config.ingest_ip);
blog(LOG_WARNING, "FTL ingest args are: %s\n", ftl_ingest_arg);
/* print error message if fork() fails */
blog(LOG_WARNING, "Forking Process\n");
Expand Down

0 comments on commit 97ca138

Please sign in to comment.