[rtmpdump] branch master updated. 294135e Cleanup prev commit

gitolite gil at avcodec.org
Tue Oct 30 16:50:57 CET 2012


The branch, master has been updated
       via  294135e6eafeb1ac338ac4bb11ebd5ef62c748b9 (commit)
       via  b77a7dc719f8b04274db91f6344f4358a78d9c5f (commit)
      from  1d07cfa60402ace8472f4661112595f1fe661913 (commit)


- Log -----------------------------------------------------------------
commit 294135e6eafeb1ac338ac4bb11ebd5ef62c748b9
Author:     Howard Chu <hyc at highlandsun.com>
AuthorDate: Tue Oct 30 08:50:34 2012 -0700
Commit:     Howard Chu <hyc at highlandsun.com>
CommitDate: Tue Oct 30 08:50:34 2012 -0700

    Cleanup prev commit

diff --git a/librtmp/amf.c b/librtmp/amf.c
index 1406be4..563486c 100644
--- a/librtmp/amf.c
+++ b/librtmp/amf.c
@@ -396,14 +396,14 @@ AMFProp_Encode(AMFObjectProperty *prop, char *pBuffer, char *pBufEnd)
       pBuffer = AMF_Encode(&prop->p_vu.p_object, pBuffer, pBufEnd);
       break;
 
-    case AMF_ECMA_ARRAY:            
+    case AMF_ECMA_ARRAY:
       pBuffer = AMF_EncodeEcmaArray(&prop->p_vu.p_object, pBuffer, pBufEnd);
       break;
-      
-    case AMF_STRICT_ARRAY:      
+
+    case AMF_STRICT_ARRAY:
       pBuffer = AMF_EncodeArray(&prop->p_vu.p_object, pBuffer, pBufEnd);
       break;
-      
+
     default:
       RTMP_Log(RTMP_LOGERROR, "%s, invalid type. %d", __FUNCTION__, prop->p_type);
       pBuffer = NULL;
@@ -708,7 +708,6 @@ AMFProp_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
 	if (nRes == -1)
 	  return -1;
 	nSize -= nRes;
-	//prop->p_type = AMF_OBJECT;
 	break;
       }
     case AMF_OBJECT_END:
@@ -726,7 +725,6 @@ AMFProp_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
 	if (nRes == -1)
 	  return -1;
 	nSize -= nRes;
-	//prop->p_type = AMF_OBJECT;
 	break;
       }
     case AMF_DATE:
diff --git a/librtmp/amf.h b/librtmp/amf.h
index 5a47d77..5de414b 100644
--- a/librtmp/amf.h
+++ b/librtmp/amf.h
@@ -106,7 +106,7 @@ extern "C"
   char *AMF_Encode(AMFObject * obj, char *pBuffer, char *pBufEnd);
   char *AMF_EncodeEcmaArray(AMFObject *obj, char *pBuffer, char *pBufEnd);
   char *AMF_EncodeArray(AMFObject *obj, char *pBuffer, char *pBufEnd);
-  
+
   int AMF_Decode(AMFObject * obj, const char *pBuffer, int nSize,
 		 int bDecodeName);
   int AMF_DecodeArray(AMFObject * obj, const char *pBuffer, int nSize,

commit b77a7dc719f8b04274db91f6344f4358a78d9c5f
Author:     goggle1 <goggle1 at 163.com>
AuthorDate: Tue Oct 30 08:47:19 2012 -0700
Commit:     Howard Chu <hyc at highlandsun.com>
CommitDate: Tue Oct 30 08:48:07 2012 -0700

    Handle AMF_ECMA_ARRAY and AMF_STRICT_ARRAY objects

diff --git a/librtmp/amf.c b/librtmp/amf.c
index ce84f81..1406be4 100644
--- a/librtmp/amf.c
+++ b/librtmp/amf.c
@@ -396,6 +396,14 @@ AMFProp_Encode(AMFObjectProperty *prop, char *pBuffer, char *pBufEnd)
       pBuffer = AMF_Encode(&prop->p_vu.p_object, pBuffer, pBufEnd);
       break;
 
+    case AMF_ECMA_ARRAY:            
+      pBuffer = AMF_EncodeEcmaArray(&prop->p_vu.p_object, pBuffer, pBufEnd);
+      break;
+      
+    case AMF_STRICT_ARRAY:      
+      pBuffer = AMF_EncodeArray(&prop->p_vu.p_object, pBuffer, pBufEnd);
+      break;
+      
     default:
       RTMP_Log(RTMP_LOGERROR, "%s, invalid type. %d", __FUNCTION__, prop->p_type);
       pBuffer = NULL;
@@ -700,7 +708,7 @@ AMFProp_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
 	if (nRes == -1)
 	  return -1;
 	nSize -= nRes;
-	prop->p_type = AMF_OBJECT;
+	//prop->p_type = AMF_OBJECT;
 	break;
       }
     case AMF_OBJECT_END:
