MCPcopy Create free account
hub / github.com/byhook/ffmpeg4android / init_report

Function init_report

ffmpeg-single-cmd/src/main/cpp/cmdutils.c:949–1018  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

947}
948
949static int init_report(const char *env)
950{
951 char *filename_template = NULL;
952 char *key, *val;
953 int ret, count = 0;
954 time_t now;
955 struct tm *tm;
956 AVBPrint filename;
957
958 if (report_file) /* already opened */
959 return 0;
960 time(&now);
961 tm = localtime(&now);
962
963 while (env && *env) {
964 if ((ret = av_opt_get_key_value(&env, "=", ":", 0, &key, &val)) < 0) {
965 if (count)
966 av_log(NULL, AV_LOG_ERROR,
967 "Failed to parse FFREPORT environment variable: %s\n",
968 av_err2str(ret));
969 break;
970 }
971 if (*env)
972 env++;
973 count++;
974 if (!strcmp(key, "file")) {
975 av_free(filename_template);
976 filename_template = val;
977 val = NULL;
978 } else if (!strcmp(key, "level")) {
979 char *tail;
980 report_file_level = strtol(val, &tail, 10);
981 if (*tail) {
982 av_log(NULL, AV_LOG_FATAL, "Invalid report file level\n");
983 exit_program(1);
984 }
985 } else {
986 av_log(NULL, AV_LOG_ERROR, "Unknown key '%s' in FFREPORT\n", key);
987 }
988 av_free(val);
989 av_free(key);
990 }
991
992 av_bprint_init(&filename, 0, 1);
993 expand_filename_template(&filename,
994 av_x_if_null(filename_template, "%p-%t.log"), tm);
995 av_free(filename_template);
996 if (!av_bprint_is_complete(&filename)) {
997 av_log(NULL, AV_LOG_ERROR, "Out of memory building report file name\n");
998 return AVERROR(ENOMEM);
999 }
1000
1001 report_file = fopen(filename.str, "w");
1002 if (!report_file) {
1003 int ret = AVERROR(errno);
1004 av_log(NULL, AV_LOG_ERROR, "Failed to open report \"%s\": %s\n",
1005 filename.str, strerror(errno));
1006 return ret;

Callers 2

parse_loglevelFunction · 0.85
opt_reportFunction · 0.85

Calls 4

exit_programFunction · 0.85
expand_filename_templateFunction · 0.85
av_x_if_nullFunction · 0.50
av_bprint_is_completeFunction · 0.50

Tested by

no test coverage detected