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
2013-10-22 19:48:50 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
52a454c41bd2ccd7b193badf5a4d2d3f31db08c6
52a454c4
1 parent
d8a99dde
rename base message to ISrsMessage
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
41 行增加
和
16 行删除
trunk/src/core/srs_core_protocol.cpp
trunk/src/core/srs_core_protocol.hpp
trunk/src/core/srs_core_protocol.cpp
查看文件 @
52a454c
...
...
@@ -320,12 +320,12 @@ int SrsProtocol::recv_message(SrsCommonMessage** pmsg)
return
ret
;
}
int
SrsProtocol
::
send_message
(
SrsOutputable
Message
*
msg
)
int
SrsProtocol
::
send_message
(
ISrs
Message
*
msg
)
{
int
ret
=
ERROR_SUCCESS
;
// free msg whatever return value.
SrsAutoFree
(
SrsOutputable
Message
,
msg
,
false
);
SrsAutoFree
(
ISrs
Message
,
msg
,
false
);
if
((
ret
=
msg
->
encode_packet
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"encode packet to message payload failed. ret=%d"
,
ret
);
...
...
@@ -479,10 +479,15 @@ int SrsProtocol::on_recv_message(SrsCommonMessage* msg)
return
ret
;
}
int
SrsProtocol
::
on_send_message
(
SrsOutputable
Message
*
msg
)
int
SrsProtocol
::
on_send_message
(
ISrs
Message
*
msg
)
{
int
ret
=
ERROR_SUCCESS
;
if
(
!
msg
->
can_decode
())
{
srs_verbose
(
"ignore the un-decodable message."
);
return
ret
;
}
SrsCommonMessage
*
common_msg
=
dynamic_cast
<
SrsCommonMessage
*>
(
msg
);
if
(
!
msg
)
{
srs_verbose
(
"ignore the shared ptr message."
);
...
...
@@ -927,18 +932,18 @@ SrsChunkStream::~SrsChunkStream()
srs_freep
(
msg
);
}
SrsOutputableMessage
::
SrsOutputable
Message
()
ISrsMessage
::
ISrs
Message
()
{
payload
=
NULL
;
size
=
0
;
}
SrsOutputableMessage
::~
SrsOutputable
Message
()
ISrsMessage
::~
ISrs
Message
()
{
free_payload
();
}
void
SrsOutputable
Message
::
free_payload
()
void
ISrs
Message
::
free_payload
()
{
srs_freepa
(
payload
);
}
...
...
@@ -955,6 +960,11 @@ SrsCommonMessage::~SrsCommonMessage()
srs_freep
(
stream
);
}
bool
SrsCommonMessage
::
can_decode
()
{
return
true
;
}
int
SrsCommonMessage
::
decode_packet
()
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -1145,6 +1155,11 @@ void SrsSharedPtrMessage::free_payload()
}
}
bool
SrsSharedPtrMessage
::
can_decode
()
{
return
true
;
}
int
SrsSharedPtrMessage
::
initialize
(
SrsMessageHeader
*
header
,
char
*
payload
,
int
size
,
int
perfer_cid
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
trunk/src/core/srs_core_protocol.hpp
查看文件 @
52a454c
...
...
@@ -47,7 +47,7 @@ class SrsChunkStream;
class
SrsAmf0Object
;
class
SrsAmf0Null
;
class
SrsAmf0Undefined
;
class
SrsOutputable
Message
;
class
ISrs
Message
;
// convert class name to string.
#define CLASS_NAME_STRING(className) #className
...
...
@@ -112,7 +112,7 @@ public:
* then sendout over socket.
* @msg this method will free it whatever return value.
*/
virtual
int
send_message
(
SrsOutputable
Message
*
msg
);
virtual
int
send_message
(
ISrs
Message
*
msg
);
private
:
/**
* when recv message, update the context.
...
...
@@ -121,7 +121,7 @@ private:
/**
* when message sentout, update the context.
*/
virtual
int
on_send_message
(
SrsOutputable
Message
*
msg
);
virtual
int
on_send_message
(
ISrs
Message
*
msg
);
/**
* try to recv interlaced message from peer,
* return error if error occur and nerver set the pmsg,
...
...
@@ -235,7 +235,7 @@ public:
/**
* message to output.
*/
class
SrsOutputable
Message
class
ISrs
Message
{
// 4.1. Message Header
public:
...
...
@@ -251,10 +251,16 @@ public:
int32_t
size
;
int8_t
*
payload
;
public
:
SrsOutputableMessage
();
virtual
~
SrsOutputableMessage
();
ISrsMessage
();
virtual
~
ISrsMessage
();
protected
:
virtual
void
free_payload
();
public
:
/**
* whether message canbe decoded.
* only update the context when message canbe decoded.
*/
virtual
bool
can_decode
()
=
0
;
/**
* encode functions.
*/
...
...
@@ -274,10 +280,10 @@ public:
* common RTMP message defines in rtmp.part2.Message-Formats.pdf.
* cannbe parse and decode.
*/
class
SrsCommonMessage
:
public
SrsOutputable
Message
class
SrsCommonMessage
:
public
ISrs
Message
{
private
:
typedef
SrsOutputable
Message
super
;
typedef
ISrs
Message
super
;
// decoded message payload.
private:
SrsStream
*
stream
;
...
...
@@ -285,6 +291,8 @@ private:
public
:
SrsCommonMessage
();
virtual
~
SrsCommonMessage
();
public
:
virtual
bool
can_decode
();
/**
* decode functions.
*/
...
...
@@ -324,10 +332,10 @@ public:
* for audio/video/data message that need less memory copy.
* and only for output.
*/
class
SrsSharedPtrMessage
:
public
SrsOutputable
Message
class
SrsSharedPtrMessage
:
public
ISrs
Message
{
private
:
typedef
SrsOutputable
Message
super
;
typedef
ISrs
Message
super
;
private
:
struct
SrsSharedPtr
{
...
...
@@ -346,6 +354,8 @@ public:
protected
:
virtual
void
free_payload
();
public
:
virtual
bool
can_decode
();
public
:
/**
* set the shared payload.
*/
...
...
请
注册
或
登录
后发表评论