diff --git a/recording-daemon/main.c b/recording-daemon/main.c index 0715dfa3d..a2181dbc0 100644 --- a/recording-daemon/main.c +++ b/recording-daemon/main.c @@ -63,6 +63,7 @@ int notify_post; int notify_nverify; int notify_threads = 5; int notify_retries = 10; +int notify_record; 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, ¬ify_nverify,"Don't verify HTTPS peer certificate", NULL }, { "notify-concurrency", 0, 0, G_OPTION_ARG_INT, ¬ify_threads,"How many simultaneous requests", "INT" }, { "notify-retries", 0, 0, G_OPTION_ARG_INT, ¬ify_retries,"How many times to retry failed requesets","INT" }, + { "notify-record", 0, 0, G_OPTION_ARG_NONE, ¬ify_record, "Also attach recorded file to request", NULL }, { NULL, } }; diff --git a/recording-daemon/main.h b/recording-daemon/main.h index 8768d424b..5d46bcb7a 100644 --- a/recording-daemon/main.h +++ b/recording-daemon/main.h @@ -46,6 +46,7 @@ extern int notify_post; extern int notify_nverify; extern int notify_threads; extern int notify_retries; +extern int notify_record; extern volatile int shutdown_flag; diff --git a/recording-daemon/notify.c b/recording-daemon/notify.c index d2037e2a0..79117d7fb 100644 --- a/recording-daemon/notify.c +++ b/recording-daemon/notify.c @@ -9,6 +9,7 @@ struct notif_req { char *name; // just for logging struct curl_slist *headers; + char *full_filename_path; time_t retry_time; unsigned int retries; @@ -40,6 +41,7 @@ static void do_notify(void *p, void *u) { // set up the CURL request + curl_mime *mime = NULL; CURL *c = curl_easy_init(); if (!c) goto fail; @@ -95,6 +97,22 @@ static void do_notify(void *p, void *u) { 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"; ret = curl_easy_perform(c); if (ret != CURLE_OK) @@ -161,8 +179,13 @@ fail: cleanup: if (c) curl_easy_cleanup(c); + + if (mime) + curl_mime_free(mime); + curl_slist_free_all(req->headers); g_free(req->name); + g_free(req->full_filename_path); 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)); 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(); notify_add_header(req, "X-Recording-Call-ID: %s", mf->call_id); diff --git a/recording-daemon/rtpengine-recording.pod b/recording-daemon/rtpengine-recording.pod index d60e78d17..ea23e5c1c 100644 --- a/recording-daemon/rtpengine-recording.pod +++ b/recording-daemon/rtpengine-recording.pod @@ -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 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). + =back =head1 EXIT STATUS