From 323dfafae8386d9d08f10a22d5be02db4e933a5b Mon Sep 17 00:00:00 2001 From: Gildas Bazin Date: Thu, 6 Nov 2003 00:12:17 +0000 Subject: [PATCH] * modules/access/v4l/v4l.c: big clean-up of the Video4Linux input. New --v4l-vdev and --v4l-adev config options and the ability to play an audio only stream. --- modules/access/v4l/v4l.c | 576 ++++++++++++++++++++++++--------------- 1 file changed, 358 insertions(+), 218 deletions(-) diff --git a/modules/access/v4l/v4l.c b/modules/access/v4l/v4l.c index c9e781bf4d..8767ad9a78 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.27 2003/10/25 20:19:19 fenrir Exp $ + * $Id: v4l.c,v 1.28 2003/11/06 00:12:17 gbazin 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 @@ -54,11 +55,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 +70,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 video device will be used.") vlc_module_begin(); set_description( _("Video4Linux input") ); @@ -76,6 +88,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 +122,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 */ - picture_t pic; + char *psz_vdev; + int fd_video; + + char *psz_adev; + int fd_audio; + + /* Video properties */ + picture_t pic; int i_fourcc; int i_channel; @@ -140,8 +164,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; @@ -151,6 +174,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 @@ -183,7 +207,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; @@ -191,14 +215,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: