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
2015-08-22 13:57:34 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
aeebddb2691b7598d83429bc32ef6c0390f9cea2
aeebddb2
1 parent
94641c81
for #442, add more information for client for api.
显示空白字符变更
内嵌
并排对比
正在显示
6 个修改的文件
包含
36 行增加
和
8 行删除
trunk/src/app/srs_app_rtmp_conn.cpp
trunk/src/app/srs_app_statistic.cpp
trunk/src/app/srs_app_statistic.hpp
trunk/src/protocol/srs_rtmp_stack.cpp
trunk/src/protocol/srs_rtmp_stack.hpp
trunk/src/protocol/srs_rtmp_utility.cpp
trunk/src/app/srs_app_rtmp_conn.cpp
查看文件 @
aeebddb
...
...
@@ -495,7 +495,7 @@ int SrsRtmpConn::stream_service_cycle()
// update the statistic when source disconveried.
SrsStatistic
*
stat
=
SrsStatistic
::
instance
();
if
((
ret
=
stat
->
on_client
(
_srs_context
->
get_id
(),
req
,
this
))
!=
ERROR_SUCCESS
)
{
if
((
ret
=
stat
->
on_client
(
_srs_context
->
get_id
(),
req
,
this
,
type
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"stat client failed. ret=%d"
,
ret
);
return
ret
;
}
...
...
trunk/src/app/srs_app_statistic.cpp
查看文件 @
aeebddb
...
...
@@ -181,6 +181,11 @@ void SrsStatisticStream::close()
SrsStatisticClient
::
SrsStatisticClient
()
{
id
=
0
;
stream
=
NULL
;
conn
=
NULL
;
req
=
NULL
;
type
=
SrsRtmpConnUnknown
;
create
=
srs_get_system_time_ms
();
}
SrsStatisticClient
::~
SrsStatisticClient
()
...
...
@@ -192,7 +197,17 @@ int SrsStatisticClient::dumps(stringstream& ss)
int
ret
=
ERROR_SUCCESS
;
ss
<<
SRS_JOBJECT_START
<<
SRS_JFIELD_ORG
(
"id"
,
id
)
<<
SRS_JFIELD_ORG
(
"id"
,
id
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_ORG
(
"vhost"
,
stream
->
vhost
->
id
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_ORG
(
"stream"
,
stream
->
id
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"ip"
,
req
->
ip
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"pageUrl"
,
req
->
pageUrl
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"swfUrl"
,
req
->
swfUrl
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"tcUrl"
,
req
->
tcUrl
)
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"url"
,
req
->
get_stream_url
())
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_STR
(
"type"
,
srs_client_type_string
(
type
))
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_BOOL
(
"publish"
,
srs_client_type_is_publish
(
type
))
<<
SRS_JFIELD_CONT
<<
SRS_JFIELD_ORG
(
"alive"
,
srs_get_system_time_ms
()
-
create
)
<<
SRS_JOBJECT_END
;
return
ret
;
...
...
@@ -322,7 +337,7 @@ void SrsStatistic::on_stream_close(SrsRequest* req)
stream
->
close
();
}
int
SrsStatistic
::
on_client
(
int
id
,
SrsRequest
*
req
,
SrsConnection
*
conn
)
int
SrsStatistic
::
on_client
(
int
id
,
SrsRequest
*
req
,
SrsConnection
*
conn
,
SrsRtmpConnType
type
)
{
int
ret
=
ERROR_SUCCESS
;
...
...
@@ -342,6 +357,8 @@ int SrsStatistic::on_client(int id, SrsRequest* req, SrsConnection* conn)
// got client.
client
->
conn
=
conn
;
client
->
req
=
req
;
client
->
type
=
type
;
stream
->
nb_clients
++
;
vhost
->
nb_clients
++
;
...
...
@@ -464,7 +481,7 @@ int SrsStatistic::dumps_clients(stringstream& ss, int start, int count)
ss
<<
SRS_JARRAY_START
;
std
::
map
<
int
,
SrsStatisticClient
*>::
iterator
it
=
clients
.
begin
();
for
(
int
i
=
0
;
i
<
count
&&
it
!=
clients
.
end
();
it
++
)
{
for
(
int
i
=
0
;
i
<
start
+
count
&&
it
!=
clients
.
end
();
it
++
,
i
++
)
{
if
(
i
<
start
)
{
continue
;
}
...
...
trunk/src/app/srs_app_statistic.hpp
查看文件 @
aeebddb
...
...
@@ -34,6 +34,7 @@ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include <string>
#include <srs_kernel_codec.hpp>
#include <srs_rtmp_stack.hpp>
class
SrsKbps
;
class
SrsRequest
;
...
...
@@ -113,7 +114,10 @@ struct SrsStatisticClient
public
:
SrsStatisticStream
*
stream
;
SrsConnection
*
conn
;
SrsRequest
*
req
;
SrsRtmpConnType
type
;
int
id
;
int64_t
create
;
public
:
SrsStatisticClient
();
virtual
~
SrsStatisticClient
();
...
...
@@ -183,8 +187,9 @@ public:
* @param id, the client srs id.
* @param req, the client request object.
* @param conn, the physical absract connection object.
* @param type, the type of connection.
*/
virtual
int
on_client
(
int
id
,
SrsRequest
*
req
,
SrsConnection
*
conn
);
virtual
int
on_client
(
int
id
,
SrsRequest
*
req
,
SrsConnection
*
conn
,
SrsRtmpConnType
type
);
/**
* client disconnect
* @remark the on_disconnect always call, while the on_client is call when
...
...
trunk/src/protocol/srs_rtmp_stack.cpp
查看文件 @
aeebddb
...
...
@@ -1747,12 +1747,17 @@ string srs_client_type_string(SrsRtmpConnType type)
{
switch
(
type
)
{
case
SrsRtmpConnPlay
:
return
"Play"
;
case
SrsRtmpConnFlashPublish
:
return
"publish(FlashPublish)"
;
case
SrsRtmpConnFMLEPublish
:
return
"publish(FMLEPublish)"
;
case
SrsRtmpConnFlashPublish
:
return
"flash-publish)"
;
case
SrsRtmpConnFMLEPublish
:
return
"fmle-publish"
;
default
:
return
"Unknown"
;
}
}
bool
srs_client_type_is_publish
(
SrsRtmpConnType
type
)
{
return
type
!=
SrsRtmpConnPlay
;
}
SrsHandshakeBytes
::
SrsHandshakeBytes
()
{
c0c1
=
s0s1s2
=
c2
=
NULL
;
...
...
trunk/src/protocol/srs_rtmp_stack.hpp
查看文件 @
aeebddb
...
...
@@ -622,6 +622,7 @@ enum SrsRtmpConnType
SrsRtmpConnFlashPublish
,
};
std
::
string
srs_client_type_string
(
SrsRtmpConnType
type
);
bool
srs_client_type_is_publish
(
SrsRtmpConnType
type
);
/**
* store the handshake bytes,
...
...
trunk/src/protocol/srs_rtmp_utility.cpp
查看文件 @
aeebddb
...
...
@@ -247,7 +247,7 @@ int srs_write_large_iovs(ISrsProtocolReaderWriter* skt, iovec* iovs, int size, s
// for srs-librtmp, @see https://github.com/simple-rtmp-server/srs/issues/213
#ifndef _WIN32
// for linux, generally it's 1024.
static
int
limits
=
sysconf
(
_SC_IOV_MAX
);
static
int
limits
=
(
int
)
sysconf
(
_SC_IOV_MAX
);
#else
static
int
limits
=
1024
;
#endif
...
...
请
注册
或
登录
后发表评论