diff --git a/CMakeLists.txt b/CMakeLists.txt index 401f0f5..841bc40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -13,7 +13,7 @@ set(CMAKE_CXX_FLAGS "-std=c++11 -Wall") find_package(Git) if(GIT_FOUND) EXECUTE_PROCESS(COMMAND ${GIT_EXECUTABLE} describe --tags --always --dirty OUTPUT_VARIABLE VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) - STRING(REGEX REPLACE "^v(.*)" "\\1" VERSION ${VERSION}) + STRING(REGEX REPLACE "^v(.*)" "\\1" VERSION "${VERSION}") add_definitions("-DVERSION=\"${VERSION}\"") endif() @@ -54,16 +54,15 @@ endif (ALSA_LIBRARY) # LOG4CPP find_path(LOG4CPP_INCLUDE_DIR log4cpp/Category.hh) -if (NOT LOG4CPP_INCLUDE_DIR) - message(STATUS "Installing liblog4cpp5-dev.") - EXEC_PROGRAM("sudo apt-get install -y liblog4cpp5-dev") -endif (NOT LOG4CPP_INCLUDE_DIR) +if (LOG4CPP_INCLUDE_DIR) + message(STATUS "Log4Cpp available") + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DHAVE_LOG4CPP") + include_directories(${LOG4CPP_INCLUDE_DIR}) -find_path(V4L2_INCLUDE_DIR log4cpp/Category.hh) -include_directories(${LOG4CPP_INCLUDE_DIR}) + find_library(LOG4CPP_LIBRARY log4cpp) + target_link_libraries(${PROJECT_NAME} "${LOG4CPP_LIBRARY}") +endif (LOG4CPP_INCLUDE_DIR) -find_library(LOG4CPP_LIBRARY log4cpp) -target_link_libraries(${PROJECT_NAME} "${LOG4CPP_LIBRARY}") # live555 find_path(LIBLIVE555_INCLUDE_DIR liveMedia/liveMedia.hh) diff --git a/README.md b/README.md index efdf223..c56c241 100644 --- a/README.md +++ b/README.md @@ -24,15 +24,11 @@ The HTTP server support : - HLS - MPEG-DASH -License ------------- -Domain public - Dependencies ------------ - liblivemedia-dev [License LGPL](http://www.live555.com/liveMedia/) > live.2012.01.07 (need StreamReplicator) - - liblog4cpp5-dev [License LGPL](http://log4cpp.sourceforge.net/#license) - libv4l2cpp [Unlicense](https://github.com/mpromonet/libv4l2cpp/blob/master/LICENSE) + - liblog4cpp5-dev [License LGPL](http://log4cpp.sourceforge.net/#license) (optional) Usage ----- diff --git a/inc/SegmentServerMediaSubsession.h b/inc/SegmentServerMediaSubsession.h index cafdcad..2622ca5 100644 --- a/inc/SegmentServerMediaSubsession.h +++ b/inc/SegmentServerMediaSubsession.h @@ -9,6 +9,7 @@ #pragma once +#include #include "UnicastServerMediaSubsession.h" // ----------------------------------------- diff --git a/src/main.cpp b/src/main.cpp index b5572cb..52e1593 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -263,6 +263,17 @@ void decodeDevice(const std::string & device, std::string & videoDev, std::strin getline(is, audioDev); } +std::string getDeviceName(const std::string & devicePath) +{ + std::string deviceName(devicePath); + size_t pos = deviceName.find_last_of('/'); + if (pos != std::string::npos) { + deviceName.erase(0,pos+1); + } + return deviceName; +} + + /* --------------------------------------------------------------------------- ** get a "deviceid" from uevent sys file ** -------------------------------------------------------------------------*/ @@ -338,7 +349,7 @@ std::string getV4l2Alsa(const std::string& v4l2device) { } } - auto deviceId = videodevices.find(basename(v4l2device.c_str())); + auto deviceId = videodevices.find(getDeviceName(v4l2device)); if (deviceId != videodevices.end()) { auto audioDeviceIt = audiodevices.find(deviceId->second); @@ -388,6 +399,10 @@ int main(int argc, char** argv) #ifdef HAVE_ALSA snd_pcm_format_t audioFmt = SND_PCM_FORMAT_S16_BE; #endif + const char* defaultPort = getenv("PORT"); + if (defaultPort != NULL) { + rtspPort = atoi(defaultPort); + } // decode parameters int c = 0; @@ -532,7 +547,7 @@ int main(int argc, char** argv) std::string baseUrl; if (devList.size() > 1) { - baseUrl = basename(videoDev.c_str()); + baseUrl = getDeviceName(videoDev); baseUrl.append("/"); } MPEG2TransportStreamFromESSource* muxer = NULL;