|
54 | 54 | #include <errno.h> |
55 | 55 | #include <fcntl.h> |
56 | 56 | #include <inttypes.h> |
| 57 | +#include <linux/videodev2.h> // for v4l2_format |
57 | 58 | #include <pthread.h> |
58 | | -#include <stdbool.h> // for bool, false, true |
59 | 59 | #include <stdio.h> |
60 | 60 | #include <stdlib.h> |
61 | 61 | #include <string.h> |
62 | 62 | #include <sys/ioctl.h> |
63 | 63 | #include <sys/mman.h> |
64 | | -#include <sys/time.h> // for gettimeofday, timeval |
65 | 64 | #include <unistd.h> |
66 | 65 |
|
67 | 66 | enum { |
|
70 | 69 | }; |
71 | 70 | #define MOD_NAME "[V4L cap.] " |
72 | 71 |
|
| 72 | +#include "compat/c23.h" // IWYU pragma: keep |
73 | 73 | #include "debug.h" |
74 | 74 | #include "lib_common.h" |
75 | | -#include "tv.h" |
76 | 75 | #include "types.h" // for device_info, video_desc, tile, vid... |
77 | 76 | #include "utils/color_out.h" |
78 | 77 | #include "utils/list.h" |
@@ -104,9 +103,6 @@ struct vidcap_v4l2_state { |
104 | 103 | struct v4l2_format src_fmt; ///< captured format |
105 | 104 | struct v4l2_format dst_fmt; ///< converted format if v4lconvert is used |
106 | 105 |
|
107 | | - struct timeval t0; |
108 | | - int frames; |
109 | | - |
110 | 106 | int buffer_count; |
111 | 107 |
|
112 | 108 | struct simple_linked_list *buffers_to_enqueue; |
@@ -591,7 +587,7 @@ static int vidcap_v4l2_init(const struct vidcap_params *params, void **state) |
591 | 587 | { |
592 | 588 | struct parsed_opts opts = { .buffer_count = DEFAULT_BUF_COUNT }; |
593 | 589 |
|
594 | | - printf("vidcap_v4l2_init\n"); |
| 590 | + MSG(VERBOSE, "vidcap_v4l2_init\n"); |
595 | 591 |
|
596 | 592 | if (vidcap_params_get_flags(params) & VIDCAP_FLAG_AUDIO_ANY) { |
597 | 593 | return VIDCAP_INIT_AUDIO_NOT_SUPPORTED; |
@@ -777,10 +773,7 @@ static int vidcap_v4l2_init(const struct vidcap_params *params, void **state) |
777 | 773 | goto error; |
778 | 774 | }; |
779 | 775 |
|
780 | | - gettimeofday(&s->t0, NULL); |
781 | | - s->frames = 0; |
782 | | - |
783 | | - MSG(NOTICE, "Capturing %dx%d @%.2f%s %s from %s\n", s->desc.width, |
| 776 | + MSG(INFO, "Capturing %dx%d @%.2f%s %s from %s\n", s->desc.width, |
784 | 777 | s->desc.height, s->desc.fps, |
785 | 778 | get_interlacing_suffix(s->desc.interlacing), |
786 | 779 | get_codec_name(s->desc.color_spec), opts.dev_name); |
@@ -890,28 +883,15 @@ static struct video_frame * vidcap_v4l2_grab(void *state, struct audio_frame **a |
890 | 883 | out->callbacks.dispose_udata = frame_data; |
891 | 884 | } |
892 | 885 |
|
893 | | - s->frames++; |
894 | | - |
895 | | - struct timeval t; |
896 | | - gettimeofday(&t, NULL); |
897 | | - double seconds = tv_diff(t, s->t0); |
898 | | - if (seconds >= 5) { |
899 | | - float fps = s->frames / seconds; |
900 | | - log_msg(LOG_LEVEL_INFO, "[V4L2 capture] %d frames in %g seconds = %g FPS\n", s->frames, seconds, fps); |
901 | | - s->t0 = t; |
902 | | - s->frames = 0; |
903 | | - } |
904 | | - |
905 | | - |
906 | 886 | return out; |
907 | 887 | } |
908 | 888 |
|
909 | 889 | static const struct video_capture_info vidcap_v4l2_info = { |
910 | | - vidcap_v4l2_probe, |
911 | | - vidcap_v4l2_init, |
912 | | - vidcap_v4l2_done, |
913 | | - vidcap_v4l2_grab, |
914 | | - VIDCAP_NO_GENERIC_FPS_INDICATOR, |
| 890 | + .probe = vidcap_v4l2_probe, |
| 891 | + .init = vidcap_v4l2_init, |
| 892 | + .done = vidcap_v4l2_done, |
| 893 | + .grab = vidcap_v4l2_grab, |
| 894 | + .generic_fps_indicator_prefix = MOD_NAME, |
915 | 895 | }; |
916 | 896 |
|
917 | 897 | REGISTER_MODULE(v4l2, &vidcap_v4l2_info, LIBRARY_CLASS_VIDEO_CAPTURE, VIDEO_CAPTURE_ABI_VERSION); |
|
0 commit comments