diff options
Diffstat (limited to 'src/input/input_v4l.c')
-rw-r--r-- | src/input/input_v4l.c | 106 |
1 files changed, 61 insertions, 45 deletions
diff --git a/src/input/input_v4l.c b/src/input/input_v4l.c index 17c4223a2..a8f387b3d 100644 --- a/src/input/input_v4l.c +++ b/src/input/input_v4l.c @@ -16,7 +16,7 @@ * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA * * v4l input plugin */ @@ -62,15 +62,35 @@ #define XINE_ENABLE_EXPERIMENTAL_FEATURES /********** logging **********/ -#define LOG_MODULE "input_v4l" +/* #define LOG_MODULE "input_v4l" */ #define LOG_VERBOSE /* #define LOG */ -#include "xine_internal.h" -#include "xineutils.h" -#include "input_plugin.h" +#ifdef LOG +#define LOG_MODULE log_line_prefix() + +static char *log_line_prefix() +{ + static int print_timestamp = 1; + struct timeval now; + struct tm now_tm; + char buffer[64]; + + if( print_timestamp ) { + gettimeofday( &now, NULL ); + localtime_r( &now.tv_sec, &now_tm ); + strftime( buffer, sizeof( buffer ), "%Y-%m-%d %H:%M:%S", &now_tm ); + printf( "%s.%6.6ld: ", buffer, now.tv_usec ); + } + return "input_v4l"; +} +#endif + +#include <xine/xine_internal.h> +#include <xine/xineutils.h> +#include <xine/input_plugin.h> #define NUM_FRAMES 15 @@ -90,9 +110,12 @@ static const resolution_t resolutions[] = { { 160, 120 } }; +static const char *const tv_standard_names[] = { "PAL", "NTSC", "SECAM", NULL }; +static const int tv_standard_values[] = { VIDEO_MODE_PAL, VIDEO_MODE_NTSC, VIDEO_MODE_SECAM }; + #define NUM_RESOLUTIONS (sizeof(resolutions)/sizeof(resolutions[0])) -#define RADIO_DEV "/dev/v4l/radio0" -#define VIDEO_DEV "/dev/v4l/video0" +#define RADIO_DEV "/dev/radio0" +#define VIDEO_DEV "/dev/video0" #if !defined(NDELAY) && defined(O_NDELAY) #define FNDELAY O_NDELAY @@ -517,11 +540,9 @@ static int extract_mrl(v4l_input_plugin_t *this, char *mrl) /* Get frequency, if available */ sscanf(locator, "/%d", &frequency); - lprintf("Tuner name: '%s' freq: %d\n", tuner_name, frequency); - } else { - xprintf(this->stream->xine, XINE_VERBOSITY_LOG, - "input_v4l: No tuner name given. Expected syntax: v4l:/tuner/frequency\n" - "input_v4l: Using currently tuned settings\n"); + + /* cannot use xprintf to log in this routine */ + lprintf("input_v4l: Tuner name: %s frequency %d\n", tuner_name, frequency ); } this->frequency = frequency; @@ -549,7 +570,8 @@ static int set_frequency(v4l_input_plugin_t *this, unsigned long frequency) ret = ioctl(fd, VIDIOCSFREQ, &this->calc_frequency); - lprintf("IOCTL set frequency (%ld) returned: %d\n", frequency, ret); + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + "input_v4l: set frequency (%ld) returned: %d\n", frequency, ret); } else { xprintf(this->stream->xine, XINE_VERBOSITY_LOG, "input_v4l: No frequency given. Expected syntax: v4l:/tuner/frequency\n" @@ -626,6 +648,7 @@ static int search_by_channel(v4l_input_plugin_t *this, char *input_source) { int ret = 0; int fd = 0; + cfg_entry_t *tv_standard_entry; lprintf("input_source: %s\n", input_source); @@ -661,11 +684,17 @@ static int search_by_channel(v4l_input_plugin_t *this, char *input_source) return -1; } + tv_standard_entry = this->stream->xine->config->lookup_entry(this->stream->xine->config, + "media.video4linux.tv_standard"); this->tuner_name = input_source; - ret = ioctl(fd, VIDIOCSCHAN, &this->input); + this->video_channel.norm = tv_standard_values[ tv_standard_entry->num_value ]; + xprintf(this->stream->xine, XINE_VERBOSITY_LOG, + "input_v4l: TV Standard configured as STD %s (%d)\n", + tv_standard_names[ tv_standard_entry->num_value ], this->video_channel.norm ); + ret = ioctl(fd, VIDIOCSCHAN, &this->video_channel); lprintf("(%d) Set channel to %d\n", ret, this->input); - + /* FIXME: Don't assume tuner 0 ? */ this->tuner = 0; @@ -821,7 +850,7 @@ static int open_video_capture_device(v4l_input_plugin_t *this) } lprintf("Device opened, tv %d\n", this->video_fd); - + /* figure out the resolution */ for (j = 0; j < NUM_RESOLUTIONS; j++) { @@ -884,7 +913,7 @@ static int open_video_capture_device(v4l_input_plugin_t *this) if (ret < 0) { close (this->video_fd); this->video_fd = -1; - lprintf("Grab: no colorspace format found\n"); + lprintf("Grab: no colour space format found\n"); return 0; } else @@ -1194,7 +1223,7 @@ static int v4l_adjust_realtime_speed(v4l_input_plugin_t *this, fifo_buffer_t *fi * Plugin read. * This function is not supported by the plugin. */ -static off_t v4l_plugin_read (input_plugin_t *this_gen, char *buf, off_t len) { +static off_t v4l_plugin_read (input_plugin_t *this_gen, void *buf, off_t len) { lprintf("Read not supported\n"); return 0; } @@ -1871,25 +1900,6 @@ static input_plugin_t *v4l_class_get_radio_instance (input_class_t *cls_gen, /* * v4l input plugin class stuff */ - -static char *v4l_class_get_video_description (input_class_t *this_gen) { - return _("v4l tv input plugin"); -} - -static char *v4l_class_get_radio_description (input_class_t *this_gen) { - return _("v4l radio input plugin"); -} - -static const char *v4l_class_get_identifier (input_class_t *this_gen) { - return "v4l"; -} - -static void v4l_class_dispose (input_class_t *this_gen) { - v4l_input_class_t *this = (v4l_input_class_t *) this_gen; - - free (this); -} - static void *init_video_class (xine_t *xine, void *data) { v4l_input_class_t *this; @@ -1900,11 +1910,11 @@ static void *init_video_class (xine_t *xine, void *data) this->xine = xine; this->input_class.get_instance = v4l_class_get_video_instance; - this->input_class.get_identifier = v4l_class_get_identifier; - this->input_class.get_description = v4l_class_get_video_description; + this->input_class.identifier = "v4l"; + this->input_class.description = N_("v4l tv input plugin"); this->input_class.get_dir = NULL; this->input_class.get_autoplay_list = NULL; - this->input_class.dispose = v4l_class_dispose; + this->input_class.dispose = default_input_class_dispose; this->input_class.eject_media = NULL; config->register_filename (config, "media.video4linux.video_device", @@ -1913,6 +1923,12 @@ static void *init_video_class (xine_t *xine, void *data) _("The path to your Video4Linux video device."), 10, NULL, NULL); + config->register_enum (config, "media.video4linux.tv_standard", 0, + tv_standard_names, _("v4l TV standard"), + _("Selects the TV standard of the input signals. " + "Either: PAL, NTSC and SECAM. "), 20, NULL, NULL); + + return this; } @@ -1926,11 +1942,11 @@ static void *init_radio_class (xine_t *xine, void *data) this->xine = xine; this->input_class.get_instance = v4l_class_get_radio_instance; - this->input_class.get_identifier = v4l_class_get_identifier; - this->input_class.get_description = v4l_class_get_radio_description; + this->input_class.identifier = "v4l"; + this->input_class.description = N_("v4l radio input plugin"); this->input_class.get_dir = NULL; this->input_class.get_autoplay_list = NULL; - this->input_class.dispose = v4l_class_dispose; + this->input_class.dispose = default_input_class_dispose; this->input_class.eject_media = NULL; config->register_filename (config, "media.video4linux.radio_device", @@ -1948,8 +1964,8 @@ static void *init_radio_class (xine_t *xine, void *data) const plugin_info_t xine_plugin_info[] EXPORTED = { /* type, API, "name", version, special_info, init_function */ - { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 17, "v4l_radio", XINE_VERSION_CODE, NULL, init_radio_class }, - { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 17, "v4l_tv", XINE_VERSION_CODE, NULL, init_video_class }, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 18, "v4l_radio", XINE_VERSION_CODE, NULL, init_radio_class }, + { PLUGIN_INPUT | PLUGIN_MUST_PRELOAD, 18, "v4l_tv", XINE_VERSION_CODE, NULL, init_video_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; |