mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
add packets interval in ms to set the right send_min_interval
This commit is contained in:
parent
de48b477ae
commit
e7714cd445
9 changed files with 48 additions and 22 deletions
|
@ -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)
|
||||
{
|
||||
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;
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue