mirror of
https://github.com/ossrs/srs.git
synced 2025-02-13 11:51:57 +00:00
Merge branch '2.0release' into develop
This commit is contained in:
commit
a5dd3a8e7b
9 changed files with 54 additions and 26 deletions
|
@ -875,8 +875,9 @@ vhost stream.control.com {
|
||||||
# delivery packets in constant interval(not cbr).
|
# delivery packets in constant interval(not cbr).
|
||||||
# @remark 0 to disable the minimal interval.
|
# @remark 0 to disable the minimal interval.
|
||||||
# @remark >0 to make the srs to send message one by one.
|
# @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
|
# default: 0
|
||||||
send_min_interval 10;
|
send_min_interval 10.0;
|
||||||
# whether reduce the sequence header,
|
# whether reduce the sequence header,
|
||||||
# for some client which cannot got duplicated sequence header,
|
# for some client which cannot got duplicated sequence header,
|
||||||
# while the sequence header is not changed yet.
|
# while the sequence header is not changed yet.
|
||||||
|
|
|
@ -256,8 +256,10 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int64_t nb_packets = 0;
|
||||||
u_int32_t pre_timestamp = 0;
|
u_int32_t pre_timestamp = 0;
|
||||||
int64_t pre_now = srs_utils_time_ms();
|
int64_t pre_now = srs_utils_time_ms();
|
||||||
|
int64_t start_time = pre_now;
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int size;
|
int size;
|
||||||
char type;
|
char type;
|
||||||
|
@ -269,7 +271,7 @@ int main(int argc, char** argv)
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (srs_human_print_rtmp_packet3(type, timestamp, data, size, pre_timestamp, pre_now) != 0) {
|
if (srs_human_print_rtmp_packet4(type, timestamp, data, size, pre_timestamp, pre_now, start_time, nb_packets++) != 0) {
|
||||||
srs_human_trace("print rtmp packet failed.");
|
srs_human_trace("print rtmp packet failed.");
|
||||||
goto rtmp_destroy;
|
goto rtmp_destroy;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2518,9 +2518,9 @@ bool SrsConfig::get_tcp_nodelay(string vhost)
|
||||||
return SRS_CONF_PERFER_FALSE(conf->arg0());
|
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);
|
SrsConfDirective* conf = get_vhost(vhost);
|
||||||
if (!conf) {
|
if (!conf) {
|
||||||
|
@ -2532,7 +2532,7 @@ int SrsConfig::get_send_min_interval(string vhost)
|
||||||
return DEFAULT;
|
return DEFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
return ::atoi(conf->arg0().c_str());
|
return ::atof(conf->arg0().c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SrsConfig::get_reduce_sequence_header(string vhost)
|
bool SrsConfig::get_reduce_sequence_header(string vhost)
|
||||||
|
|
|
@ -529,7 +529,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* the minimal send interval in ms.
|
* 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.
|
* whether reduce the sequence header.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -256,9 +256,9 @@ int SrsRtmpConn::on_reload_vhost_smi(string vhost)
|
||||||
return ret;
|
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) {
|
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;
|
send_min_interval = smi;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,7 +615,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe
|
||||||
// set the sock options.
|
// set the sock options.
|
||||||
set_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);
|
send_min_interval, mw_sleep, mw_enabled, realtime);
|
||||||
|
|
||||||
while (!disposed) {
|
while (!disposed) {
|
||||||
|
@ -667,7 +667,7 @@ int SrsRtmpConn::do_playing(SrsSource* source, SrsConsumer* consumer, SrsQueueRe
|
||||||
// get messages from consumer.
|
// get messages from consumer.
|
||||||
// each msg in msgs.msgs must be free, for the SrsMessageArray never free them.
|
// 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.
|
// @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) {
|
if ((ret = consumer->dump_packets(&msgs, count)) != ERROR_SUCCESS) {
|
||||||
srs_error("get messages from consumer failed. ret=%d", ret);
|
srs_error("get messages from consumer failed. ret=%d", ret);
|
||||||
return 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.
|
// apply the minimal interval for delivery stream in ms.
|
||||||
if (send_min_interval > 0) {
|
if (send_min_interval > 0) {
|
||||||
st_usleep(send_min_interval * 1000);
|
st_usleep((int64_t)(send_min_interval * 1000));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ private:
|
||||||
// @see https://github.com/simple-rtmp-server/srs/issues/257
|
// @see https://github.com/simple-rtmp-server/srs/issues/257
|
||||||
bool realtime;
|
bool realtime;
|
||||||
// the minimal interval in ms for delivery stream.
|
// the minimal interval in ms for delivery stream.
|
||||||
int send_min_interval;
|
double send_min_interval;
|
||||||
public:
|
public:
|
||||||
SrsRtmpConn(SrsServer* svr, st_netfd_t c);
|
SrsRtmpConn(SrsServer* svr, st_netfd_t c);
|
||||||
virtual ~SrsRtmpConn();
|
virtual ~SrsRtmpConn();
|
||||||
|
|
|
@ -1450,6 +1450,13 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// when already got metadata, drop when reduce sequence header.
|
||||||
|
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.
|
// create a shared ptr message.
|
||||||
srs_freep(cache_metadata);
|
srs_freep(cache_metadata);
|
||||||
cache_metadata = new SrsSharedPtrMessage();
|
cache_metadata = new SrsSharedPtrMessage();
|
||||||
|
@ -1463,10 +1470,6 @@ int SrsSource::on_meta_data(SrsCommonMessage* msg, SrsOnMetaDataPacket* metadata
|
||||||
srs_verbose("initialize shared ptr metadata success.");
|
srs_verbose("initialize shared ptr metadata success.");
|
||||||
|
|
||||||
// copy to all consumer
|
// copy to all consumer
|
||||||
bool drop_for_reduce = false;
|
|
||||||
if (cache_metadata && _srs_config->get_reduce_sequence_header(_req->vhost)) {
|
|
||||||
drop_for_reduce = true;
|
|
||||||
}
|
|
||||||
if (!drop_for_reduce) {
|
if (!drop_for_reduce) {
|
||||||
std::vector<SrsConsumer*>::iterator it;
|
std::vector<SrsConsumer*>::iterator it;
|
||||||
for (it = consumers.begin(); it != consumers.end(); ++it) {
|
for (it = consumers.begin(); it != consumers.end(); ++it) {
|
||||||
|
|
|
@ -2324,9 +2324,20 @@ 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)
|
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;
|
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;
|
int diff = 0;
|
||||||
if (pre_timestamp > 0) {
|
if (pre_timestamp > 0) {
|
||||||
diff = (int)timestamp - (int)pre_timestamp;
|
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;
|
u_int32_t pts;
|
||||||
if (srs_utils_parse_timestamp(timestamp, type, data, size, &pts) != 0) {
|
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_trace("Rtmp packet id=%"PRId64"/%.1f, type=%s, dts=%d, diff=%d, ndiff=%d, size=%d, DecodeError",
|
||||||
srs_human_flv_tag_type2string(type), timestamp, diff, ndiff, size
|
nb_packets, pi, srs_human_flv_tag_type2string(type), timestamp, diff, ndiff, size
|
||||||
);
|
);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == SRS_RTMP_TYPE_VIDEO) {
|
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_trace("Video packet id=%"PRId64"/%.1f, 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,
|
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_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_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))
|
srs_human_flv_video_frame_type2string(srs_utils_flv_video_frame_type(data, size))
|
||||||
);
|
);
|
||||||
} else if (type == SRS_RTMP_TYPE_AUDIO) {
|
} 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_trace("Audio packet id=%"PRId64"/%.1f, 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,
|
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_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_rate2string(srs_utils_flv_audio_sound_rate(data, size)),
|
||||||
srs_human_flv_audio_sound_size2string(srs_utils_flv_audio_sound_size(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))
|
srs_human_flv_audio_aac_packet_type2string(srs_utils_flv_audio_aac_packet_type(data, size))
|
||||||
);
|
);
|
||||||
} else if (type == SRS_RTMP_TYPE_SCRIPT) {
|
} else if (type == SRS_RTMP_TYPE_SCRIPT) {
|
||||||
srs_human_verbose("Data packet type=%s, time=%d, diff=%d, ndiff=%d, size=%d",
|
srs_human_verbose("Data packet id=%"PRId64"/%.1f, type=%s, time=%d, diff=%d, ndiff=%d, size=%d",
|
||||||
srs_human_flv_tag_type2string(type), timestamp, diff, ndiff, size);
|
nb_packets, pi, srs_human_flv_tag_type2string(type), timestamp, diff, ndiff, size);
|
||||||
int nparsed = 0;
|
int nparsed = 0;
|
||||||
while (nparsed < size) {
|
while (nparsed < size) {
|
||||||
int nb_parsed_this = 0;
|
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);
|
srs_freep(amf0_str);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
srs_human_trace("Rtmp packet type=%#x, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d",
|
srs_human_trace("Rtmp packet id=%"PRId64"/%.1f, type=%#x, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d",
|
||||||
type, timestamp, pts, diff, ndiff, size);
|
nb_packets, pi, type, timestamp, pts, diff, ndiff, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
|
@ -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.
|
* @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);
|
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);
|
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);
|
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.
|
// log to console, for use srs-librtmp application.
|
||||||
extern const char* srs_human_format_time();
|
extern const char* srs_human_format_time();
|
||||||
|
|
Loading…
Reference in a new issue