/*****************************************************************************
* v4l2.c : Video4Linux2 input module for VLC
*****************************************************************************
- * Copyright (C) 2002-2009 the VideoLAN team
+ * Copyright (C) 2002-2009 VLC authors and VideoLAN
* Copyright (C) 2011-2012 RĂ©mi Denis-Courmont
*
* Authors: Benjamin Pracht <bigben at videolan dot org>
* Antoine Cellerier <dionoea at videolan d.t org>
* Dennis Lou <dlou99 at yahoo dot com>
*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU Lesser General Public License as published by
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation; either version 2.1 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
#include <string.h>
#include <assert.h>
+#include <sys/types.h>
+#include <fcntl.h>
+
#include <vlc_common.h>
#include <vlc_plugin.h>
+#include <vlc_fs.h>
#include "v4l2.h"
-#define DEVICE_TEXT N_( "Device" )
-#define DEVICE_LONGTEXT N_("Video device node." )
+#define VIDEO_DEVICE_TEXT N_( "Video capture device" )
+#define VIDEO_DEVICE_LONGTEXT N_("Video capture device node." )
+#define VBI_DEVICE_TEXT N_("VBI capture device")
+#define VBI_DEVICE_LONGTEXT N_( \
+ "The device node where VBI data can be read " \
+ " (for closed captions) " )
#define STANDARD_TEXT N_( "Standard" )
#define STANDARD_LONGTEXT N_( \
"Video standard (Default, SECAM, PAL, or NTSC)." )
/*#define FPS_TEXT N_( "Frame rate" )
#define FPS_LONGTEXT N_( "Maximum frame rate to use (0 = no limits)." )*/
+#define RADIO_DEVICE_TEXT N_( "Radio device" )
+#define RADIO_DEVICE_LONGTEXT N_("Radio tuner device node." )
+#define FREQUENCY_TEXT N_("Frequency")
+#define FREQUENCY_LONGTEXT N_( \
+ "Tuner frequency in Hz or kHz (see debug output)" )
+#define TUNER_AUDIO_MODE_TEXT N_("Audio mode")
+#define TUNER_AUDIO_MODE_LONGTEXT N_( \
+ "Tuner audio mono/stereo and track selection." )
+
#define CTRL_RESET_TEXT N_( "Reset controls" )
#define CTRL_RESET_LONGTEXT N_( "Reset controls to defaults." )
#define BRIGHTNESS_TEXT N_( "Brightness" )
N_("Off"), N_("50 Hz"), N_("60 Hz"), N_("Automatic"),
};
#define BKLT_COMPENSATE_TEXT N_( "Backlight compensation" )
-#define BKLT_COMPENSATE_LONGTEXT N_( "Backlight compensation." )
+#define BKLT_COMPENSATE_LONGTEXT BKLT_COMPENSATE_TEXT
#define BAND_STOP_FILTER_TEXT N_( "Band-stop filter" )
#define BAND_STOP_FILTER_LONGTEXT N_( \
"Cut a light band induced by fluorescent lighting (unit undocumented)." )
"To list available controls, increase verbosity (-vvv) " \
"or use the v4l2-ctl application." )
-#define FREQUENCY_TEXT N_("Frequency")
-#define FREQUENCY_LONGTEXT N_( \
- "Tuner frequency in Hz or kHz (see debug output)" )
-#define TUNER_AUDIO_MODE_TEXT N_("Audio mode")
-#define TUNER_AUDIO_MODE_LONGTEXT N_( \
- "Tuner audio mono/stereo and track selection." )
-
#define ASPECT_TEXT N_("Picture aspect-ratio n:m")
#define ASPECT_LONGTEXT N_("Define input picture aspect-ratio to use. Default is 4:3" )
};
vlc_module_begin ()
- set_shortname( N_("Video4Linux2") )
- set_description( N_("Video4Linux2 input") )
+ set_shortname( N_("V4L") )
+ set_description( N_("Video4Linux input") )
set_category( CAT_INPUT )
set_subcategory( SUBCAT_INPUT_ACCESS )
set_section( N_( "Video input" ), NULL )
add_loadfile( CFG_PREFIX "dev", "/dev/video0",
- DEVICE_TEXT, DEVICE_LONGTEXT, false )
+ VIDEO_DEVICE_TEXT, VIDEO_DEVICE_LONGTEXT, false )
change_safe()
+#ifdef ZVBI_COMPILED
+ add_loadfile( CFG_PREFIX "vbidev", NULL,
+ VBI_DEVICE_TEXT, VBI_DEVICE_LONGTEXT, false )
+#endif
add_string( CFG_PREFIX "standard", "",
STANDARD_TEXT, STANDARD_LONGTEXT, false )
change_string_list( standards_vlc, standards_user )
add_obsolete_bool( CFG_PREFIX "use-libv4l2" ) /* since 2.1.0 */
set_section( N_( "Tuner" ), NULL )
+ add_loadfile( CFG_PREFIX "radio-dev", "/dev/radio0",
+ RADIO_DEVICE_TEXT, RADIO_DEVICE_LONGTEXT, false )
+ change_safe()
add_obsolete_integer( CFG_PREFIX "tuner" ) /* since 2.1.0 */
add_integer( CFG_PREFIX "tuner-frequency", -1, FREQUENCY_TEXT,
FREQUENCY_LONGTEXT, true )
add_submodule ()
add_shortcut( "v4l", "v4l2", "v4l2c" )
- set_description( N_("Video4Linux2 Compressed A/V") )
+ set_description( N_("Video4Linux compressed A/V input") )
set_capability( "access", 0 )
/* use these when open as access_demux fails; VLC will use another demux */
set_callbacks( AccessOpen, AccessClose )
+ add_submodule ()
+ add_shortcut ("radio" /*, "fm", "am" */)
+ set_description (N_("Video4Linux radio tuner"))
+ set_capability ("access_demux", 0)
+ set_callbacks (RadioOpen, RadioClose)
+
vlc_module_end ()
/**
}
}
+int OpenDevice (vlc_object_t *obj, const char *path, uint32_t *restrict caps)
+{
+ msg_Dbg (obj, "opening device '%s'", path);
+
+ int rawfd = vlc_open (path, O_RDWR);
+ if (rawfd == -1)
+ {
+ msg_Err (obj, "cannot open device '%s': %m", path);
+ return -1;
+ }
+
+ int fd = v4l2_fd_open (rawfd, 0);
+ if (fd == -1)
+ {
+ msg_Warn (obj, "cannot initialize user-space library: %m");
+ /* fallback to direct kernel mode anyway */
+ fd = rawfd;
+ }
+
+ /* Get device capabilites */
+ struct v4l2_capability cap;
+ if (v4l2_ioctl (fd, VIDIOC_QUERYCAP, &cap) < 0)
+ {
+ msg_Err (obj, "cannot get device capabilities: %m");
+ v4l2_close (fd);
+ return -1;
+ }
+
+ msg_Dbg (obj, "device %s using driver %s (version %u.%u.%u) on %s",
+ cap.card, cap.driver, (cap.version >> 16) & 0xFF,
+ (cap.version >> 8) & 0xFF, cap.version & 0xFF, cap.bus_info);
+
+ if (cap.capabilities & V4L2_CAP_DEVICE_CAPS)
+ {
+ msg_Dbg (obj, " with capabilities 0x%08"PRIX32" "
+ "(overall 0x%08"PRIX32")", cap.device_caps, cap.capabilities);
+ *caps = cap.device_caps;
+ }
+ else
+ {
+ msg_Dbg (obj, " with unknown capabilities "
+ "(overall 0x%08"PRIX32")", cap.capabilities);
+ *caps = cap.capabilities;
+ }
+ return fd;
+}
+
v4l2_std_id var_InheritStandard (vlc_object_t *obj, const char *varname)
{
char *name = var_InheritString (obj, varname);