#include <vlc_plugin.h>
#include <vlc_demux.h>
-#include <vlc_codecs.h>
-
/*****************************************************************************
* Module descriptor
*****************************************************************************/
"playing MJPEG from a file. Use 0 (this is the default value) for a " \
"live stream (from a camera).")
-vlc_module_begin();
- set_shortname( "MJPEG");
- set_description( N_("M-JPEG camera demuxer") );
- set_capability( "demux", 5 );
- set_callbacks( Open, Close );
- set_category( CAT_INPUT );
- set_subcategory( SUBCAT_INPUT_DEMUX );
- add_float( "mjpeg-fps", 0.0, NULL, FPS_TEXT, FPS_LONGTEXT, false );
-vlc_module_end();
+vlc_module_begin ()
+ set_shortname( "MJPEG")
+ set_description( N_("M-JPEG camera demuxer") )
+ set_capability( "demux", 5 )
+ set_callbacks( Open, Close )
+ set_category( CAT_INPUT )
+ set_subcategory( SUBCAT_INPUT_DEMUX )
+ add_float( "mjpeg-fps", 0.0, NULL, FPS_TEXT, FPS_LONGTEXT, false )
+vlc_module_end ()
/*****************************************************************************
* Local prototypes
int i;
char *p_line;
- while( *p_pos > p_sys->i_data_peeked )
+ while( *p_pos >= p_sys->i_data_peeked )
{
if( ! Peek( p_demux, false ) )
{
{
return NULL;
}
+ p_buf = p_sys->p_peek + *p_pos;
+ i_size = p_sys->i_data_peeked - *p_pos;
}
- p_buf = p_sys->p_peek + *p_pos;
- i_size = p_sys->i_data_peeked - *p_pos;
}
*p_pos += ( i + 1 );
if( i > 0 && '\r' == p_buf[i - 1] )
*p_header_size = -1;
return false;
}
- if( p_sys->i_data_peeked < 3)
+ if( p_sys->i_data_peeked < 5)
{
msg_Err( p_demux, "data shortage" );
*p_header_size = -2;
return false;
}
- if( strncmp( (char *)p_sys->p_peek, "--", 2 ) )
+ if( strncmp( (char *)p_sys->p_peek, "--", 2 ) != 0
+ && strncmp( (char *)p_sys->p_peek, "\r\n--", 4 ) != 0 )
{
*p_header_size = 0;
return false;
}
- i_pos = 2;
+ i_pos = *p_sys->p_peek == '-' ? 2 : 4;
psz_line = GetLine( p_demux, &i_pos );
if( NULL == psz_line )
{
}
else
{
- p_block->i_dts = p_block->i_pts = p_sys->i_time;
+ p_block->i_dts = p_block->i_pts = VLC_TS_0 + p_sys->i_time;
p_sys->i_time += p_sys->i_frame_length;
}
demux_t *p_demux = (demux_t*)p_this;
demux_sys_t *p_sys;
int i_size;
- int b_matched = false;
- vlc_value_t val;
+ bool b_matched = false;
+ float f_fps;
p_demux->pf_control = Control;
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) );
}
- var_Create( p_demux, "mjpeg-fps", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
- var_Get( p_demux, "mjpeg-fps", &val );
+ f_fps = var_CreateGetFloat( p_demux, "mjpeg-fps" );
p_sys->i_frame_length = 0;
/* Check for jpeg file extension */
demux_IsPathExtension( p_demux, ".jpg" ) )
{
p_sys->b_still = true;
- if( val.f_float)
+ if( f_fps )
{
- p_sys->i_still_length = 1000000.0 / val.f_float;
+ p_sys->i_still_length = 1000000.0 / f_fps;
}
else
{
p_sys->i_still_length = 1000000;
}
}
- else if ( val.f_float )
+ else if ( f_fps )
{
- p_sys->i_frame_length = 1000000.0 / val.f_float;
+ p_sys->i_frame_length = 1000000.0 / f_fps;
}
es_format_Init( &p_sys->fmt, VIDEO_ES, 0 );
- p_sys->fmt.i_codec = VLC_FOURCC('m','j','p','g');
+ p_sys->fmt.i_codec = VLC_CODEC_MJPG;
p_sys->p_es = es_out_Add( p_demux->out, &p_sys->fmt );
return VLC_SUCCESS;
demux_sys_t *p_sys = p_demux->p_sys;
int i;
- if( p_sys->b_still && p_sys->i_still_end && p_sys->i_still_end < mdate() )
+ if( p_sys->b_still && p_sys->i_still_end )
{
/* Still frame, wait until the pause delay is gone */
+ mwait( p_sys->i_still_end );
p_sys->i_still_end = 0;
- }
- else if( p_sys->b_still && p_sys->i_still_end )
- {
- msleep( 400 );
return 1;
}