Browse Source

MT#61822 support on-demand loading of DB media

Change-Id: Ia356fbebdbb752ea7da314b8b16481eb302204d1
pull/1897/head
Richard Fuchs 11 months ago
parent
commit
db9144b91c
3 changed files with 32 additions and 2 deletions
  1. +28
    -0
      daemon/media_player.c
  2. +3
    -1
      docs/rtpengine.md
  3. +1
    -1
      etc/rtpengine.conf

+ 28
- 0
daemon/media_player.c View File

@ -1330,6 +1330,27 @@ static struct media_player_media_file *media_player_media_files_get_create(const
return fo;
}
static struct media_player_media_file *media_player_db_id_get_create(unsigned long long id) {
__auto_type fo = media_player_db_id_get_only(id);
if (fo)
return fo;
fo = media_player_db_id_read(id);
if (!fo)
return NULL;
RWLOCK_W(&media_player_db_media_ids_lock);
LOCK(&media_player_db_media_lock);
// someone else may have beaten us to it
if (t_hash_table_is_set(media_player_db_media) && t_hash_table_lookup(media_player_db_media, GUINT_TO_POINTER(id)))
return fo; // return the only reference, will disappear once player finishes
// insert new reference
media_player_db_id_insert(id, obj_get(fo));
return fo;
}
static struct media_player_media_file *(*media_player_media_files_get)(const str *fn)
= media_player_media_files_get_only;
@ -2039,6 +2060,13 @@ bool media_player_preload_db(char **ids) {
for (char **idp = ids; *idp; idp++) {
char *id_s = *idp;
while (*id_s == ' ')
id_s++;
if (!strcmp(id_s, "ondemand") || !strcmp(id_s, "on demand") || !strcmp(id_s, "on-demand")) {
media_player_db_id_get = media_player_db_id_get_create;
continue;
}
char *endp = NULL;
unsigned long long id = strtoull(id_s, &endp, 0);


+ 3
- 1
docs/rtpengine.md View File

@ -1176,7 +1176,9 @@ call to inject-DTMF won't be sent to __\-\-dtmf-log-dest=__ or __\-\-listen-tcp-
Similar to the __preload-media-files__ option, but preloads media from
database instead of reading them from files. Each entry must be an integer
corresponding to an index from the database.
corresponding to an index from the database. On-demand loading is also
supported by supplying the special string `on-demand` instead of an index
number.
- __\-\-db-media-reload=__*SECONDS*


+ 1
- 1
etc/rtpengine.conf View File

@ -167,7 +167,7 @@ recording-method = proc
# preload-media-files = /var/media/file1.wav ; /var/media/file2.wav ; /var/media/file3.wav ; on-demand
# media-files-reload = 60
# preload-db-media = 1; 2; 3; 4
# preload-db-media = 1; 2; 3; 4; on-demand
# db-media-reload = 3600
# signalling templates (see key `templates` above)


Loading…
Cancel
Save