X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fv4l%2Fv4l.c;h=f06ce6d02a71d792f9a60f5ae1f3889936b30b7d;hb=c525c6f2202623b228c4de3dd9ab4141cd0fa14b;hp=7f1fe58d0252d991f79a9f009a0f2fb0e906e1a3;hpb=1a0ee7db04f71f4db0bff773d45f50c66464c560;p=vlc diff --git a/modules/access/v4l/v4l.c b/modules/access/v4l/v4l.c index 7f1fe58d02..f06ce6d02a 100644 --- a/modules/access/v4l/v4l.c +++ b/modules/access/v4l/v4l.c @@ -7,6 +7,7 @@ * Author: Laurent Aimar * Paul Forgey * Gildas Bazin + * Benjamin Pracht * * 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 @@ -66,11 +67,8 @@ /***************************************************************************** * Module descriptior *****************************************************************************/ -static int AccessOpen ( vlc_object_t * ); -static void AccessClose( vlc_object_t * ); - -static int DemuxOpen ( vlc_object_t * ); -static void DemuxClose ( vlc_object_t * ); +static int Open ( vlc_object_t * ); +static void Close( vlc_object_t * ); #define CACHING_TEXT N_("Caching value in ms") #define CACHING_LONGTEXT N_( \ @@ -88,9 +86,67 @@ static void DemuxClose ( vlc_object_t * ); #define CHROMA_LONGTEXT N_( \ "Force the Video4Linux video device to use a specific chroma format " \ "(eg. I420 (default), RV24, etc.)") +#define FREQUENCY_TEXT N_( "Frequency" ) +#define FREQUENCY_LONGTEXT N_( \ + "Frequency to capture (in kHz), if applicable" ) +#define CHANNEL_TEXT N_( "Channel" ) +#define CHANNEL_LONGTEXT N_( \ + "Channel of the card to use (Usually, 0 = tuner, " \ + "1 = composite, 2 = svideo)" ) +#define NORM_TEXT N_( "Norm" ) +#define NORM_LONGTEXT N_( \ + "Defines the norm of the stream (Automatic, SECAM, PAL, or NTSC)" ) +#define AUDIO_TEXT N_( "Audio Channel" ) +#define AUDIO_LONGTEXT N_( \ + "Audio Channel to use, if there are several audio input" ) +#define WIDTH_TEXT N_( "Width" ) +#define WIDTH_LONGTEXT N_( "Width of the stream to capture " \ + "(-1 for autodetect)" ) +#define HEIGHT_TEXT N_( "Height" ) +#define HEIGHT_LONGTEXT N_( "Height of the stream to capture " \ + "(-1 for autodetect)" ) +#define BRIGHTNESS_TEXT N_( "Brightness" ) +#define BRIGHTNESS_LONGTEXT N_( \ + "Set the Brightness of the video input" ) +#define HUE_TEXT N_( "Hue" ) +#define HUE_LONGTEXT N_( \ + "Set the Hue of the video input" ) +#define COLOUR_TEXT N_( "Color" ) +#define COLOUR_LONGTEXT N_( \ + "Set the Color of the video input" ) +#define CONTRAST_TEXT N_( "Contrast" ) +#define CONTRAST_LONGTEXT N_( \ + "Set the Contrast of the video input" ) +#define TUNER_TEXT N_( "Tuner" ) +#define TUNER_LONGTEXT N_( "Tuner to use, if there are several ones" ) +#define SAMPLERATE_TEXT N_( "Samplerate" ) +#define SAMPLERATE_LONGTEXT N_( \ + "Samplerate of the captures audio stream, in Hz" ) +#define STEREO_TEXT N_( "Stereo" ) +#define STEREO_LONGTEXT N_( \ + "If this option is set, the audio stream will be captured in stereo" ) +#define MJPEG_TEXT N_( "MJPEG" ) +#define MJPEG_LONGTEXT N_( \ + "Set this option if the capture device outputs MJPEG" ) +#define DECIMATION_TEXT N_( "Decimation" ) +#define DECIMATION_LONGTEXT N_( \ + "Set the Decimation level for MJPEG streams" ) +#define QUALITY_TEXT N_( "Quality" ) +#define QUALITY_LONGTEXT N_( "Set the quality of the stream" ) +#define FPS_TEXT N_( "Framerate" ) +#define FPS_LONGTEXT N_( "Framerate to capture, if applicable " \ + "(-1 for auto)" ) + +static int i_norm_list[] = + { VIDEO_MODE_AUTO, VIDEO_MODE_SECAM, VIDEO_MODE_PAL, VIDEO_MODE_NTSC }; +static char *psz_norm_list_text[] = + { N_("Automatic"), N_("SECAM"), N_("PAL"), N_("NTSC") }; vlc_module_begin(); + set_shortname( _("Video4Linux") ); set_description( _("Video4Linux input") ); + set_category( CAT_INPUT ); + set_subcategory( SUBCAT_INPUT_ACCESS ); add_integer( "v4l-caching", DEFAULT_PTS_DELAY / 1000, NULL, CACHING_TEXT, CACHING_LONGTEXT, VLC_TRUE ); @@ -100,27 +156,54 @@ vlc_module_begin(); VLC_FALSE ); add_string( "v4l-chroma", NULL, NULL, CHROMA_TEXT, CHROMA_LONGTEXT, VLC_TRUE ); + add_float( "v4l-fps", -1.0, NULL, FPS_TEXT, FPS_LONGTEXT, VLC_TRUE ); + add_integer( "v4l-samplerate", 44100, NULL, SAMPLERATE_TEXT, + SAMPLERATE_LONGTEXT, VLC_TRUE ); + add_integer( "v4l-channel", 0, NULL, CHANNEL_TEXT, CHANNEL_LONGTEXT, + VLC_TRUE ); + add_integer( "v4l-tuner", -1, NULL, TUNER_TEXT, TUNER_LONGTEXT, VLC_TRUE ); + add_integer( "v4l-norm", VIDEO_MODE_AUTO, NULL, NORM_TEXT, NORM_LONGTEXT, + VLC_FALSE ); + change_integer_list( i_norm_list, psz_norm_list_text, 0 ); + add_integer( "v4l-frequency", -1, NULL, FREQUENCY_TEXT, FREQUENCY_LONGTEXT, + VLC_FALSE ); + add_integer( "v4l-audio", -1, NULL, AUDIO_TEXT, AUDIO_LONGTEXT, VLC_TRUE ); + add_bool( "v4l-stereo", VLC_TRUE, NULL, STEREO_TEXT, STEREO_LONGTEXT, + VLC_TRUE ); + add_integer( "v4l-width", 0, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, VLC_TRUE ); + add_integer( "v4l-height", 0, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, + VLC_TRUE ); + add_integer( "v4l-brightness", -1, NULL, BRIGHTNESS_TEXT, + BRIGHTNESS_LONGTEXT, VLC_TRUE ); + add_integer( "v4l-colour", -1, NULL, COLOUR_TEXT, COLOUR_LONGTEXT, + VLC_TRUE ); + add_integer( "v4l-hue", -1, NULL, HUE_TEXT, HUE_LONGTEXT, VLC_TRUE ); + add_integer( "v4l-contrast", -1, NULL, CONTRAST_TEXT, CONTRAST_LONGTEXT, + VLC_TRUE ); + add_bool( "v4l-mjpeg", VLC_FALSE, NULL, MJPEG_TEXT, MJPEG_LONGTEXT, + VLC_TRUE ); + add_integer( "v4l-decimation", 1, NULL, DECIMATION_TEXT, + DECIMATION_LONGTEXT, VLC_TRUE ); + add_integer( "v4l-quality", 100, NULL, QUALITY_TEXT, QUALITY_LONGTEXT, + VLC_TRUE ); add_shortcut( "v4l" ); - set_capability( "access", 10 ); - set_callbacks( AccessOpen, AccessClose ); - - add_submodule(); - set_description( _("Video4Linux demuxer") ); - add_shortcut( "v4l" ); - set_capability( "demux", 200 ); - set_callbacks( DemuxOpen, DemuxClose ); + set_capability( "access_demux", 10 ); + set_callbacks( Open, Close ); vlc_module_end(); - /***************************************************************************** * Access: local prototypes *****************************************************************************/ -static int Read ( input_thread_t *, byte_t *, size_t ); +static int Demux ( demux_t * ); +static int Control( demux_t *, int, va_list ); -static void ParseMRL ( input_thread_t * ); -static int OpenVideoDev( input_thread_t *, char * ); -static int OpenAudioDev( input_thread_t *, char * ); +static void ParseMRL ( demux_t * ); +static int OpenVideoDev( demux_t *, char * ); +static int OpenAudioDev( demux_t *, char * ); + +static block_t *GrabAudio( demux_t * ); +static block_t *GrabVideo( demux_t * ); #define MJPEG_BUFFER_SIZE (256*1024) @@ -163,7 +246,7 @@ static struct { 0, 0 } }; -struct access_sys_t +struct demux_sys_t { /* Devices */ char *psz_device; /* Main device from MRL, can be video or audio */ @@ -208,131 +291,139 @@ struct access_sys_t struct video_mmap vid_mmap; struct video_picture vid_picture; - uint8_t *p_video_frame; - int i_video_frame_size; - int i_video_frame_size_allocated; + int i_video_frame_size; + es_out_id_t *p_es_video; /* Audio properties */ vlc_fourcc_t i_acodec_raw; int i_sample_rate; vlc_bool_t b_stereo; - - uint8_t *p_audio_frame; - int i_audio_frame_size; - 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 - - /* data */ - int i_data_size; - int i_data_pos; - uint8_t *p_data; // never allocated - + int i_audio_max_frame_size; + block_t *p_block_audio; + es_out_id_t *p_es_audio; }; -/* - * header: - * fcc ".v4l" - * u32 stream count - * fcc "auds"|"vids" 0 - * fcc codec 4 - * if vids - * u32 width 8 - * u32 height 12 - * u32 padding 16 - * if auds - * u32 channels 12 - * u32 samplerate 8 - * u32 samplesize 16 - * - * data: - * u32 stream number - * u32 data size - * u8 data - */ - -static void SetDWBE( uint8_t *p, uint32_t dw ) -{ - p[0] = (dw >> 24)&0xff; - p[1] = (dw >> 16)&0xff; - p[2] = (dw >> 8)&0xff; - p[3] = (dw )&0xff; -} - -static void SetQWBE( uint8_t *p, uint64_t qw ) -{ - SetDWBE( p, (qw >> 32)&0xffffffff ); - SetDWBE( &p[4], qw&0xffffffff); -} - /***************************************************************************** - * AccessOpen: opens v4l device + * Open: opens v4l device ***************************************************************************** * * url: