[vlc-devel] [PATCH v3 06/14] stats: use new md5 API

Marvin Scholz epirat07 at gmail.com
Wed Apr 8 16:10:16 CEST 2020


---
 modules/stream_out/stats.c | 24 +++++++++++-------------
 1 file changed, 11 insertions(+), 13 deletions(-)

diff --git a/modules/stream_out/stats.c b/modules/stream_out/stats.c
index d6dd7cc0cb..cd7e71e47c 100644
--- a/modules/stream_out/stats.c
+++ b/modules/stream_out/stats.c
@@ -31,7 +31,7 @@
 #include <vlc_plugin.h>
 #include <vlc_sout.h>
 #include <vlc_block.h>
-#include <vlc_md5.h>
+#include <vlc_hash.h>
 #include <vlc_fs.h>
 
 /*****************************************************************************
@@ -50,7 +50,7 @@ typedef struct
     void *next_id;
     const char *type;
     vlc_tick_t previous_dts,track_duration;
-    struct md5_s hash;
+    vlc_hash_md5_t hash;
 } sout_stream_id_sys_t;
 
 static void *Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
@@ -82,7 +82,7 @@ static void *Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
     id->segment_number = 0;
     id->previous_dts = VLC_TICK_INVALID;
     id->track_duration = 0;
-    InitMD5( &id->hash );
+    vlc_hash_md5_Init( &id->hash );
 
     msg_Dbg( p_stream, "%s: Adding track type:%s id:%d", p_sys->prefix, id->type, id->id);
     return id;
@@ -90,11 +90,11 @@ static void *Add( sout_stream_t *p_stream, const es_format_t *p_fmt )
 
 static void Del( sout_stream_t *p_stream, void *_id )
 {
+    char outputhash[VLC_HASH_MD5_DIGEST_HEX_SIZE];
     sout_stream_sys_t *p_sys = (sout_stream_sys_t *)p_stream->p_sys;
     sout_stream_id_sys_t *id = (sout_stream_id_sys_t *)_id;
 
-    EndMD5( &id->hash );
-    char *outputhash = psz_md5_hash( &id->hash );
+    vlc_hash_md5_FinishHex( &id->hash, outputhash, sizeof(outputhash) );
     unsigned int num,den;
     vlc_ureduce( &num, &den, id->track_duration, id->segment_number, 0 );
     msg_Dbg( p_stream, "%s: Removing track type:%s id:%d", p_sys->prefix, id->type, id->id );
@@ -106,7 +106,6 @@ static void Del( sout_stream_t *p_stream, void *_id )
         msg_Info( p_stream, "%s: final type:%s id:%d segments:%"PRIu64" total_duration:%"PRId64" avg_track:%d/%d md5:%16s",
                p_sys->prefix, id->type, id->id, id->segment_number, id->track_duration, num, den, outputhash );
     }
-    free( outputhash );
     free( id );
 }
 
@@ -114,16 +113,16 @@ static int Send( sout_stream_t *p_stream, void *_id, block_t *p_buffer )
 {
     sout_stream_sys_t *p_sys = (sout_stream_sys_t *)p_stream->p_sys;
     sout_stream_id_sys_t *id = (sout_stream_id_sys_t *)_id;
-    struct md5_s hash;
+    vlc_hash_md5_t hash;
 
     block_t *p_block = p_buffer;
     while ( p_block != NULL )
     {
-        InitMD5( &hash );
-        AddMD5( &hash, p_block->p_buffer, p_block->i_buffer );
-        AddMD5( &id->hash, p_block->p_buffer, p_block->i_buffer );
-        EndMD5( &hash );
-        char *outputhash = psz_md5_hash( &hash );
+        char outputhash[VLC_HASH_MD5_DIGEST_HEX_SIZE];
+        vlc_hash_md5_Init( &hash );
+        vlc_hash_md5_Update( &hash, p_block->p_buffer, p_block->i_buffer );
+        vlc_hash_md5_Update( &id->hash, p_block->p_buffer, p_block->i_buffer );
+        vlc_hash_md5_FinishHex( &hash, outputhash, sizeof(outputhash) );
 
         /* We could just set p_sys->output to stdout and remove user of msg_Dbg
          * if we don't need ability to output info to gui modules (like qt messages window
@@ -144,7 +143,6 @@ static int Send( sout_stream_t *p_stream, void *_id, block_t *p_buffer )
                   p_block->i_length, outputhash );
         }
         id->track_duration += p_block->i_length ? p_block->i_length : dts_difference;
-        free( outputhash );
         id->previous_dts = p_block->i_dts;
         p_block = p_block->p_next;
     }
-- 
2.24.1 (Apple Git-126)



More information about the vlc-devel mailing list