Browse Source

TT#109618 keep track of actual file name used for recordings

Change-Id: I74b51e0621a687b8dd3ad21939e70675fbb49e4f
pull/1194/head
Richard Fuchs 5 years ago
parent
commit
e860e076f8
3 changed files with 6 additions and 28 deletions
  1. +3
    -18
      recording-daemon/db.c
  2. +1
    -0
      recording-daemon/output.c
  3. +2
    -10
      recording-daemon/types.h

+ 3
- 18
recording-daemon/db.c View File

@ -371,29 +371,16 @@ void db_close_stream(output_t *op) {
double now = now_double();
str stream;
char *filename = 0;
MYSQL_BIND b[3];
stream.s = 0;
stream.len = 0;
if ((output_storage & OUTPUT_STORAGE_DB)) {
filename = malloc(strlen(op->full_filename) +
strlen(op->file_format) + 2);
if (!filename) {
ilog(LOG_ERR, "Failed to allocate memory for filename");
if ((output_storage & OUTPUT_STORAGE_FILE))
goto file;
return;
}
strcpy(filename, op->full_filename);
strcat(filename, ".");
strcat(filename, op->file_format);
FILE *f = fopen(filename, "rb");
FILE *f = fopen(op->filename, "rb");
if (!f) {
ilog(LOG_ERR, "Failed to open file: %s%s%s", FMT_M(filename));
ilog(LOG_ERR, "Failed to open file: %s%s%s", FMT_M(op->filename));
if ((output_storage & OUTPUT_STORAGE_FILE))
goto file;
free(filename);
return;
}
fseek(f, 0, SEEK_END);
@ -406,7 +393,6 @@ void db_close_stream(output_t *op) {
ilog(LOG_ERR, "Failed to read from stream");
if ((output_storage & OUTPUT_STORAGE_FILE))
goto file;
free(filename);
return;
}
}
@ -425,8 +411,7 @@ file:;
if (stream.s)
free(stream.s);
if (!(output_storage & OUTPUT_STORAGE_FILE))
remove(filename);
free(filename);
remove(op->filename);
}
void db_delete_stream(output_t *op) {


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

@ -111,6 +111,7 @@ int output_config(output_t *output, const format_t *requested_format, format_t *
goto err;
got_fn:
g_strlcpy(output->filename, full_fn, sizeof(output->filename));
err = "failed to open avio";
av_ret = avio_open(&output->fmtctx->pb, full_fn, AVIO_FLAG_WRITE);
if (av_ret < 0)


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

@ -142,21 +142,13 @@ struct metafile_s {
struct output_s {
char full_filename[PATH_MAX], // path + filename
file_path[PATH_MAX],
file_name[PATH_MAX];
file_name[PATH_MAX],
filename[PATH_MAX * 2]; // path + filename + suffix
const char *file_format;
unsigned long long db_id;
// format_t requested_format,
// actual_format;
// AVCodecContext *avcctx;
AVFormatContext *fmtctx;
AVStream *avst;
// AVPacket avpkt;
// AVAudioFifo *fifo;
// int64_t fifo_pts; // pts of first data in fifo
// int64_t mux_dts; // last dts passed to muxer
// AVFrame *frame;
encoder_t *encoder;
};


Loading…
Cancel
Save