X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fv4l.c;h=28c1a008425cd7a76b16905eab6fca362e6faa4a;hb=8b8e192964fd55a2910f8da291c37f4b91773539;hp=f9e534cf70c3391c966d9d1f152b407db1a25969;hpb=552e595131c5f1d66eba8e3c22c2b1c509be5153;p=vlc diff --git a/modules/access/v4l.c b/modules/access/v4l.c index f9e534cf70..28c1a00842 100644 --- a/modules/access/v4l.c +++ b/modules/access/v4l.c @@ -28,20 +28,24 @@ * Preamble *****************************************************************************/ -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include #include #include #include -#include -#include +#include +#include +#include -#include -#include #include -#include #include -#include #include +#include +#include /* From GStreamer's v4l plugin: * Because of some really cool feature in video4linux1, also known as @@ -61,8 +65,9 @@ #include #include "videodev_mjpeg.h" -#include - +#ifdef HAVE_LIBV4L1 +#include +#endif /***************************************************************************** * Module descriptior *****************************************************************************/ @@ -77,10 +82,6 @@ static void Close( vlc_object_t * ); #define VDEV_LONGTEXT N_( \ "Name of the video device to use. " \ "If you don't specify anything, no video device will be used.") -#define ADEV_TEXT N_("Audio device name") -#define ADEV_LONGTEXT N_( \ - "Name of the audio device to use. " \ - "If you don't specify anything, no audio device will be used.") #define CHROMA_TEXT N_("Video input chroma format") #define CHROMA_LONGTEXT N_( \ "Force the Video4Linux video device to use a specific chroma format " \ @@ -118,12 +119,6 @@ static void Close( vlc_object_t * ); "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 captured audio stream, in Hz (eg: 11025, 22050, 44100)" ) -#define STEREO_TEXT N_( "Stereo" ) -#define STEREO_LONGTEXT N_( \ - "Capture the audio stream in stereo." ) #define MJPEG_TEXT N_( "MJPEG" ) #define MJPEG_LONGTEXT N_( \ "Set this option if the capture device outputs MJPEG" ) @@ -136,60 +131,63 @@ static void Close( vlc_object_t * ); #define FPS_LONGTEXT N_( "Framerate to capture, if applicable " \ "(-1 for autodetect)." ) -static int i_norm_list[] = +#define AUDIO_DEPRECATED_ERROR N_( \ + "Alsa or OSS audio capture in the v4l access is deprecated. " \ + "please use 'v4l:/""/ :input-slave=alsa:/""/' or " \ + "'v4l:/""/ :input-slave=oss:/""/' instead." ) + +static const int i_norm_list[] = { VIDEO_MODE_AUTO, VIDEO_MODE_SECAM, VIDEO_MODE_PAL, VIDEO_MODE_NTSC }; -static const char *psz_norm_list_text[] = +static const char *const 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 ); +#define V4L_DEFAULT "/dev/video" + +vlc_module_begin () + set_shortname( N_("Video4Linux") ) + set_description( N_("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 ); - 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 ); + CACHING_TEXT, CACHING_LONGTEXT, true ) + add_obsolete_string( "v4l-vdev" ); + add_obsolete_string( "v4l-adev" ); 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 ); + true ) + add_float( "v4l-fps", -1.0, NULL, FPS_TEXT, FPS_LONGTEXT, true ) + add_obsolete_integer( "v4l-samplerate" ); add_integer( "v4l-channel", 0, NULL, CHANNEL_TEXT, CHANNEL_LONGTEXT, - VLC_TRUE ); - add_integer( "v4l-tuner", -1, NULL, TUNER_TEXT, TUNER_LONGTEXT, VLC_TRUE ); + true ) + add_integer( "v4l-tuner", -1, NULL, TUNER_TEXT, TUNER_LONGTEXT, 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 ); + false ) + change_integer_list( i_norm_list, psz_norm_list_text, NULL ); 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 ); + false ) + add_integer( "v4l-audio", -1, NULL, AUDIO_TEXT, AUDIO_LONGTEXT, true ) + add_obsolete_bool( "v4l-stereo" ); + add_integer( "v4l-width", 0, NULL, WIDTH_TEXT, WIDTH_LONGTEXT, true ) add_integer( "v4l-height", 0, NULL, HEIGHT_TEXT, HEIGHT_LONGTEXT, - VLC_TRUE ); + true ) add_integer( "v4l-brightness", -1, NULL, BRIGHTNESS_TEXT, - BRIGHTNESS_LONGTEXT, VLC_TRUE ); + BRIGHTNESS_LONGTEXT, 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 ); + true ) + add_integer( "v4l-hue", -1, NULL, HUE_TEXT, HUE_LONGTEXT, 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 ); + true ) + add_bool( "v4l-mjpeg", false, NULL, MJPEG_TEXT, MJPEG_LONGTEXT, + true ) add_integer( "v4l-decimation", 1, NULL, DECIMATION_TEXT, - DECIMATION_LONGTEXT, VLC_TRUE ); + DECIMATION_LONGTEXT, true ) add_integer( "v4l-quality", 100, NULL, QUALITY_TEXT, QUALITY_LONGTEXT, - VLC_TRUE ); + true ) - add_shortcut( "v4l" ); - set_capability( "access_demux", 10 ); - set_callbacks( Open, Close ); -vlc_module_end(); + add_shortcut( "v4l" ) + set_capability( "access_demux", 10 ) + set_callbacks( Open, Close ) +vlc_module_end () /***************************************************************************** * Access: local prototypes @@ -199,9 +197,6 @@ static int Control( demux_t *, int, va_list ); 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) @@ -220,43 +215,36 @@ struct quicktime_mjpeg_app1 uint32_t i_data_offset; /* following SOS marker data */ }; -static struct +static const struct { int i_v4l; - int i_fourcc; + vlc_fourcc_t i_fourcc; } v4lchroma_to_fourcc[] = { - { VIDEO_PALETTE_GREY, VLC_FOURCC( 'G', 'R', 'E', 'Y' ) }, + { VIDEO_PALETTE_GREY, VLC_CODEC_GREY }, { VIDEO_PALETTE_HI240, VLC_FOURCC( 'I', '2', '4', '0' ) }, - { VIDEO_PALETTE_RGB565, VLC_FOURCC( 'R', 'V', '1', '6' ) }, - { VIDEO_PALETTE_RGB555, VLC_FOURCC( 'R', 'V', '1', '5' ) }, - { VIDEO_PALETTE_RGB24, VLC_FOURCC( 'R', 'V', '2', '4' ) }, - { VIDEO_PALETTE_RGB32, VLC_FOURCC( 'R', 'V', '3', '2' ) }, - { VIDEO_PALETTE_YUV422, VLC_FOURCC( 'Y', 'U', 'Y', '2' ) }, - { VIDEO_PALETTE_YUV422, VLC_FOURCC( 'Y', 'U', 'Y', 'V' ) }, - { VIDEO_PALETTE_YUYV, VLC_FOURCC( 'Y', 'U', 'Y', '2' ) }, - { VIDEO_PALETTE_YUYV, VLC_FOURCC( 'Y', 'U', 'Y', 'V' ) }, - { VIDEO_PALETTE_UYVY, VLC_FOURCC( 'U', 'Y', 'V', 'Y' ) }, + { VIDEO_PALETTE_RGB565, VLC_CODEC_RGB16 }, + { VIDEO_PALETTE_RGB555, VLC_CODEC_RGB15 }, + { VIDEO_PALETTE_RGB24, VLC_CODEC_RGB24 }, + { VIDEO_PALETTE_RGB32, VLC_CODEC_RGB32 }, + { VIDEO_PALETTE_YUV422, VLC_CODEC_YUYV }, + { VIDEO_PALETTE_YUYV, VLC_CODEC_YUYV }, + { VIDEO_PALETTE_UYVY, VLC_CODEC_UYVY }, { VIDEO_PALETTE_YUV420, VLC_FOURCC( 'I', '4', '2', 'N' ) }, { VIDEO_PALETTE_YUV411, VLC_FOURCC( 'I', '4', '1', 'N' ) }, { VIDEO_PALETTE_RAW, VLC_FOURCC( 'G', 'R', 'A', 'W' ) }, - { VIDEO_PALETTE_YUV422P, VLC_FOURCC( 'I', '4', '2', '2' ) }, - { VIDEO_PALETTE_YUV420P, VLC_FOURCC( 'I', '4', '2', '0' ) }, - { VIDEO_PALETTE_YUV411P, VLC_FOURCC( 'I', '4', '1', '1' ) }, + { VIDEO_PALETTE_YUV422P, VLC_CODEC_I422 }, + { VIDEO_PALETTE_YUV420P, VLC_CODEC_I420 }, + { VIDEO_PALETTE_YUV411P, VLC_CODEC_I411 }, { 0, 0 } }; struct demux_sys_t { /* Devices */ - char *psz_device; /* Main device from MRL, can be video or audio */ - - char *psz_vdev; - int fd_video; - - char *psz_adev; - int fd_audio; + char *psz_device; /* Main device from MRL */ + int i_fd; /* Video properties */ picture_t pic; @@ -278,7 +266,7 @@ struct demux_sys_t 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; + bool b_mjpeg; int i_decimation; int i_quality; @@ -293,17 +281,17 @@ struct demux_sys_t struct video_picture vid_picture; 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; - int i_audio_max_frame_size; - block_t *p_block_audio; - es_out_id_t *p_es_audio; + es_out_id_t *p_es; }; +#ifndef HAVE_LIBV4L1 +# define v4l1_close close +# define v4l1_ioctl ioctl +# define v4l1_mmap mmap +# define v4l1_munmap munmap +# define v4l1_open vlc_open +#endif + /***************************************************************************** * Open: opens v4l device ***************************************************************************** @@ -315,7 +303,6 @@ static int Open( vlc_object_t *p_this ) { demux_t *p_demux = (demux_t*)p_this; demux_sys_t *p_sys; - vlc_value_t val; /* Only when selected */ if( *p_demux->psz_access == '\0' ) @@ -327,208 +314,80 @@ static int Open( vlc_object_t *p_this ) p_demux->info.i_update = 0; p_demux->info.i_title = 0; p_demux->info.i_seekpoint = 0; - p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); - memset( p_sys, 0, sizeof( demux_sys_t ) ); - - var_Create( p_demux, "v4l-audio", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-audio", &val ); - p_sys->i_audio = val.i_int; - - var_Create( p_demux, "v4l-channel", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-channel", &val ); - p_sys->i_channel = val.i_int; - - var_Create( p_demux, "v4l-norm", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-norm", &val ); - p_sys->i_norm = val.i_int; - - var_Create( p_demux, "v4l-tuner", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-tuner", &val ); - p_sys->i_tuner = val.i_int; - - var_Create( p_demux, "v4l-frequency", - VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-frequency", &val ); - p_sys->i_frequency = val.i_int; + p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) ); + if( !p_sys ) + return VLC_ENOMEM; - var_Create( p_demux, "v4l-fps", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-fps", &val ); - p_sys->f_fps = val.f_float; + p_sys->i_audio = var_CreateGetInteger( p_demux, "v4l-audio" ); + p_sys->i_channel = var_CreateGetInteger( p_demux, "v4l-channel" ); + p_sys->i_norm = var_CreateGetInteger( p_demux, "v4l-norm" ); + p_sys->i_tuner = var_CreateGetInteger( p_demux, "v4l-tuner" ); + p_sys->i_frequency = var_CreateGetInteger( p_demux, "v4l-frequency" ); - var_Create( p_demux, "v4l-width", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-width", &val ); - p_sys->i_width = val.i_int; + p_sys->f_fps = var_CreateGetFloat( p_demux, "v4l-fps" ); + p_sys->i_width = var_CreateGetInteger( p_demux, "v4l-width" ); + p_sys->i_height = var_CreateGetInteger( p_demux, "v4l-height" ); + p_sys->i_video_pts = -1; + p_sys->i_brightness = var_CreateGetInteger( p_demux, "v4l-brightness" ); - var_Create( p_demux, "v4l-height", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-height", &val ); - p_sys->i_height = val.i_int; + p_sys->i_hue = var_CreateGetInteger( p_demux, "v4l-hue" ); + p_sys->i_colour = var_CreateGetInteger( p_demux, "v4l-colour" ); + p_sys->i_contrast = var_CreateGetInteger( p_demux, "v4l-contrast" ); - p_sys->i_video_pts = -1; + p_sys->b_mjpeg = var_CreateGetBool( p_demux, "v4l-mjpeg" ); + p_sys->i_decimation = var_CreateGetInteger( p_demux, "v4l-decimation" ); + p_sys->i_quality = var_CreateGetInteger( p_demux, "v4l-quality" ); - var_Create( p_demux, "v4l-brightness", VLC_VAR_INTEGER | - VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-brightness", &val ); - p_sys->i_brightness = val.i_int; + p_sys->psz_device = NULL; + p_sys->i_fd = -1; - var_Create( p_demux, "v4l-hue", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-hue", &val ); - p_sys->i_hue = -1; - - var_Create( p_demux, "v4l-colour", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-colour", &val ); - p_sys->i_colour = val.i_int; - - var_Create( p_demux, "v4l-contrast", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-contrast", &val ); - p_sys->i_contrast = val.i_int; - - var_Create( p_demux, "v4l-mjpeg", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-mjpeg", &val ); - p_sys->b_mjpeg = val.b_bool; - - var_Create( p_demux, "v4l-decimation", VLC_VAR_INTEGER | - VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-decimation", &val ); - p_sys->i_decimation = val.i_int; - - var_Create( p_demux, "v4l-quality", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-quality", &val ); - p_sys->i_quality = val.i_int; - - var_Create( p_demux, "v4l-samplerate", - VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-samplerate", &val ); - p_sys->i_sample_rate = val.i_int; - - var_Create( p_demux, "v4l-stereo", VLC_VAR_BOOL | VLC_VAR_DOINHERIT ); - var_Get( p_demux, "v4l-stereo", &val ); - p_sys->b_stereo = val.b_bool; - - p_sys->psz_device = p_sys->psz_vdev = p_sys->psz_adev = NULL; - p_sys->fd_video = -1; - p_sys->fd_audio = -1; - - p_sys->p_es_video = p_sys->p_es_audio = 0; - p_sys->p_block_audio = 0; + p_sys->p_es = NULL; ParseMRL( p_demux ); - /* Find main device (video or audio) */ - if( p_sys->psz_device && *p_sys->psz_device ) - { - msg_Dbg( p_demux, "main device=`%s'", p_sys->psz_device ); - - /* Try to open as video device */ - p_sys->fd_video = OpenVideoDev( p_demux, p_sys->psz_device ); - - if( p_sys->fd_video < 0 ) - { - /* Try to open as audio device */ - p_sys->fd_audio = OpenAudioDev( p_demux, p_sys->psz_device ); - if( p_sys->fd_audio >= 0 ) - { - if( p_sys->psz_adev ) free( p_sys->psz_adev ); - p_sys->psz_adev = p_sys->psz_device; - p_sys->psz_device = NULL; - } - } - else - { - if( p_sys->psz_vdev ) free( p_sys->psz_vdev ); - p_sys->psz_vdev = p_sys->psz_device; - p_sys->psz_device = NULL; - } - } - - /* If no device opened, only continue if the access was forced */ - if( p_sys->fd_video < 0 && p_sys->fd_audio < 0 ) - { - if( strcmp( p_demux->psz_access, "v4l" ) ) - { - Close( p_this ); - return VLC_EGENERIC; - } - } - - /* Find video device */ - if( p_sys->fd_video < 0 ) - { - if( !p_sys->psz_vdev || !*p_sys->psz_vdev ) - { - if( p_sys->psz_vdev ) free( p_sys->psz_vdev ); - p_sys->psz_vdev = var_CreateGetString( p_demux, "v4l-vdev" );; - } - - if( p_sys->psz_vdev && *p_sys->psz_vdev ) - { - p_sys->fd_video = OpenVideoDev( p_demux, p_sys->psz_vdev ); - } - } - - /* Find audio device */ - if( p_sys->fd_audio < 0 ) - { - if( !p_sys->psz_adev || !*p_sys->psz_adev ) - { - if( p_sys->psz_adev ) free( p_sys->psz_adev ); - p_sys->psz_adev = var_CreateGetString( p_demux, "v4l-adev" );; - } - - if( p_sys->psz_adev && *p_sys->psz_adev ) - { - p_sys->fd_audio = OpenAudioDev( p_demux, p_sys->psz_adev ); - } - } - - if( p_sys->fd_video < 0 && p_sys->fd_audio < 0 ) + msg_Dbg( p_this, "opening device '%s'", p_sys->psz_device ); + p_sys->i_fd = OpenVideoDev( p_demux, p_sys->psz_device ); + if( p_sys->i_fd < 0 ) { Close( p_this ); return VLC_EGENERIC; } + msg_Dbg( p_demux, "v4l grabbing started" ); /* Declare elementary streams */ - if( p_sys->fd_video >= 0 ) + es_format_t fmt; + es_format_Init( &fmt, VIDEO_ES, p_sys->i_fourcc ); + fmt.video.i_width = p_sys->i_width; + fmt.video.i_height = p_sys->i_height; + fmt.video.i_sar_num = 4 * fmt.video.i_height; + fmt.video.i_sar_den = 3 * fmt.video.i_width; + + /* Setup rgb mask for RGB formats */ + switch( p_sys->i_fourcc ) { - es_format_t fmt; - es_format_Init( &fmt, VIDEO_ES, p_sys->i_fourcc ); - fmt.video.i_width = p_sys->i_width; - fmt.video.i_height = p_sys->i_height; - fmt.video.i_aspect = 4 * VOUT_ASPECT_FACTOR / 3; - - /* Setup rgb mask for RGB formats */ - if( p_sys->i_fourcc == VLC_FOURCC('R','V','2','4') ) - { - /* This is in BGR format */ - fmt.video.i_bmask = 0x00ff0000; + case VLC_CODEC_RGB15: + fmt.video.i_rmask = 0x001f; + fmt.video.i_gmask = 0x03e0; + fmt.video.i_bmask = 0x7c00; + break; + case VLC_CODEC_RGB16: + fmt.video.i_rmask = 0x001f; + fmt.video.i_gmask = 0x07e0; + fmt.video.i_bmask = 0xf800; + break; + case VLC_CODEC_RGB24: + case VLC_CODEC_RGB32: + fmt.video.i_rmask = 0x00ff0000; fmt.video.i_gmask = 0x0000ff00; - fmt.video.i_rmask = 0x000000ff; - } - - msg_Dbg( p_demux, "added new video es %4.4s %dx%d", - (char*)&fmt.i_codec, fmt.video.i_width, fmt.video.i_height ); - p_sys->p_es_video = es_out_Add( p_demux->out, &fmt ); + fmt.video.i_bmask = 0x000000ff; + break; } - if( p_sys->fd_audio >= 0 ) - { - es_format_t fmt; - es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC('a','r','a','w') ); - - fmt.audio.i_channels = p_sys->b_stereo ? 2 : 1; - fmt.audio.i_rate = p_sys->i_sample_rate; - fmt.audio.i_bitspersample = 16; // FIXME ? - fmt.audio.i_blockalign = fmt.audio.i_channels * - fmt.audio.i_bitspersample / 8; - fmt.i_bitrate = fmt.audio.i_channels * fmt.audio.i_rate * - fmt.audio.i_bitspersample; - - msg_Dbg( p_demux, "new audio es %d channels %dHz", - fmt.audio.i_channels, fmt.audio.i_rate ); - - p_sys->p_es_audio = es_out_Add( p_demux->out, &fmt ); - } + msg_Dbg( p_demux, "added new video es %4.4s %dx%d", + (char*)&fmt.i_codec, fmt.video.i_width, fmt.video.i_height ); + p_sys->p_es = es_out_Add( p_demux->out, &fmt ); /* Update default_pts to a suitable value for access */ var_Create( p_demux, "v4l-caching", VLC_VAR_INTEGER | VLC_VAR_DOINHERIT ); @@ -544,26 +403,22 @@ static void Close( vlc_object_t *p_this ) demux_t *p_demux = (demux_t *)p_this; demux_sys_t *p_sys = p_demux->p_sys; - if( p_sys->psz_device ) free( p_sys->psz_device ); - if( p_sys->psz_vdev ) free( p_sys->psz_vdev ); - if( p_sys->psz_adev ) free( p_sys->psz_adev ); - if( p_sys->fd_video >= 0 ) close( p_sys->fd_video ); - if( p_sys->fd_audio >= 0 ) close( p_sys->fd_audio ); - if( p_sys->p_block_audio ) block_Release( p_sys->p_block_audio ); + free( p_sys->psz_device ); + if( p_sys->i_fd >= 0 ) v4l1_close( p_sys->i_fd ); if( p_sys->b_mjpeg ) { int i_noframe = -1; - ioctl( p_sys->fd_video, MJPIOC_QBUF_CAPT, &i_noframe ); + v4l1_ioctl( p_sys->i_fd, MJPIOC_QBUF_CAPT, &i_noframe ); } if( p_sys->p_video_mmap && p_sys->p_video_mmap != MAP_FAILED ) { if( p_sys->b_mjpeg ) - munmap( p_sys->p_video_mmap, p_sys->mjpeg_buffers.size * + v4l1_munmap( p_sys->p_video_mmap, p_sys->mjpeg_buffers.size * p_sys->mjpeg_buffers.count ); else - munmap( p_sys->p_video_mmap, p_sys->vid_mbuf.size ); + v4l1_munmap( p_sys->p_video_mmap, p_sys->vid_mbuf.size ); } free( p_sys ); @@ -574,17 +429,17 @@ static void Close( vlc_object_t *p_this ) *****************************************************************************/ static int Control( demux_t *p_demux, int i_query, va_list args ) { - vlc_bool_t *pb; + bool *pb; int64_t *pi64; switch( i_query ) { /* Special for access_demux */ case DEMUX_CAN_PAUSE: - case DEMUX_SET_PAUSE_STATE: + case DEMUX_CAN_SEEK: case DEMUX_CAN_CONTROL_PACE: - pb = (vlc_bool_t*)va_arg( args, vlc_bool_t * ); - *pb = VLC_FALSE; + pb = (bool*)va_arg( args, bool * ); + *pb = false; return VLC_SUCCESS; case DEMUX_GET_PTS_DELAY: @@ -611,27 +466,17 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) static int Demux( demux_t *p_demux ) { demux_sys_t *p_sys = p_demux->p_sys; - es_out_id_t *p_es = p_sys->p_es_audio; - block_t *p_block = NULL; - /* Try grabbing audio frames first */ - if( p_sys->fd_audio < 0 || !( p_block = GrabAudio( p_demux ) ) ) - { - /* Try grabbing video frame */ - p_es = p_sys->p_es_video; - if( p_sys->fd_video > 0 ) p_block = GrabVideo( p_demux ); - } + block_t *p_block = GrabVideo( p_demux ); if( !p_block ) { - /* Sleep so we do not consume all the cpu, 10ms seems - * like a good value (100fps) */ - msleep( 10000 ); + msleep( 10000 ); /* Unfortunately v4l doesn't allow polling */ return 1; } es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts ); - es_out_Send( p_demux->out, p_es, p_block ); + es_out_Send( p_demux->out, p_sys->p_es, p_block ); return 1; } @@ -778,48 +623,11 @@ static void ParseMRL( demux_t *p_demux ) p_sys->i_tuner = strtol( psz_parser + strlen( "tuner=" ), &psz_parser, 0 ); } - else if( !strncmp( psz_parser, "adev=", strlen( "adev=" ) ) ) - { - int i_len; - - psz_parser += strlen( "adev=" ); - if( strchr( psz_parser, ':' ) ) - { - i_len = strchr( psz_parser, ':' ) - psz_parser; - } - else - { - i_len = strlen( psz_parser ); - } - - p_sys->psz_adev = strndup( psz_parser, i_len ); - - psz_parser += i_len; - } - else if( !strncmp( psz_parser, "samplerate=", - strlen( "samplerate=" ) ) ) - { - p_sys->i_sample_rate = - strtol( psz_parser + strlen( "samplerate=" ), - &psz_parser, 0 ); - } - else if( !strncmp( psz_parser, "stereo", strlen( "stereo" ) ) ) - { - psz_parser += strlen( "stereo" ); - - p_sys->b_stereo = VLC_TRUE; - } - else if( !strncmp( psz_parser, "mono", strlen( "mono" ) ) ) - { - psz_parser += strlen( "mono" ); - - p_sys->b_stereo = VLC_FALSE; - } else if( !strncmp( psz_parser, "mjpeg", strlen( "mjpeg" ) ) ) { psz_parser += strlen( "mjpeg" ); - p_sys->b_mjpeg = VLC_TRUE; + p_sys->b_mjpeg = true; } else if( !strncmp( psz_parser, "decimation=", strlen( "decimation=" ) ) ) @@ -837,8 +645,19 @@ static void ParseMRL( demux_t *p_demux ) } else if( !strncmp( psz_parser, "fps=", strlen( "fps=" ) ) ) { - p_sys->f_fps = strtof( psz_parser + strlen( "fps=" ), - &psz_parser ); + p_sys->f_fps = us_strtof( psz_parser + strlen( "fps=" ), + &psz_parser ); + } + else if( !strncmp( psz_parser, "adev=", strlen( "adev=" ) ) + || !strncmp( psz_parser, "samplerate=", strlen( "samplerate=" ) ) + || !strncmp( psz_parser, "stereo", strlen( "stereo" ) ) + || !strncmp( psz_parser, "mono", strlen( "mono" ) ) ) + { + if( strchr( psz_parser, ':' ) ) + psz_parser = strchr( psz_parser, ':' ); + else + psz_parser += strlen( psz_parser ); + msg_Err( p_demux, AUDIO_DEPRECATED_ERROR ); } else { @@ -858,10 +677,10 @@ static void ParseMRL( demux_t *p_demux ) } if( *psz_dup ) - { p_sys->psz_device = strdup( psz_dup ); - } - if( psz_dup ) free( psz_dup ); + else + p_sys->psz_device = strdup( V4L_DEFAULT ); + free( psz_dup ); } /***************************************************************************** @@ -876,13 +695,13 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) struct mjpeg_params mjpeg; int i; - if( ( i_fd = open( psz_device, O_RDWR ) ) < 0 ) + if( ( i_fd = v4l1_open( psz_device, O_RDWR ) ) < 0 ) { msg_Err( p_demux, "cannot open device (%m)" ); goto vdev_failed; } - if( ioctl( i_fd, VIDIOCGCAP, &p_sys->vid_cap ) < 0 ) + if( v4l1_ioctl( i_fd, VIDIOCGCAP, &p_sys->vid_cap ) < 0 ) { msg_Err( p_demux, "cannot get capabilities (%m)" ); goto vdev_failed; @@ -927,7 +746,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) } vid_channel.channel = p_sys->i_channel; - if( ioctl( i_fd, VIDIOCGCHAN, &vid_channel ) < 0 ) + if( v4l1_ioctl( i_fd, VIDIOCGCHAN, &vid_channel ) < 0 ) { msg_Err( p_demux, "cannot get channel infos (%m)" ); goto vdev_failed; @@ -944,7 +763,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) } vid_channel.norm = p_sys->i_norm; - if( ioctl( i_fd, VIDIOCSCHAN, &vid_channel ) < 0 ) + if( v4l1_ioctl( i_fd, VIDIOCSCHAN, &vid_channel ) < 0 ) { msg_Err( p_demux, "cannot set channel (%m)" ); goto vdev_failed; @@ -959,7 +778,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) if( p_sys->i_tuner >= 0 ) { vid_tuner.tuner = p_sys->i_tuner; - if( ioctl( i_fd, VIDIOCGTUNER, &vid_tuner ) < 0 ) + if( v4l1_ioctl( i_fd, VIDIOCGTUNER, &vid_tuner ) < 0 ) { msg_Err( p_demux, "cannot get tuner (%m)" ); goto vdev_failed; @@ -974,7 +793,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) /* FIXME FIXME to be checked FIXME FIXME */ //vid_tuner.mode = p_sys->i_norm; - if( ioctl( i_fd, VIDIOCSTUNER, &vid_tuner ) < 0 ) + if( v4l1_ioctl( i_fd, VIDIOCSTUNER, &vid_tuner ) < 0 ) { msg_Err( p_demux, "cannot set tuner (%m)" ); goto vdev_failed; @@ -990,7 +809,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) if( p_sys->i_frequency >= 0 ) { int driver_frequency = p_sys->i_frequency * 16 /1000; - if( ioctl( i_fd, VIDIOCSFREQ, &driver_frequency ) < 0 ) + if( v4l1_ioctl( i_fd, VIDIOCSFREQ, &driver_frequency ) < 0 ) { msg_Err( p_demux, "cannot set frequency (%m)" ); goto vdev_failed; @@ -1009,7 +828,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) if( p_sys->i_audio >= 0 ) { vid_audio.audio = p_sys->i_audio; - if( ioctl( i_fd, VIDIOCGAUDIO, &vid_audio ) < 0 ) + if( v4l1_ioctl( i_fd, VIDIOCGAUDIO, &vid_audio ) < 0 ) { msg_Err( p_demux, "cannot get audio (%m)" ); goto vdev_failed; @@ -1018,7 +837,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) /* unmute audio */ vid_audio.flags &= ~VIDEO_AUDIO_MUTE; - if( ioctl( i_fd, VIDIOCSAUDIO, &vid_audio ) < 0 ) + if( v4l1_ioctl( i_fd, VIDIOCSAUDIO, &vid_audio ) < 0 ) { msg_Err( p_demux, "cannot set audio (%m)" ); goto vdev_failed; @@ -1031,10 +850,10 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) * or height */ if( p_sys->b_mjpeg ) { - struct quicktime_mjpeg_app1 *p_app1; + struct quicktime_mjpeg_app1 p_app1; int32_t i_offset; - if( ioctl( i_fd, MJPIOC_G_PARAMS, &mjpeg ) < 0 ) + if( v4l1_ioctl( i_fd, MJPIOC_G_PARAMS, &mjpeg ) < 0 ) { msg_Err( p_demux, "cannot get mjpeg params (%m)" ); goto vdev_failed; @@ -1053,12 +872,11 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) mjpeg.APP_len = 40; /* aligned */ - p_app1 = (struct quicktime_mjpeg_app1 *)mjpeg.APP_data; - p_app1->i_reserved = 0; - p_app1->i_tag = VLC_FOURCC( 'm','j','p','g' ); - p_app1->i_field_size = 0; - p_app1->i_padded_field_size = 0; - p_app1->i_next_field = 0; + p_app1.i_reserved = 0; + p_app1.i_tag = VLC_FOURCC( 'm','j','p','g' ); + p_app1.i_field_size = 0; + p_app1.i_padded_field_size = 0; + p_app1.i_next_field = 0; /* XXX WARNING XXX */ /* these's nothing magic about these values. We are dangerously * assuming the encoder card is encoding mjpeg-a and is not throwing @@ -1070,21 +888,22 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) * does conform to standards outside of Apple Quicktime. */ i_offset = 0x2e; - p_app1->i_DQT_offset = hton32( i_offset ); + p_app1.i_DQT_offset = hton32( i_offset ); i_offset = 0xb4; - p_app1->i_DHT_offset = hton32( i_offset ); + p_app1.i_DHT_offset = hton32( i_offset ); i_offset = 0x258; - p_app1->i_SOF_offset = hton32( i_offset ); + p_app1.i_SOF_offset = hton32( i_offset ); i_offset = 0x26b; - p_app1->i_SOS_offset = hton32( i_offset ); + p_app1.i_SOS_offset = hton32( i_offset ); i_offset = 0x279; - p_app1->i_data_offset = hton32( i_offset ); + p_app1.i_data_offset = hton32( i_offset ); + memcpy(mjpeg.APP_data, &p_app1, sizeof(struct quicktime_mjpeg_app1)); /* SOF and SOS aren't specified by the mjpeg API because they aren't * optional. They will be present in the output. */ mjpeg.jpeg_markers = JPEG_MARKER_DHT | JPEG_MARKER_DQT; - if( ioctl( i_fd, MJPIOC_S_PARAMS, &mjpeg ) < 0 ) + if( v4l1_ioctl( i_fd, MJPIOC_S_PARAMS, &mjpeg ) < 0 ) { msg_Err( p_demux, "cannot set mjpeg params (%m)" ); goto vdev_failed; @@ -1100,7 +919,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) { struct video_window vid_win; - if( ioctl( i_fd, VIDIOCGWIN, &vid_win ) < 0 ) + if( v4l1_ioctl( i_fd, VIDIOCGWIN, &vid_win ) < 0 ) { msg_Err( p_demux, "cannot get win (%m)" ); goto vdev_failed; @@ -1127,7 +946,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) if( !p_sys->b_mjpeg ) { /* set hue/color/.. */ - if( ioctl( i_fd, VIDIOCGPICT, &p_sys->vid_picture ) == 0 ) + if( v4l1_ioctl( i_fd, VIDIOCGPICT, &p_sys->vid_picture ) == 0 ) { struct video_picture vid_picture = p_sys->vid_picture; @@ -1147,7 +966,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) { vid_picture.contrast = p_sys->i_contrast; } - if( ioctl( i_fd, VIDIOCSPICT, &vid_picture ) == 0 ) + if( v4l1_ioctl( i_fd, VIDIOCSPICT, &vid_picture ) == 0 ) { msg_Dbg( p_demux, "v4l device uses brightness: %d", vid_picture.brightness ); @@ -1161,7 +980,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) } /* Find out video format used by device */ - if( ioctl( i_fd, VIDIOCGPICT, &p_sys->vid_picture ) == 0 ) + if( v4l1_ioctl( i_fd, VIDIOCGPICT, &p_sys->vid_picture ) == 0 ) { struct video_picture vid_picture = p_sys->vid_picture; char *psz; @@ -1170,10 +989,12 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) p_sys->i_fourcc = 0; psz = var_CreateGetString( p_demux, "v4l-chroma" ); - if( strlen( psz ) >= 4 ) + + const vlc_fourcc_t i_chroma = + vlc_fourcc_GetCodecFromString( VIDEO_ES, psz ); + if( i_chroma ) { vid_picture.palette = 0; - int i_chroma = VLC_FOURCC( psz[0], psz[1], psz[2], psz[3] ); /* Find out v4l chroma code */ for( i = 0; v4lchroma_to_fourcc[i].i_v4l != 0; i++ ) @@ -1188,7 +1009,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) free( psz ); if( vid_picture.palette && - !ioctl( i_fd, VIDIOCSPICT, &vid_picture ) ) + !v4l1_ioctl( i_fd, VIDIOCSPICT, &vid_picture ) ) { p_sys->vid_picture = vid_picture; } @@ -1196,14 +1017,14 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) { /* Try to set the format to something easy to encode */ vid_picture.palette = VIDEO_PALETTE_YUV420P; - if( ioctl( i_fd, VIDIOCSPICT, &vid_picture ) == 0 ) + if( v4l1_ioctl( i_fd, VIDIOCSPICT, &vid_picture ) == 0 ) { p_sys->vid_picture = vid_picture; } else { vid_picture.palette = VIDEO_PALETTE_YUV422P; - if( ioctl( i_fd, VIDIOCSPICT, &vid_picture ) == 0 ) + if( v4l1_ioctl( i_fd, VIDIOCSPICT, &vid_picture ) == 0 ) { p_sys->vid_picture = vid_picture; } @@ -1234,13 +1055,13 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) p_sys->mjpeg_buffers.count = 8; p_sys->mjpeg_buffers.size = MJPEG_BUFFER_SIZE; - if( ioctl( i_fd, MJPIOC_REQBUFS, &p_sys->mjpeg_buffers ) < 0 ) + if( v4l1_ioctl( i_fd, MJPIOC_REQBUFS, &p_sys->mjpeg_buffers ) < 0 ) { msg_Err( p_demux, "mmap unsupported" ); goto vdev_failed; } - p_sys->p_video_mmap = mmap( 0, + p_sys->p_video_mmap = v4l1_mmap( 0, p_sys->mjpeg_buffers.size * p_sys->mjpeg_buffers.count, PROT_READ | PROT_WRITE, MAP_SHARED, i_fd, 0 ); if( p_sys->p_video_mmap == MAP_FAILED ) @@ -1249,13 +1070,13 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) goto vdev_failed; } - p_sys->i_fourcc = VLC_FOURCC( 'm','j','p','g' ); + p_sys->i_fourcc = VLC_CODEC_MJPG; p_sys->i_frame_pos = -1; /* queue up all the frames */ for( i = 0; i < (int)p_sys->mjpeg_buffers.count; i++ ) { - if( ioctl( i_fd, MJPIOC_QBUF_CAPT, &i ) < 0 ) + if( v4l1_ioctl( i_fd, MJPIOC_QBUF_CAPT, &i ) < 0 ) { msg_Err( p_demux, "unable to queue frame" ); goto vdev_failed; @@ -1265,10 +1086,9 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) else { /* Fill in picture_t fields */ - vout_InitPicture( VLC_OBJECT(p_demux), &p_sys->pic, p_sys->i_fourcc, - p_sys->i_width, p_sys->i_height, p_sys->i_width * - VOUT_ASPECT_FACTOR / p_sys->i_height ); - if( !p_sys->pic.i_planes ) + if( picture_Setup( &p_sys->pic, p_sys->i_fourcc, + p_sys->i_width, p_sys->i_height, + 1, 1 ) ) { msg_Err( p_demux, "unsupported chroma" ); goto vdev_failed; @@ -1286,13 +1106,13 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) (char*)&p_sys->i_fourcc ); /* Allocate mmap buffer */ - if( ioctl( i_fd, VIDIOCGMBUF, &p_sys->vid_mbuf ) < 0 ) + if( v4l1_ioctl( i_fd, VIDIOCGMBUF, &p_sys->vid_mbuf ) < 0 ) { msg_Err( p_demux, "mmap unsupported" ); goto vdev_failed; } - p_sys->p_video_mmap = mmap( 0, p_sys->vid_mbuf.size, + p_sys->p_video_mmap = v4l1_mmap( 0, p_sys->vid_mbuf.size, PROT_READ|PROT_WRITE, MAP_SHARED, i_fd, 0 ); if( p_sys->p_video_mmap == MAP_FAILED ) @@ -1307,7 +1127,7 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) p_sys->vid_mmap.width = p_sys->i_width; p_sys->vid_mmap.height = p_sys->i_height; p_sys->vid_mmap.format = p_sys->vid_picture.palette; - if( ioctl( i_fd, VIDIOCMCAPTURE, &p_sys->vid_mmap ) < 0 ) + if( v4l1_ioctl( i_fd, VIDIOCMCAPTURE, &p_sys->vid_mmap ) < 0 ) { msg_Warn( p_demux, "%4.4s refused", (char*)&p_sys->i_fourcc ); msg_Err( p_demux, "chroma selection failed" ); @@ -1318,104 +1138,10 @@ static int OpenVideoDev( demux_t *p_demux, char *psz_device ) vdev_failed: - if( i_fd >= 0 ) close( i_fd ); - return -1; -} - -/***************************************************************************** - * OpenAudioDev: - *****************************************************************************/ -static int OpenAudioDev( demux_t *p_demux, char *psz_device ) -{ - demux_sys_t *p_sys = p_demux->p_sys; - int i_fd, i_format; - - if( (i_fd = open( psz_device, O_RDONLY | O_NONBLOCK )) < 0 ) - { - msg_Err( p_demux, "cannot open audio device (%m)" ); - goto adev_fail; - } - - i_format = AFMT_S16_LE; - if( ioctl( i_fd, SNDCTL_DSP_SETFMT, &i_format ) < 0 - || i_format != AFMT_S16_LE ) - { - msg_Err( p_demux, "cannot set audio format (16b little endian) " - "(%m)" ); - goto adev_fail; - } - - if( ioctl( i_fd, SNDCTL_DSP_STEREO, - &p_sys->b_stereo ) < 0 ) - { - msg_Err( p_demux, "cannot set audio channels count (%m)" ); - goto adev_fail; - } - - if( ioctl( i_fd, SNDCTL_DSP_SPEED, - &p_sys->i_sample_rate ) < 0 ) - { - msg_Err( p_demux, "cannot set audio sample rate (%m)" ); - goto adev_fail; - } - - msg_Dbg( p_demux, "openened adev=`%s' %s %dHz", - psz_device, p_sys->b_stereo ? "stereo" : "mono", - p_sys->i_sample_rate ); - - p_sys->i_audio_max_frame_size = 6 * 1024; - - return i_fd; - - adev_fail: - - if( i_fd >= 0 ) close( i_fd ); + if( i_fd >= 0 ) v4l1_close( i_fd ); return -1; } -/***************************************************************************** - * GrabAudio: grab audio - *****************************************************************************/ -static block_t *GrabAudio( demux_t *p_demux ) -{ - demux_sys_t *p_sys = p_demux->p_sys; - struct audio_buf_info buf_info; - int i_read, i_correct; - block_t *p_block; - - if( p_sys->p_block_audio ) p_block = p_sys->p_block_audio; - else p_block = block_New( p_demux, p_sys->i_audio_max_frame_size ); - - if( !p_block ) - { - msg_Warn( p_demux, "cannot get block" ); - return 0; - } - - p_sys->p_block_audio = p_block; - - i_read = read( p_sys->fd_audio, p_block->p_buffer, - p_sys->i_audio_max_frame_size ); - - if( i_read <= 0 ) return 0; - - p_block->i_buffer = i_read; - p_sys->p_block_audio = 0; - - /* Correct the date because of kernel buffering */ - i_correct = i_read; - if( ioctl( p_sys->fd_audio, SNDCTL_DSP_GETISPACE, &buf_info ) == 0 ) - { - i_correct += buf_info.bytes; - } - - p_block->i_pts = p_block->i_dts = - mdate() - I64C(1000000) * (mtime_t)i_correct / - 2 / ( p_sys->b_stereo ? 2 : 1) / p_sys->i_sample_rate; - - return p_block; -} - /***************************************************************************** * GrabVideo: *****************************************************************************/ @@ -1426,7 +1152,7 @@ static uint8_t *GrabCapture( demux_t *p_demux ) p_sys->vid_mmap.frame = (p_sys->i_frame_pos + 1) % p_sys->vid_mbuf.frames; - while( ioctl( p_sys->fd_video, VIDIOCMCAPTURE, &p_sys->vid_mmap ) < 0 ) + while( v4l1_ioctl( p_sys->i_fd, VIDIOCMCAPTURE, &p_sys->vid_mmap ) < 0 ) { if( errno != EAGAIN ) { @@ -1434,7 +1160,7 @@ static uint8_t *GrabCapture( demux_t *p_demux ) return NULL; } - if( p_demux->b_die ) + if( !vlc_object_alive (p_demux) ) { return NULL; } @@ -1442,7 +1168,7 @@ static uint8_t *GrabCapture( demux_t *p_demux ) msg_Dbg( p_demux, "grab failed, trying again" ); } - while( ioctl(p_sys->fd_video, VIDIOCSYNC, &p_sys->i_frame_pos) < 0 ) + while( v4l1_ioctl(p_sys->i_fd, VIDIOCSYNC, &p_sys->i_frame_pos) < 0 ) { if( errno != EAGAIN && errno != EINTR ) { @@ -1468,7 +1194,7 @@ static uint8_t *GrabMJPEG( demux_t *p_demux ) /* re-queue the last frame we sync'd */ if( p_sys->i_frame_pos != -1 ) { - while( ioctl( p_sys->fd_video, MJPIOC_QBUF_CAPT, + while( v4l1_ioctl( p_sys->i_fd, MJPIOC_QBUF_CAPT, &p_sys->i_frame_pos ) < 0 ) { if( errno != EAGAIN && errno != EINTR ) @@ -1480,7 +1206,7 @@ static uint8_t *GrabMJPEG( demux_t *p_demux ) } /* sync on the next frame */ - while( ioctl( p_sys->fd_video, MJPIOC_SYNC, &sync ) < 0 ) + while( v4l1_ioctl( p_sys->i_fd, MJPIOC_SYNC, &sync ) < 0 ) { if( errno != EAGAIN && errno != EINTR ) {