Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
胡斌
/
srs
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
winlin
2014-03-08 13:41:15 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
57ce04ae12ed82d531280a40a8df4e5af37c1712
57ce04ae
1 parent
404207db
amf0 utest: remove struct use class instead, move class together
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
97 行增加
和
91 行删除
trunk/src/rtmp/srs_protocol_amf0.cpp
trunk/src/rtmp/srs_protocol_amf0.hpp
trunk/src/rtmp/srs_protocol_amf0.cpp
查看文件 @
57ce04a
...
...
@@ -625,6 +625,68 @@ SrsAmf0Any* SrsAmf0EcmaArray::ensure_property_string(std::string name)
return
properties
.
ensure_property_string
(
name
);
}
int
SrsAmf0Size
::
utf8
(
string
value
)
{
return
2
+
value
.
length
();
}
int
SrsAmf0Size
::
str
(
string
value
)
{
return
1
+
SrsAmf0Size
::
utf8
(
value
);
}
int
SrsAmf0Size
::
number
()
{
return
1
+
8
;
}
int
SrsAmf0Size
::
null
()
{
return
1
;
}
int
SrsAmf0Size
::
undefined
()
{
return
1
;
}
int
SrsAmf0Size
::
boolean
()
{
return
1
+
1
;
}
int
SrsAmf0Size
::
object
(
SrsAmf0Object
*
obj
)
{
if
(
!
obj
)
{
return
0
;
}
return
obj
->
size
();
}
int
SrsAmf0Size
::
object_eof
()
{
return
2
+
1
;
}
int
SrsAmf0Size
::
array
(
SrsAmf0EcmaArray
*
arr
)
{
if
(
!
arr
)
{
return
0
;
}
return
arr
->
size
();
}
int
SrsAmf0Size
::
any
(
SrsAmf0Any
*
o
)
{
if
(
!
o
)
{
return
0
;
}
return
o
->
size
();
}
int
srs_amf0_read_utf8
(
SrsStream
*
stream
,
std
::
string
&
value
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -1194,65 +1256,3 @@ int srs_amf0_write_ecma_array(SrsStream* stream, SrsAmf0EcmaArray* value)
{
return
value
->
write
(
stream
);
}
int
SrsAmf0Size
::
utf8
(
string
value
)
{
return
2
+
value
.
length
();
}
int
SrsAmf0Size
::
str
(
string
value
)
{
return
1
+
SrsAmf0Size
::
utf8
(
value
);
}
int
SrsAmf0Size
::
number
()
{
return
1
+
8
;
}
int
SrsAmf0Size
::
null
()
{
return
1
;
}
int
SrsAmf0Size
::
undefined
()
{
return
1
;
}
int
SrsAmf0Size
::
boolean
()
{
return
1
+
1
;
}
int
SrsAmf0Size
::
object
(
SrsAmf0Object
*
obj
)
{
if
(
!
obj
)
{
return
0
;
}
return
obj
->
size
();
}
int
SrsAmf0Size
::
object_eof
()
{
return
2
+
1
;
}
int
SrsAmf0Size
::
array
(
SrsAmf0EcmaArray
*
arr
)
{
if
(
!
arr
)
{
return
0
;
}
return
arr
->
size
();
}
int
SrsAmf0Size
::
any
(
SrsAmf0Any
*
o
)
{
if
(
!
o
)
{
return
0
;
}
return
o
->
size
();
}
...
...
trunk/src/rtmp/srs_protocol_amf0.hpp
查看文件 @
57ce04a
...
...
@@ -34,7 +34,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <vector>
class
SrsStream
;
class
SrsAmf0Object
;
/**
* any amf0 value.
...
...
@@ -44,8 +43,9 @@ class SrsAmf0Object;
* | strict-array-type | date-type | long-string-type | xml-document-type
* | typed-object-type
*/
struct
SrsAmf0Any
class
SrsAmf0Any
{
public
:
char
marker
;
SrsAmf0Any
();
...
...
@@ -69,8 +69,9 @@ struct SrsAmf0Any
* string-type = string-marker UTF-8
* @return default value is empty string.
*/
struct
SrsAmf0String
:
public
SrsAmf0Any
class
SrsAmf0String
:
public
SrsAmf0Any
{
public
:
std
::
string
value
;
SrsAmf0String
(
const
char
*
_value
=
NULL
);
...
...
@@ -86,8 +87,9 @@ struct SrsAmf0String : public SrsAmf0Any
* 0 is false, <> 0 is true
* @return default value is false.
*/
struct
SrsAmf0Boolean
:
public
SrsAmf0Any
class
SrsAmf0Boolean
:
public
SrsAmf0Any
{
public
:
bool
value
;
SrsAmf0Boolean
(
bool
_value
=
false
);
...
...
@@ -102,8 +104,9 @@ struct SrsAmf0Boolean : public SrsAmf0Any
* number-type = number-marker DOUBLE
* @return default value is 0.
*/
struct
SrsAmf0Number
:
public
SrsAmf0Any
class
SrsAmf0Number
:
public
SrsAmf0Any
{
public
:
double
value
;
SrsAmf0Number
(
double
_value
=
0.0
);
...
...
@@ -117,8 +120,9 @@ struct SrsAmf0Number : public SrsAmf0Any
* 2.7 null Type
* null-type = null-marker
*/
struct
SrsAmf0Null
:
public
SrsAmf0Any
class
SrsAmf0Null
:
public
SrsAmf0Any
{
public
:
SrsAmf0Null
();
virtual
~
SrsAmf0Null
();
...
...
@@ -130,8 +134,9 @@ struct SrsAmf0Null : public SrsAmf0Any
* 2.8 undefined Type
* undefined-type = undefined-marker
*/
struct
SrsAmf0Undefined
:
public
SrsAmf0Any
class
SrsAmf0Undefined
:
public
SrsAmf0Any
{
public
:
SrsAmf0Undefined
();
virtual
~
SrsAmf0Undefined
();
...
...
@@ -143,8 +148,9 @@ struct SrsAmf0Undefined : public SrsAmf0Any
* object-end-type = UTF-8-empty object-end-marker
* 0x00 0x00 0x09
*/
struct
SrsAmf0ObjectEOF
:
public
SrsAmf0Any
class
SrsAmf0ObjectEOF
:
public
SrsAmf0Any
{
public
:
int16_t
utf8_empty
;
SrsAmf0ObjectEOF
();
...
...
@@ -159,7 +165,7 @@ struct SrsAmf0ObjectEOF : public SrsAmf0Any
* if ordered in map, the string compare order, the FMLE will creash when
* get the response of connect app.
*/
struct
SrsUnSortedHashtable
class
SrsUnSortedHashtable
{
private
:
typedef
std
::
pair
<
std
::
string
,
SrsAmf0Any
*>
SrsObjectPropertyType
;
...
...
@@ -184,7 +190,7 @@ public:
* anonymous-object-type = object-marker *(object-property)
* object-property = (UTF-8 value-type) | (UTF-8-empty object-end-marker)
*/
struct
SrsAmf0Object
:
public
SrsAmf0Any
class
SrsAmf0Object
:
public
SrsAmf0Any
{
private
:
SrsUnSortedHashtable
properties
;
...
...
@@ -213,7 +219,7 @@ public:
* associative-count = U32
* object-property = (UTF-8 value-type) | (UTF-8-empty object-end-marker)
*/
struct
SrsAmf0EcmaArray
:
public
SrsAmf0Any
class
SrsAmf0EcmaArray
:
public
SrsAmf0Any
{
private
:
SrsUnSortedHashtable
properties
;
...
...
@@ -238,6 +244,24 @@ public:
};
/**
* the class to get amf0 object size
*/
class
SrsAmf0Size
{
public
:
static
int
utf8
(
std
::
string
value
);
static
int
str
(
std
::
string
value
);
static
int
number
();
static
int
null
();
static
int
undefined
();
static
int
boolean
();
static
int
object
(
SrsAmf0Object
*
obj
);
static
int
object_eof
();
static
int
array
(
SrsAmf0EcmaArray
*
arr
);
static
int
any
(
SrsAmf0Any
*
o
);
};
/**
* read amf0 utf8 string from stream.
* 1.3.1 Strings and UTF-8
* UTF-8 = U16 *(UTF8-char)
...
...
@@ -311,24 +335,6 @@ extern int srs_amf0_read_ecma_array(SrsStream* stream, SrsAmf0EcmaArray*& value)
extern
int
srs_amf0_write_ecma_array
(
SrsStream
*
stream
,
SrsAmf0EcmaArray
*
value
);
/**
* the class to get amf0 object size
*/
class
SrsAmf0Size
{
public
:
static
int
utf8
(
std
::
string
value
);
static
int
str
(
std
::
string
value
);
static
int
number
();
static
int
null
();
static
int
undefined
();
static
int
boolean
();
static
int
object
(
SrsAmf0Object
*
obj
);
static
int
object_eof
();
static
int
array
(
SrsAmf0EcmaArray
*
arr
);
static
int
any
(
SrsAmf0Any
*
o
);
};
/**
* convert the any to specified object.
* @return T*, the converted object. never NULL.
* @remark, user must ensure the current object type,
...
...
请
注册
或
登录
后发表评论