4 * Copyright (C) 2005-2008 Team XBMC
6 * Copyright (C) 2008-2009 Andrej Stepanchuk
7 * Copyright (C) 2009-2010 Howard Chu
9 * This file is part of librtmp.
11 * librtmp is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as
13 * published by the Free Software Foundation; either version 2.1,
14 * or (at your option) any later version.
16 * librtmp is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with librtmp see the file COPYING. If not, write to
23 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 * Boston, MA 02110-1301, USA.
25 * http://www.gnu.org/copyleft/lgpl.html
41 { AMF_NUMBER
= 0, AMF_BOOLEAN
, AMF_STRING
, AMF_OBJECT
,
42 AMF_MOVIECLIP
, /* reserved, not used */
43 AMF_NULL
, AMF_UNDEFINED
, AMF_REFERENCE
, AMF_ECMA_ARRAY
, AMF_OBJECT_END
,
44 AMF_STRICT_ARRAY
, AMF_DATE
, AMF_LONG_STRING
, AMF_UNSUPPORTED
,
45 AMF_RECORDSET
, /* reserved, not used */
46 AMF_XML_DOC
, AMF_TYPED_OBJECT
,
47 AMF_AVMPLUS
, /* switch to AMF3 */
52 { AMF3_UNDEFINED
= 0, AMF3_NULL
, AMF3_FALSE
, AMF3_TRUE
,
53 AMF3_INTEGER
, AMF3_DOUBLE
, AMF3_STRING
, AMF3_XML_DOC
, AMF3_DATE
,
54 AMF3_ARRAY
, AMF3_OBJECT
, AMF3_XML
, AMF3_BYTE_ARRAY
62 #define AVC(str) {str,sizeof(str)-1}
63 #define AVMATCH(a1,a2) ((a1)->av_len == (a2)->av_len && !memcmp((a1)->av_val,(a2)->av_val,(a1)->av_len))
65 struct AMFObjectProperty
;
67 typedef struct AMFObject
70 struct AMFObjectProperty
*o_props
;
73 typedef struct AMFObjectProperty
86 char *AMF_EncodeString(char *output
, char *outend
, const AVal
* str
);
87 char *AMF_EncodeNumber(char *output
, char *outend
, double dVal
);
88 char *AMF_EncodeInt16(char *output
, char *outend
, short nVal
);
89 char *AMF_EncodeInt24(char *output
, char *outend
, int nVal
);
90 char *AMF_EncodeInt32(char *output
, char *outend
, int nVal
);
91 char *AMF_EncodeBoolean(char *output
, char *outend
, int bVal
);
93 /* Shortcuts for AMFProp_Encode */
94 char *AMF_EncodeNamedString(char *output
, char *outend
, const AVal
* name
, const AVal
* value
);
95 char *AMF_EncodeNamedNumber(char *output
, char *outend
, const AVal
* name
, double dVal
);
96 char *AMF_EncodeNamedBoolean(char *output
, char *outend
, const AVal
* name
, int bVal
);
98 unsigned short AMF_DecodeInt16(const char *data
);
99 unsigned int AMF_DecodeInt24(const char *data
);
100 unsigned int AMF_DecodeInt32(const char *data
);
101 void AMF_DecodeString(const char *data
, AVal
* str
);
102 void AMF_DecodeLongString(const char *data
, AVal
* str
);
103 int AMF_DecodeBoolean(const char *data
);
104 double AMF_DecodeNumber(const char *data
);
106 char *AMF_Encode(AMFObject
* obj
, char *pBuffer
, char *pBufEnd
);
107 char *AMF_EncodeEcmaArray(AMFObject
*obj
, char *pBuffer
, char *pBufEnd
);
108 char *AMF_EncodeArray(AMFObject
*obj
, char *pBuffer
, char *pBufEnd
);
110 int AMF_Decode(AMFObject
* obj
, const char *pBuffer
, int nSize
,
112 int AMF_DecodeArray(AMFObject
* obj
, const char *pBuffer
, int nSize
,
113 int nArrayLen
, int bDecodeName
);
114 int AMF3_Decode(AMFObject
* obj
, const char *pBuffer
, int nSize
,
116 void AMF_Dump(AMFObject
* obj
);
117 void AMF_Reset(AMFObject
* obj
);
119 void AMF_AddProp(AMFObject
* obj
, const AMFObjectProperty
* prop
);
120 int AMF_CountProp(AMFObject
* obj
);
121 AMFObjectProperty
*AMF_GetProp(AMFObject
* obj
, const AVal
* name
,
124 AMFDataType
AMFProp_GetType(AMFObjectProperty
* prop
);
125 void AMFProp_SetNumber(AMFObjectProperty
* prop
, double dval
);
126 void AMFProp_SetBoolean(AMFObjectProperty
* prop
, int bflag
);
127 void AMFProp_SetString(AMFObjectProperty
* prop
, AVal
* str
);
128 void AMFProp_SetObject(AMFObjectProperty
* prop
, AMFObject
* obj
);
130 void AMFProp_GetName(AMFObjectProperty
* prop
, AVal
* name
);
131 void AMFProp_SetName(AMFObjectProperty
* prop
, AVal
* name
);
132 double AMFProp_GetNumber(AMFObjectProperty
* prop
);
133 int AMFProp_GetBoolean(AMFObjectProperty
* prop
);
134 void AMFProp_GetString(AMFObjectProperty
* prop
, AVal
* str
);
135 void AMFProp_GetObject(AMFObjectProperty
* prop
, AMFObject
* obj
);
137 int AMFProp_IsValid(AMFObjectProperty
* prop
);
139 char *AMFProp_Encode(AMFObjectProperty
* prop
, char *pBuffer
, char *pBufEnd
);
140 int AMF3Prop_Decode(AMFObjectProperty
* prop
, const char *pBuffer
,
141 int nSize
, int bDecodeName
);
142 int AMFProp_Decode(AMFObjectProperty
* prop
, const char *pBuffer
,
143 int nSize
, int bDecodeName
);
145 void AMFProp_Dump(AMFObjectProperty
* prop
);
146 void AMFProp_Reset(AMFObjectProperty
* prop
);
148 typedef struct AMF3ClassDef
151 char cd_externalizable
;
157 void AMF3CD_AddProp(AMF3ClassDef
* cd
, AVal
* prop
);
158 AVal
*AMF3CD_GetProp(AMF3ClassDef
* cd
, int idx
);
164 #endif /* __AMF_H__ */