@@ -148,6 +148,9 @@ struct CaSync {
148148 uint64_t chunk_size_max ;
149149
150150 CaCompressionType compression_type ;
151+
152+ uint64_t first_chunk_request_nsec ;
153+ uint64_t last_chunk_request_nsec ;
151154};
152155
153156static CaSync * ca_sync_new (void ) {
@@ -2325,6 +2328,9 @@ static int ca_sync_process_decoder_request(CaSync *s) {
23252328 if (r < 0 )
23262329 return log_debug_errno (r , "Failed to put decoder EOF: %m" );
23272330
2331+ if (s -> last_chunk_request_nsec == 0 )
2332+ s -> last_chunk_request_nsec = now (CLOCK_MONOTONIC );
2333+
23282334 return CA_SYNC_STEP ;
23292335 }
23302336
@@ -2343,6 +2349,9 @@ static int ca_sync_process_decoder_request(CaSync *s) {
23432349 if (!ca_sync_seed_ready (s ))
23442350 return CA_SYNC_POLL ;
23452351
2352+ if (s -> first_chunk_request_nsec == 0 )
2353+ s -> first_chunk_request_nsec = now (CLOCK_MONOTONIC );
2354+
23462355 r = ca_sync_get (s , & s -> next_chunk , CA_CHUNK_UNCOMPRESSED , & p , & chunk_size , NULL , & origin );
23472356 if (r == - EAGAIN ) /* Don't have this right now, but requested it now */
23482357 return CA_SYNC_STEP ;
@@ -4399,6 +4408,21 @@ int ca_sync_get_remote_request_bytes(CaSync *s, uint64_t *ret) {
43994408 return 0 ;
44004409}
44014410
4411+ int ca_sync_get_decoding_time_nsec (CaSync * s , uint64_t * ret ) {
4412+ if (!s )
4413+ return - EINVAL ;
4414+ if (!ret )
4415+ return - EINVAL ;
4416+
4417+ if (s -> first_chunk_request_nsec == 0 || s -> last_chunk_request_nsec == 0 )
4418+ return - ENODATA ;
4419+ if (s -> first_chunk_request_nsec > s -> last_chunk_request_nsec )
4420+ return - ENODATA ;
4421+
4422+ * ret = s -> last_chunk_request_nsec - s -> first_chunk_request_nsec ;
4423+ return 0 ;
4424+ }
4425+
44024426int ca_sync_set_compression_type (CaSync * s , CaCompressionType compression ) {
44034427 if (!s )
44044428 return - EINVAL ;
0 commit comments