From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id 932934BF9A for ; Tue, 2 Sep 2025 00:37:51 +0000 (UTC) Authentication-Results: ffbox; dkim=fail (body hash mismatch (got b'xoAYtZcJHsdB6cJDYRMioEOFz/alHqNwKkmAV1LYsfQ=', expected b'fnDVLnAvYaBOS2e5TKyOo5mt+EmuGFnnxY96mHSIxYk=')) header.d=ffmpeg.org header.i=@ffmpeg.org header.a=rsa-sha256 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1756773457; h=mime-version : to : message-id : reply-to : subject : list-id : list-archive : list-archive : list-help : list-owner : list-post : list-subscribe : list-unsubscribe : from : cc : content-type : content-transfer-encoding : from; bh=xoAYtZcJHsdB6cJDYRMioEOFz/alHqNwKkmAV1LYsfQ=; b=F1eVKpqROj/1FTa9bmUwnFQHm5GaphB57ONxMqsTu0HBzXBk597shsCeoJ9mDDp0Tcsti vzVX70dMnUjbwcFgzaDeuaGKRJc80LnhAu28XDUR0La0xzjELU1xHuu2oUMgGDgAAOsoxMw 7TFxg4Gv/LmKpwZEg4ms3i3eIwbSMP1AKSggtLhVPEerHIUvfGmwKzlbJrgU0k9R0XWYkM8 kVpWd44ujdLVMwYeMLvR95QVP4MkRl1esHgsPsCH6UxOeAphqs62ZnaL23OBjIJOpUG5u7X /i7i01d2EaN2YsAwkRsA3md9iT8TKENQ+uAMW/IGFutSQzmgdz3UM8EXM0JQ== Received: from [172.19.0.4] (unknown [172.19.0.4]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 6246768E7AA; Tue, 2 Sep 2025 03:37:37 +0300 (EEST) ARC-Seal: i=1; cv=none; a=rsa-sha256; d=ffmpeg.org; s=arc; t=1756773445; b=Avep6rETFNeL4/aZm88BylwJe9SBD1tjGhJ1swk93rjnZdBoEGyK6cXfYHYhk/0eJVpag IpjRAf/u6N4dZoTeW6p6l1/gv7Qp4DAAOaV5uzPjSUv/aLVbtjSn0m9NFSLYg/mBCpDs/Ua jU9RsNjt6ACLZgqTf1OmNKbJuu+3LhaQ5mQbPGyHTENOKDuHBMGXrJbdt1ObswqeYQBUNy/ +j1Bc/CIAqWECpBjHXGAgT8gRKhZGeuMph9IxVyoXvkN4BqmA6cWkSlZERpnacLe5bSnlUC wsiWx9IvbvsCs7MJDcu8ZOKH35e15+VEevIrTdIb48OBcCa7u+YLpck2C/fw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=ffmpeg.org; s=arc; t=1756773445; h=from : sender : reply-to : subject : date : message-id : to : cc : mime-version : content-type : content-transfer-encoding : content-id : content-description : resent-date : resent-from : resent-sender : resent-to : resent-cc : resent-message-id : in-reply-to : references : list-id : list-help : list-unsubscribe : list-subscribe : list-post : list-owner : list-archive; bh=w5BEj6R/0EHrSwO0qS9BCJdfaOVXSVOHlcKZpIZyXXA=; b=hEdFwH2RUkxUf4Ga6OOVJlv7o+OW29ChvQQGYWYNuTD2NTn66ecSFfKO8YqzgBdgr3HLM WHZQaP6n+rlUjXGaTdYc5FtACAFEX1FtI9AklTcO0r/X20FkNrr+/YQKqAVUBjp7KTheXLZ dw/NiJJknGSXyIolwFUAkifiVlIc3XImDViGoCMc/5czdArMfX7RFtH+n45L9pIOaBs3lCY mIwR0YyFB9n9d7mvf2tAmEmuLAndkBYv3o32kZlm24Ry30EtlIfJW7Mn4+LFc1J+RaUawZX ShkMjUiVktEMgua6zYDoBkgkhUoUtuYoQaratcWc4ocqFCnbmIjh+xtXzd7A== ARC-Authentication-Results: i=1; ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none; dmarc=none Authentication-Results: ffmpeg.org; dkim=pass header.d=ffmpeg.org header.i=@ffmpeg.org; arc=none (Message is not ARC signed); dmarc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ffmpeg.org; i=@ffmpeg.org; q=dns/txt; s=mail; t=1756773436; h=content-type : mime-version : content-transfer-encoding : from : to : reply-to : subject : from; bh=fnDVLnAvYaBOS2e5TKyOo5mt+EmuGFnnxY96mHSIxYk=; b=LtOMDOI/hcLyjYwfqhb96juXSvl4/+5b54HtR7kIpdJ1L7zhojvWqtVJAWlJclw5jhQ71 8z5gAIxgTTPKWrgEdoGHRoDWW2N1dLr4B6sBfSY4orRfFuCM3LjmYZeR+WtIACEoUzYAqEH y3kwxzS9A+ZXy+7Mk5iiJN8Wzt9eeaPoyuoUFlNW7Z8BiZfv0oflfJbbnS4jUUipXf0pImZ kL3dQSIYpWwf1NIUF5ibaASftMEG1kOEbhHiJgITXMCLbkUxKkfiC/0K42yZtGLqrx7LNut UM3MTlNo1nfl5iGv/KrCGRdXqrrJIcctldG0kxXalJK3uAISgFaMSpbg1pVQ== Received: from 5d8f51c41678 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id A193D6801DC for ; Tue, 2 Sep 2025 03:37:16 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Message-ID: <175677343683.25.12395839022854773097@463a07221176> Message-ID-Hash: NLDKV3Y2VWKFXDDZJEQDAMBBXZ7DWULV X-Message-ID-Hash: NLDKV3Y2VWKFXDDZJEQDAMBBXZ7DWULV X-MailFrom: code@ffmpeg.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-ffmpeg-devel.ffmpeg.org-0; header-match-ffmpeg-devel.ffmpeg.org-1; header-match-ffmpeg-devel.ffmpeg.org-2; header-match-ffmpeg-devel.ffmpeg.org-3; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list Reply-To: FFmpeg development discussions and patches Subject: [FFmpeg-devel] [PATCH] avformat/whip: make time measure more precise (PR #20391) List-Id: FFmpeg development discussions and patches Archived-At: Archived-At: List-Archive: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Jack Lau via ffmpeg-devel Cc: Jack Lau Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Archived-At: List-Archive: List-Post: PR #20391 opened by Jack Lau (JackLau) URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20391 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20391.patch Use av_gettime_relative() replace av_gettime() to get better measure Changed the display precision from showing only integers to showing two decimal places (in milliseconds) Signed-off-by: Jack Lau refer to https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20030#issuecomment-822 and https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20030#issuecomment-823 >>From 7c9162f8ca1753f13e2a46ad58b34a6b05e884dd Mon Sep 17 00:00:00 2001 From: Jack Lau Date: Tue, 2 Sep 2025 08:28:36 +0800 Subject: [PATCH] avformat/whip: make time measure more precise Use av_gettime_relative() replace av_gettime() to get better measure Changed the display precision from showing only integers to showing two decimal places (in milliseconds) Signed-off-by: Jack Lau --- libavformat/whip.c | 50 +++++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/libavformat/whip.c b/libavformat/whip.c index 1fcf19aaa3..e8b8a16d9f 100644 --- a/libavformat/whip.c +++ b/libavformat/whip.c @@ -151,7 +151,7 @@ #define WHIP_SDP_CREATOR_IP "127.0.0.1" /* Calculate the elapsed time from starttime to endtime in milliseconds. */ -#define ELAPSED(starttime, endtime) ((int)(endtime - starttime) / 1000) +#define ELAPSED(starttime, endtime) ((float)(endtime - starttime) / 1000) /* STUN Attribute, comprehension-required range (0x0000-0x7FFF) */ enum STUNAttr { @@ -370,7 +370,7 @@ static av_cold int initialize(AVFormatContext *s) WHIPContext *whip = s->priv_data; uint32_t seed; - whip->whip_starttime = av_gettime(); + whip->whip_starttime = av_gettime_relative(); ret = certificate_key_init(s); if (ret < 0) { @@ -391,9 +391,9 @@ static av_cold int initialize(AVFormatContext *s) if (whip->state < WHIP_STATE_INIT) whip->state = WHIP_STATE_INIT; - whip->whip_init_time = av_gettime(); - av_log(whip, AV_LOG_VERBOSE, "Init state=%d, handshake_timeout=%dms, pkt_size=%d, seed=%d, elapsed=%dms\n", - whip->state, whip->handshake_timeout, whip->pkt_size, seed, ELAPSED(whip->whip_starttime, av_gettime())); + whip->whip_init_time = av_gettime_relative(); + av_log(whip, AV_LOG_VERBOSE, "Init state=%d, handshake_timeout=%dms, pkt_size=%d, seed=%d, elapsed=%.2fms\n", + whip->state, whip->handshake_timeout, whip->pkt_size, seed, ELAPSED(whip->whip_starttime, av_gettime_relative())); return 0; } @@ -682,7 +682,7 @@ static int generate_sdp_offer(AVFormatContext *s) if (whip->state < WHIP_STATE_OFFER) whip->state = WHIP_STATE_OFFER; - whip->whip_offer_time = av_gettime(); + whip->whip_offer_time = av_gettime_relative(); av_log(whip, AV_LOG_VERBOSE, "Generated state=%d, offer: %s\n", whip->state, whip->sdp_offer); end: @@ -898,10 +898,10 @@ static int parse_answer(AVFormatContext *s) if (whip->state < WHIP_STATE_NEGOTIATED) whip->state = WHIP_STATE_NEGOTIATED; - whip->whip_answer_time = av_gettime(); - av_log(whip, AV_LOG_VERBOSE, "SDP state=%d, offer=%zuB, answer=%zuB, ufrag=%s, pwd=%zuB, transport=%s://%s:%d, elapsed=%dms\n", + whip->whip_answer_time = av_gettime_relative(); + av_log(whip, AV_LOG_VERBOSE, "SDP state=%d, offer=%zuB, answer=%zuB, ufrag=%s, pwd=%zuB, transport=%s://%s:%d, elapsed=%.2fms\n", whip->state, strlen(whip->sdp_offer), strlen(whip->sdp_answer), whip->ice_ufrag_remote, strlen(whip->ice_pwd_remote), - whip->ice_protocol, whip->ice_host, whip->ice_port, ELAPSED(whip->whip_starttime, av_gettime())); + whip->ice_protocol, whip->ice_host, whip->ice_port, ELAPSED(whip->whip_starttime, av_gettime_relative())); end: avio_context_free(&pb); @@ -1179,9 +1179,9 @@ static int udp_connect(AVFormatContext *s) if (whip->state < WHIP_STATE_UDP_CONNECTED) whip->state = WHIP_STATE_UDP_CONNECTED; - whip->whip_udp_time = av_gettime(); - av_log(whip, AV_LOG_VERBOSE, "UDP state=%d, elapsed=%dms, connected to udp://%s:%d\n", - whip->state, ELAPSED(whip->whip_starttime, av_gettime()), whip->ice_host, whip->ice_port); + whip->whip_udp_time = av_gettime_relative(); + av_log(whip, AV_LOG_VERBOSE, "UDP state=%d, elapsed=%.2fms, connected to udp://%s:%d\n", + whip->state, ELAPSED(whip->whip_starttime, av_gettime_relative()), whip->ice_host, whip->ice_port); end: av_dict_free(&opts); @@ -1191,7 +1191,7 @@ end: static int ice_dtls_handshake(AVFormatContext *s) { int ret = 0, size, i; - int64_t starttime = av_gettime(), now; + int64_t starttime = av_gettime_relative(), now; WHIPContext *whip = s->priv_data; AVDictionary *opts = NULL; char buf[256], *cert_buf = NULL, *key_buf = NULL; @@ -1225,9 +1225,9 @@ next_packet: /* DTLS handshake is done, exit the loop. */ break; - now = av_gettime(); + now = av_gettime_relative(); if (now - starttime >= whip->handshake_timeout * 1000) { - av_log(whip, AV_LOG_ERROR, "DTLS handshake timeout=%dms, cost=%dms, elapsed=%dms, state=%d\n", + av_log(whip, AV_LOG_ERROR, "DTLS handshake timeout=%dms, cost=%.2fms, elapsed=%.2fms, state=%d\n", whip->handshake_timeout, ELAPSED(starttime, now), ELAPSED(whip->whip_starttime, now), whip->state); ret = AVERROR(ETIMEDOUT); goto end; @@ -1254,10 +1254,10 @@ next_packet: if (ice_is_binding_response(whip->buf, ret)) { if (whip->state < WHIP_STATE_ICE_CONNECTED) { whip->state = WHIP_STATE_ICE_CONNECTED; - whip->whip_ice_time = av_gettime(); - av_log(whip, AV_LOG_VERBOSE, "ICE STUN ok, state=%d, url=udp://%s:%d, location=%s, username=%s:%s, res=%dB, elapsed=%dms\n", + whip->whip_ice_time = av_gettime_relative(); + av_log(whip, AV_LOG_VERBOSE, "ICE STUN ok, state=%d, url=udp://%s:%d, location=%s, username=%s:%s, res=%dB, elapsed=%.2fms\n", whip->state, whip->ice_host, whip->ice_port, whip->whip_resource_url ? whip->whip_resource_url : "", - whip->ice_ufrag_remote, whip->ice_ufrag_local, ret, ELAPSED(whip->whip_starttime, av_gettime())); + whip->ice_ufrag_remote, whip->ice_ufrag_local, ret, ELAPSED(whip->whip_starttime, av_gettime_relative())); ff_url_join(buf, sizeof(buf), "dtls", NULL, whip->ice_host, whip->ice_port, NULL); av_dict_set_int(&opts, "mtu", whip->pkt_size, 0); @@ -1302,8 +1302,8 @@ next_packet: } if (!ret) { whip->state = WHIP_STATE_DTLS_FINISHED; - whip->whip_dtls_time = av_gettime(); - av_log(whip, AV_LOG_VERBOSE, "DTLS handshake is done, elapsed=%dms\n", + whip->whip_dtls_time = av_gettime_relative(); + av_log(whip, AV_LOG_VERBOSE, "DTLS handshake is done, elapsed=%.2fms\n", ELAPSED(whip->whip_starttime, whip->whip_dtls_time)); } goto next_packet; @@ -1401,9 +1401,9 @@ static int setup_srtp(AVFormatContext *s) if (whip->state < WHIP_STATE_SRTP_FINISHED) whip->state = WHIP_STATE_SRTP_FINISHED; - whip->whip_srtp_time = av_gettime(); - av_log(whip, AV_LOG_VERBOSE, "SRTP setup done, state=%d, suite=%s, key=%zuB, elapsed=%dms\n", - whip->state, suite, sizeof(send_key), ELAPSED(whip->whip_starttime, av_gettime())); + whip->whip_srtp_time = av_gettime_relative(); + av_log(whip, AV_LOG_VERBOSE, "SRTP setup done, state=%d, suite=%s, key=%zuB, elapsed=%.2fms\n", + whip->state, suite, sizeof(send_key), ELAPSED(whip->whip_starttime, av_gettime_relative())); end: return ret; @@ -1559,8 +1559,8 @@ static int create_rtp_muxer(AVFormatContext *s) if (whip->state < WHIP_STATE_READY) whip->state = WHIP_STATE_READY; av_log(whip, AV_LOG_INFO, "Muxer state=%d, buffer_size=%d, max_packet_size=%d, " - "elapsed=%dms(init:%d,offer:%d,answer:%d,udp:%d,ice:%d,dtls:%d,srtp:%d)\n", - whip->state, buffer_size, max_packet_size, ELAPSED(whip->whip_starttime, av_gettime()), + "elapsed=%.2fms(init:%.2f,offer:%.2f,answer:%.2f,udp:%.2f,ice:%.2f,dtls:%.2f,srtp:%.2f)\n", + whip->state, buffer_size, max_packet_size, ELAPSED(whip->whip_starttime, av_gettime_relative()), ELAPSED(whip->whip_starttime, whip->whip_init_time), ELAPSED(whip->whip_init_time, whip->whip_offer_time), ELAPSED(whip->whip_offer_time, whip->whip_answer_time), -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- ffmpeg-devel@ffmpeg.org To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org