Browse Source

MT#61822 add CLI command to reload media

Change-Id: I9c8c5423f1872169d9690282626abaad41c2597d
pull/1897/head
Richard Fuchs 11 months ago
parent
commit
77e8542229
2 changed files with 43 additions and 0 deletions
  1. +38
    -0
      daemon/cli.c
  2. +5
    -0
      utils/rtpengine-ctl

+ 38
- 0
daemon/cli.c View File

@ -31,6 +31,7 @@
#include "rtplib.h"
#include "ssrc.h"
#include "codec.h"
#include "media_player.h"
typedef struct cli_handler_t cli_handler_t;
typedef void (*cli_handler_func)(str *, struct cli_writer *, const cli_handler_t *);
@ -107,6 +108,9 @@ static void cli_incoming_tag_info(str *instr, struct cli_writer *cw, const cli_h
#ifdef WITH_TRANSCODING
static void cli_incoming_tag_delay(str *instr, struct cli_writer *cw, const cli_handler_t *);
static void cli_incoming_tag_detdtmf(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 *);
#endif
static const cli_handler_t cli_set_handlers[] = {
@ -178,6 +182,17 @@ static const cli_handler_t cli_params_handlers[] = {
{ "revert", cli_incoming_params_revert, NULL },
{ NULL, },
};
#ifdef WITH_TRANSCODING
static const cli_handler_t cli_media_reload_handlers[] = {
{ "file", cli_incoming_media_reload_file, NULL },
{ "files", cli_incoming_media_reload_files, NULL },
{ NULL, },
};
static const cli_handler_t cli_media_handlers[] = {
{ "reload", cli_generic_handler, cli_media_reload_handlers },
{ NULL, },
};
#endif
static const cli_handler_t cli_top_handlers[] = {
{ "list", cli_generic_handler, cli_list_handlers },
{ "terminate", cli_incoming_terminate, NULL },
@ -191,6 +206,9 @@ static const cli_handler_t cli_top_handlers[] = {
{ "standby", cli_incoming_standby, NULL },
{ "debug", cli_incoming_debug, NULL },
{ "call", cli_incoming_call, NULL },
#ifdef WITH_TRANSCODING
{ "media", cli_generic_handler, cli_media_handlers },
#endif
{ NULL, },
};
@ -1755,3 +1773,23 @@ static void cli_incoming_set_controltos(str *instr, struct cli_writer *cw, const
cw->cw_printf(cw, "Success setting redis-connect-timeout to %ld\n", tos);
}
#ifdef WITH_TRANSCODING
static void cli_incoming_media_reload_file(str *instr, struct cli_writer *cw, const cli_handler_t *handler) {
if (instr->len == 0) {
cw->cw_printf(cw, "More parameters required.\n");
return ;
}
bool ok = media_player_reload_file(instr);
if (ok)
cw->cw_printf(cw, "Success\n");
else
cw->cw_printf(cw, "Failed to reload '" STR_FORMAT "'\n", STR_FMT(instr));
}
static void cli_incoming_media_reload_files(str *instr, struct cli_writer *cw, const cli_handler_t *handler) {
unsigned int num = media_player_reload_files();
cw->cw_printf(cw, "%u media files reloaded\n", num);
}
#endif

+ 5
- 0
utils/rtpengine-ctl View File

@ -163,6 +163,11 @@ sub showusage {
print "\n";
print " debug <callid> <on/off> : set debugging flag for given call\n";
print "\n";
print " media <option>\n";
print " reload <option>\n";
print " file <file name> : reload one media file into memory\n";
print " files : reload all media files currently in memory\n";
print "\n";
print "\n";
print " Return Value:\n";
print " 0 on success with output from server side, other values for failure.\n";


Loading…
Cancel
Save