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-19 15:14:26 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
e7714cd445d2dc5ee4c0dd65bedf48f9920d8faf
e7714cd4
1 parent
de48b477
add packets interval in ms to set the right send_min_interval
隐藏空白字符变更
内嵌
并排对比
正在显示
9 个修改的文件
包含
48 行增加
和
22 行删除
trunk/conf/full.conf
trunk/research/librtmp/srs_rtmp_dump.c
trunk/src/app/srs_app_config.cpp
trunk/src/app/srs_app_config.hpp
trunk/src/app/srs_app_rtmp_conn.cpp
trunk/src/app/srs_app_rtmp_conn.hpp
trunk/src/app/srs_app_source.cpp
trunk/src/libs/srs_librtmp.cpp
trunk/src/libs/srs_librtmp.hpp
trunk/conf/full.conf
查看文件 @
e7714cd
...
...
@@ -875,8 +875,9 @@ vhost stream.control.com {
# delivery packets in constant interval(not cbr).
# @remark 0 to disable the minimal interval.
# @remark >0 to make the srs to send message one by one.
# @remark user can get the right packets interval in ms by srs_rtmp_dump.
# default: 0
send_min_interval
10
;
send_min_interval
10
.
0
;
# whether reduce the sequence header,
# for some client which cannot got duplicated sequence header,
# while the sequence header is not changed yet.
...
...
trunk/research/librtmp/srs_rtmp_dump.c
查看文件 @
e7714cd
...
...
@@ -256,8 +256,10 @@ int main(int argc, char** argv)
}
}
int64_t
nb_packets
=
0
;
u_int32_t
pre_timestamp
=
0
;
int64_t
pre_now
=
srs_utils_time_ms
();
int64_t
start_time
=
pre_now
;
for
(;;)
{
int
size
;
char
type
;
...
...
@@ -269,7 +271,7 @@ int main(int argc, char** argv)
goto
rtmp_destroy
;
}
if
(
srs_human_print_rtmp_packet
3
(
type
,
timestamp
,
data
,
size
,
pre_timestamp
,
pre_now
)
!=
0
)
{
if
(
srs_human_print_rtmp_packet
4
(
type
,
timestamp
,
data
,
size
,
pre_timestamp
,
pre_now
,
start_time
,
nb_packets
++
)
!=
0
)
{
srs_human_trace
(
"print rtmp packet failed."
);
goto
rtmp_destroy
;
}
...
...
trunk/src/app/srs_app_config.cpp
查看文件 @
e7714cd
...
...
@@ -2518,9 +2518,9 @@ bool SrsConfig::get_tcp_nodelay(string vhost)
return
SRS_CONF_PERFER_FALSE
(
conf
->
arg0
());
}
int
SrsConfig
::
get_send_min_interval
(
string
vhost
)
double
SrsConfig
::
get_send_min_interval
(
string
vhost
)
{
static
int
DEFAULT
=
0
;
static
double
DEFAULT
=
0.
0
;
SrsConfDirective
*
conf
=
get_vhost
(
vhost
);
if
(
!
conf
)
{
...
...
@@ -2532,7 +2532,7 @@ int SrsConfig::get_send_min_interval(string vhost)
return
DEFAULT
;
}
return
::
ato
i
(
conf
->
arg0
().
c_str
());
return
::
ato
f
(
conf
->
arg0
().
c_str
());
}
bool
SrsConfig
::
get_reduce_sequence_header
(
string
vhost
)
...
...
trunk/src/app/srs_app_config.hpp
查看文件 @
e7714cd
...
...
@@ -529,7 +529,7 @@ public:
/**
* the minimal send interval in ms.
*/
virtual
int
get_send_min_interval
(
std
::
string
vhost
);
virtual
double
get_send_min_interval
(
std
::
string
vhost
);
/**
* whether reduce the sequence header.
*/
...
...
trunk/src/app/srs_app_rtmp_conn.cpp
查看文件 @
e7714cd
...
...
@@ -256,9 +256,9 @@ int SrsRtmpConn::on_reload_vhost_smi(string vhost)
return
ret
;
}
int
smi
=
_srs_config
->
get_send_min_interval
(
vhost
);
double
smi
=
_srs_config
->
get_send_min_interval
(
vhost
);
if
(
smi
!=
send_min_interval
)
{
srs_trace
(
"apply smi %
d=>%d
"
,
send_min_interval
,
smi
);
srs_trace
(
"apply smi %
.2f=>%.2f
"
,
send_min_interval
,
smi
);
send_min_interval
=
smi
;
}
...
...
@@ -615,7 +615,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe
// set the sock options.
set_sock_options
();
srs_trace
(
"start play smi=%
d
, mw_sleep=%d, mw_enabled=%d, realtime=%d"
,
srs_trace
(
"start play smi=%
.2f
, mw_sleep=%d, mw_enabled=%d, realtime=%d"
,
send_min_interval
,
mw_sleep
,
mw_enabled
,
realtime
);
while
(
!
disposed
)
{
...
...
@@ -667,7 +667,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe
// get messages from consumer.
// each msg in msgs.msgs must be free, for the SrsMessageArray never free them.
// @remark when enable send_min_interval, only fetch one message a time.
int
count
=
send_min_interval
?
1
:
0
;
int
count
=
(
send_min_interval
>
0
)
?
1
:
0
;
if
((
ret
=
consumer
->
dump_packets
(
&
msgs
,
count
))
!=
ERROR_SUCCESS
)
{
srs_error
(
"get messages from consumer failed. ret=%d"
,
ret
);
return
ret
;
...
...
@@ -745,7 +745,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe
// apply the minimal interval for delivery stream in ms.
if
(
send_min_interval
>
0
)
{
st_usleep
(
send_min_interval
*
1000
);
st_usleep
(
(
int64_t
)(
send_min_interval
*
1000
)
);
}
}
...
...
trunk/src/app/srs_app_rtmp_conn.hpp
查看文件 @
e7714cd
...
...
@@ -86,7 +86,7 @@ private:
// @see https://github.com/simple-rtmp-server/srs/issues/257
bool
realtime
;
// the minimal interval in ms for delivery stream.
int
send_min_interval
;
double
send_min_interval
;
public
:
SrsRtmpConn
(
SrsServer
*
svr
,
st_netfd_t
c
);
virtual
~
SrsRtmpConn
();
...
...
trunk/src/app/srs_app_source.cpp
查看文件 @
e7714cd
...
...
@@ -1454,6 +1454,7 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata
bool
drop_for_reduce
=
false
;
if
(
cache_metadata
&&
_srs_config
->
get_reduce_sequence_header
(
_req
->
vhost
))
{
drop_for_reduce
=
true
;
srs_warn
(
"drop for reduce sh metadata, size=%d"
,
msg
->
size
);
}
// create a shared ptr message.
...
...
trunk/src/libs/srs_librtmp.cpp
查看文件 @
e7714cd
...
...
@@ -2325,8 +2325,19 @@ int srs_human_print_rtmp_packet2(char type, u_int32_t timestamp, char* data, int
int
srs_human_print_rtmp_packet3
(
char
type
,
u_int32_t
timestamp
,
char
*
data
,
int
size
,
u_int32_t
pre_timestamp
,
int64_t
pre_now
)
{
return
srs_human_print_rtmp_packet4
(
type
,
timestamp
,
data
,
size
,
pre_timestamp
,
pre_now
,
0
,
0
);
}
int
srs_human_print_rtmp_packet4
(
char
type
,
u_int32_t
timestamp
,
char
*
data
,
int
size
,
u_int32_t
pre_timestamp
,
int64_t
pre_now
,
int64_t
starttime
,
int64_t
nb_packets
)
{
int
ret
=
ERROR_SUCCESS
;
// packets interval in milliseconds.
double
pi
=
0
;
if
(
pre_now
>
starttime
)
{
pi
=
(
pre_now
-
starttime
)
/
(
double
)
nb_packets
;
}
int
diff
=
0
;
if
(
pre_timestamp
>
0
)
{
diff
=
(
int
)
timestamp
-
(
int
)
pre_timestamp
;
...
...
@@ -2339,22 +2350,22 @@ int srs_human_print_rtmp_packet3(char type, u_int32_t timestamp, char* data, int
u_int32_t
pts
;
if
(
srs_utils_parse_timestamp
(
timestamp
,
type
,
data
,
size
,
&
pts
)
!=
0
)
{
srs_human_trace
(
"Rtmp packet type=%s, dts=%d, diff=%d, ndiff=%d, size=%d, DecodeError"
,
srs_human_flv_tag_type2string
(
type
),
timestamp
,
diff
,
ndiff
,
size
srs_human_trace
(
"Rtmp packet id=%"
PRId64
"/%.1f, type=%s, dts=%d, diff=%d, ndiff=%d, size=%d, DecodeError"
,
nb_packets
,
pi
,
srs_human_flv_tag_type2string
(
type
),
timestamp
,
diff
,
ndiff
,
size
);
return
ret
;
}
if
(
type
==
SRS_RTMP_TYPE_VIDEO
)
{
srs_human_trace
(
"Video packet type=%s, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d, %s(%s,%s)"
,
srs_human_flv_tag_type2string
(
type
),
timestamp
,
pts
,
diff
,
ndiff
,
size
,
srs_human_trace
(
"Video packet id=%"
PRId64
"/%.1f, type=%s, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d, %s(%s,%s)"
,
nb_packets
,
pi
,
srs_human_flv_tag_type2string
(
type
),
timestamp
,
pts
,
diff
,
ndiff
,
size
,
srs_human_flv_video_codec_id2string
(
srs_utils_flv_video_codec_id
(
data
,
size
)),
srs_human_flv_video_avc_packet_type2string
(
srs_utils_flv_video_avc_packet_type
(
data
,
size
)),
srs_human_flv_video_frame_type2string
(
srs_utils_flv_video_frame_type
(
data
,
size
))
);
}
else
if
(
type
==
SRS_RTMP_TYPE_AUDIO
)
{
srs_human_trace
(
"Audio packet type=%s, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d, %s(%s,%s,%s,%s)"
,
srs_human_flv_tag_type2string
(
type
),
timestamp
,
pts
,
diff
,
ndiff
,
size
,
srs_human_trace
(
"Audio packet id=%"
PRId64
"/%.1f, type=%s, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d, %s(%s,%s,%s,%s)"
,
nb_packets
,
pi
,
srs_human_flv_tag_type2string
(
type
),
timestamp
,
pts
,
diff
,
ndiff
,
size
,
srs_human_flv_audio_sound_format2string
(
srs_utils_flv_audio_sound_format
(
data
,
size
)),
srs_human_flv_audio_sound_rate2string
(
srs_utils_flv_audio_sound_rate
(
data
,
size
)),
srs_human_flv_audio_sound_size2string
(
srs_utils_flv_audio_sound_size
(
data
,
size
)),
...
...
@@ -2362,8 +2373,8 @@ int srs_human_print_rtmp_packet3(char type, u_int32_t timestamp, char* data, int
srs_human_flv_audio_aac_packet_type2string
(
srs_utils_flv_audio_aac_packet_type
(
data
,
size
))
);
}
else
if
(
type
==
SRS_RTMP_TYPE_SCRIPT
)
{
srs_human_verbose
(
"Data packet type=%s, time=%d, diff=%d, ndiff=%d, size=%d"
,
srs_human_flv_tag_type2string
(
type
),
timestamp
,
diff
,
ndiff
,
size
);
srs_human_verbose
(
"Data packet id=%"
PRId64
"/%.1f, type=%s, time=%d, diff=%d, ndiff=%d, size=%d"
,
nb_packets
,
pi
,
srs_human_flv_tag_type2string
(
type
),
timestamp
,
diff
,
ndiff
,
size
);
int
nparsed
=
0
;
while
(
nparsed
<
size
)
{
int
nb_parsed_this
=
0
;
...
...
@@ -2379,8 +2390,8 @@ int srs_human_print_rtmp_packet3(char type, u_int32_t timestamp, char* data, int
srs_freep
(
amf0_str
);
}
}
else
{
srs_human_trace
(
"Rtmp packet type=%#x, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d"
,
type
,
timestamp
,
pts
,
diff
,
ndiff
,
size
);
srs_human_trace
(
"Rtmp packet id=%"
PRId64
"/%.1f, type=%#x, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d"
,
nb_packets
,
pi
,
type
,
timestamp
,
pts
,
diff
,
ndiff
,
size
);
}
return
ret
;
...
...
trunk/src/libs/srs_librtmp.hpp
查看文件 @
e7714cd
...
...
@@ -904,8 +904,19 @@ extern const char* srs_human_flv_audio_aac_packet_type2string(char aac_packet_ty
* @return an error code for parse the timetstamp to dts and pts.
*/
extern
int
srs_human_print_rtmp_packet
(
char
type
,
u_int32_t
timestamp
,
char
*
data
,
int
size
);
/**
* @param pre_timestamp the previous timestamp in ms to calc the diff.
*/
extern
int
srs_human_print_rtmp_packet2
(
char
type
,
u_int32_t
timestamp
,
char
*
data
,
int
size
,
u_int32_t
pre_timestamp
);
/**
* @param pre_now the previous system time in ms to calc the ndiff.
*/
extern
int
srs_human_print_rtmp_packet3
(
char
type
,
u_int32_t
timestamp
,
char
*
data
,
int
size
,
u_int32_t
pre_timestamp
,
int64_t
pre_now
);
/**
* @param starttime the rtmpdump starttime in ms.
* @param nb_packets the number of packets received, to calc the packets interval in ms.
*/
extern
int
srs_human_print_rtmp_packet4
(
char
type
,
u_int32_t
timestamp
,
char
*
data
,
int
size
,
u_int32_t
pre_timestamp
,
int64_t
pre_now
,
int64_t
starttime
,
int64_t
nb_packets
);
// log to console, for use srs-librtmp application.
extern
const
char
*
srs_human_format_time
();
...
...
请
注册
或
登录
后发表评论