X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Faccess%2Fdc1394.c;h=ab2cd1d42450dc16dda98e5f28b86886eeff6aca;hb=fd7f8f854a13f7b65cb2b8622755aa47ee932919;hp=1bed7254a1e8e801b6eeb782a54c7e9d4aaef190;hpb=97b3335a04da42b56fc81439a4f057a311dc37fa;p=vlc diff --git a/modules/access/dc1394.c b/modules/access/dc1394.c index 1bed7254a1..ab2cd1d424 100644 --- a/modules/access/dc1394.c +++ b/modules/access/dc1394.c @@ -8,7 +8,7 @@ ***************************************************************************** * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; + * License as published by the Free Software Foundation; * version 2 of the License. * * This library is distributed in the hope that it will be useful, @@ -26,13 +26,16 @@ * Preamble *****************************************************************************/ -#include -#include -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include +#include +#include -#include -#include -#include #ifdef HAVE_FCNTL_H # include @@ -60,12 +63,12 @@ static void Close( vlc_object_t * ); static void OpenAudioDev( demux_t *p_demux ); static inline void CloseAudioDev( demux_t *p_demux ); -vlc_module_begin(); - set_description( _("dc1394 input") ); - set_capability( "access_demux", 10 ); - add_shortcut( "dc1394" ); - set_callbacks( Open, Close ); -vlc_module_end(); +vlc_module_begin () + set_description( N_("dc1394 input") ) + set_capability( "access_demux", 10 ) + add_shortcut( "dc1394" ) + set_callbacks( Open, Close ) +vlc_module_end () typedef struct __dc_camera { @@ -215,6 +218,9 @@ static int Open( vlc_object_t *p_this ) int i_aspect; int result = 0; + if( strncmp(p_demux->psz_access, "dc1394", 6) != 0 ) + return VLC_EGENERIC; + /* Set up p_demux */ p_demux->pf_demux = Demux; p_demux->pf_control = Control; @@ -222,13 +228,9 @@ static int Open( vlc_object_t *p_this ) p_demux->info.i_title = 0; p_demux->info.i_seekpoint = 0; - p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); + p_demux->p_sys = p_sys = calloc( 1, sizeof( demux_sys_t ) ); if( !p_sys ) - { - msg_Err( p_demux, "not enough memory available" ); return VLC_ENOMEM; - } - memset( p_sys, 0, sizeof( demux_sys_t ) ); memset( &fmt, 0, sizeof( es_format_t ) ); /* DEFAULTS */ @@ -476,11 +478,11 @@ static int Open( vlc_object_t *p_this ) i_height = p_sys->camera.frame_height; i_aspect = vout_InitPicture( VLC_OBJECT(p_demux), &p_sys->pic, - VLC_FOURCC('U', 'Y', 'V', 'Y'), + VLC_CODEC_UYVY, i_width, i_height, i_width * VOUT_ASPECT_FACTOR / i_height ); - es_format_Init( &fmt, VIDEO_ES, VLC_FOURCC('U', 'Y', 'V', 'Y') ); + es_format_Init( &fmt, VIDEO_ES, VLC_CODEC_UYVY ); fmt.video.i_width = i_width; fmt.video.i_height = i_height; @@ -496,11 +498,11 @@ static int Open( vlc_object_t *p_this ) if( p_sys->fd_audio >= 0 ) { es_format_t fmt; - es_format_Init( &fmt, AUDIO_ES, VLC_FOURCC('a','r','a','w') ); + es_format_Init( &fmt, AUDIO_ES, VLC_CODEC_S16L ); /* FIXME: hmm, ?? */ fmt.audio.i_channels = p_sys->channels ? p_sys->channels : 1; fmt.audio.i_rate = p_sys->i_sample_rate; - fmt.audio.i_bitspersample = 16; /* FIXME: hmm, ?? */ + fmt.audio.i_bitspersample = 16; fmt.audio.i_blockalign = fmt.audio.i_channels * fmt.audio.i_bitspersample / 8; fmt.i_bitrate = fmt.audio.i_channels * fmt.audio.i_rate * @@ -574,7 +576,7 @@ static void OpenAudioDev( demux_t *p_demux ) CloseAudioDev( p_demux ); } - msg_Dbg( p_demux, "openened adev=`%s' %s %dHz", + msg_Dbg( p_demux, "opened adev=`%s' %s %dHz", psz_device, (p_sys->channels > 1) ? "stereo" : "mono", p_sys->i_sample_rate ); @@ -626,10 +628,8 @@ static void Close( vlc_object_t *p_this ) dc1394_destroy_handle( p_sys->fd_video ); CloseAudioDev( p_demux ); - if( p_sys->camera_nodes ) - free( p_sys->camera_nodes ); - if( p_sys->audio_device ) - free( p_sys->audio_device ); + free( p_sys->camera_nodes ); + free( p_sys->audio_device ); free( p_sys ); } @@ -750,7 +750,7 @@ static block_t *GrabAudio( demux_t *p_demux ) i_correct += buf_info.bytes; p_block->i_pts = p_block->i_dts = - mdate() - I64C(1000000) * (mtime_t)i_correct / + mdate() - INT64_C(1000000) * (mtime_t)i_correct / 2 / p_sys->channels / p_sys->i_sample_rate; return p_block; } @@ -797,17 +797,18 @@ static int Demux( demux_t *p_demux ) *****************************************************************************/ 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_CAN_SEEK: case DEMUX_SET_PAUSE_STATE: 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: @@ -830,15 +831,12 @@ static int Control( demux_t *p_demux, int i_query, va_list args ) static int process_options( demux_t *p_demux ) { demux_sys_t *p_sys = p_demux->p_sys; - char *psz_dup; + char *psz_dup; char *psz_parser; char *token = NULL; char *state = NULL; float rate_f; - if( strncmp(p_demux->psz_access, "dc1394", 6) != 0 ) - return VLC_EGENERIC; - psz_dup = strdup( p_demux->psz_path ); psz_parser = psz_dup; for( token = strtok_r( psz_parser,":",&state); token; @@ -856,7 +854,7 @@ static int process_options( demux_t *p_demux ) "video size of 160x120 is actually disabled for lack of chroma " "support. It will relased ASAP, until then try an higher size " "(320x240 and 640x480 are fully supported)" ); - free(psz_dup); + free( psz_dup ); return VLC_EGENERIC; #if 0 p_sys->frame_size = MODE_160x120_YUV444; @@ -883,7 +881,7 @@ static int process_options( demux_t *p_demux ) " 160x120, 320x240, and 640x480. " "Please specify one of them. You have specified %s.", token ); - free(psz_dup); + free( psz_dup ); return VLC_EGENERIC; } msg_Dbg( p_demux, "Requested video size : %s",token ); @@ -911,7 +909,7 @@ static int process_options( demux_t *p_demux ) " 1.875, 3.75, 7.5, 15, 30, 60. " "Please specify one of them. You have specified %s.", token); - free(psz_dup); + free( psz_dup ); return VLC_EGENERIC; } msg_Dbg( p_demux, "Requested frame rate : %s",token ); @@ -926,7 +924,7 @@ static int process_options( demux_t *p_demux ) msg_Err( p_demux, "Bad brightness value '%s', " "must be an unsigned integer.", token ); - free(psz_dup); + free( psz_dup ); return VLC_EGENERIC; } } @@ -955,7 +953,7 @@ static int process_options( demux_t *p_demux ) msg_Err( p_demux, "Bad camera number '%s', " "must be an unsigned integer.", token ); - free(psz_dup); + free( psz_dup ); return VLC_EGENERIC; } } @@ -977,7 +975,7 @@ static int process_options( demux_t *p_demux ) msg_Err(p_demux, "Bad capture method value '%s', " "it can be 'raw1394' or 'video1394'.", token ); - free(psz_dup); + free( psz_dup ); return VLC_EGENERIC; } } @@ -1008,7 +1006,7 @@ static int process_options( demux_t *p_demux ) sscanf( token, "0x%llx", &p_sys->selected_uid ); } } - if( psz_dup ) free( psz_dup ); + free( psz_dup ); return VLC_SUCCESS; }