From: hyc Date: Thu, 17 Dec 2009 01:39:51 +0000 (+0000) Subject: More namespace cleanup X-Git-Tag: v2.4~405 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e091ec9a007347adcb3a06043ea10f83bb70c7eb;p=rtmpdump More namespace cleanup git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@81 400ebc74-4327-4243-bc38-086b20814532 --- diff --git a/Makefile b/Makefile index 5f56562..5170a57 100644 --- a/Makefile +++ b/Makefile @@ -47,5 +47,5 @@ log.o: log.c log.h Makefile parseurl.o: parseurl.c parseurl.h log.h Makefile streams.o: streams.cpp rtmp.h log.h Makefile rtmp.o: rtmp.c rtmp.h handshake.h dh.h log.h amf.h Makefile -amf.o: amf.c amf.h bytes.h Makefile +amf.o: amf.c amf.h bytes.h log.h Makefile rtmpdump.o: rtmpdump.c rtmp.h log.h amf.h Makefile diff --git a/log.c b/log.c index 7a07e7b..b6be0f4 100644 --- a/log.c +++ b/log.c @@ -27,11 +27,11 @@ #define MAX_PRINT_LEN 2048 -extern int debuglevel; +int debuglevel = LOGERROR; static int neednl; -FILE *fmsg; +static FILE *fmsg; void LogSetOutput(FILE *file) { diff --git a/log.h b/log.h index 85eb1bf..afd67c5 100644 --- a/log.h +++ b/log.h @@ -27,8 +27,8 @@ #ifdef __cplusplus extern "C" { #endif -// Enable this to get full debugging output -//#define _DEBUG +/* Enable this to get full debugging output */ +/* #define _DEBUG */ #define CRYPTO #ifdef _DEBUG @@ -42,6 +42,16 @@ extern "C" { #define LOGDEBUG 4 #define LOGALL 5 +#define Log AMF_Log +#define LogHex AMF_LogHex +#define LogHexString AMF_LogHexString +#define LogPrintf AMF_LogPrintf +#define LogSetOutput AMF_LogSetOutput +#define LogStatus AMF_LogStatus +#define debuglevel AMF_debuglevel + +extern int debuglevel; + void LogSetOutput(FILE *file); void LogPrintf(const char *format, ...); void LogStatus(const char *format, ...); diff --git a/rtmp.c b/rtmp.c index bd8e927..3838428 100644 --- a/rtmp.c +++ b/rtmp.c @@ -57,9 +57,9 @@ static const int packetSize[] = { 12, 8, 4, 1 }; #define RTMP_PACKET_SIZE_SMALL 2 #define RTMP_PACKET_SIZE_MINIMUM 3 -extern bool bCtrlC; +bool RTMP_ctrlC; -char RTMPProtocolStrings[][7] = { +const char RTMPProtocolStrings[][7] = { "RTMP", "RTMPT", "RTMPS", @@ -68,7 +68,7 @@ char RTMPProtocolStrings[][7] = { "RTMFP" }; -char RTMPProtocolStringsLower[][7] = { +const char RTMPProtocolStringsLower[][7] = { "rtmp", "rtmpt", "rtmps", @@ -841,7 +841,7 @@ WriteN(RTMP * r, const char *buffer, int n) Log(LOGERROR, "%s, RTMP send error %d (%d bytes)", __FUNCTION__, sockerr, n); - if (sockerr == EINTR && !bCtrlC) + if (sockerr == EINTR && !RTMP_ctrlC) continue; RTMP_Close(r); @@ -2188,7 +2188,7 @@ again: int sockerr = GetSockError(); Log(LOGDEBUG, "%s, recv returned %d. GetSockError(): %d (%s)", __FUNCTION__, nBytes, sockerr, strerror(sockerr)); - if (sockerr == EINTR && !bCtrlC) + if (sockerr == EINTR && !RTMP_ctrlC) goto again; if (sockerr == EWOULDBLOCK || sockerr == EAGAIN) diff --git a/rtmp.h b/rtmp.h index 5246c1f..affe2d1 100644 --- a/rtmp.h +++ b/rtmp.h @@ -56,7 +56,8 @@ #define RTMP_CHANNELS 65600 -extern char RTMPProtocolStringsLower[][7]; +extern const char RTMPProtocolStringsLower[][7]; +extern bool RTMP_ctrlC; int32_t RTMP_GetTime(); diff --git a/rtmpdump.c b/rtmpdump.c index f35fc22..4819612 100644 --- a/rtmpdump.c +++ b/rtmpdump.c @@ -45,8 +45,6 @@ #include "log.h" #include "parseurl.h" -int debuglevel = 1; - #define RTMPDUMP_VERSION "v2.0" #define RD_SUCCESS 0 @@ -89,12 +87,11 @@ uint32_t nIgnoredFrameCounter = 0; #define MAX_IGNORED_FRAMES 50 FILE *file = 0; -bool bCtrlC = false; void sigIntHandler(int sig) { - bCtrlC = true; + RTMP_ctrlC = true; LogPrintf("Caught signal: %d, cleaning up, just a second...\n", sig); // ignore all these signals now and let the connection close signal(SIGINT, SIG_IGN); @@ -1015,7 +1012,7 @@ Download(RTMP * rtmp, // connected RTMP object #endif } - while (!bCtrlC && nRead > -1 && RTMP_IsConnected(rtmp)); + while (!RTMP_ctrlC && nRead > -1 && RTMP_IsConnected(rtmp)); free(buffer); Log(LOGDEBUG, "WriteStream returned: %d", nRead); @@ -1038,7 +1035,7 @@ Download(RTMP * rtmp, // connected RTMP object if (nRead == -3) return RD_SUCCESS; - if ((duration > 0 && *percent < 99.9) || bCtrlC || nRead < 0 + if ((duration > 0 && *percent < 99.9) || RTMP_ctrlC || nRead < 0 || RTMP_IsTimedout(rtmp)) { return RD_INCOMPLETE; @@ -1580,7 +1577,7 @@ main(int argc, char **argv) netstackdump_read = fopen("netstackdump_read", "wb"); #endif - while (!bCtrlC) + while (!RTMP_ctrlC) { Log(LOGDEBUG, "Setting buffer time to: %dms", bufferTime); RTMP_SetBufferMS(&rtmp, bufferTime);