Skip to content

Commit

Permalink
Some fixes to make this build on Linux, fixed a few other lil things.
Browse files Browse the repository at this point in the history
  • Loading branch information
Stephen Conley committed May 4, 2017
1 parent b1f8abe commit 0ea0f6a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
8 changes: 4 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ set (CMAKE_CXX_STANDARD 11)
set (rtmptd_VERSION_MAJOR 1)
set (rtmptd_VERSION_MINOR 0)

# CFlags ... find civetweb, boost, tbb
set (CMAKE_CXX_FLAGS "-I../../civetweb-1.9.1/include -g")
# CFlags ... find civetweb, boost
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -I../../civetweb/include")

# Linker flags ... civetweb + tbb
set (CMAKE_EXE_LINKER_FLAGS "-L../../civetweb-1.9.1 -lcivetweb -ltbb")
# Find Civet
find_library(CIVET_LIBRARY NAMES civetweb HINTS "../civetweb")

# Includes
include_directories(src)
Expand Down
1 change: 1 addition & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
add_executable(rtmptd main.cpp)
target_link_libraries(rtmptd ${CIVET_LIBRARY} m rt dl pthread)
24 changes: 18 additions & 6 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
*/

#include <string>
#include <cstring>
#include <chrono>
#include <unordered_map>
#include <stdexcept>
Expand Down Expand Up @@ -688,10 +689,11 @@ int main(int argc, char** argv, char** envp)
return -1;
}

options = (const char**)malloc(sizeof(const char*) * (argc));
int j = 0;

// These are civet arguments.
if(argc > 3) {
options = (const char**)malloc(sizeof(const char*) * (argc-2));
int j = 0;

// Parse 'em
for(int i = 3; i < argc; i+=2) {
Expand All @@ -700,24 +702,31 @@ int main(int argc, char** argv, char** envp)
struct group* myGroup = getgrnam(argv[i+1]);

if(!myGroup) {
std::cerr << "Unknown group: " << argv[i+1];
std::cerr << "Unknown group: " << argv[i+1]
<< std::endl;
return -1;
}

if(setgid(myGroup->gr_gid) < 0) {
perror("Could not set group");
return -1;
}
} else if(!strcmp(argv[i], "enable_keep_alive")) {
// ignore this parameter -- we will add it
continue;
} else {
options[j] = argv[i];
options[++j] = argv[i+1];
j++;
}
}

options[j] = NULL;
}

// add keep alive
options[j] = "enable_keep_alive";
options[++j] = "yes";
options[++j] = NULL;

// init library - use IPv6
mg_init_library(8);

Expand All @@ -734,7 +743,7 @@ int main(int argc, char** argv, char** envp)
server = new RTMPServer(argv[1], argv[2]);
} catch(std::runtime_error& e) {
// Probably couldn't resolve host.
std::cerr << e.what();
std::cerr << e.what() << std::endl;
mg_stop(ctx);
mg_exit_library();
return (int) -1;
Expand Down Expand Up @@ -764,5 +773,8 @@ int main(int argc, char** argv, char** envp)

// Un-init
mg_exit_library();

free(options);

return (int) 0;
}

0 comments on commit 0ea0f6a

Please sign in to comment.