Browse Source

All RTP packet data for a call goes to one PCAP file.

This involved moving all code from fs.(c|h) to recording.(c|h).
We still spoof packets, so the UDP will look like all monologues are coming
over the same port and will probably look like they are all one stream if
you look at the PCAP file.
pull/245/head
Dylan Mikus 10 years ago
committed by Eric Green
parent
commit
f516684ade
8 changed files with 106 additions and 88 deletions
  1. +1
    -1
      daemon/Makefile
  2. +13
    -14
      daemon/call.c
  3. +1
    -9
      daemon/call.h
  4. +19
    -10
      daemon/call_interfaces.c
  5. +2
    -2
      daemon/main.c
  6. +3
    -3
      daemon/media_socket.c
  7. +43
    -43
      daemon/recording.c
  8. +24
    -6
      daemon/recording.h

+ 1
- 1
daemon/Makefile View File

@ -69,7 +69,7 @@ endif
SRCS= main.c kernel.c poller.c aux.c control_tcp.c streambuf.c call.c control_udp.c redis.c \
bencode.c cookie_cache.c udp_listener.c control_ng.c sdp.c str.c stun.c rtcp.c \
crypto.c rtp.c call_interfaces.c dtls.c log.c cli.c graphite.c ice.c socket.c \
media_socket.c rtcp_xr.c homer.c fs.c
media_socket.c rtcp_xr.c homer.c recording.c
OBJS= $(SRCS:.c=.o)


+ 13
- 14
daemon/call.c View File

