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 17:18:44 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
3691c106faee66c5208d54857c5d72553944471f
3691c106
1 parent
34f94a1b
amf0 utest: add usage for amf0
显示空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
34 行增加
和
2 行删除
trunk/src/rtmp/srs_protocol_amf0.hpp
trunk/src/rtmp/srs_protocol_rtmp_stack.cpp
trunk/src/rtmp/srs_protocol_amf0.hpp
查看文件 @
3691c10
...
...
@@ -37,6 +37,35 @@ class SrsStream;
class
SrsAmf0Object
;
class
SrsAmf0EcmaArray
;
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
// amf0 codec
// 1. SrsAmf0Any: read any from stream
// SrsAmf0Any* pany = NULL;
// if ((ret = srs_amf0_read_any(stream, &pany)) != ERROR_SUCCESS) {
// return ret;
// }
// 2. SrsAmf0Any: convert to specifid type, for instance, string
// SrsAmf0Any* pany = ...
// if (pany && pany->is_string()) {
// string v = pany->to_str();
// }
// 3. SrsAmf0Any: parse specified type to any, for instance, string
// SrsAmf0Any* pany = SrsAmf0Any::str("winlin");
// 4. SrsAmf0Size: get amf0 instance size
// int size = SrsAmf0Size::str("winlin");
// 5. SrsAmf0Object: the amf0 object, directly new is ok.
// SrsAmf0Object* obj = SrsAmf0Any::object();
// SrsAmf0Object* obj = new SrsAmf0Object();
// 5. SrsAmf0EcmaArray: the amf0 ecma array, directly new is ok.
// SrsAmf0EcmaArray* arr = SrsAmf0Any::array();
// SrsAmf0EcmaArray* arr = new SrsAmf0EcmaArray();
// for detail usage, see interfaces of each object.
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////
/**
* any amf0 value.
* 2.1 Types Overview
...
...
trunk/src/rtmp/srs_protocol_rtmp_stack.cpp
查看文件 @
3691c10
...
...
@@ -2624,6 +2624,7 @@ int SrsPlayPacket::decode(SrsStream* stream)
}
SrsAutoFree
(
SrsAmf0Any
,
reset_value
,
false
);
if
(
reset_value
)
{
// check if the value is bool or number
// An optional Boolean value or number that specifies whether
// to flush any previous playlist
...
...
@@ -2636,6 +2637,7 @@ int SrsPlayPacket::decode(SrsStream* stream)
srs_error
(
"amf0 invalid type=%#x, requires number or bool, ret=%d"
,
reset_value
->
marker
,
ret
);
return
ret
;
}
}
srs_info
(
"amf0 decode play packet success"
);
...
...
@@ -3188,7 +3190,7 @@ int SrsOnMetaDataPacket::decode(SrsStream* stream)
return
ret
;
}
if
(
any
->
is_object
())
{
if
(
any
&&
any
->
is_object
())
{
srs_freep
(
metadata
);
metadata
=
dynamic_cast
<
SrsAmf0Object
*>
(
any
);
srs_info
(
"decode metadata object success"
);
...
...
@@ -3199,10 +3201,11 @@ int SrsOnMetaDataPacket::decode(SrsStream* stream)
if
(
!
arr
)
{
ret
=
ERROR_RTMP_AMF0_DECODE
;
srs_error
(
"decode metadata array failed. ret=%d"
,
ret
);
srs_freep
(
any
);
return
ret
;
}
// if ecma array, copy to object.
SrsAutoFree
(
SrsAmf0EcmaArray
,
arr
,
false
);
for
(
int
i
=
0
;
i
<
arr
->
size
();
i
++
)
{
metadata
->
set
(
arr
->
key_at
(
i
),
arr
->
value_at
(
i
));
}
...
...
请
注册
或
登录
后发表评论