From dc9a5fd18baffc95ba66b668bf93ca66e2fdfef4 Mon Sep 17 00:00:00 2001 From: Alessandro Pignotti Date: Mon, 14 Mar 2011 13:27:53 +0100 Subject: [PATCH] Add ENABLE_RTMP compile time switch --- CMakeLists.txt | 8 +++++--- backends/rtmputils.cpp | 17 ++++++++++++----- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 04a500b1bc..516d96416d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -233,9 +233,11 @@ IF(ENABLE_CURL) ADD_DEFINITIONS(-DENABLE_CURL) ENDIF(ENABLE_CURL) -#TODO: add ENABLE_RTMP switch -pkg_check_modules(RTMP REQUIRED librtmp) -SET(OPTIONAL_LIBRARIES ${OPTIONAL_LIBRARIES} ${RTMP_LIBRARIES}) +IF(ENABLE_RTMP) + pkg_check_modules(RTMP REQUIRED librtmp) + SET(OPTIONAL_LIBRARIES ${OPTIONAL_LIBRARIES} ${RTMP_LIBRARIES}) + ADD_DEFINITIONS(-DENABLE_RTMP) +ENDIF(ENABLE_RTMP) IF(ENABLE_DEBIAN_ALTERNATIVES) SET(PLUGIN_DIRECTORY ${PRIVATELIBDIR}) diff --git a/backends/rtmputils.cpp b/backends/rtmputils.cpp index c50a58b253..b44acd568a 100644 --- a/backends/rtmputils.cpp +++ b/backends/rtmputils.cpp @@ -18,10 +18,11 @@ **************************************************************************/ #include "rtmputils.h" -#include #include "swf.h" -#include +#ifdef ENABLE_RTMP +#include +#endif using namespace lightspark; using namespace std; @@ -39,6 +40,7 @@ void RTMPDownloader::threadAbort() void RTMPDownloader::execute() { +#ifdef ENABLE_RTMP //Allocate and initialize the RTMP context RTMP* rtmpCtx=RTMP_Alloc(); RTMP_Init(rtmpCtx); @@ -56,7 +58,6 @@ void RTMPDownloader::execute() int ret=RTMP_SetupURL(rtmpCtx, urlBuf); cout << "Setup " << ret << endl; //TODO: add return if fails - //ofstream f("puppa.flv"); ret=RTMP_Connect(rtmpCtx, NULL); cout << "Connect " << ret << endl; ret=RTMP_ConnectStream(rtmpCtx, 0); @@ -73,10 +74,16 @@ void RTMPDownloader::execute() if(ret==0 || hasFailed() || aborting) break; append((uint8_t*)buf,ret); - //f.write(buf,ret); } - //f.close(); RTMP_Close(rtmpCtx); RTMP_Free(rtmpCtx); delete[] urlBuf; +#else + //ENABLE_RTMP not defined + LOG(LOG_ERROR,_("NET: RTMP not enabled in this build. Downloader will always fail.")); + setFailed(); + return; +#endif + //Notify the downloader no more data should be expected + setFinished(); }