diff --git a/daemon/cli.c b/daemon/cli.c index 9eb4c433d..e264364b8 100644 --- a/daemon/cli.c +++ b/daemon/cli.c @@ -112,6 +112,7 @@ static void cli_incoming_tag_detdtmf(str *instr, struct cli_writer *cw, const cl static void cli_incoming_media_list_files(str *instr, struct cli_writer *cw, const cli_handler_t *); static void cli_incoming_media_list_dbs(str *instr, struct cli_writer *cw, const cli_handler_t *); static void cli_incoming_media_list_caches(str *instr, struct cli_writer *cw, const cli_handler_t *); +static void cli_incoming_media_list_players(str *instr, struct cli_writer *cw, const cli_handler_t *); static void cli_incoming_media_reload_file(str *instr, struct cli_writer *cw, const cli_handler_t *); static void cli_incoming_media_reload_files(str *instr, struct cli_writer *cw, const cli_handler_t *); @@ -207,6 +208,7 @@ static const cli_handler_t cli_media_list_handlers[] = { { "files", cli_incoming_media_list_files, NULL }, { "dbs", cli_incoming_media_list_dbs, NULL }, { "caches", cli_incoming_media_list_caches, NULL }, + { "players", cli_incoming_media_list_players, NULL }, { NULL, }, }; static const cli_handler_t cli_media_add_handlers[] = { @@ -2002,6 +2004,15 @@ static void cli_incoming_media_list_caches(str *instr, struct cli_writer *cw, co } } +static void cli_incoming_media_list_players(str *instr, struct cli_writer *cw, const cli_handler_t *handler) { + charp_q list = media_player_list_player_cache(); + while (list.head) { + char *s = t_queue_pop_head(&list); + cw->cw_printf(cw, "%s\n", s); + g_free(s); + } +} + static void cli_incoming_media_evict_cache(str *instr, struct cli_writer *cw, const cli_handler_t *handler) { if (instr->len == 0) { cw->cw_printf(cw, "More parameters required.\n"); diff --git a/daemon/media_player.c b/daemon/media_player.c index 8aae6ded0..6d156904b 100644 --- a/daemon/media_player.c +++ b/daemon/media_player.c @@ -2616,3 +2616,19 @@ unsigned int media_player_reload_caches(void) { media_player_iterate_db_cache(media_player_reload_caches_all, &ret); return ret; } + +charp_q media_player_list_player_cache(void) { + charp_q ret = TYPED_GQUEUE_INIT; +#ifdef WITH_TRANSCODING + if (!t_hash_table_is_set(media_player_cache)) + return ret; + media_player_cache_ht_iter iter; + LOCK(&media_player_cache_lock); + t_hash_table_iter_init(&iter, media_player_cache); + struct media_player_cache_entry *entry; + while (t_hash_table_iter_next(&iter, NULL, &entry)) + t_queue_push_tail(&ret, g_strdup_printf("%s for PT " STR_FORMAT, entry->info_str, + STR_FMT(&entry->index.dst_pt.encoding_with_full_params))); +#endif + return ret; +} diff --git a/include/media_player.h b/include/media_player.h index 3116fd2da..958a9b666 100644 --- a/include/media_player.h +++ b/include/media_player.h @@ -173,6 +173,7 @@ bool media_player_add_cache(unsigned long long); bool media_player_reload_cache(unsigned long long); unsigned int media_player_reload_caches(void); enum thread_looper_action media_player_refresh_cache(void); +charp_q media_player_list_player_cache(void); struct send_timer *send_timer_new(struct packet_stream *); void send_timer_push(struct send_timer *, struct codec_packet *); diff --git a/utils/rtpengine-ctl b/utils/rtpengine-ctl index f7f3bd9d9..13a68bf4d 100755 --- a/utils/rtpengine-ctl +++ b/utils/rtpengine-ctl @@ -168,6 +168,7 @@ sub showusage { print " files : list media files currently in memory\n"; print " dbs : list database media entries currently in memory\n"; print " caches : list database media entries currently in file cache\n"; + print " players : list contents of player cache\n"; print " reload