[rtmpdump] r312 - in trunk: librtmp/rtmp.c librtmp/rtmp.h rtmpsrv.c rtmpsuck.c
hyc
subversion at mplayerhq.hu
Mon Mar 8 16:31:33 CET 2010
Author: hyc
Date: Mon Mar 8 16:31:32 2010
New Revision: 312
Log:
Cleanup m_sb compat macros
Modified:
trunk/librtmp/rtmp.c
trunk/librtmp/rtmp.h
trunk/rtmpsrv.c
trunk/rtmpsuck.c
Modified: trunk/librtmp/rtmp.c
==============================================================================
--- trunk/librtmp/rtmp.c Mon Mar 8 16:14:55 2010 (r311)
+++ trunk/librtmp/rtmp.c Mon Mar 8 16:31:32 2010 (r312)
@@ -155,15 +155,15 @@ RTMP_Init(RTMP * r)
r->m_vecChannelsIn[i] = NULL;
r->m_vecChannelsOut[i] = NULL;
}
- r->m_socket = -1;
+ r->m_sb.sb_socket = -1;
RTMP_Close(r);
r->m_nBufferMS = 300;
r->m_fDuration = 0;
- r->m_pBufferStart = NULL;
+ r->m_sb.sb_start = NULL;
r->m_fAudioCodecs = 3191.0;
r->m_fVideoCodecs = 252.0;
r->m_fEncoding = 0.0;
- r->m_bTimedout = false;
+ r->m_sb.sb_timedout = false;
r->m_pausing = 0;
r->m_mediaChannel = 0;
}
@@ -177,13 +177,13 @@ RTMP_GetDuration(RTMP * r)
bool
RTMP_IsConnected(RTMP * r)
{
- return r->m_socket != -1;
+ return r->m_sb.sb_socket != -1;
}
bool
RTMP_IsTimedout(RTMP * r)
{
- return r->m_bTimedout;
+ return r->m_sb.sb_timedout;
}
void
@@ -335,15 +335,15 @@ RTMP_Connect0(RTMP *r, struct sockaddr *
// close any previous connection
RTMP_Close(r);
- r->m_bTimedout = false;
+ r->m_sb.sb_timedout = false;
r->m_pausing = 0;
r->m_fDuration = 0.0;
- r->m_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
- if (r->m_socket != -1)
+ r->m_sb.sb_socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
+ if (r->m_sb.sb_socket != -1)
{
if (connect
- (r->m_socket, service, sizeof(struct sockaddr)) < 0)
+ (r->m_sb.sb_socket, service, sizeof(struct sockaddr)) < 0)
{
int err = GetSockError();
Log(LOGERROR, "%s, failed to connect socket. %d (%s)", __FUNCTION__,
@@ -373,14 +373,14 @@ RTMP_Connect0(RTMP *r, struct sockaddr *
// set timeout
SET_RCVTIMEO(tv, r->Link.timeout);
if (setsockopt
- (r->m_socket, SOL_SOCKET, SO_RCVTIMEO, (char *) &tv, sizeof(tv)))
+ (r->m_sb.sb_socket, SOL_SOCKET, SO_RCVTIMEO, (char *) &tv, sizeof(tv)))
{
Log(LOGERROR, "%s, Setting socket timeout to %ds failed!",
__FUNCTION__, r->Link.timeout);
}
int on = 1;
- setsockopt(r->m_socket, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
+ setsockopt(r->m_sb.sb_socket, IPPROTO_TCP, TCP_NODELAY, &on, sizeof(on));
return true;
}
@@ -586,7 +586,7 @@ RTMP_GetNextMediaPacket(RTMP * r, RTMPPa
if (bHasMediaPacket)
r->m_bPlaying = true;
- else if (r->m_bTimedout && !r->m_pausing)
+ else if (r->m_sb.sb_timedout && !r->m_pausing)
r->m_pauseStamp = r->m_channelTimestamp[r->m_mediaChannel];
return bHasMediaPacket;
@@ -756,7 +756,7 @@ ReadN(RTMP * r, char *buffer, int n)
int nOriginalSize = n;
char *ptr;
- r->m_bTimedout = false;
+ r->m_sb.sb_timedout = false;
#ifdef _DEBUG
memset(buffer, 0, n);
@@ -766,19 +766,19 @@ ReadN(RTMP * r, char *buffer, int n)
while (n > 0)
{
int nBytes = 0, nRead;
- if (r->m_nBufferSize == 0)
+ if (r->m_sb.sb_size == 0)
if (RTMPSockBuf_Fill(&r->m_sb)<1)
{
- if (!r->m_bTimedout)
+ if (!r->m_sb.sb_timedout)
RTMP_Close(r);
return 0;
}
- nRead = ((n < r->m_nBufferSize) ? n : r->m_nBufferSize);
+ nRead = ((n < r->m_sb.sb_size) ? n : r->m_sb.sb_size);
if (nRead > 0)
{
- memcpy(ptr, r->m_pBufferStart, nRead);
- r->m_pBufferStart += nRead;
- r->m_nBufferSize -= nRead;
+ memcpy(ptr, r->m_sb.sb_start, nRead);
+ r->m_sb.sb_start += nRead;
+ r->m_sb.sb_size -= nRead;
nBytes = nRead;
r->m_nBytesIn += nRead;
if (r->m_bSendCounter && r->m_nBytesIn > r->m_nBytesInSent + r->m_nClientBW / 2)
@@ -837,7 +837,7 @@ WriteN(RTMP * r, const char *buffer, int
fwrite(ptr, 1, n, netstackdump);
#endif
- int nBytes = send(r->m_socket, ptr, n, 0);
+ int nBytes = send(r->m_sb.sb_socket, ptr, n, 0);
//Log(LOGDEBUG, "%s: %d\n", __FUNCTION__, nBytes);
if (nBytes < 0)
@@ -1908,7 +1908,7 @@ RTMP_ReadPacket(RTMP * r, RTMPPacket * p
{
char hbuf[RTMP_MAX_HEADER_SIZE] = { 0 }, *header = hbuf;
- Log(LOGDEBUG2, "%s: fd=%d", __FUNCTION__, r->m_socket);
+ Log(LOGDEBUG2, "%s: fd=%d", __FUNCTION__, r->m_sb.sb_socket);
if (ReadN(r, hbuf, 1) == 0)
{
@@ -2205,7 +2205,7 @@ RTMP_SendChunk(RTMP *r, RTMPChunk *chunk
bool wrote;
char hbuf[RTMP_MAX_HEADER_SIZE];
- Log(LOGDEBUG2, "%s: fd=%d, size=%d", __FUNCTION__, r->m_socket, chunk->c_chunkSize);
+ Log(LOGDEBUG2, "%s: fd=%d, size=%d", __FUNCTION__, r->m_sb.sb_socket, chunk->c_chunkSize);
LogHexString(LOGDEBUG2, chunk->c_header, chunk->c_headerSize);
if (chunk->c_chunkSize)
{
@@ -2323,7 +2323,7 @@ RTMP_SendPacket(RTMP * r, RTMPPacket * p
char *buffer = packet->m_body;
int nChunkSize = r->m_outChunkSize;
- Log(LOGDEBUG2, "%s: fd=%d, size=%d", __FUNCTION__, r->m_socket, nSize);
+ Log(LOGDEBUG2, "%s: fd=%d, size=%d", __FUNCTION__, r->m_sb.sb_socket, nSize);
while (nSize+hSize)
{
int wrote;
@@ -2399,10 +2399,10 @@ RTMP_Close(RTMP * r)
int i;
if (RTMP_IsConnected(r))
- closesocket(r->m_socket);
+ closesocket(r->m_sb.sb_socket);
r->m_stream_id = -1;
- r->m_socket = -1;
+ r->m_sb.sb_socket = -1;
r->m_inChunkSize = RTMP_DEFAULT_CHUNKSIZE;
r->m_outChunkSize = RTMP_DEFAULT_CHUNKSIZE;
r->m_nBWCheckCounter = 0;
@@ -2431,7 +2431,7 @@ RTMP_Close(RTMP * r)
r->m_numCalls = 0;
r->m_bPlaying = false;
- r->m_nBufferSize = 0;
+ r->m_sb.sb_size = 0;
#ifdef CRYPTO
if(r->Link.dh)
Modified: trunk/librtmp/rtmp.h
==============================================================================
--- trunk/librtmp/rtmp.h Mon Mar 8 16:14:55 2010 (r311)
+++ trunk/librtmp/rtmp.h Mon Mar 8 16:31:32 2010 (r312)
@@ -204,11 +204,6 @@ typedef struct RTMP
double m_fDuration; // duration of stream in seconds
RTMPSockBuf m_sb;
-#define m_socket m_sb.sb_socket
-#define m_nBufferSize m_sb.sb_size
-#define m_pBufferStart m_sb.sb_start
-#define m_pBuffer m_sb.sb_buf
-#define m_bTimedout m_sb.sb_timedout
} RTMP;
bool RTMP_ParseURL(const char *url, int *protocol, char **host,
Modified: trunk/rtmpsrv.c
==============================================================================
--- trunk/rtmpsrv.c Mon Mar 8 16:14:55 2010 (r311)
+++ trunk/rtmpsrv.c Mon Mar 8 16:31:32 2010 (r312)
@@ -851,7 +851,7 @@ void doServe(STREAMING_SERVER * server,
else
{
RTMP_Init(&rtmp);
- rtmp.m_socket = sockfd;
+ rtmp.m_sb.sb_socket = sockfd;
if (!RTMP_Serve(&rtmp))
{
Log(LOGERROR, "Handshake failed");
Modified: trunk/rtmpsuck.c
==============================================================================
--- trunk/rtmpsuck.c Mon Mar 8 16:14:55 2010 (r311)
+++ trunk/rtmpsuck.c Mon Mar 8 16:31:32 2010 (r312)
@@ -737,7 +737,7 @@ void doServe(STREAMING_SERVER * server,
{
RTMP_Init(&server->rs);
RTMP_Init(&server->rc);
- server->rs.m_socket = sockfd;
+ server->rs.m_sb.sb_socket = sockfd;
if (!RTMP_Serve(&server->rs))
{
Log(LOGERROR, "Handshake failed");
@@ -768,22 +768,22 @@ void doServe(STREAMING_SERVER * server,
int n;
int sr, cr;
- cr = server->rc.m_nBufferSize;
- sr = server->rs.m_nBufferSize;
+ cr = server->rc.m_sb.sb_size;
+ sr = server->rs.m_sb.sb_size;
if (cr || sr)
{
}
else
{
- n = server->rs.m_socket;
- if (server->rc.m_socket > n)
- n = server->rc.m_socket;
+ n = server->rs.m_sb.sb_socket;
+ if (server->rc.m_sb.sb_socket > n)
+ n = server->rc.m_sb.sb_socket;
FD_ZERO(&rfds);
if (RTMP_IsConnected(&server->rs))
FD_SET(sockfd, &rfds);
if (RTMP_IsConnected(&server->rc))
- FD_SET(server->rc.m_socket, &rfds);
+ FD_SET(server->rc.m_sb.sb_socket, &rfds);
/* give more time to start up if we're not playing yet */
tv.tv_sec = server->f_cur ? 30 : 60;
@@ -803,9 +803,9 @@ void doServe(STREAMING_SERVER * server,
Log(LOGERROR, "Request timeout/select failed, ignoring request");
goto cleanup;
}
- if (FD_ISSET(server->rs.m_socket, &rfds))
+ if (FD_ISSET(server->rs.m_sb.sb_socket, &rfds))
sr = 1;
- if (FD_ISSET(server->rc.m_socket, &rfds))
+ if (FD_ISSET(server->rc.m_sb.sb_socket, &rfds))
cr = 1;
}
if (sr)
More information about the rtmpdump
mailing list