X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fv4l%2Fv4l.c;h=813845f337e2d88dcf7e7e1b435d73be9e56b308;hb=5a6c9e6c0fa7661853400967050b39c906cc02f2;hp=39365343a2b83c23fe7967bd982eb987c082f60e;hpb=8e8dada27fbcbfb07fea99eb12cc34e384e24d10;p=vlc diff --git a/modules/access/v4l/v4l.c b/modules/access/v4l/v4l.c index 39365343a2..813845f337 100644 --- a/modules/access/v4l/v4l.c +++ b/modules/access/v4l/v4l.c @@ -2,10 +2,11 @@ * v4l.c : Video4Linux input module for vlc ***************************************************************************** * Copyright (C) 2002 VideoLAN - * $Id: v4l.c,v 1.24 2003/09/07 22:49:05 fenrir Exp $ + * $Id: v4l.c,v 1.31 2003/11/23 18:31:54 alexis Exp $ * * Author: Laurent Aimar * Paul Forgey + * Gildas Bazin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -40,8 +41,23 @@ #include #include #include - #include + +/* From GStreamer's v4l plugin: + * Because of some really cool feature in video4linux1, also known as + * 'not including sys/types.h and sys/time.h', we had to include it + * ourselves. In all their intelligence, these people decided to fix + * this in the next version (video4linux2) in such a cool way that it + * breaks all compilations of old stuff... + * The real problem is actually that linux/time.h doesn't use proper + * macro checks before defining types like struct timeval. The proper + * fix here is to either fuck the kernel header (which is what we do + * by defining _LINUX_TIME_H, an innocent little hack) or by fixing it + * upstream, which I'll consider doing later on. If you get compiler + * errors here, check your linux/time.h && sys/time.h header setup. +*/ +#define _LINUX_TIME_H + #include #include "videodev_mjpeg.h" @@ -54,11 +70,14 @@ static int AccessOpen ( vlc_object_t * ); static void AccessClose ( vlc_object_t * ); static int Read ( input_thread_t *, byte_t *, size_t ); +static void ParseMRL ( input_thread_t * ); +static int OpenVideoDev( input_thread_t *, char * ); +static int OpenAudioDev( input_thread_t *, char * ); + static int DemuxOpen ( vlc_object_t * ); static void DemuxClose ( vlc_object_t * ); static int Demux ( input_thread_t * ); - /***************************************************************************** * Module descriptior *****************************************************************************/ @@ -66,6 +85,14 @@ static int Demux ( input_thread_t * ); #define CACHING_LONGTEXT N_( \ "Allows you to modify the default caching value for v4l streams. This " \ "value should be set in miliseconds units." ) +#define VDEV_TEXT N_("Video device name") +#define VDEV_LONGTEXT N_( \ + "Specify the name of the video device that will be used. " \ + "If you don't specify anything, no video device will be used.") +#define ADEV_TEXT N_("Audio device name") +#define ADEV_LONGTEXT N_( \ + "Specify the name of the audio device that will be used. " \ + "If you don't specify anything, no audio device will be used.") vlc_module_begin(); set_description( _("Video4Linux input") ); @@ -76,6 +103,11 @@ vlc_module_begin(); set_capability( "access", 10 ); set_callbacks( AccessOpen, AccessClose ); + add_string( "v4l-vdev", "/dev/video", 0, VDEV_TEXT, VDEV_LONGTEXT, + VLC_FALSE ); + add_string( "v4l-adev", "/dev/dsp", 0, ADEV_TEXT, ADEV_LONGTEXT, + VLC_FALSE ); + add_submodule(); set_description( _("Video4Linux demuxer") ); add_shortcut( "v4l" ); @@ -105,10 +137,17 @@ struct quicktime_mjpeg_app1 struct access_sys_t { - char *psz_video_device; - int fd; + /* Devices */ + char *psz_device; /* Main device from MRL, can be video or audio */ + + char *psz_vdev; + int fd_video; - picture_t pic; + char *psz_adev; + int fd_audio; + + /* Video properties */ + picture_t pic; int i_fourcc; int i_channel; @@ -119,6 +158,9 @@ struct access_sys_t int i_width; int i_height; + float f_fps; /* <= 0.0 mean to grab at full rate */ + mtime_t i_video_pts; /* only used when f_fps > 0 */ + vlc_bool_t b_mjpeg; int i_decimation; int i_quality; @@ -137,8 +179,7 @@ struct access_sys_t int i_video_frame_size; int i_video_frame_size_allocated; - char *psz_adev; - int fd_audio; + /* Audio properties */ vlc_fourcc_t i_acodec_raw; int i_sample_rate; vlc_bool_t b_stereo; @@ -148,6 +189,7 @@ struct access_sys_t int i_audio_frame_size_allocated; /* header */ + int i_streams; int i_header_size; int i_header_pos; uint8_t *p_header; // at lest 8 bytes allocated @@ -180,7 +222,7 @@ struct access_sys_t * u8 data */ -static void SetDWBE( uint8_t *p, uint32_t dw ) +static void SetDWBE( uint8_t *p, uint32_t dw ) { p[0] = (dw >> 24)&0xff; p[1] = (dw >> 16)&0xff; @@ -188,14 +230,14 @@ static void SetDWBE( uint8_t *p, uint32_t dw ) p[3] = (dw )&0xff; } -static void SetQWBE( uint8_t *p, uint64_t qw ) +static void SetQWBE( uint8_t *p, uint64_t qw ) { SetDWBE( p, (qw >> 32)&0xffffffff ); SetDWBE( &p[4], qw&0xffffffff); } /***************************************************************************** - * Open: open device: + * AccessOpen: opens v4l device ***************************************************************************** * * url: