正在显示
3 个修改的文件
包含
25 行增加
和
24 行删除
| @@ -759,18 +759,6 @@ About the HLS overhead of SRS, we compare the overhead to FLV by remux the HLS t | @@ -759,18 +759,6 @@ About the HLS overhead of SRS, we compare the overhead to FLV by remux the HLS t | ||
| 759 | 759 | ||
| 760 | The HLS overhead is calc by: (HLS - FLV) / FLV * 100% | 760 | The HLS overhead is calc by: (HLS - FLV) / FLV * 100% |
| 761 | 761 | ||
| 762 | -### Bytes Api | ||
| 763 | - | ||
| 764 | -The api provides bytes of vhost, stream and srs. | ||
| 765 | - | ||
| 766 | -| Connections | tcpdump | srs | deviation | | ||
| 767 | -| ----------- | ---------- | ---------- | --------- | | ||
| 768 | -| 1 | 201687968 | 201687968 | 0% | | ||
| 769 | -| 100 | 12456042662 | 12458284053 | 0.018% | | ||
| 770 | -| 500 | 11623083989 | 11633158616 | 0.087% | | ||
| 771 | - | ||
| 772 | -The tcpdump command is `tcpdump src 192.168.1.151 and port 1935 -i eth0 and tcp -ql`. | ||
| 773 | - | ||
| 774 | ## Architecture | 762 | ## Architecture |
| 775 | 763 | ||
| 776 | SRS always use the most simple architecture to support complex transaction. | 764 | SRS always use the most simple architecture to support complex transaction. |
| @@ -258,8 +258,8 @@ int main(int argc, char** argv) | @@ -258,8 +258,8 @@ int main(int argc, char** argv) | ||
| 258 | 258 | ||
| 259 | int64_t nb_packets = 0; | 259 | int64_t nb_packets = 0; |
| 260 | u_int32_t pre_timestamp = 0; | 260 | u_int32_t pre_timestamp = 0; |
| 261 | - int64_t pre_now = srs_utils_time_ms(); | ||
| 262 | - int64_t start_time = pre_now; | 261 | + int64_t pre_now = -1; |
| 262 | + int64_t start_time = -1; | ||
| 263 | for (;;) { | 263 | for (;;) { |
| 264 | int size; | 264 | int size; |
| 265 | char type; | 265 | char type; |
| @@ -271,6 +271,13 @@ int main(int argc, char** argv) | @@ -271,6 +271,13 @@ int main(int argc, char** argv) | ||
| 271 | goto rtmp_destroy; | 271 | goto rtmp_destroy; |
| 272 | } | 272 | } |
| 273 | 273 | ||
| 274 | + if (pre_now == -1) { | ||
| 275 | + pre_now = srs_utils_time_ms(); | ||
| 276 | + } | ||
| 277 | + if (start_time == -1) { | ||
| 278 | + start_time = srs_utils_time_ms(); | ||
| 279 | + } | ||
| 280 | + | ||
| 274 | if (srs_human_print_rtmp_packet4(type, timestamp, data, size, pre_timestamp, pre_now, start_time, nb_packets++) != 0) { | 281 | if (srs_human_print_rtmp_packet4(type, timestamp, data, size, pre_timestamp, pre_now, start_time, nb_packets++) != 0) { |
| 275 | srs_human_trace("print rtmp packet failed."); | 282 | srs_human_trace("print rtmp packet failed."); |
| 276 | goto rtmp_destroy; | 283 | goto rtmp_destroy; |
| @@ -2338,6 +2338,12 @@ int srs_human_print_rtmp_packet4(char type, u_int32_t timestamp, char* data, int | @@ -2338,6 +2338,12 @@ int srs_human_print_rtmp_packet4(char type, u_int32_t timestamp, char* data, int | ||
| 2338 | pi = (pre_now - starttime) / (double)nb_packets; | 2338 | pi = (pre_now - starttime) / (double)nb_packets; |
| 2339 | } | 2339 | } |
| 2340 | 2340 | ||
| 2341 | + // global fps(video and audio mixed fps). | ||
| 2342 | + double gfps = 0; | ||
| 2343 | + if (pi > 0) { | ||
| 2344 | + gfps = 1000 / pi; | ||
| 2345 | + } | ||
| 2346 | + | ||
| 2341 | int diff = 0; | 2347 | int diff = 0; |
| 2342 | if (pre_timestamp > 0) { | 2348 | if (pre_timestamp > 0) { |
| 2343 | diff = (int)timestamp - (int)pre_timestamp; | 2349 | 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 | @@ -2350,22 +2356,22 @@ int srs_human_print_rtmp_packet4(char type, u_int32_t timestamp, char* data, int | ||
| 2350 | 2356 | ||
| 2351 | u_int32_t pts; | 2357 | u_int32_t pts; |
| 2352 | if (srs_utils_parse_timestamp(timestamp, type, data, size, &pts) != 0) { | 2358 | if (srs_utils_parse_timestamp(timestamp, type, data, size, &pts) != 0) { |
| 2353 | - srs_human_trace("Rtmp packet id=%"PRId64"/%.1f, type=%s, dts=%d, diff=%d, ndiff=%d, size=%d, DecodeError", | ||
| 2354 | - nb_packets, pi, srs_human_flv_tag_type2string(type), timestamp, diff, ndiff, size | 2359 | + srs_human_trace("Rtmp packet id=%"PRId64"/%.1f/%.1f, type=%s, dts=%d, diff=%d, ndiff=%d, size=%d, DecodeError", |
| 2360 | + nb_packets, pi, gfps, srs_human_flv_tag_type2string(type), timestamp, diff, ndiff, size | ||
| 2355 | ); | 2361 | ); |
| 2356 | return ret; | 2362 | return ret; |
| 2357 | } | 2363 | } |
| 2358 | 2364 | ||
| 2359 | if (type == SRS_RTMP_TYPE_VIDEO) { | 2365 | if (type == SRS_RTMP_TYPE_VIDEO) { |
| 2360 | - srs_human_trace("Video packet id=%"PRId64"/%.1f, type=%s, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d, %s(%s,%s)", | ||
| 2361 | - nb_packets, pi, srs_human_flv_tag_type2string(type), timestamp, pts, diff, ndiff, size, | 2366 | + srs_human_trace("Video packet id=%"PRId64"/%.1f/%.1f, type=%s, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d, %s(%s,%s)", |
| 2367 | + nb_packets, pi, gfps, srs_human_flv_tag_type2string(type), timestamp, pts, diff, ndiff, size, | ||
| 2362 | srs_human_flv_video_codec_id2string(srs_utils_flv_video_codec_id(data, size)), | 2368 | srs_human_flv_video_codec_id2string(srs_utils_flv_video_codec_id(data, size)), |
| 2363 | srs_human_flv_video_avc_packet_type2string(srs_utils_flv_video_avc_packet_type(data, size)), | 2369 | srs_human_flv_video_avc_packet_type2string(srs_utils_flv_video_avc_packet_type(data, size)), |
| 2364 | srs_human_flv_video_frame_type2string(srs_utils_flv_video_frame_type(data, size)) | 2370 | srs_human_flv_video_frame_type2string(srs_utils_flv_video_frame_type(data, size)) |
| 2365 | ); | 2371 | ); |
| 2366 | } else if (type == SRS_RTMP_TYPE_AUDIO) { | 2372 | } else if (type == SRS_RTMP_TYPE_AUDIO) { |
| 2367 | - 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)", | ||
| 2368 | - nb_packets, pi, srs_human_flv_tag_type2string(type), timestamp, pts, diff, ndiff, size, | 2373 | + 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)", |
| 2374 | + nb_packets, pi, gfps, srs_human_flv_tag_type2string(type), timestamp, pts, diff, ndiff, size, | ||
| 2369 | srs_human_flv_audio_sound_format2string(srs_utils_flv_audio_sound_format(data, size)), | 2375 | srs_human_flv_audio_sound_format2string(srs_utils_flv_audio_sound_format(data, size)), |
| 2370 | srs_human_flv_audio_sound_rate2string(srs_utils_flv_audio_sound_rate(data, size)), | 2376 | srs_human_flv_audio_sound_rate2string(srs_utils_flv_audio_sound_rate(data, size)), |
| 2371 | srs_human_flv_audio_sound_size2string(srs_utils_flv_audio_sound_size(data, size)), | 2377 | 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 | @@ -2373,8 +2379,8 @@ int srs_human_print_rtmp_packet4(char type, u_int32_t timestamp, char* data, int | ||
| 2373 | srs_human_flv_audio_aac_packet_type2string(srs_utils_flv_audio_aac_packet_type(data, size)) | 2379 | srs_human_flv_audio_aac_packet_type2string(srs_utils_flv_audio_aac_packet_type(data, size)) |
| 2374 | ); | 2380 | ); |
| 2375 | } else if (type == SRS_RTMP_TYPE_SCRIPT) { | 2381 | } else if (type == SRS_RTMP_TYPE_SCRIPT) { |
| 2376 | - srs_human_verbose("Data packet id=%"PRId64"/%.1f, type=%s, time=%d, diff=%d, ndiff=%d, size=%d", | ||
| 2377 | - nb_packets, pi, srs_human_flv_tag_type2string(type), timestamp, diff, ndiff, size); | 2382 | + srs_human_verbose("Data packet id=%"PRId64"/%.1f/%.1f, type=%s, time=%d, diff=%d, ndiff=%d, size=%d", |
| 2383 | + nb_packets, pi, gfps, srs_human_flv_tag_type2string(type), timestamp, diff, ndiff, size); | ||
| 2378 | int nparsed = 0; | 2384 | int nparsed = 0; |
| 2379 | while (nparsed < size) { | 2385 | while (nparsed < size) { |
| 2380 | int nb_parsed_this = 0; | 2386 | int nb_parsed_this = 0; |
| @@ -2390,8 +2396,8 @@ int srs_human_print_rtmp_packet4(char type, u_int32_t timestamp, char* data, int | @@ -2390,8 +2396,8 @@ int srs_human_print_rtmp_packet4(char type, u_int32_t timestamp, char* data, int | ||
| 2390 | srs_freep(amf0_str); | 2396 | srs_freep(amf0_str); |
| 2391 | } | 2397 | } |
| 2392 | } else { | 2398 | } else { |
| 2393 | - srs_human_trace("Rtmp packet id=%"PRId64"/%.1f, type=%#x, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d", | ||
| 2394 | - nb_packets, pi, type, timestamp, pts, diff, ndiff, size); | 2399 | + srs_human_trace("Rtmp packet id=%"PRId64"/%.1f/%.1f, type=%#x, dts=%d, pts=%d, diff=%d, ndiff=%d, size=%d", |
| 2400 | + nb_packets, pi, gfps, type, timestamp, pts, diff, ndiff, size); | ||
| 2395 | } | 2401 | } |
| 2396 | 2402 | ||
| 2397 | return ret; | 2403 | return ret; |
-
请 注册 或 登录 后发表评论