diff --git a/daemon/call_interfaces.c b/daemon/call_interfaces.c index 51e2a81c9..efd8cd402 100644 --- a/daemon/call_interfaces.c +++ b/daemon/call_interfaces.c @@ -740,6 +740,12 @@ static const char *call_offer_answer_ng(bencode_item_t *input, struct callmaster chopper->iov_num, chopper->str_len); bencode_dictionary_add_string(output, "result", "ok"); + struct recording *recording = call->recording; + if (opmode == OP_ANSWER && call->record_call && recording != NULL && recording->meta_fp != NULL) { + struct iovec *iov = &g_array_index(chopper->iov, struct iovec, 0); + int iovcnt = chopper->iov_num; + meta_write_sdp(recording->meta_fp, iov, iovcnt); + } bencode_dictionary_get_str(input, "metadata", &metadata); if (metadata.len > 0 && call->recording != NULL) { if (call->recording->metadata != NULL) { diff --git a/daemon/recording.c b/daemon/recording.c index 97940e500..e635265bf 100644 --- a/daemon/recording.c +++ b/daemon/recording.c @@ -184,6 +184,19 @@ str *meta_setup_file(struct recording *recording, str callid) { } } +/** + * Write out a block of SDP to the metadata file. + */ +ssize_t meta_write_sdp(FILE *meta_fp, struct iovec *sdp_iov, int iovcnt) { + fprintf(meta_fp, "\n"); + int meta_fd = fileno(meta_fp); + // File pointers buffer data, whereas direct writing using the file + // descriptor does not. Make sure to flush any unwritten contents + // so the file contents appear in order. + fflush(meta_fp); + writev(meta_fd, sdp_iov, iovcnt); +} + /** * Writes metadata to metafile, closes file, and renames it to finished location. * Returns non-zero for failure. diff --git a/daemon/recording.h b/daemon/recording.h index 8b7fe7786..63d294c0e 100644 --- a/daemon/recording.h +++ b/daemon/recording.h @@ -63,6 +63,11 @@ int detect_setup_recording(struct call *call, str recordcall); */ str *meta_setup_file(struct recording *recording, str callid); +/** + * Write out a block of SDP to the metadata file. + */ +ssize_t meta_write_sdp(FILE *meta_fp, struct iovec *sdp_iov, int iovcnt); + /** * Writes metadata to metafile, closes file, and moves it to finished location. * Returns non-zero for failure.