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-11-23 20:33:10 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
b87318dec0b5a8d1113133b7cb4de8d07ec3fe9c
b87318de
1 parent
195a857f
extract method to process publish message
隐藏空白字符变更
内嵌
并排对比
正在显示
2 个修改的文件
包含
60 行增加
和
46 行删除
trunk/src/core/srs_core_client.cpp
trunk/src/core/srs_core_client.hpp
trunk/src/core/srs_core_client.cpp
查看文件 @
b87318d
...
...
@@ -351,62 +351,74 @@ int SrsClient::publish(SrsSource* source, bool is_fmle)
srs_trace
(
"<- clock=%u, time=%"
PRId64
", obytes=%"
PRId64
", ibytes=%"
PRId64
", okbps=%d, ikbps=%d"
,
(
int
)(
srs_get_system_time_ms
()
/
1000
),
pithy_print
.
get_age
(),
rtmp
->
get_send_bytes
(),
rtmp
->
get_recv_bytes
(),
rtmp
->
get_send_kbps
(),
rtmp
->
get_recv_kbps
());
}
// process audio packet
if
(
msg
->
header
.
is_audio
()
&&
((
ret
=
source
->
on_audio
(
msg
))
!=
ERROR_SUCCESS
))
{
srs_error
(
"process audio message failed. ret=%d"
,
ret
);
if
((
ret
=
process_publish_message
(
source
,
hls
,
msg
,
is_fmle
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"process publish message failed. ret=%d"
,
ret
);
return
ret
;
}
// process video packet
if
(
msg
->
header
.
is_video
()
&&
((
ret
=
source
->
on_video
(
msg
))
!=
ERROR_SUCCESS
))
{
srs_error
(
"process video message failed. ret=%d"
,
ret
);
}
return
ret
;
}
int
SrsClient
::
process_publish_message
(
SrsSource
*
source
,
SrsHLS
*
hls
,
SrsCommonMessage
*
msg
,
bool
is_fmle
)
{
int
ret
=
ERROR_SUCCESS
;
// process audio packet
if
(
msg
->
header
.
is_audio
()
&&
((
ret
=
source
->
on_audio
(
msg
))
!=
ERROR_SUCCESS
))
{
srs_error
(
"process audio message failed. ret=%d"
,
ret
);
return
ret
;
}
// process video packet
if
(
msg
->
header
.
is_video
()
&&
((
ret
=
source
->
on_video
(
msg
))
!=
ERROR_SUCCESS
))
{
srs_error
(
"process video message failed. ret=%d"
,
ret
);
return
ret
;
}
// process onMetaData
if
(
msg
->
header
.
is_amf0_data
()
||
msg
->
header
.
is_amf3_data
())
{
if
((
ret
=
msg
->
decode_packet
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"decode onMetaData message failed. ret=%d"
,
ret
);
return
ret
;
}
// process onMetaData
if
(
msg
->
header
.
is_amf0_data
()
||
msg
->
header
.
is_amf3_data
())
{
if
((
ret
=
msg
->
decode_packet
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"decode onMetaData message failed. ret=%d"
,
ret
);
SrsPacket
*
pkt
=
msg
->
get_packet
();
if
(
dynamic_cast
<
SrsOnMetaDataPacket
*>
(
pkt
))
{
SrsOnMetaDataPacket
*
metadata
=
dynamic_cast
<
SrsOnMetaDataPacket
*>
(
pkt
);
if
((
ret
=
source
->
on_meta_data
(
msg
,
metadata
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"process onMetaData message failed. ret=%d"
,
ret
);
return
ret
;
}
SrsPacket
*
pkt
=
msg
->
get_packet
();
if
(
dynamic_cast
<
SrsOnMetaDataPacket
*>
(
pkt
))
{
SrsOnMetaDataPacket
*
metadata
=
dynamic_cast
<
SrsOnMetaDataPacket
*>
(
pkt
);
if
((
ret
=
source
->
on_meta_data
(
msg
,
metadata
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"process onMetaData message failed. ret=%d"
,
ret
);
return
ret
;
}
srs_trace
(
"process onMetaData message success."
);
continue
;
}
srs_trace
(
"ignore AMF0/AMF3 data message."
);
continue
;
srs_trace
(
"process onMetaData message success."
);
return
ret
;
}
// process UnPublish event.
if
(
msg
->
header
.
is_amf0_command
()
||
msg
->
header
.
is_amf3_command
())
{
if
((
ret
=
msg
->
decode_packet
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"decode unpublish message failed. ret=%d"
,
ret
);
return
ret
;
}
// flash unpublish.
if
(
!
is_fmle
)
{
srs_trace
(
"flash publish finished."
);
return
ret
;
}
srs_trace
(
"ignore AMF0/AMF3 data message."
);
return
ret
;
}
// process UnPublish event.
if
(
msg
->
header
.
is_amf0_command
()
||
msg
->
header
.
is_amf3_command
())
{
if
((
ret
=
msg
->
decode_packet
())
!=
ERROR_SUCCESS
)
{
srs_error
(
"decode unpublish message failed. ret=%d"
,
ret
);
return
ret
;
}
SrsPacket
*
pkt
=
msg
->
get_packet
();
if
(
dynamic_cast
<
SrsFMLEStartPacket
*>
(
pkt
))
{
SrsFMLEStartPacket
*
unpublish
=
dynamic_cast
<
SrsFMLEStartPacket
*>
(
pkt
);
return
rtmp
->
fmle_unpublish
(
res
->
stream_id
,
unpublish
->
transaction_id
);
}
srs_trace
(
"ignore AMF0/AMF3 command message."
);
continue
;
// flash unpublish.
if
(
!
is_fmle
)
{
srs_trace
(
"flash publish finished."
);
return
ret
;
}
SrsPacket
*
pkt
=
msg
->
get_packet
();
if
(
dynamic_cast
<
SrsFMLEStartPacket
*>
(
pkt
))
{
SrsFMLEStartPacket
*
unpublish
=
dynamic_cast
<
SrsFMLEStartPacket
*>
(
pkt
);
return
rtmp
->
fmle_unpublish
(
res
->
stream_id
,
unpublish
->
transaction_id
);
}
srs_trace
(
"ignore AMF0/AMF3 command message."
);
return
ret
;
}
return
ret
;
...
...
trunk/src/core/srs_core_client.hpp
查看文件 @
b87318d
...
...
@@ -39,6 +39,7 @@ class SrsSource;
class
SrsRefer
;
class
SrsConsumer
;
class
SrsCommonMessage
;
class
SrsHLS
;
/**
* the client provides the main logic control for RTMP clients.
...
...
@@ -60,6 +61,7 @@ private:
virtual
int
check_vhost
();
virtual
int
playing
(
SrsSource
*
source
);
virtual
int
publish
(
SrsSource
*
source
,
bool
is_fmle
);
virtual
int
process_publish_message
(
SrsSource
*
source
,
SrsHLS
*
hls
,
SrsCommonMessage
*
msg
,
bool
is_fmle
);
virtual
int
get_peer_ip
();
virtual
int
process_play_control_msg
(
SrsConsumer
*
consumer
,
SrsCommonMessage
*
msg
);
};
...
...
请
注册
或
登录
后发表评论