From 5803cf6e916a64aa4d83ac07348773e7480c8fd2 Mon Sep 17 00:00:00 2001 From: hyc Date: Sat, 13 Mar 2010 04:36:08 +0000 Subject: [PATCH] Fix pause/seek status git-svn-id: svn://svn.mplayerhq.hu/rtmpdump/trunk@339 400ebc74-4327-4243-bc38-086b20814532 --- librtmp/log.c | 14 +++++++------- librtmp/log.h | 3 +-- librtmp/rtmp.c | 38 ++++++++++++++++++++++++++++++++++++-- 3 files changed, 44 insertions(+), 11 deletions(-) diff --git a/librtmp/log.c b/librtmp/log.c index 6ac6d93..be73193 100644 --- a/librtmp/log.c +++ b/librtmp/log.c @@ -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 debuglevel ) + if ( level > AMF_debuglevel ) return; for(i=0; i debuglevel ) + if ( !data || level > AMF_debuglevel ) return; /* in case len is zero */ diff --git a/librtmp/log.h b/librtmp/log.h index 8c635b2..dfaa273 100644 --- a/librtmp/log.h +++ b/librtmp/log.h @@ -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, ...); diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c index 2396925..0dfe277 100644 --- a/librtmp/rtmp.c +++ b/librtmp/rtmp.c @@ -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, unsigned int nBodySize) 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, unsigned int nBodySize) } // 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 buflen) 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) { -- 2.40.0