-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[RFC] Enhance message content send to 'stderr' #9
base: master
Are you sure you want to change the base?
Changes from all commits
53355bb
e26d443
52ff3d1
d069211
a26d9de
437da0b
a55d409
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,6 +37,24 @@ | |
|
||
#include "v4l2-request-test.h" | ||
|
||
const struct codec codec[] = { | ||
{ | ||
.name = "MPEG-2", | ||
.description = "Moving Pictures Expert Group Version-4 (MPEG-2)", | ||
.type = CODEC_TYPE_MPEG2, | ||
}, | ||
{ | ||
.name = "H.264", | ||
.description = "Moving Pictures Expert Group Version-4 (MPEG-4)", | ||
.type = CODEC_TYPE_H264, | ||
}, | ||
{ | ||
.name = "H.265", | ||
.description = "High-Efficiency Video Coding (HEVC)", | ||
.type = CODEC_TYPE_H265, | ||
}, | ||
}; | ||
|
||
struct format_description formats[] = { | ||
{ | ||
.description = "NV12 YUV", | ||
|
@@ -64,58 +82,57 @@ struct format_description formats[] = { | |
|
||
static void print_help(void) | ||
{ | ||
printf("Usage: v4l2-request-test [OPTIONS] [SLICES PATH]\n\n" | ||
"Options:\n" | ||
" -v [video path] path for the video node\n" | ||
" -m [media path] path for the media node\n" | ||
" -d [DRM path] path for the DRM node\n" | ||
" -D [DRM driver] DRM driver to use\n" | ||
" -s [slices filename format] format for filenames in the slices path\n" | ||
" -f [fps] number of frames to display per second\n" | ||
" -P [video preset] video preset to use\n" | ||
" -i enable interactive mode\n" | ||
" -l loop preset frames\n" | ||
" -q enable quiet mode\n" | ||
" -h help\n\n" | ||
"Video presets:\n"); | ||
printf("Usage: v4l2-request-test [OPTIONS]\n\n" | ||
"Options:\n" | ||
" -v, --device <dev>\n" | ||
" --video-device <dev> Use device <dev> as the video device.\n" | ||
" -m, --media-device <dev> Use device <dev> as the media device.\n" | ||
" -d, --drm-device <dev> Use device <dev > as DRM device.\n" | ||
" -D, --drm-driver <name> Use given DRM driver.\n" | ||
" -s, --slices-path <path> Use <path> to find stored video slices.\n" | ||
" -S, --slices-format <slices format>\n" | ||
" Regex/format describing filenames stored in the slices path.\n" | ||
" -f, --fps <fps> Display given number of frames per seconds.\n" | ||
" -P, --preset-name <name> Use given preset-name for video decoding.\n" | ||
" -i, --interactive Enable interactive mode.\n" | ||
" -l, --loop Loop preset frames.\n" | ||
" -q, --quiet Enable quiet mode.\n" | ||
" -h, --help This help message.\n\n"); | ||
|
||
presets_usage(); | ||
} | ||
|
||
static void print_summary(struct config *config, struct preset *preset) | ||
{ | ||
printf("Config:\n"); | ||
printf(" Video path: %s\n", config->video_path); | ||
printf(" Media path: %s\n", config->media_path); | ||
printf(" DRM path: %s\n", config->drm_path); | ||
printf(" DRM driver: %s\n", config->drm_driver); | ||
printf(" Slices path: %s\n", config->slices_path); | ||
printf(" Slices filename format: %s\n", config->slices_filename_format); | ||
printf(" FPS: %d\n\n", config->fps); | ||
printf(" Video device: %s\n", config->video_path); | ||
printf(" Media device: %s\n", config->media_path); | ||
printf(" DRM device: %s\n", config->drm_path); | ||
printf(" DRM driver: %s\n", config->drm_driver); | ||
printf(" Slices path: %s\n", config->slices_path); | ||
printf(" Slices format: %s\n", config->slices_filename_format); | ||
printf(" FPS: %d\n\n", config->fps); | ||
|
||
printf("Preset:\n"); | ||
printf(" Name: %s\n", preset->name); | ||
printf(" Description: %s\n", preset->description); | ||
printf(" License: %s\n", preset->license); | ||
printf(" Attribution: %s\n", preset->attribution); | ||
printf(" Width: %d\n", preset->width); | ||
printf(" Height: %d\n", preset->height); | ||
printf(" Name: %s\n", preset->name); | ||
printf(" Description: %s\n", preset->description); | ||
printf(" License: %s\n", preset->license); | ||
printf(" Attribution: %s\n", preset->attribution); | ||
printf(" Width: %d\n", preset->width); | ||
printf(" Height: %d\n", preset->height); | ||
printf(" Frames count: %d\n", preset->frames_count); | ||
|
||
printf(" Format: "); | ||
printf(" Codec Type: "); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replacing Format with Codec is definitely a change I would take in, but adding more than the short names for the codecs seems overkill. If you'd like to improve this area, one thing would be to use proper names: MPEG-2, H.264 and H.265 instead. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will produce an update. |
||
|
||
switch (preset->type) { | ||
case CODEC_TYPE_MPEG2: | ||
printf("MPEG2"); | ||
break; | ||
case CODEC_TYPE_H264: | ||
printf("H264"); | ||
break; | ||
case CODEC_TYPE_H265: | ||
printf("H265"); | ||
printf("%s -> %s", | ||
codec[preset->type].name, codec[preset->type].description); | ||
break; | ||
default: | ||
printf("Invalid"); | ||
printf("Invalid codec type!"); | ||
break; | ||
} | ||
|
||
|
@@ -257,7 +274,26 @@ int main(int argc, char *argv[]) | |
setup_config(&config); | ||
|
||
while (1) { | ||
opt = getopt(argc, argv, "v:m:d:D:s:f:P:ilqh"); | ||
int option_index = 0; | ||
static struct option long_options[] = { | ||
{ "device", required_argument, 0, 'v' }, | ||
{ "video-device", required_argument, 0, 'v' }, | ||
{ "media-device", required_argument, 0, 'm' }, | ||
{ "drm-device", required_argument, 0, 'd' }, | ||
{ "drm-driver", required_argument, 0, 'D' }, | ||
{ "slices-path", required_argument, 0, 's'}, | ||
{ "slices-format", required_argument, 0, 'S'}, | ||
{ "fps", required_argument, 0, 'f' }, | ||
{ "preset-name", required_argument, 0, 'P'}, | ||
{ "interactive", no_argument, 0, 'i'}, | ||
{ "loop", no_argument, 0, 'l'}, | ||
{ "quiet", no_argument, 0, 'q'}, | ||
{ "help", no_argument, 0, 'h'}, | ||
{ 0, 0, 0, 0 } | ||
}; | ||
|
||
opt = getopt_long(argc, argv, "v:m:d:D:s:S:f:P:ilqh", | ||
long_options, &option_index); | ||
if (opt == -1) | ||
break; | ||
|
||
|
@@ -279,6 +315,10 @@ int main(int argc, char *argv[]) | |
config.drm_driver = strdup(optarg); | ||
break; | ||
case 's': | ||
free(config.slices_path); | ||
config.slices_path = strdup(optarg); | ||
break; | ||
case 'S': | ||
free(config.slices_filename_format); | ||
config.slices_filename_format = strdup(optarg); | ||
break; | ||
|
@@ -320,9 +360,7 @@ int main(int argc, char *argv[]) | |
|
||
width = preset->width; | ||
height = preset->height; | ||
if (optind < argc) | ||
config.slices_path = strdup(argv[optind]); | ||
else | ||
if (config.slices_path == NULL) | ||
asprintf(&config.slices_path, "data/%s", config.preset_name); | ||
|
||
print_summary(&config, preset); | ||
|
@@ -360,7 +398,8 @@ int main(int argc, char *argv[]) | |
for (i = 0; i < ARRAY_SIZE(formats); i++) { | ||
test = video_engine_format_test(video_fd, | ||
formats[i].v4l2_mplane, width, | ||
height, formats[i].v4l2_format); | ||
height, formats[i].v4l2_format, | ||
config.quiet); | ||
if (test) { | ||
selected_format = &formats[i]; | ||
break; | ||
|
@@ -375,18 +414,21 @@ int main(int argc, char *argv[]) | |
|
||
printf("Destination format: %s\n", selected_format->description); | ||
|
||
test = video_engine_capabilities_test(video_fd, V4L2_CAP_STREAMING); | ||
test = video_engine_capabilities_test(video_fd, V4L2_CAP_STREAMING, | ||
config.quiet); | ||
if (!test) { | ||
fprintf(stderr, "Missing required driver streaming capability\n"); | ||
goto error; | ||
} | ||
|
||
if (selected_format->v4l2_mplane) | ||
test = video_engine_capabilities_test(video_fd, | ||
V4L2_CAP_VIDEO_M2M_MPLANE); | ||
V4L2_CAP_VIDEO_M2M_MPLANE, | ||
config.quiet); | ||
else | ||
test = video_engine_capabilities_test(video_fd, | ||
V4L2_CAP_VIDEO_M2M); | ||
V4L2_CAP_VIDEO_M2M, | ||
config.quiet); | ||
|
||
if (!test) { | ||
fprintf(stderr, "Missing required driver M2M capability\n"); | ||
|
@@ -395,15 +437,16 @@ int main(int argc, char *argv[]) | |
|
||
rc = video_engine_start(video_fd, media_fd, width, height, | ||
selected_format, preset->type, &video_buffers, | ||
config.buffers_count, &video_setup); | ||
config.buffers_count, &video_setup, | ||
config.quiet); | ||
if (rc < 0) { | ||
fprintf(stderr, "Unable to start video engine\n"); | ||
goto error; | ||
} | ||
|
||
rc = display_engine_start(drm_fd, width, height, selected_format, | ||
video_buffers, config.buffers_count, | ||
&gem_buffers, &display_setup); | ||
&gem_buffers, &display_setup, config.quiet); | ||
if (rc < 0) { | ||
fprintf(stderr, "Unable to start display engine\n"); | ||
goto error; | ||
|
@@ -487,7 +530,7 @@ int main(int argc, char *argv[]) | |
rc = video_engine_decode(video_fd, v4l2_index, &frame.frame, | ||
preset->type, ts, slice_data, | ||
slice_size, video_buffers, | ||
&video_setup); | ||
&video_setup, config.quiet); | ||
if (rc < 0) { | ||
fprintf(stderr, "Unable to decode video frame\n"); | ||
goto error; | ||
|
@@ -523,7 +566,8 @@ int main(int argc, char *argv[]) | |
clock_gettime(CLOCK_MONOTONIC, &display_before); | ||
|
||
rc = display_engine_show(drm_fd, v4l2_index, video_buffers, | ||
gem_buffers, &display_setup); | ||
gem_buffers, &display_setup, | ||
config.quiet); | ||
if (rc < 0) { | ||
fprintf(stderr, "Unable to display video frame\n"); | ||
goto error; | ||
|
@@ -564,13 +608,14 @@ int main(int argc, char *argv[]) | |
} | ||
|
||
rc = video_engine_stop(video_fd, video_buffers, config.buffers_count, | ||
&video_setup); | ||
&video_setup, config.quiet); | ||
if (rc < 0) { | ||
fprintf(stderr, "Unable to stop video engine\n"); | ||
goto error; | ||
} | ||
|
||
rc = display_engine_stop(drm_fd, gem_buffers, &display_setup); | ||
rc = display_engine_stop(drm_fd, gem_buffers, &display_setup, | ||
config.quiet); | ||
if (rc < 0) { | ||
fprintf(stderr, "Unable to stop display engine\n"); | ||
goto error; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These functions are not expected to interact with the user other than for printing out errors, so I don't think I'll take this in.