#include <vlc_plugin.h>
#include <vlc_input.h>
#include <vlc_demux.h>
-#include <vlc_charset.h>
+#include <vlc_fs.h>
#include <vlc_picture.h>
#ifdef HAVE_FCNTL_H
*****************************************************************************/
static int Open ( vlc_object_t * );
static void Close( vlc_object_t * );
-static void OpenAudioDev( demux_t *p_demux );
+static int OpenAudioDev( demux_t *p_demux );
static inline void CloseAudioDev( demux_t *p_demux );
-vlc_module_begin ()
+vlc_module_begin()
set_description( N_("dc1394 input") )
set_capability( "access_demux", 10 )
add_shortcut( "dc1394" )
set_callbacks( Open, Close )
-vlc_module_end ()
+vlc_module_end()
struct demux_sys_t
{
int i_audio_max_frame_size;
int fd_audio;
char *audio_device;
-#define NO_ROTATION 0
-#define ROTATION_LEFT 1
-#define ROTATION_RIGHT 2
es_out_id_t *p_es_audio;
};
static int FindCamera( demux_sys_t *sys, demux_t *p_demux )
{
dc1394camera_list_t *list;
+ int i_ret = VLC_EGENERIC;
msg_Dbg( p_demux, "Scanning for ieee1394 ports ..." );
if( dc1394_camera_enumerate (sys->p_dccontext, &list) != DC1394_SUCCESS )
{
msg_Err(p_demux, "Can not ennumerate cameras");
- dc1394_camera_free_list (list);
- return VLC_EGENERIC;
+ goto end;
}
if( list->num == 0 )
{
msg_Err(p_demux, "Can not find cameras");
- dc1394_camera_free_list (list);
- return VLC_EGENERIC;
+ goto end;
}
sys->num_cameras = list->num;
}
if( !found )
{
- msg_Err( p_demux, "Can't find camera with uid : 0x%llx.",
+ msg_Err( p_demux, "Can't find camera with uid : 0x%"PRIx64".",
sys->selected_uid );
- dc1394_camera_free_list (list);
- return VLC_EGENERIC;
+ goto end;
}
}
else if( sys->selected_camera >= (int)list->num )
{
msg_Err( p_demux, "There are not this many cameras. (%d/%d)",
sys->selected_camera, sys->num_cameras );
- dc1394_camera_free_list (list);
- return VLC_EGENERIC;
+ goto end;
}
else if( sys->selected_camera >= 0 )
{
list->ids[0].guid);
}
+ i_ret = VLC_SUCCESS;
+
+end:
dc1394_camera_free_list (list);
- return VLC_SUCCESS;
+ return i_ret;
}
/*****************************************************************************
{
msg_Err( p_demux, "Bad MRL, please check the option line "
"(MRL was: %s)",
- p_demux->psz_path );
+ p_demux->psz_location );
free( p_sys );
- p_demux->p_sys = NULL;
return VLC_EGENERIC;
}
if( !p_sys->p_dccontext )
{
msg_Err( p_demux, "Failed to initialise libdc1394");
- free(p_demux->p_sys);
- p_demux->p_sys = NULL;
+ free( p_sys );
return VLC_EGENERIC;
}
{
dc1394_free( p_sys->p_dccontext );
free( p_sys );
- p_demux->p_sys = NULL;
return VLC_EGENERIC;
}
msg_Err( p_demux, "No camera found !!" );
dc1394_free( p_sys->p_dccontext );
free( p_sys );
- p_demux->p_sys = NULL;
return VLC_EGENERIC;
}
msg_Err( p_demux, "Unable to set initial focus to %u",
p_sys->focus );
}
- msg_Dbg( p_demux, "Initial focus set to %u", p_sys->focus );
+ else
+ msg_Dbg( p_demux, "Initial focus set to %u", p_sys->focus );
}
if( dc1394_feature_set_value( p_sys->camera,
msg_Err( p_demux, "Unable to set initial brightness to %u",
p_sys->brightness );
}
- msg_Dbg( p_demux, "Initial brightness set to %u", p_sys->brightness );
+ else
+ msg_Dbg( p_demux, "Initial brightness set to %u", p_sys->brightness );
if( dc1394_video_set_framerate( p_sys->camera,
p_sys->frame_rate ) != DC1394_SUCCESS )
i_height = p_sys->height;
if( picture_Setup( &p_sys->pic, VLC_CODEC_UYVY,
- i_width, i_height,
- i_width * VOUT_ASPECT_FACTOR / i_height ) )
+ i_width, i_height, 1, 1 ) )
{
msg_Err( p_demux ,"unknown chroma" );
Close( p_this );
if( p_sys->audio_device )
{
- OpenAudioDev( p_demux );
- if( p_sys->fd_audio >= 0 )
+ if( OpenAudioDev( p_demux ) == VLC_SUCCESS )
{
es_format_t fmt;
es_format_Init( &fmt, AUDIO_ES, VLC_CODEC_S16L ); /* FIXME: hmm, ?? */
return VLC_SUCCESS;
}
-static void OpenAudioDev( demux_t *p_demux )
+static int OpenAudioDev( demux_t *p_demux )
{
demux_sys_t *p_sys = p_demux->p_sys;
char *psz_device = p_sys->audio_device;
int i_format = AFMT_S16_LE;
int result;
- p_sys->fd_audio = utf8_open( psz_device, O_RDONLY | O_NONBLOCK );
+ p_sys->fd_audio = vlc_open( psz_device, O_RDONLY | O_NONBLOCK );
if( p_sys->fd_audio < 0 )
{
msg_Err( p_demux, "Cannot open audio device (%s)", psz_device );
- CloseAudioDev( p_demux );
+ return VLC_EGENERIC;
}
if( !p_sys->i_sample_rate )
{
msg_Err( p_demux, "Cannot set audio format (16b little endian) "
"(%d)", i_format );
- CloseAudioDev( p_demux );
+ goto error;
}
result = ioctl( p_sys->fd_audio, SNDCTL_DSP_CHANNELS, &p_sys->channels );
{
msg_Err( p_demux, "Cannot set audio channels count (%d)",
p_sys->channels );
- CloseAudioDev( p_demux );
+ goto error;
}
result = ioctl( p_sys->fd_audio, SNDCTL_DSP_SPEED, &p_sys->i_sample_rate );
{
msg_Err( p_demux, "Cannot set audio sample rate (%d)",
p_sys->i_sample_rate );
- CloseAudioDev( p_demux );
+ goto error;
}
msg_Dbg( p_demux, "Opened adev=`%s' %s %dHz",
p_sys->i_sample_rate );
p_sys->i_audio_max_frame_size = 32 * 1024;
+
+ return VLC_SUCCESS;
+
+error:
+ CloseAudioDev( p_demux );
+ p_sys->fd_audio = -1;
+ return VLC_EGENERIC;
}
static inline void CloseAudioDev( demux_t *p_demux )
{
- demux_sys_t *p_sys = NULL;
+ demux_sys_t *p_sys = p_demux->p_sys;
- if( p_demux )
- {
- p_sys = p_demux->p_sys;
- if( p_sys->fd_audio >= 0 )
- close( p_sys->fd_audio );
- }
+ if( p_sys->fd_audio >= 0 )
+ close( p_sys->fd_audio );
}
/*****************************************************************************
dc1394_camera_free(p_sys->camera);
dc1394_free(p_sys->p_dccontext);
- if( p_sys->audio_device )
- free( p_sys->audio_device );
-
+ free( p_sys->video_device );
+ free( p_sys->audio_device );
free( p_sys );
}
p_sys->i_audio_max_frame_size );
if( i_read <= 0 )
+ {
+ block_Release( p_block );
return NULL;
+ }
p_block->i_buffer = i_read;
block_t *p_blockv = NULL;
/* Try grabbing audio frames first */
- if( p_sys->fd_audio > 0 )
+ if( p_sys->fd_audio >= 0 )
p_blocka = GrabAudio( p_demux );
/* Try grabbing video frame */
const char *in_fmt = NULL;
float rate_f;
- if( strncmp(p_demux->psz_access, "dc1394", 6) != 0 )
- return VLC_EGENERIC;
-
- psz_dup = strdup( p_demux->psz_path );
+ psz_dup = strdup( p_demux->psz_location );
psz_parser = psz_dup;
for( token = strtok_r( psz_parser,":",&state); token;
token = strtok_r( NULL, ":", &state ) )
else if( strncmp( token, "uid=", strlen("uid=") ) == 0)
{
token += strlen("uid=");
- sscanf( token, "0x%llx", &p_sys->selected_uid );
+ sscanf( token, "0x%"SCNx64, &p_sys->selected_uid );
}
}
else // YUV422 default
p_sys->video_mode = DC1394_VIDEO_MODE_640x480_YUV422;
}
+
+ free( psz_dup );
return VLC_SUCCESS;
}