[FFmpeg-cvslog] rtmp: Factorize the code by adding handle_ping

Samuel Pitoiset git at videolan.org
Thu Jul 26 21:55:12 CEST 2012


ffmpeg | branch: master | Samuel Pitoiset <samuel.pitoiset at gmail.com> | Sat Jul 21 12:59:51 2012 +0200| [0ffd5161c4f8610fa0133c50bfc19beab761f5c1] | committer: Martin Storsjö

rtmp: Factorize the code by adding handle_ping

Signed-off-by: Martin Storsjö <martin at martin.st>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=0ffd5161c4f8610fa0133c50bfc19beab761f5c1
---

 libavformat/rtmpproto.c |   20 ++++++++++++++++----
 1 file changed, 16 insertions(+), 4 deletions(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 1536157..31fa28b 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -880,6 +880,20 @@ static int rtmp_handshake(URLContext *s, RTMPContext *rt)
     return 0;
 }
 
+static int handle_ping(URLContext *s, RTMPPacket *pkt)
+{
+    RTMPContext *rt = s->priv_data;
+    int t, ret;
+
+    t = AV_RB16(pkt->data);
+    if (t == 6) {
+        if ((ret = gen_pong(s, rt, pkt)) < 0)
+            return ret;
+    }
+
+    return 0;
+}
+
 static int handle_client_bw(URLContext *s, RTMPPacket *pkt)
 {
     RTMPContext *rt = s->priv_data;
@@ -946,10 +960,8 @@ static int rtmp_parse_result(URLContext *s, RTMPContext *rt, RTMPPacket *pkt)
         av_log(s, AV_LOG_DEBUG, "New chunk size = %d\n", rt->chunk_size);
         break;
     case RTMP_PT_PING:
-        t = AV_RB16(pkt->data);
-        if (t == 6)
-            if ((ret = gen_pong(s, rt, pkt)) < 0)
-                return ret;
+        if ((ret = handle_ping(s, pkt)) < 0)
+            return ret;
         break;
     case RTMP_PT_CLIENT_BW:
         if ((ret = handle_client_bw(s, pkt)) < 0)



More information about the ffmpeg-cvslog mailing list