From 170ad05148aa938cd06f69a00c5baabc76dcc04c Mon Sep 17 00:00:00 2001 From: winlin Date: Wed, 19 Aug 2015 15:31:19 +0800 Subject: [PATCH] add gfps and nb_packets --- README.md | 12 ------------ trunk/research/librtmp/srs_rtmp_dump.c | 11 +++++++++-- trunk/src/libs/srs_librtmp.cpp | 26 ++++++++++++++++---------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index cdb19fb1b..896bf474a 100755 --- a/README.md +++ b/README.md @@ -759,18 +759,6 @@ About the HLS overhead of SRS, we compare the overhead to FLV by remux the HLS t The HLS overhead is calc by: (HLS - FLV) / FLV * 100% -### Bytes Api - -The api provides bytes of vhost, stream and srs. - -| Connections | tcpdump | srs | deviation | -| ----------- | ---------- | ---------- | --------- | -| 1 | 201687968 | 201687968 | 0% | -| 100 | 12456042662 | 12458284053 | 0.018% | -| 500 | 11623083989 | 11633158616 | 0.087% | - -The tcpdump command is `tcpdump src 192.168.1.151 and port 1935 -i eth0 and tcp -ql`. - ## Architecture SRS always use the most simple architecture to support complex transaction. diff --git a/trunk/research/librtmp/srs_rtmp_dump.c b/trunk/research/librtmp/srs_rtmp_dump.c index 49ea8edb9..3f3d030aa 100644 --- a/trunk/research/librtmp/srs_rtmp_dump.c +++ b/trunk/research/librtmp/srs_rtmp_dump.c @@ -258,8 +258,8 @@ 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; + int64_t pre_now = -1; + int64_t start_time = -1; for (;;) { int size; char type; @@ -271,6 +271,13 @@ int main(int argc, char** argv) goto rtmp_destroy; } + if (pre_now == -1) { + pre_now = srs_utils_time_ms(); + } + if (start_time == -1) { + start_time = srs_utils_time_ms(); + } + 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."); goto rtmp_destroy; diff --git a/trunk/src/libs/srs_librtmp.cpp b/trunk/src/libs/srs_librtmp.cpp index 78b253e1f..dada8f0cd 100644 --- a/trunk/src/libs/srs_librtmp.cpp +++ b/trunk/src/libs/srs_librtmp.cpp @@ -2338,6 +2338,12 @@ int srs_human_print_rtmp_packet4(char type, u_int32_t timestamp, char* data, int pi = (pre_now - starttime) / (double)nb_packets; } + // global fps(video and audio mixed fps). + double gfps = 0; + if (pi > 0) { + gfps = 1000 / pi; + } + int diff = 0; if (pre_timestamp > 0) { diff = (int)timestamp - (int)pre_timestamp; @@ -2350,22 +2356,22 @@ int srs_human_print_rtmp_packet4(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 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 + srs_human_trace("Rtmp packet id=%"PRId64"/%.1f/%.1f, type=%s, dts=%d, diff=%d, ndiff=%d, size=%d, DecodeError", + nb_packets, pi, gfps, srs_human_flv_tag_type2string(type), timestamp, diff, ndiff, size ); return ret; } if (type == SRS_RTMP_TYPE_VIDEO) { - 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_trace("Video packet id=%"PRId64"/%.1f/%.1f, type=%s, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d, %s(%s,%s)", + nb_packets, pi, gfps, 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 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_trace("Audio packet id=%"PRId64"/%.1f/%.1f, type=%s, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d, %s(%s,%s,%s,%s)", + nb_packets, pi, gfps, 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)), @@ -2373,8 +2379,8 @@ int srs_human_print_rtmp_packet4(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 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); + srs_human_verbose("Data packet id=%"PRId64"/%.1f/%.1f, type=%s, time=%d, diff=%d, ndiff=%d, size=%d", + nb_packets, pi, gfps, srs_human_flv_tag_type2string(type), timestamp, diff, ndiff, size); int nparsed = 0; while (nparsed < size) { int nb_parsed_this = 0; @@ -2390,8 +2396,8 @@ int srs_human_print_rtmp_packet4(char type, u_int32_t timestamp, char* data, int srs_freep(amf0_str); } } else { - 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); + srs_human_trace("Rtmp packet id=%"PRId64"/%.1f/%.1f, type=%#x, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d", + nb_packets, pi, gfps, type, timestamp, pts, diff, ndiff, size); } return ret;