[rtmpdump] r339 - in trunk/librtmp: log.c log.h rtmp.c
hyc
subversion at mplayerhq.hu
Sat Mar 13 05:36:10 CET 2010
Author: hyc
Date: Sat Mar 13 05:36:08 2010
New Revision: 339
Log:
Fix pause/seek status
Modified:
trunk/librtmp/log.c
trunk/librtmp/log.h
trunk/librtmp/rtmp.c
Modified: trunk/librtmp/log.c
==============================================================================
--- trunk/librtmp/log.c Sat Mar 13 05:17:02 2010 (r338)
+++ trunk/librtmp/log.c Sat Mar 13 05:36:08 2010 (r339)
@@ -30,7 +30,7 @@
#define MAX_PRINT_LEN 2048
-AMF_LogLevel debuglevel = LOGERROR;
+AMF_LogLevel AMF_debuglevel = LOGERROR;
static int neednl;
@@ -55,7 +55,7 @@ void LogPrintf(const char *format, ...)
len = vsnprintf(str, MAX_PRINT_LEN-1, format, args);
va_end(args);
- if ( debuglevel==LOGCRIT )
+ if ( AMF_debuglevel==LOGCRIT )
return;
if ( !fmsg ) fmsg = stderr;
@@ -80,7 +80,7 @@ void LogStatus(const char *format, ...)
vsnprintf(str, MAX_PRINT_LEN-1, format, args);
va_end(args);
- if ( debuglevel==LOGCRIT )
+ if ( AMF_debuglevel==LOGCRIT )
return;
if ( !fmsg ) fmsg = stderr;
@@ -99,12 +99,12 @@ void Log(int level, const char *format,
va_end(args);
// Filter out 'no-name'
- if ( debuglevel<LOGALL && strstr(str, "no-name" ) != NULL )
+ if ( AMF_debuglevel<LOGALL && strstr(str, "no-name" ) != NULL )
return;
if ( !fmsg ) fmsg = stderr;
- if ( level <= debuglevel ) {
+ if ( level <= AMF_debuglevel ) {
if (neednl) {
putc('\n', fmsg);
neednl = 0;
@@ -119,7 +119,7 @@ void Log(int level, const char *format,
void LogHex(int level, const char *data, unsigned long len)
{
unsigned long i;
- if ( level > debuglevel )
+ if ( level > AMF_debuglevel )
return;
for(i=0; i<len; i++) {
LogPrintf("%02X ", (unsigned char)data[i]);
@@ -136,7 +136,7 @@ void LogHexString(int level, const char
char line[BP_LEN];
unsigned long i;
- if ( !data || level > debuglevel )
+ if ( !data || level > AMF_debuglevel )
return;
/* in case len is zero */
Modified: trunk/librtmp/log.h
==============================================================================
--- trunk/librtmp/log.h Sat Mar 13 05:17:02 2010 (r338)
+++ trunk/librtmp/log.h Sat Mar 13 05:36:08 2010 (r339)
@@ -46,9 +46,8 @@ typedef enum
#define LogPrintf AMF_LogPrintf
#define LogSetOutput AMF_LogSetOutput
#define LogStatus AMF_LogStatus
-#define debuglevel AMF_debuglevel
-extern AMF_LogLevel debuglevel;
+extern AMF_LogLevel AMF_debuglevel;
void LogSetOutput(FILE *file);
void LogPrintf(const char *format, ...);
Modified: trunk/librtmp/rtmp.c
==============================================================================
--- trunk/librtmp/rtmp.c Sat Mar 13 05:17:02 2010 (r338)
+++ trunk/librtmp/rtmp.c Sat Mar 13 05:36:08 2010 (r339)
@@ -1283,6 +1283,9 @@ RTMP_SendSeek(RTMP *r, double dTime)
packet.m_nBodySize = enc - packet.m_body;
+ r->m_read.flags |= RTMP_READ_SEEKING;
+ r->m_read.nResumeTS = (int)dTime;
+
return RTMP_SendPacket(r, &packet, true);
}
@@ -1595,6 +1598,8 @@ AVC("NetConnection.Connect.InvalidApp");
static const AVal av_NetStream_Play_Start = AVC("NetStream.Play.Start");
static const AVal av_NetStream_Play_Complete = AVC("NetStream.Play.Complete");
static const AVal av_NetStream_Play_Stop = AVC("NetStream.Play.Stop");
+static const AVal av_NetStream_Seek_Notify = AVC("NetStream.Seek.Notify");
+static const AVal av_NetStream_Pause_Notify = AVC("NetStream.Pause.Notify");
// Returns 0 for OK/Failed/error, 1 for 'Stop or Complete'
static int
@@ -1720,7 +1725,7 @@ HandleInvoke(RTMP *r, const char *body,
Log(LOGERROR, "Closing connection: %s", code.av_val);
}
- if (AVMATCH(&code, &av_NetStream_Play_Start))
+ else if (AVMATCH(&code, &av_NetStream_Play_Start))
{
int i;
r->m_bPlaying = true;
@@ -1735,12 +1740,26 @@ HandleInvoke(RTMP *r, const char *body,
}
// Return 1 if this is a Play.Complete or Play.Stop
- if (AVMATCH(&code, &av_NetStream_Play_Complete)
+ else if (AVMATCH(&code, &av_NetStream_Play_Complete)
|| AVMATCH(&code, &av_NetStream_Play_Stop))
{
RTMP_Close(r);
ret = 1;
}
+
+ else if (AVMATCH(&code, &av_NetStream_Seek_Notify))
+ {
+ r->m_read.flags &= ~RTMP_READ_SEEKING;
+ }
+
+ else if (AVMATCH(&code, &av_NetStream_Pause_Notify))
+ {
+ if (r->m_pausing == 1 || r->m_pausing == 2)
+ {
+ RTMP_SendPause(r, false, r->m_pauseStamp);
+ r->m_pausing = 3;
+ }
+ }
}
else
{
@@ -2880,6 +2899,12 @@ Read_1_Packet(RTMP *r, char *buf, int bu
ret = RTMP_READ_IGNORE;
break;
}
+
+ if (r->m_read.flags & RTMP_READ_SEEKING)
+ {
+ ret = RTMP_READ_IGNORE;
+ break;
+ }
#if 1 /* _DEBUG */
Log(LOGDEBUG, "type: %02X, size: %d, TS: %d ms, abs TS: %d",
packet.m_packetType, nPacketLen, packet.m_nTimeStamp,
@@ -3335,6 +3360,15 @@ RTMP_Read(RTMP *r, char *buf, int size)
r->m_read.flags |= RTMP_READ_HEADER;
}
+ if ((r->m_read.flags & RTMP_READ_SEEKING) && r->m_read.buf)
+ {
+ /* drop whatever's here */
+ free(r->m_read.buf);
+ r->m_read.buf = NULL;
+ r->m_read.bufpos = NULL;
+ r->m_read.buflen = 0;
+ }
+
/* If there's leftover data buffered, use it up */
if (r->m_read.buf)
{
More information about the rtmpdump
mailing list