@@ -718,7 +726,7 @@ AMFProp_Decode(AMFObjectProperty *prop, const char *pBuffer, int nSize,
 	if (nRes == -1)
 	  return -1;
 	nSize -= nRes;
-	prop->p_type = AMF_OBJECT;
+	//prop->p_type = AMF_OBJECT;
 	break;
       }
     case AMF_DATE:
@@ -815,6 +823,18 @@ AMFProp_Dump(AMFObjectProperty *prop)
       AMF_Dump(&prop->p_vu.p_object);
       return;
     }
+  else if (prop->p_type == AMF_ECMA_ARRAY)
+    {
+      RTMP_Log(RTMP_LOGDEBUG, "Property: <%sECMA_ARRAY>", strRes);
+      AMF_Dump(&prop->p_vu.p_object);
+      return;
+    }
+  else if (prop->p_type == AMF_STRICT_ARRAY)
+    {
+      RTMP_Log(RTMP_LOGDEBUG, "Property: <%sSTRICT_ARRAY>", strRes);
+      AMF_Dump(&prop->p_vu.p_object);
+      return;
+    }
 
   switch (prop->p_type)
     {
@@ -888,6 +908,76 @@ AMF_Encode(AMFObject *obj, char *pBuffer, char *pBufEnd)
   return pBuffer;
 }
 
+char *
+AMF_EncodeEcmaArray(AMFObject *obj, char *pBuffer, char *pBufEnd)
+{
+  int i;
+
+  if (pBuffer+4 >= pBufEnd)
+    return NULL;
+
+  *pBuffer++ = AMF_ECMA_ARRAY;
+
+  pBuffer = AMF_EncodeInt32(pBuffer, pBufEnd, obj->o_num);
+
+  for (i = 0; i < obj->o_num; i++)
+    {
+      char *res = AMFProp_Encode(&obj->o_props[i], pBuffer, pBufEnd);
+      if (res == NULL)
+	{
+	  RTMP_Log(RTMP_LOGERROR, "AMF_Encode - failed to encode property in index %d",
+	      i);
+	  break;
+	}
+      else
+	{
+	  pBuffer = res;
+	}
+    }
+
+  if (pBuffer + 3 >= pBufEnd)
+    return NULL;			/* no room for the end marker */
+
+  pBuffer = AMF_EncodeInt24(pBuffer, pBufEnd, AMF_OBJECT_END);
+
+  return pBuffer;
+}
+
+char *
+AMF_EncodeArray(AMFObject *obj, char *pBuffer, char *pBufEnd)
+{
+  int i;
+
+  if (pBuffer+4 >= pBufEnd)
+    return NULL;
+
+  *pBuffer++ = AMF_STRICT_ARRAY;
+
+  pBuffer = AMF_EncodeInt32(pBuffer, pBufEnd, obj->o_num);
+
+  for (i = 0; i < obj->o_num; i++)
+    {
+      char *res = AMFProp_Encode(&obj->o_props[i], pBuffer, pBufEnd);
+      if (res == NULL)
+	{
+	  RTMP_Log(RTMP_LOGERROR, "AMF_Encode - failed to encode property in index %d",
+	      i);
+	  break;
+	}
+      else
+	{
+	  pBuffer = res;
+	}
+    }
+
+  //if (pBuffer + 3 >= pBufEnd)
+  //  return NULL;			/* no room for the end marker */
+
+  //pBuffer = AMF_EncodeInt24(pBuffer, pBufEnd, AMF_OBJECT_END);
+
+  return pBuffer;
+}
+
 int
 AMF_DecodeArray(AMFObject *obj, const char *pBuffer, int nSize,
 		int nArrayLen, int bDecodeName)
diff --git a/librtmp/amf.h b/librtmp/amf.h
index b945beb..5a47d77 100644
--- a/librtmp/amf.h
+++ b/librtmp/amf.h
@@ -104,6 +104,9 @@ extern "C"
   double AMF_DecodeNumber(const char *data);
 
   char *AMF_Encode(AMFObject * obj, char *pBuffer, char *pBufEnd);
+  char *AMF_EncodeEcmaArray(AMFObject *obj, char *pBuffer, char *pBufEnd);
+  char *AMF_EncodeArray(AMFObject *obj, char *pBuffer, char *pBufEnd);
+  
   int AMF_Decode(AMFObject * obj, const char *pBuffer, int nSize,
 		 int bDecodeName);
   int AMF_DecodeArray(AMFObject * obj, const char *pBuffer, int nSize,

-----------------------------------------------------------------------

Summary of changes:
 librtmp/amf.c |   92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 librtmp/amf.h |    3 ++
 2 files changed, 93 insertions(+), 2 deletions(-)


hooks/post-receive
-- 



More information about the rtmpdump mailing list