@ -36,7 +36,7 @@
#include "ice.h"
#include "rtpengine_config.h"
#include "log_funcs.h"
#include "fs.h"
#include "recording.h"
@ -1523,11 +1523,13 @@ int monologue_offer_answer(struct call_monologue *other_ml, GQueue *streams,
ml_media = other_ml_media = NULL;
str *pcap_path = recording_setup_file(call, monologue);
if (pcap_path != NULL != NULL && monologue->recording_pdumper != NULL
&& call->meta_fp) {
// Write the location of the PCAP file to the metadata file
fprintf(call->meta_fp, "%s\n", pcap_path->s);
if (call->recording != NULL && call->recording->recording_pdumper == NULL) {
str *pcap_path = recording_setup_file(call->recording);
if (pcap_path != NULL && call->recording->recording_pdumper != NULL
&& call->recording->meta_fp) {
// Write the location of the PCAP file to the metadata file
fprintf(call->recording->meta_fp, "%s\n", pcap_path->s);
}
}
for (media_iter = streams->head; media_iter; media_iter = media_iter->next) {
@ -2216,13 +2218,12 @@ void call_destroy(struct call *c) {
obj_put(sfd);
}
while (c->recording_pcaps) {
free(c->recording_pcaps->data);
c->recording_pcaps = g_slist_delete_link(c->recording_pcaps, c->recording_pcaps);
if (c->recording != NULL) {
recording_finish_file(c->recording);
free(c->recording->metadata);
}
meta_finish_file(c);
free(c->metadata);
rwlock_unlock_w(&c->master_lock);
}
@ -2319,6 +2320,7 @@ static struct call *call_create(const str *callid, struct callmaster *m) {
ilog(LOG_NOTICE, "Creating new call");
c = obj_alloc0("call", sizeof(*c), __call_free);
c->recording = NULL;
c->callmaster = m;
mutex_init(&c->buffer_lock);
call_buffer_init(&c->buffer);
@ -2415,8 +2417,6 @@ struct call_monologue *__monologue_create(struct call *call) {
ret->call = call;
ret->created = poller_now;
ret->other_tags = g_hash_table_new(str_hash, str_equal);
ret->recording_pd = NULL;
ret->recording_pdumper = NULL;
g_queue_init(&ret->medias);
gettimeofday(&ret->started, NULL);
@ -2491,7 +2491,6 @@ static void __monologue_destroy(struct call_monologue *monologue) {
GList *l;
call = monologue->call;
recording_finish_file(monologue);
g_hash_table_remove(call->tags, &monologue->tag);


+ 1
- 9
daemon/call.h View File

@ -399,9 +399,6 @@ struct call_monologue {
GHashTable *other_tags;
struct call_monologue *active_dialogue;
GQueue medias;
pcap_t *recording_pd;
pcap_dumper_t *recording_pdumper;
str *recording_path;
};
struct call {
@ -423,9 +420,6 @@ struct call {
GQueue endpoint_maps;
struct dtls_cert *dtls_cert; /* for outgoing */
unsigned int record_call;
GSList *recording_pcaps;
str callid;
time_t created;
time_t last_signal;
@ -438,9 +432,7 @@ struct call {
unsigned int redis_hosted_db;
unsigned int foreign_call; // created_via_redis_notify call
str *meta_filepath;
FILE *meta_fp;
str *metadata;
struct recording *recording;
};
struct callmaster_config {


+ 19
- 10
daemon/call_interfaces.c View File

@ -18,6 +18,7 @@
#include "control_udp.h"
#include "rtp.h"
#include "ice.h"
#include "recording.h"
@ -689,17 +690,26 @@ static const char *call_offer_answer_ng(bencode_item_t *input, struct callmaster
goto out;
if (recordcall.s && !str_cmp(&recordcall, "yes")) {
if (!call->record_call) {
meta_setup_file(call);
call->record_call = 1;
if (call->recording == NULL) {
call->recording = g_slice_alloc0(sizeof(struct recording));
call->recording->recording_pd = NULL;
call->recording->recording_pdumper = NULL;
meta_setup_file(call->recording);
}
bencode_dictionary_get_str(input, "metadata", &metadata);
if (metadata.len > 0) {
free(call->metadata);
call->metadata = str_dup(&metadata);
free(call->recording->metadata);
call->recording->metadata = str_dup(&metadata);
}
} else {
call->record_call = 0;
if (call->recording != NULL) {
g_slice_free1(sizeof(*(call->recording)), call->recording);
str *rec_metadata = call->recording->metadata;
if (rec_metadata != NULL) {
free(rec_metadata);
}
}
call->recording = NULL;
}
if (!call->created_from && addr) {
@ -750,10 +760,9 @@ 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");
bencode_item_t *recordings = bencode_dictionary_add_list(output, "recordings");
GList *l;
char *recording_path;
for (l = call->recording_pcaps; l; l = l->next) {
bencode_list_add_string(recordings, l->data);
if (call->recording != NULL && call->recording->recording_path != NULL) {
char *recording_path = call->recording->recording_path->s;
bencode_list_add_string(recordings, recording_path);
}
errstr = NULL;


+ 2
- 2
daemon/main.c View File

@ -30,7 +30,7 @@
#include "socket.h"
#include "media_socket.h"
#include "homer.h"
#include "fs.h"
#include "recording.h"
@ -521,7 +521,7 @@ static void init_everything() {
socket_init();
log_init();
fs_init(spooldir);
recording_fs_init(spooldir);
clock_gettime(CLOCK_REALTIME, &ts);
srandom(ts.tv_sec ^ ts.tv_nsec);
SSL_library_init();


+ 3
- 3
daemon/media_socket.c View File

@ -18,7 +18,7 @@
#include "aux.h"
#include "log_funcs.h"
#include "poller.h"
#include "fs.h"
#include "recording.h"
@ -834,7 +834,7 @@ void kernelize(struct packet_stream *stream) {
struct packet_stream *sink = NULL;
const char *nk_warn_msg;
if (PS_ISSET(stream, KERNELIZED) || call->record_call)
if (PS_ISSET(stream, KERNELIZED) || call->recording != NULL)
return;
if (cm->conf.kernelid < 0)
goto no_kernel;
@ -1035,8 +1035,8 @@ static int stream_packet(struct stream_fd *sfd, str *s, const endpoint_t *fsin,
struct rtp_header *rtp_h;
struct rtp_stats *rtp_s;
recording_pdumper = sfd->stream->media->monologue->recording_pdumper;
call = sfd->call;
recording_pdumper = call->recording != NULL ? call->recording->recording_pdumper : NULL;
cm = call->callmaster;
rwlock_lock_r(&call->master_lock);


daemon/fs.c → daemon/recording.c View File


daemon/fs.h → daemon/recording.h View File


Loading…
Cancel
Save