Browse Source

TT#52651 make recording to output files optional

Change-Id: I12c288b965641352658ce3b499c2ee90593e1322
changes/32/27232/5
Richard Fuchs 7 years ago
parent
commit
2ef8028eb2
7 changed files with 31 additions and 5 deletions
  1. +4
    -0
      recording-daemon/decoder.c
  2. +8
    -1
      recording-daemon/main.c
  3. +1
    -0
      recording-daemon/main.h
  4. +6
    -3
      recording-daemon/metafile.c
  5. +9
    -0
      recording-daemon/output.c
  6. +1
    -1
      recording-daemon/stream.c
  7. +2
    -0
      recording-daemon/types.h

+ 4
- 0
recording-daemon/decoder.c View File

@ -90,6 +90,9 @@ static int decoder_got_frame(decoder_t *dec, AVFrame *frame, void *op, void *mp,
(unsigned int) frame->extended_data[0][2],
(unsigned int) frame->extended_data[0][3]);
if (!metafile->recording_on)
goto no_recording;
// handle mix output
pthread_mutex_lock(&metafile->mix_lock);
if (metafile->mix_out) {
@ -118,6 +121,7 @@ no_mix_out:
ilog(LOG_ERR, "Failed to add decoded packet to individual output");
}
no_recording:
av_frame_free(&frame);
return 0;


+ 8
- 1
recording-daemon/main.c View File

@ -37,6 +37,7 @@ static const char *output_format = "wav";
int output_mixed;
int output_single;
int output_enabled = 1;
int decoding_enabled;
const char *c_mysql_host,
*c_mysql_user,
*c_mysql_pass,
@ -69,9 +70,11 @@ static void signals(void) {
static void setup(void) {
log_init("rtpengine-recording");
if (output_enabled) {
if (decoding_enabled) {
codeclib_init(0);
output_init(output_format);
}
if (output_enabled) {
if (!g_file_test(output_dir, G_FILE_TEST_IS_DIR)) {
ilog(LOG_INFO, "Creating output dir '%s'", output_dir);
if (mkdir(output_dir, 0700))
@ -179,9 +182,13 @@ static void options(int *argc, char ***argv) {
//the daemon has no function
die("Both output and forwarding are disabled");
}
output_format = NULL;
} else if (!output_mixed && !output_single)
output_mixed = output_single = 1;
if (output_enabled || tcp_send_to_ep.address.family)
decoding_enabled = 1;
if (!os_str || !strcmp(os_str, "file"))
output_storage = OUTPUT_STORAGE_FILE;
else if (!strcmp(os_str, "db"))


+ 1
- 0
recording-daemon/main.h View File

@ -20,6 +20,7 @@ extern const char *output_dir;
extern int output_mixed;
extern int output_single;
extern int output_enabled;
extern int decoding_enabled;
extern const char *c_mysql_host,
*c_mysql_user,
*c_mysql_pass,


+ 6
- 3
recording-daemon/metafile.c View File

@ -70,7 +70,7 @@ static void meta_destroy(metafile_t *mf) {
// mf is locked
static void meta_stream_interface(metafile_t *mf, unsigned long snum, char *content) {
db_do_call(mf);
if (output_enabled) {
if (output_enabled && output_mixed) {
pthread_mutex_lock(&mf->mix_lock);
if (!mf->mix && output_mixed) {
char buf[256];
@ -107,7 +107,7 @@ static void meta_rtp_payload_type(metafile_t *mf, unsigned long mnum, unsigned i
ilog(LOG_ERR, "Payload type number %u is invalid", payload_num);
return;
}
if (output_enabled) {
if (decoding_enabled) {
pthread_mutex_lock(&mf->payloads_lock);
mf->payload_types[payload_num] = g_string_chunk_insert(mf->gsc,
payload_type);
@ -146,6 +146,8 @@ static void meta_section(metafile_t *mf, char *section, char *content, unsigned
tag_name(mf, lu, content);
else if (sscanf_match(section, "LABEL %lu", &lu) == 1)
tag_label(mf, lu, content);
else if (sscanf_match(section, "RECORDING %u", &u) == 1)
mf->recording_on = u;
}
@ -167,8 +169,9 @@ static metafile_t *metafile_get(char *name) {
mf->forward_fd = -1;
mf->forward_count = 0;
mf->forward_failed = 0;
mf->recording_on = 1;
if (output_enabled) {
if (decoding_enabled) {
pthread_mutex_init(&mf->payloads_lock, NULL);
pthread_mutex_init(&mf->mix_lock, NULL);
mf->ssrc_hash = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, ssrc_free);


+ 9
- 0
recording-daemon/output.c View File

@ -12,6 +12,8 @@
static const codec_def_t *output_codec;
static const char *output_file_format;
static const codec_def_t *tcp_send_codec;
int mp3_bitrate;
@ -168,6 +170,13 @@ void output_close(output_t *output) {
void output_init(const char *format) {
str codec;
str_init(&codec, "PCM-S16LE");
tcp_send_codec = codec_find(&codec, MT_AUDIO);
assert(tcp_send_codec != NULL);
if (!format)
return;
if (!strcmp(format, "wav")) {
str_init(&codec, "PCM-S16LE");
output_file_format = "wav";


+ 1
- 1
recording-daemon/stream.c View File

@ -75,7 +75,7 @@ static void stream_handler(handler_t *handler) {
else
g_atomic_int_inc(&stream->metafile->forward_count);
}
if (output_enabled)
if (decoding_enabled)
packet_process(stream, buf, ret); // consumes buf
else
free(buf);


+ 2
- 0
recording-daemon/types.h View File

@ -112,6 +112,8 @@ struct metafile_s {
pthread_mutex_t payloads_lock;
char *payload_types[128];
int recording_on:1;
};


Loading…
Cancel
Save