Browse Source

Link recording metadata SDP to RTP packet numbers

We write out what RTP packet number the SDP came before. When we receive
an SDP offer or answer, we write out the RTP packet number that the SDP
preceeded. This will let us split the RTP recording PCAP around SDP
renegotiation for things like hold/unhold.

Also write out whether the SDP was an offer or an answer.
pull/245/head
Dylan Mikus 10 years ago
committed by Eric Green
parent
commit
5fe68b9097
4 changed files with 18 additions and 4 deletions
  1. +2
    -1
      daemon/call_interfaces.c
  2. +1
    -0
      daemon/media_socket.c
  3. +12
    -2
      daemon/recording.c
  4. +3
    -1
      daemon/recording.h

+ 2
- 1
daemon/call_interfaces.c View File

@ -744,7 +744,8 @@ static const char *call_offer_answer_ng(bencode_item_t *input, struct callmaster
if (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);
meta_write_sdp(recording->meta_fp, iov, iovcnt,
call->recording->packet_num, opmode);
}
bencode_dictionary_get_str(input, "metadata", &metadata);
if (metadata.len > 0 && call->recording != NULL) {


+ 1
- 0
daemon/media_socket.c View File

@ -1202,6 +1202,7 @@ loop_ok:
// If recording pcap dumper is set, then we record the call.
if (recording_pdumper != NULL && call->record_call) {
stream_pcap_dump(recording_pdumper, stream, s);
call->recording->packet_num += 1;
}
if (handler_ret >= 0) {


+ 12
- 2
daemon/recording.c View File

@ -136,6 +136,7 @@ int set_record_call(struct call *call, str recordcall) {
call->recording = g_slice_alloc0(sizeof(struct recording));
call->recording->recording_pd = NULL;
call->recording->recording_pdumper = NULL;
call->recording->packet_num = 0;
meta_setup_file(call->recording, call->callid);
}
} else if (!str_cmp(&recordcall, "no")) {
@ -204,12 +205,21 @@ 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");
ssize_t meta_write_sdp(FILE *meta_fp, struct iovec *sdp_iov, int iovcnt,
uint64_t packet_num, enum call_opmode opmode) {
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.
fprintf(meta_fp, "\nSDP mode: ");
if (opmode == OP_ANSWER) {
fprintf(meta_fp, "answer");
} else if (opmode == OP_OFFER) {
fprintf(meta_fp, "offer");
} else {
fprintf(meta_fp, "other");
}
fprintf(meta_fp, "\nSDP before RTP packet: %llu\n\n", packet_num);
fflush(meta_fp);
return writev(meta_fd, sdp_iov, iovcnt);
}


+ 3
- 1
daemon/recording.h View File

@ -20,6 +20,7 @@ struct recording {
str *metadata;
pcap_t *recording_pd;
pcap_dumper_t *recording_pdumper;
uint64_t *packet_num;
str *recording_path;
};
@ -79,7 +80,8 @@ 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);
ssize_t meta_write_sdp(FILE *meta_fp, struct iovec *sdp_iov, int iovcnt,
uint64_t packet_num, enum call_opmode opmode);
/**
* Writes metadata to metafile, closes file, and moves it to finished location.


Loading…
Cancel
Save