Skip to content

Commit

Permalink
add error level to errors
Browse files Browse the repository at this point in the history
  • Loading branch information
odrling committed Jan 31, 2024
1 parent 41abc96 commit 4e62051
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 15 deletions.
29 changes: 20 additions & 9 deletions dakara_check.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,33 @@

enum dakara_stream_result {
OK,
UNHANDLED_STREAM,
UNKNOWN_STREAM,
LAVC_AAC_STREAM,
TOO_MANY_AUDIO_STREAMS,
TOO_MANY_VIDEO_STREAMS,
TOO_MANY_SUBTITLE_STREAMS,
ATTACHMENT_STREAM,
};

static char const *const dakara_results_error_reports[] = {
[OK] = "OK",
[UNHANDLED_STREAM] = "Unhandled stream type",
[LAVC_AAC_STREAM] = "Lavc/FFMPEG AAC stream",
[TOO_MANY_AUDIO_STREAMS] = "Too many audio streams",
[TOO_MANY_VIDEO_STREAMS] = "Too many video streams",
[TOO_MANY_SUBTITLE_STREAMS] = "Internal subtitle track should be removed",
[ATTACHMENT_STREAM] = "Attachment found (probably a font)",
enum dakara_check_error_level {
NONE,
WARNING,
ERROR,
};

struct dakara_check_report {
char const *const message;
enum dakara_check_error_level error_level;
};

static struct dakara_check_report dakara_results_error_reports[] = {
[OK] = {"OK", NONE},
[UNKNOWN_STREAM] = {"Unknown stream type", WARNING},
[LAVC_AAC_STREAM] = {"Lavc/FFMPEG AAC stream", ERROR},
[TOO_MANY_AUDIO_STREAMS] = {"Too many audio streams", ERROR},
[TOO_MANY_VIDEO_STREAMS] = {"Too many video streams", ERROR},
[TOO_MANY_SUBTITLE_STREAMS] = {"Internal subtitle track should be removed", ERROR},
[ATTACHMENT_STREAM] = {"Attachment found (probably a font)", ERROR},
};

struct dakara_check_results {
Expand Down
11 changes: 7 additions & 4 deletions libdakara_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct dakara_check_results *dakara_check(char *filepath,
res->passed = false;
break;
default:
res->streams[ui] = UNHANDLED_STREAM;
res->streams[ui] = UNKNOWN_STREAM;
res->passed = false;
}
}
Expand All @@ -94,9 +94,12 @@ void dakara_check_print_results(struct dakara_check_results *res,
char *filepath) {
unsigned int ui;
for (ui = 0; ui < res->n_streams; ui++) {
if (res->streams[ui] != OK)
printf("%s: Stream %d: %s\n", filepath, ui,
dakara_results_error_reports[res->streams[ui]]);
if (res->streams[ui] != OK) {
struct dakara_check_report report =
dakara_results_error_reports[res->streams[ui]];
printf("%s: Stream %d (error level %d): %s\n", filepath, ui,
report.error_level, report.message);
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
project('dakara_check', 'c', version: '2.0.3')
project('dakara_check', 'c', version: '3.0.0')

git = find_program('git', required: false)

Expand All @@ -25,7 +25,7 @@ libdakara_check = library(
dependencies: deps,
install: true,
version: meson.project_version(),
soversion: '2',
soversion: '3',
)

dakara_check_exe = executable(
Expand Down

0 comments on commit 4e62051

Please sign in to comment.