[FFmpeg-cvslog] rtmp: Tokenize the AMF connection parameters manually instead of using strtok_r

Martin Storsjö git at videolan.org
Wed Jun 13 23:02:28 CEST 2012


ffmpeg | branch: master | Martin Storsjö <martin at martin.st> | Wed Jun 13 10:51:22 2012 +0300| [053386864219eccbcca1886c55f902f9555428a5] | committer: Martin Storsjö

rtmp: Tokenize the AMF connection parameters manually instead of using strtok_r

This fixes builds on platforms without strtok_r (windows).

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

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

 libavformat/rtmpproto.c |   25 +++++++++++++++++++------
 1 file changed, 19 insertions(+), 6 deletions(-)

diff --git a/libavformat/rtmpproto.c b/libavformat/rtmpproto.c
index 56011f1..2b15d80 100644
--- a/libavformat/rtmpproto.c
+++ b/libavformat/rtmpproto.c
@@ -115,7 +115,7 @@ static const uint8_t rtmp_server_key[] = {
 
 static int rtmp_write_amf_data(URLContext *s, char *param, uint8_t **p)
 {
-    char *field, *value, *saveptr;
+    char *field, *value;
     char type;
 
     /* The type must be B for Boolean, N for number, S for string, O for
@@ -130,8 +130,12 @@ static int rtmp_write_amf_data(URLContext *s, char *param, uint8_t **p)
         value = param + 2;
     } else if (param[0] == 'N' && param[1] && param[2] == ':') {
         type = param[1];
-        field = strtok_r(param + 3, ":", &saveptr);
-        value = strtok_r(NULL, ":", &saveptr);
+        field = param + 3;
+        value = strchr(field, ':');
+        if (!value)
+            goto fail;
+        *value = '\0';
+        value++;
 
         if (!field || !value)
             goto fail;
@@ -226,18 +230,27 @@ static int gen_connect(URLContext *s, RTMPContext *rt)
     ff_amf_write_object_end(&p);
 
     if (rt->conn) {
-        char *param, *saveptr;
+        char *param = rt->conn;
 
         // Write arbitrary AMF data to the Connect message.
-        param = strtok_r(rt->conn, " ", &saveptr);
         while (param != NULL) {
+            char *sep;
+            param += strspn(param, " ");
+            if (!*param)
+                break;
+            sep = strchr(param, ' ');
+            if (sep)
+                *sep = '\0';
             if ((ret = rtmp_write_amf_data(s, param, &p)) < 0) {
                 // Invalid AMF parameter.
                 ff_rtmp_packet_destroy(&pkt);
                 return ret;
             }
 
-            param = strtok_r(NULL, " ", &saveptr);
+            if (sep)
+                param = sep + 1;
+            else
+                break;
         }
     }
 



More information about the ffmpeg-cvslog mailing list