From dcdeb6a9de6b312498dfa36a923859fbc2da84ef Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Wed, 8 Jan 2025 12:19:39 -0400 Subject: [PATCH] MT#61822 add db-cache-reload Change-Id: I4976329d2a778fc9a87773a2d85c48bc1b0977ba --- daemon/main.c | 4 ++++ daemon/media_player.c | 9 +++++++++ docs/rtpengine.md | 5 +++++ etc/rtpengine.conf | 1 + include/main.h | 1 + include/media_player.h | 1 + 6 files changed, 21 insertions(+) diff --git a/daemon/main.c b/daemon/main.c index 3dc281343..517c5a07a 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -679,6 +679,7 @@ static void options(int *argc, char ***argv, GHashTable *templates) { { "db-media-reload",0,0,G_OPTION_ARG_INT, &rtpe_config.db_refresh,"Reload preloaded media from DB at a certain interval","SECONDS"}, { "db-media-cache",0,0, G_OPTION_ARG_FILENAME, &rtpe_config.db_media_cache,"Directory to store media loaded from database","PATH"}, { "preload-db-cache",0,0,G_OPTION_ARG_STRING_ARRAY,&rtpe_config.preload_db_cache,"Preload media from database for playback into file cache","INT"}, + { "db-cache-reload",0,0,G_OPTION_ARG_INT, &rtpe_config.cache_refresh,"Refresh/reload cached media from DB at a certain interval","SECONDS"}, { "audio-buffer-length",0,0, G_OPTION_ARG_INT,&rtpe_config.audio_buffer_length,"Length in milliseconds of audio buffer","INT"}, { "audio-buffer-delay",0,0, G_OPTION_ARG_INT,&rtpe_config.audio_buffer_delay,"Initial delay in milliseconds for buffered audio","INT"}, { "audio-player",0,0, G_OPTION_ARG_STRING, &use_audio_player, "When to enable the internal audio player","on-demand|play-media|transcoding|always"}, @@ -1609,6 +1610,9 @@ int main(int argc, char **argv) { thread_create_looper(media_player_refresh_db, rtpe_config.idle_scheduling, rtpe_config.idle_priority, "db refresh", rtpe_config.db_refresh * 1000000LL); + thread_create_looper(media_player_refresh_cache, rtpe_config.idle_scheduling, + rtpe_config.idle_priority, "cache refresh", rtpe_config.cache_refresh * 1000000LL); + if (!is_addr_unspecified(&rtpe_config.redis_ep.address) && initial_rtpe_config.redis_delete_async) thread_create_detach(redis_delete_async_loop, NULL, "redis async"); diff --git a/daemon/media_player.c b/daemon/media_player.c index 319aa3cc6..1c6f91e8d 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -2263,6 +2263,15 @@ enum thread_looper_action media_player_refresh_db(void) { return TLA_CONTINUE; } +enum thread_looper_action media_player_refresh_cache(void) { + if (rtpe_config.cache_refresh <= 0) + return TLA_BREAK; + + media_player_reload_caches(); + + return TLA_CONTINUE; +} + #ifdef WITH_TRANSCODING // media_player_media_files_names_lock must be held // media_player_media_files_lock must not be held diff --git a/docs/rtpengine.md b/docs/rtpengine.md index bbc0585d9..53030d428 100644 --- a/docs/rtpengine.md +++ b/docs/rtpengine.md @@ -1205,6 +1205,11 @@ call to inject-DTMF won't be sent to __\-\-dtmf-log-dest=__ or __\-\-listen-tcp- instead of storing the media in memory. On-demand loading is also supported. +- __\-\-cache-media-reload=__*SECONDS* + + Similar to the __db-media-reload__ but applicable to media stored in the + filesystem-backed cache. + - __\-\-audio-buffer-length=__*INT* Set the buffer length used by the audio player (see below) in milliseconds. The diff --git a/etc/rtpengine.conf b/etc/rtpengine.conf index bab3b6355..210fac925 100644 --- a/etc/rtpengine.conf +++ b/etc/rtpengine.conf @@ -171,6 +171,7 @@ recording-method = proc # db-media-reload = 3600 # db-media-cache = /var/cache/rtpengine # preload-db-cache = 1; 2; 3; 4; on-demand +# cache-media-reload = 3600 # signalling templates (see key `templates` above) [templates] diff --git a/include/main.h b/include/main.h index 6671f368f..d6a90c0da 100644 --- a/include/main.h +++ b/include/main.h @@ -95,6 +95,7 @@ enum endpoint_learning { X(max_recv_iters) \ X(media_refresh) \ X(db_refresh) \ + X(cache_refresh) \ #define RTPE_CONFIG_UINT64_PARAMS \ X(bw_limit) diff --git a/include/media_player.h b/include/media_player.h index 6e9cd3977..35a5fce39 100644 --- a/include/media_player.h +++ b/include/media_player.h @@ -169,6 +169,7 @@ unsigned int media_player_evict_caches(void); bool media_player_preload_cache(char **); bool media_player_reload_cache(unsigned long long); unsigned int media_player_reload_caches(void); +enum thread_looper_action media_player_refresh_cache(void); struct send_timer *send_timer_new(struct packet_stream *); void send_timer_push(struct send_timer *, struct codec_packet *);