diff --git a/Makefile b/Makefile index 4e48a2e..62b2fb4 100644 --- a/Makefile +++ b/Makefile @@ -2,18 +2,10 @@ # Makefile for IPTV plugin # -# Debugging on/off - -#IPTV_DEBUG = 1 - # Default shell for EXT protocol #IPTV_EXTSHELL = /bin/bash -# Strip debug symbols? Set eg. to /bin/true if not - -STRIP = strip - # The official name of this plugin. # This name will be used in the '-P...' option of VDR to load the plugin. # By default the main source file also carries this name. @@ -41,6 +33,7 @@ TMPDIR ?= /tmp export CFLAGS = $(call PKGCFG,cflags) export CXXFLAGS = $(call PKGCFG,cxxflags) +STRIP ?= /bin/true ### The version number of VDR's plugin API: @@ -69,10 +62,6 @@ INCLUDES += DEFINES += -DPLUGIN_NAME_I18N='"$(PLUGIN)"' -ifdef IPTV_DEBUG -DEFINES += -DDEBUG -endif - ifdef IPTV_EXTSHELL DEFINES += -DEXTSHELL='"$(IPTV_EXTSHELL)"' endif @@ -139,9 +128,7 @@ install-i18n: $(I18Nmsgs) $(SOFILE): $(OBJS) $(CXX) $(CXXFLAGS) $(LDFLAGS) -shared $(OBJS) $(LIBS) -o $@ -ifndef IPTV_DEBUG @$(STRIP) $@ -endif install-lib: $(SOFILE) install -D $^ $(DESTDIR)$(LIBDIR)/$^.$(APIVERSION) diff --git a/log.h b/log.h index 4082b77..37f463d 100644 --- a/log.h +++ b/log.h @@ -26,7 +26,7 @@ #define debug6(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug6) ? dsyslog("IPTV6: " x) : void() ) // 0x0040: TBD #define debug7(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug7) ? dsyslog("IPTV7: " x) : void() ) -// 0x0080: TBD +// 0x0080: CURL #define debug8(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug8) ? dsyslog("IPTV8: " x) : void() ) // 0x0100: TBD #define debug9(x...) void( IptvConfig.IsTraceMode(cIptvConfig::eTraceModeDebug9) ? dsyslog("IPTV9: " x) : void() ) diff --git a/protocolcurl.c b/protocolcurl.c index 657dc00..d286218 100644 --- a/protocolcurl.c +++ b/protocolcurl.c @@ -55,6 +55,35 @@ cIptvProtocolCurl::~cIptvProtocolCurl() DELETE_POINTER(ringBufferM); } +int cIptvProtocolCurl::DebugCallback(CURL *handleP, curl_infotype typeP, char *dataP, size_t sizeP, void *userPtrP) +{ + cIptvProtocolCurl *obj = reinterpret_cast(dataP); + + if (obj) { + switch (typeP) { + case CURLINFO_TEXT: + debug8("%s INFO %.*s", __PRETTY_FUNCTION__, (int)sizeP, dataP); + break; + case CURLINFO_HEADER_IN: + debug8("%s HEAD <<< %.*s", __PRETTY_FUNCTION__, (int)sizeP, dataP); + break; + case CURLINFO_HEADER_OUT: + debug8("%s HEAD >>>\n%.*s", __PRETTY_FUNCTION__, (int)sizeP, dataP); + break; + case CURLINFO_DATA_IN: + debug8("%s DATA <<< %zu", __PRETTY_FUNCTION__, sizeP); + break; + case CURLINFO_DATA_OUT: + debug8("%s DATA >>> %zu", __PRETTY_FUNCTION__, sizeP); + break; + default: + break; + } + } + + return 0; +} + size_t cIptvProtocolCurl::WriteCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP) { cIptvProtocolCurl *obj = reinterpret_cast(dataP); @@ -258,10 +287,10 @@ bool cIptvProtocolCurl::Connect() CURLcode res = CURLE_OK; cString netrc = cString::sprintf("%s/netrc", IptvConfig.GetConfigDirectory()); -#ifdef DEBUG // Verbose output iptv_curl_easy_setopt(handleM, CURLOPT_VERBOSE, 1L); -#endif + iptv_curl_easy_setopt(handleM, CURLOPT_DEBUGFUNCTION, cIptvProtocolCurl::DebugCallback); + iptv_curl_easy_setopt(handleM, CURLOPT_DEBUGDATA, this); // Set callbacks iptv_curl_easy_setopt(handleM, CURLOPT_WRITEFUNCTION, cIptvProtocolCurl::WriteCallback); diff --git a/protocolcurl.h b/protocolcurl.h index fb6e66b..888fb87 100644 --- a/protocolcurl.h +++ b/protocolcurl.h @@ -36,6 +36,7 @@ private: eKeepAliveIntervalMs = 300000 // in milliseconds }; + static int DebugCallback(CURL *handleP, curl_infotype typeP, char *dataP, size_t sizeP, void *userPtrP); static size_t WriteCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP); static size_t WriteRtspCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP); static size_t DescribeCallback(void *ptrP, size_t sizeP, size_t nmembP, void *dataP);