TT#75351 delete DB streams that have no corresponding file

Change-Id: I07bdfd6f4dfbcef82d0eb11461672f211badde78
changes/90/37290/3
Richard Fuchs 6 years ago
parent dbd27f930b
commit 92adeb0dbb

@ -58,6 +58,7 @@ static MYSQL_STMT __thread
*stm_close_call,
*stm_insert_stream,
*stm_close_stream,
*stm_delete_stream,
*stm_config_stream,
*stm_insert_metadata;
@ -75,6 +76,7 @@ static void reset_conn(void) {
my_stmt_close(&stm_close_call);
my_stmt_close(&stm_insert_stream);
my_stmt_close(&stm_close_stream);
my_stmt_close(&stm_delete_stream);
my_stmt_close(&stm_config_stream);
my_stmt_close(&stm_insert_metadata);
mysql_close(mysql_conn);
@ -139,6 +141,8 @@ static int check_conn(void) {
"end_timestamp = ? where id = ?"))
goto err;
}
if (prep(&stm_delete_stream, "delete from recording_streams where id = ?"))
goto err;
if (prep(&stm_config_stream, "update recording_streams set channels = ?, sample_rate = ? where id = ?"))
goto err;
if (prep(&stm_insert_metadata, "insert into recording_metakeys (`call`, `key`, `value`) values " \
@ -425,6 +429,18 @@ file:;
free(filename);
}
void db_delete_stream(output_t *op) {
if (check_conn())
return;
if (op->db_id == 0)
return;
MYSQL_BIND b[1];
my_ull(&b[0], &op->db_id);
execute_wrap(&stm_delete_stream, b, NULL);
}
void db_config_stream(output_t *op) {
if (check_conn())
return;

@ -8,6 +8,7 @@ void db_do_call(metafile_t *);
void db_close_call(metafile_t *);
void db_do_stream(metafile_t *mf, output_t *op, const char *type, stream_t *, unsigned long ssrc);
void db_close_stream(output_t *op);
void db_delete_stream(output_t *op);
void db_config_stream(output_t *op);

@ -16,7 +16,7 @@ int mp3_bitrate;
static void output_shutdown(output_t *output);
static int output_shutdown(output_t *output);
@ -133,15 +133,17 @@ err:
}
static void output_shutdown(output_t *output) {
static int output_shutdown(output_t *output) {
if (!output)
return;
return 0;
if (!output->fmtctx)
return;
return 0;
int ret = 0;
if (output->fmtctx->pb) {
av_write_trailer(output->fmtctx);
avio_closep(&output->fmtctx->pb);
ret = 1;
}
avformat_free_context(output->fmtctx);
@ -154,14 +156,18 @@ static void output_shutdown(output_t *output) {
output->fmtctx = NULL;
output->avst = NULL;
return ret;
}
void output_close(output_t *output) {
if (!output)
return;
output_shutdown(output);
if (output_shutdown(output))
db_close_stream(output);
else
db_delete_stream(output);
encoder_free(output->encoder);
g_slice_free1(sizeof(*output), output);
}

Loading…
Cancel
Save