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-18 11:28:22 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e5770b10b14f0f49ee8e2699405d83a421905a93
e5770b10
1 parent
8029b746
refine the colorful log for srs. remove the log when client close.
显示空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
32 行增加
和
17 行删除
trunk/src/app/srs_app_client.cpp
trunk/src/app/srs_app_conn.cpp
trunk/src/app/srs_app_log.cpp
trunk/src/kernel/srs_kernel_error.cpp
trunk/src/kernel/srs_kernel_error.hpp
trunk/src/rtmp/srs_protocol_rtmp_stack.cpp
trunk/src/app/srs_app_client.cpp
查看文件 @
e5770b1
...
...
@@ -197,7 +197,9 @@ int SrsClient::service_cycle()
// when not system control error, fatal error, return.
if
(
!
srs_is_system_control_error
(
ret
))
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
&&
!
srs_is_client_gracefully_close
(
ret
))
{
srs_error
(
"stream service cycle failed. ret=%d"
,
ret
);
}
return
ret
;
}
...
...
@@ -409,7 +411,9 @@ int SrsClient::playing(SrsSource* source)
srs_verbose
(
"play loop recv message. ret=%d"
,
ret
);
if
(
ret
!=
ERROR_SUCCESS
&&
ret
!=
ERROR_SOCKET_TIMEOUT
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
&&
!
srs_is_client_gracefully_close
(
ret
))
{
srs_error
(
"recv client control message failed. ret=%d"
,
ret
);
}
return
ret
;
}
if
((
ret
=
process_play_control_msg
(
consumer
,
msg
))
!=
ERROR_SUCCESS
)
{
...
...
trunk/src/app/srs_app_conn.cpp
查看文件 @
e5770b1
...
...
@@ -63,7 +63,7 @@ void SrsConnection::cycle()
ret
=
do_cycle
();
// if socket io error, set to closed.
if
(
ret
==
ERROR_SOCKET_READ
||
ret
==
ERROR_SOCKET_READ_FULLY
||
ret
==
ERROR_SOCKET_WRITE
)
{
if
(
srs_is_client_gracefully_close
(
ret
)
)
{
ret
=
ERROR_SOCKET_CLOSED
;
}
...
...
@@ -74,7 +74,7 @@ void SrsConnection::cycle()
// client close peer.
if
(
ret
==
ERROR_SOCKET_CLOSED
)
{
srs_
trace
(
"client disconnect peer. ret=%d"
,
ret
);
srs_
warn
(
"client disconnect peer. ret=%d"
,
ret
);
}
server
->
remove
(
this
);
...
...
trunk/src/app/srs_app_log.cpp
查看文件 @
e5770b1
...
...
@@ -218,11 +218,15 @@ void SrsFastLog::write_log(char *str_log, int size, int _level)
log_data
[
size
++
]
=
0
;
// if is error msg, then print color msg.
// \033[1;31m : red text code in shell
// \033[1;31m : normal text code
if
(
_level
==
SrsLogLevel
::
Error
)
{
printf
(
"
\033
[1;31m%s
\033
[0m"
,
str_log
);
}
else
{
// \033[31m : red text code in shell
// \033[32m : green text code in shell
// \033[33m : yellow text code in shell
// \033[0m : normal text code
if
(
_level
<=
SrsLogLevel
::
Trace
)
{
printf
(
"%s"
,
str_log
);
}
else
if
(
_level
==
SrsLogLevel
::
Warn
)
{
printf
(
"
\033
[33m%s
\033
[0m"
,
str_log
);
}
else
{
printf
(
"
\033
[31m%s
\033
[0m"
,
str_log
);
}
}
...
...
trunk/src/kernel/srs_kernel_error.cpp
查看文件 @
e5770b1
...
...
@@ -29,3 +29,9 @@ bool srs_is_system_control_error(int error_code)
||
error_code
==
ERROR_CONTROL_REPUBLISH
;
}
bool
srs_is_client_gracefully_close
(
int
error_code
)
{
return
error_code
==
ERROR_SOCKET_READ
||
error_code
==
ERROR_SOCKET_READ_FULLY
||
error_code
==
ERROR_SOCKET_WRITE
;
}
...
...
trunk/src/kernel/srs_kernel_error.hpp
查看文件 @
e5770b1
...
...
@@ -162,5 +162,6 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
* whether the error code is an system control error.
*/
extern
bool
srs_is_system_control_error
(
int
error_code
);
extern
bool
srs_is_client_gracefully_close
(
int
error_code
);
#endif
...
...
trunk/src/rtmp/srs_protocol_rtmp_stack.cpp
查看文件 @
e5770b1
...
...
@@ -371,7 +371,7 @@ int SrsProtocol::recv_message(SrsCommonMessage** pmsg)
SrsCommonMessage
*
msg
=
NULL
;
if
((
ret
=
recv_interlaced_message
(
&
msg
))
!=
ERROR_SUCCESS
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
&&
!
srs_is_client_gracefully_close
(
ret
)
)
{
srs_error
(
"recv interlaced message failed. ret=%d"
,
ret
);
}
return
ret
;
...
...
@@ -712,7 +712,7 @@ int SrsProtocol::recv_interlaced_message(SrsCommonMessage** pmsg)
int
cid
=
0
;
int
bh_size
=
0
;
if
((
ret
=
read_basic_header
(
fmt
,
cid
,
bh_size
))
!=
ERROR_SUCCESS
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
&&
!
srs_is_client_gracefully_close
(
ret
)
)
{
srs_error
(
"read basic header failed. ret=%d"
,
ret
);
}
return
ret
;
...
...
@@ -749,7 +749,7 @@ int SrsProtocol::recv_interlaced_message(SrsCommonMessage** pmsg)
// chunk stream message header
int
mh_size
=
0
;
if
((
ret
=
read_message_header
(
chunk
,
fmt
,
bh_size
,
mh_size
))
!=
ERROR_SUCCESS
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
&&
!
srs_is_client_gracefully_close
(
ret
)
)
{
srs_error
(
"read message header failed. ret=%d"
,
ret
);
}
return
ret
;
...
...
@@ -763,7 +763,7 @@ int SrsProtocol::recv_interlaced_message(SrsCommonMessage** pmsg)
SrsCommonMessage
*
msg
=
NULL
;
int
payload_size
=
0
;
if
((
ret
=
read_message_payload
(
chunk
,
bh_size
,
mh_size
,
payload_size
,
&
msg
))
!=
ERROR_SUCCESS
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
&&
!
srs_is_client_gracefully_close
(
ret
)
)
{
srs_error
(
"read message payload failed. ret=%d"
,
ret
);
}
return
ret
;
...
...
@@ -797,7 +797,7 @@ int SrsProtocol::read_basic_header(char& fmt, int& cid, int& bh_size)
int
required_size
=
1
;
if
((
ret
=
buffer
->
ensure_buffer_bytes
(
skt
,
required_size
))
!=
ERROR_SUCCESS
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
&&
!
srs_is_client_gracefully_close
(
ret
)
)
{
srs_error
(
"read 1bytes basic header failed. required_size=%d, ret=%d"
,
required_size
,
ret
);
}
return
ret
;
...
...
@@ -817,7 +817,7 @@ int SrsProtocol::read_basic_header(char& fmt, int& cid, int& bh_size)
if
(
cid
==
0
)
{
required_size
=
2
;
if
((
ret
=
buffer
->
ensure_buffer_bytes
(
skt
,
required_size
))
!=
ERROR_SUCCESS
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
&&
!
srs_is_client_gracefully_close
(
ret
)
)
{
srs_error
(
"read 2bytes basic header failed. required_size=%d, ret=%d"
,
required_size
,
ret
);
}
return
ret
;
...
...
@@ -830,7 +830,7 @@ int SrsProtocol::read_basic_header(char& fmt, int& cid, int& bh_size)
}
else
if
(
cid
==
1
)
{
required_size
=
3
;
if
((
ret
=
buffer
->
ensure_buffer_bytes
(
skt
,
3
))
!=
ERROR_SUCCESS
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
&&
!
srs_is_client_gracefully_close
(
ret
)
)
{
srs_error
(
"read 3bytes basic header failed. required_size=%d, ret=%d"
,
required_size
,
ret
);
}
return
ret
;
...
...
@@ -908,7 +908,7 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz
int
required_size
=
bh_size
+
mh_size
;
if
((
ret
=
buffer
->
ensure_buffer_bytes
(
skt
,
required_size
))
!=
ERROR_SUCCESS
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
&&
!
srs_is_client_gracefully_close
(
ret
)
)
{
srs_error
(
"read %dbytes message header failed. required_size=%d, ret=%d"
,
mh_size
,
required_size
,
ret
);
}
return
ret
;
...
...
@@ -1017,7 +1017,7 @@ int SrsProtocol::read_message_header(SrsChunkStream* chunk, char fmt, int bh_siz
required_size
=
bh_size
+
mh_size
;
srs_verbose
(
"read header ext time. fmt=%d, ext_time=%d, mh_size=%d"
,
fmt
,
chunk
->
extended_timestamp
,
mh_size
);
if
((
ret
=
buffer
->
ensure_buffer_bytes
(
skt
,
required_size
))
!=
ERROR_SUCCESS
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
&&
!
srs_is_client_gracefully_close
(
ret
)
)
{
srs_error
(
"read %dbytes message header failed. required_size=%d, ret=%d"
,
mh_size
,
required_size
,
ret
);
}
return
ret
;
...
...
@@ -1119,7 +1119,7 @@ int SrsProtocol::read_message_payload(SrsChunkStream* chunk, int bh_size, int mh
// read payload to buffer
int
required_size
=
bh_size
+
mh_size
+
payload_size
;
if
((
ret
=
buffer
->
ensure_buffer_bytes
(
skt
,
required_size
))
!=
ERROR_SUCCESS
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
)
{
if
(
ret
!=
ERROR_SOCKET_TIMEOUT
&&
!
srs_is_client_gracefully_close
(
ret
)
)
{
srs_error
(
"read payload failed. required_size=%d, ret=%d"
,
required_size
,
ret
);
}
return
ret
;
...
...
请
注册
或
登录
后发表评论