[rtmpdump] [PATCH v5] Fix Handle AMF_ECMA_ARRAY and AMF_STRICT_ARRAY objects

Steven Penny svnpenn at gmail.com
Wed Dec 5 23:36:14 CET 2012


This fixes metadata and percent logging.

http://lists.mplayerhq.hu/pipermail/rtmpdump/2012-November/002189.html

Bad example
  INFO: Metadata:
  2256.298 kB / 174.99 sec
  Download complete

Good example
  INFO: Metadata:
  INFO:   duration              175.01
  INFO:   moovPosition          2182010.00
  INFO:   audiocodecid          mp4a
  INFO:   aacaot                2.00
  INFO:   audiosamplerate       44100.00
  INFO:   audiochannels         2.00
  INFO: tags:
  INFO:   -¬too                 FAAC 1.28
  INFO: trackinfo:
  INFO:   length                7717888.00
  INFO:   timescale             44100.00
  INFO: sampledescription:
  INFO:   sampletype            mp4a
  2256.298 kB / 174.99 sec (99.9%)
  Download complete
---
 librtmp/rtmp.c |   83 +++++++++++++++++++++++++++++--------------------------
 1 files changed, 44 insertions(+), 39 deletions(-)

diff --git a/librtmp/rtmp.c b/librtmp/rtmp.c
index bfe5a16..a06b815 100644
--- a/librtmp/rtmp.c
+++ b/librtmp/rtmp.c
@@ -3280,7 +3280,7 @@ RTMP_FindFirstMatchingProperty(AMFObject *obj, const AVal *name,
 	  return TRUE;
 	}
 
-      if (prop->p_type == AMF_OBJECT)
+      if (prop->p_type == AMF_OBJECT || prop->p_type == AMF_ECMA_ARRAY)
 	{
 	  if (RTMP_FindFirstMatchingProperty(&prop->p_vu.p_object, name, p))
 	    return TRUE;
@@ -3323,44 +3323,49 @@ DumpMetaData(AMFObject *obj)
   for (n = 0; n < obj->o_num; n++)
     {
       prop = AMF_GetProp(obj, NULL, n);
-      if (prop->p_type != AMF_OBJECT)
-	{
-	  char str[256] = "";
-	  switch (prop->p_type)
-	    {
-	    case AMF_NUMBER:
-	      snprintf(str, 255, "%.2f", prop->p_vu.p_number);
-	      break;
-	    case AMF_BOOLEAN:
-	      snprintf(str, 255, "%s",
-		       prop->p_vu.p_number != 0. ? "TRUE" : "FALSE");
-	      break;
-	    case AMF_STRING:
-	      snprintf(str, 255, "%.*s", prop->p_vu.p_aval.av_len,
-		       prop->p_vu.p_aval.av_val);
-	      break;
-	    case AMF_DATE:
-	      snprintf(str, 255, "timestamp:%.2f", prop->p_vu.p_number);
-	      break;
-	    default:
-	      snprintf(str, 255, "INVALID TYPE 0x%02x",
-		       (unsigned char)prop->p_type);
-	    }
-	  if (prop->p_name.av_len)
-	    {
-	      /* chomp */
-	      if (strlen(str) >= 1 && str[strlen(str) - 1] == '\n')
-		str[strlen(str) - 1] = '\0';
-	      RTMP_Log(RTMP_LOGINFO, "  %-22.*s%s", prop->p_name.av_len,
-			prop->p_name.av_val, str);
-	    }
-	}
-      else
-	{
-	  if (prop->p_name.av_len)
-	    RTMP_Log(RTMP_LOGINFO, "%.*s:", prop->p_name.av_len, prop->p_name.av_val);
-	  DumpMetaData(&prop->p_vu.p_object);
-	}
+      char str[256] = "";
+      switch (prop->p_type)
+  {
+    case AMF_OBJECT:
+    case AMF_ECMA_ARRAY:
+    case AMF_STRICT_ARRAY:
+      break;
+    case AMF_NUMBER:
+      snprintf(str, 255, "%.2f", prop->p_vu.p_number);
+      break;
+    case AMF_BOOLEAN:
+      snprintf(str, 255, "%s", prop->p_vu.p_number != 0. ? "TRUE" : "FALSE");
+      break;
+    case AMF_STRING:
+      snprintf(str, 255, "%.*s", prop->p_vu.p_aval.av_len,
+        prop->p_vu.p_aval.av_val);
+      break;
+    case AMF_DATE:
+      snprintf(str, 255, "timestamp:%.2f", prop->p_vu.p_number);
+      break;
+    default:
+      snprintf(str, 255, "INVALID TYPE 0x%02x", (unsigned char)prop->p_type);
+  }
+    if (prop->p_name.av_len)
+      {
+  if (strlen(str))
+    {
+      /* chomp */
+      if (strlen(str) >= 1 && str[strlen(str) - 1] == '\n')
+        str[strlen(str) - 1] = '\0';
+      RTMP_Log(RTMP_LOGINFO, "  %-22.*s%s", prop->p_name.av_len,
+        prop->p_name.av_val, str);
+    }
+  else
+    {
+      RTMP_Log(RTMP_LOGINFO, "%.*s:", prop->p_name.av_len,
+        prop->p_name.av_val);
+    }
+      }
+    if (!strlen(str))
+      {
+        DumpMetaData(&prop->p_vu.p_object);
+      }
     }
   return FALSE;
 }
-- 
1.7.9



More information about the rtmpdump mailing list