Browse Source

MT#55283 Support attaching recorded file

closes #1611

Change-Id: Id03400fb79339f4b0ed1eddfd6dce56295e57cef
pull/1623/head
Serdar GÜÇLÜER 3 years ago
committed by Richard Fuchs
parent
commit
a75d55444b
4 changed files with 34 additions and 0 deletions
  1. +2
    -0
      recording-daemon/main.c
  2. +1
    -0
      recording-daemon/main.h
  3. +24
    -0
      recording-daemon/notify.c
  4. +7
    -0
      recording-daemon/rtpengine-recording.pod

+ 2
- 0
recording-daemon/main.c View File

@ -63,6 +63,7 @@ int notify_post;
int notify_nverify; int notify_nverify;
int notify_threads = 5; int notify_threads = 5;
int notify_retries = 10; int notify_retries = 10;
int notify_record;
static GQueue threads = G_QUEUE_INIT; // only accessed from main thread static GQueue threads = G_QUEUE_INIT; // only accessed from main thread
@ -218,6 +219,7 @@ static void options(int *argc, char ***argv) {
{ "notify-no-verify", 0, 0, G_OPTION_ARG_NONE, &notify_nverify,"Don't verify HTTPS peer certificate", NULL }, { "notify-no-verify", 0, 0, G_OPTION_ARG_NONE, &notify_nverify,"Don't verify HTTPS peer certificate", NULL },
{ "notify-concurrency", 0, 0, G_OPTION_ARG_INT, &notify_threads,"How many simultaneous requests", "INT" }, { "notify-concurrency", 0, 0, G_OPTION_ARG_INT, &notify_threads,"How many simultaneous requests", "INT" },
{ "notify-retries", 0, 0, G_OPTION_ARG_INT, &notify_retries,"How many times to retry failed requesets","INT" }, { "notify-retries", 0, 0, G_OPTION_ARG_INT, &notify_retries,"How many times to retry failed requesets","INT" },
{ "notify-record", 0, 0, G_OPTION_ARG_NONE, &notify_record, "Also attach recorded file to request", NULL },
{ NULL, } { NULL, }
}; };


+ 1
- 0
recording-daemon/main.h View File

@ -46,6 +46,7 @@ extern int notify_post;
extern int notify_nverify; extern int notify_nverify;
extern int notify_threads; extern int notify_threads;
extern int notify_retries; extern int notify_retries;
extern int notify_record;
extern volatile int shutdown_flag; extern volatile int shutdown_flag;


+ 24
- 0
recording-daemon/notify.c View File

@ -9,6 +9,7 @@
struct notif_req { struct notif_req {
char *name; // just for logging char *name; // just for logging
struct curl_slist *headers; struct curl_slist *headers;
char *full_filename_path;
time_t retry_time; time_t retry_time;
unsigned int retries; unsigned int retries;
@ -40,6 +41,7 @@ static void do_notify(void *p, void *u) {
// set up the CURL request // set up the CURL request
curl_mime *mime = NULL;
CURL *c = curl_easy_init(); CURL *c = curl_easy_init();
if (!c) if (!c)
goto fail; goto fail;
@ -95,6 +97,22 @@ static void do_notify(void *p, void *u) {
goto fail; goto fail;
} }
if (notify_record) {
err = "initializing curl mime&part";
curl_mimepart *part;
mime = curl_mime_init(c);
part = curl_mime_addpart(mime);
curl_mime_name(part, "ngfile");
if (ret != CURLE_OK)
goto fail;
curl_mime_filedata(part, req->full_filename_path);
if (ret != CURLE_OK)
goto fail;
curl_easy_setopt(c, CURLOPT_MIMEPOST, mime);
if (ret != CURLE_OK)
goto fail;
}
err = "performing request"; err = "performing request";
ret = curl_easy_perform(c); ret = curl_easy_perform(c);
if (ret != CURLE_OK) if (ret != CURLE_OK)
@ -161,8 +179,13 @@ fail:
cleanup: cleanup:
if (c) if (c)
curl_easy_cleanup(c); curl_easy_cleanup(c);
if (mime)
curl_mime_free(mime);
curl_slist_free_all(req->headers); curl_slist_free_all(req->headers);
g_free(req->name); g_free(req->name);
g_free(req->full_filename_path);
g_slice_free1(sizeof(*req), req); g_slice_free1(sizeof(*req), req);
} }
@ -264,6 +287,7 @@ void notify_push_output(output_t *o, metafile_t *mf, tag_t *tag) {
struct notif_req *req = g_slice_alloc0(sizeof(*req)); struct notif_req *req = g_slice_alloc0(sizeof(*req));
req->name = g_strdup(o->file_name); req->name = g_strdup(o->file_name);
req->full_filename_path = g_strdup_printf("%s.%s", o->full_filename, o->file_format);
double now = now_double(); double now = now_double();
notify_add_header(req, "X-Recording-Call-ID: %s", mf->call_id); notify_add_header(req, "X-Recording-Call-ID: %s", mf->call_id);


+ 7
- 0
recording-daemon/rtpengine-recording.pod View File

@ -331,6 +331,13 @@ How many times to retry a failed HTTP notification before giving up. An
exponential falloff time is used for each subsequent attempt, starting with 5 exponential falloff time is used for each subsequent attempt, starting with 5
seconds. seconds.
=item B<--notify-record>
Attach recorded file to HTTP notification request. If enabled, notification
request behaves as HTTP POST (ignoring B<--notify-post>). Note that this option
is incompatible with DB-only storage as no recording file exists on storage
(see B<output-storage>).
=back =back
=head1 EXIT STATUS =head1 EXIT STATUS


Loading…
Cancel
Save