Write out rewritten SDP from answer to metadata file

pull/245/head
Dylan Mikus 10 years ago committed by Eric Green
parent 466c52c18e
commit 0b33b4815a

@ -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) {

@ -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.

@ -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.

Loading…
Cancel
Save