libexplain  1.4.D001
libexplain/buffer/v4l2_timecode.c
Go to the documentation of this file.
00001 /*
00002  * libexplain - a library of system-call-specific strerror replacements
00003  * Copyright (C) 2011, 2013 Peter Miller
00004  *
00005  * This program is free software; you can redistribute it and/or modify
00006  * it under the terms of the GNU Lesser General Public License as
00007  * published by the Free Software Foundation; either version 3 of the
00008  * License, or (at your option) any later version.
00009  *
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Lesser General Public License for more details.
00014  *
00015  * You should have received a copy of the GNU Lesser General Public License
00016  * along with this program. If not, see <http://www.gnu.org/licenses/>.
00017  */
00018 
00019 #include <libexplain/ac/linux/videodev2.h>
00020 
00021 #include <libexplain/buffer/hexdump.h>
00022 #include <libexplain/buffer/int.h>
00023 #include <libexplain/buffer/pointer.h>
00024 #include <libexplain/buffer/v4l2_timecode.h>
00025 #include <libexplain/buffer/v4l2_timecode_flags.h>
00026 #include <libexplain/buffer/v4l2_timecode_type.h>
00027 #include <libexplain/is_efault.h>
00028 #include <libexplain/sizeof.h>
00029 
00030 
00031 #ifdef HAVE_LINUX_VIDEODEV2_H
00032 
00033 static int
00034 all_zero(const unsigned char *data, size_t data_size)
00035 {
00036     while (data_size > 0)
00037     {
00038         if (*data)
00039             return 0;
00040         ++data;
00041         --data_size;
00042     }
00043     return 1;
00044 }
00045 
00046 
00047 void
00048 explain_buffer_v4l2_timecode(explain_string_buffer_t *sb,
00049     const struct v4l2_timecode *data)
00050 {
00051     if (explain_is_efault_pointer(data, sizeof(*data)))
00052     {
00053         explain_buffer_pointer(sb, data);
00054         return;
00055     }
00056 
00057     explain_string_buffer_puts(sb, "{ type = ");
00058     explain_buffer_v4l2_timecode_type(sb, data->type);
00059     explain_string_buffer_puts(sb, ", flags = ");
00060     explain_buffer_v4l2_timecode_flags(sb, data->flags);
00061     explain_string_buffer_puts(sb, ", frames = ");
00062     explain_buffer_int(sb, data->frames);
00063     explain_string_buffer_puts(sb, ", seconds = ");
00064     explain_buffer_int(sb, data->seconds);
00065     explain_string_buffer_puts(sb, ", minutes = ");
00066     explain_buffer_int(sb, data->minutes);
00067     explain_string_buffer_puts(sb, ", hours = ");
00068     explain_buffer_int(sb, data->hours);
00069     if (!all_zero(data->userbits, SIZEOF(data->userbits)))
00070     {
00071         explain_string_buffer_puts(sb, ", userbits = ");
00072         explain_buffer_mostly_text(sb, data->userbits, sizeof(data->userbits));
00073     }
00074     explain_string_buffer_puts(sb, " }");
00075 }
00076 
00077 #endif
00078 
00079 /* vim: set ts=8 sw=4 et : */