| 1 |
|
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
|
|---|
| 25 |
|
|---|
| 26 |
|
|---|
| 27 |
|
|---|
| 28 |
|
|---|
| 29 |
|
|---|
| 30 |
|
|---|
| 31 |
#ifdef HAVE_CONFIG_H |
|---|
| 32 |
# include "config.h" |
|---|
| 33 |
#endif |
|---|
| 34 |
|
|---|
| 35 |
#include <vlc_common.h> |
|---|
| 36 |
#include <vlc_plugin.h> |
|---|
| 37 |
#include <vlc_demux.h> |
|---|
| 38 |
|
|---|
| 39 |
#include <vlc_codecs.h> |
|---|
| 40 |
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 |
|
|---|
| 44 |
static int Open ( vlc_object_t * ); |
|---|
| 45 |
static void Close( vlc_object_t * ); |
|---|
| 46 |
|
|---|
| 47 |
#define FPS_TEXT N_("Frames per Second") |
|---|
| 48 |
#define FPS_LONGTEXT N_("This is the desired frame rate when " \ |
|---|
| 49 |
"playing MJPEG from a file. Use 0 (this is the default value) for a " \ |
|---|
| 50 |
"live stream (from a camera).") |
|---|
| 51 |
|
|---|
| 52 |
vlc_module_begin(); |
|---|
| 53 |
set_shortname( "MJPEG"); |
|---|
| 54 |
set_description( N_("M-JPEG camera demuxer") ); |
|---|
| 55 |
set_capability( "demux", 5 ); |
|---|
| 56 |
set_callbacks( Open, Close ); |
|---|
| 57 |
set_category( CAT_INPUT ); |
|---|
| 58 |
set_subcategory( SUBCAT_INPUT_DEMUX ); |
|---|
| 59 |
add_float( "mjpeg-fps", 0.0, NULL, FPS_TEXT, FPS_LONGTEXT, false ); |
|---|
| 60 |
vlc_module_end(); |
|---|
| 61 |
|
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
|
|---|
| 65 |
static int MimeDemux( demux_t * ); |
|---|
| 66 |
static int MjpgDemux( demux_t * ); |
|---|
| 67 |
static int Control( demux_t *, int i_query, va_list args ); |
|---|
| 68 |
|
|---|
| 69 |
struct demux_sys_t |
|---|
| 70 |
{ |
|---|
| 71 |
es_format_t fmt; |
|---|
| 72 |
es_out_id_t *p_es; |
|---|
| 73 |
|
|---|
| 74 |
bool b_still; |
|---|
| 75 |
mtime_t i_still_end; |
|---|
| 76 |
mtime_t i_still_length; |
|---|
| 77 |
|
|---|
| 78 |
mtime_t i_time; |
|---|
| 79 |
mtime_t i_frame_length; |
|---|
| 80 |
char *psz_separator; |
|---|
| 81 |
int i_frame_size_estimate; |
|---|
| 82 |
const uint8_t *p_peek; |
|---|
| 83 |
int i_data_peeked; |
|---|
| 84 |
int i_level; |
|---|
| 85 |
}; |
|---|
| 86 |
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 |
|
|---|
| 90 |
|
|---|
| 91 |
static bool Peek( demux_t *p_demux, bool b_first ) |
|---|
| 92 |
{ |
|---|
| 93 |
int i_data; |
|---|
| 94 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 95 |
|
|---|
| 96 |
if( b_first ) |
|---|
| 97 |
{ |
|---|
| 98 |
p_sys->i_data_peeked = 0; |
|---|
| 99 |
} |
|---|
| 100 |
else if( p_sys->i_data_peeked == p_sys->i_frame_size_estimate ) |
|---|
| 101 |
{ |
|---|
| 102 |
p_sys->i_frame_size_estimate += 5120; |
|---|
| 103 |
} |
|---|
| 104 |
i_data = stream_Peek( p_demux->s, &p_sys->p_peek, |
|---|
| 105 |
p_sys->i_frame_size_estimate ); |
|---|
| 106 |
if( i_data == p_sys->i_data_peeked ) |
|---|
| 107 |
{ |
|---|
| 108 |
msg_Warn( p_demux, "no more data" ); |
|---|
| 109 |
return false; |
|---|
| 110 |
} |
|---|
| 111 |
p_sys->i_data_peeked = i_data; |
|---|
| 112 |
if( i_data <= 0 ) |
|---|
| 113 |
{ |
|---|
| 114 |
msg_Warn( p_demux, "cannot peek data" ); |
|---|
| 115 |
return false; |
|---|
| 116 |
} |
|---|
| 117 |
return true; |
|---|
| 118 |
} |
|---|
| 119 |
|
|---|
| 120 |
|
|---|
| 121 |
|
|---|
| 122 |
|
|---|
| 123 |
static char* GetLine( demux_t *p_demux, int *p_pos ) |
|---|
| 124 |
{ |
|---|
| 125 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 126 |
const uint8_t *p_buf; |
|---|
| 127 |
int i_size; |
|---|
| 128 |
int i; |
|---|
| 129 |
char *p_line; |
|---|
| 130 |
|
|---|
| 131 |
while( *p_pos > p_sys->i_data_peeked ) |
|---|
| 132 |
{ |
|---|
| 133 |
if( ! Peek( p_demux, false ) ) |
|---|
| 134 |
{ |
|---|
| 135 |
return NULL; |
|---|
| 136 |
} |
|---|
| 137 |
} |
|---|
| 138 |
p_buf = p_sys->p_peek + *p_pos; |
|---|
| 139 |
i_size = p_sys->i_data_peeked - *p_pos; |
|---|
| 140 |
i = 0; |
|---|
| 141 |
while( p_buf[i] != '\n' ) |
|---|
| 142 |
{ |
|---|
| 143 |
i++; |
|---|
| 144 |
if( i == i_size ) |
|---|
| 145 |
{ |
|---|
| 146 |
if( ! Peek( p_demux, false ) ) |
|---|
| 147 |
{ |
|---|
| 148 |
return NULL; |
|---|
| 149 |
} |
|---|
| 150 |
} |
|---|
| 151 |
p_buf = p_sys->p_peek + *p_pos; |
|---|
| 152 |
i_size = p_sys->i_data_peeked - *p_pos; |
|---|
| 153 |
} |
|---|
| 154 |
*p_pos += ( i + 1 ); |
|---|
| 155 |
if( i > 0 && '\r' == p_buf[i - 1] ) |
|---|
| 156 |
{ |
|---|
| 157 |
i--; |
|---|
| 158 |
} |
|---|
| 159 |
p_line = malloc( i + 1 ); |
|---|
| 160 |
if( p_line == NULL ) |
|---|
| 161 |
return NULL; |
|---|
| 162 |
strncpy ( p_line, (char*)p_buf, i ); |
|---|
| 163 |
p_line[i] = '\0'; |
|---|
| 164 |
|
|---|
| 165 |
return p_line; |
|---|
| 166 |
} |
|---|
| 167 |
|
|---|
| 168 |
|
|---|
| 169 |
|
|---|
| 170 |
|
|---|
| 171 |
|
|---|
| 172 |
|
|---|
| 173 |
|
|---|
| 174 |
static bool CheckMimeHeader( demux_t *p_demux, int *p_header_size ) |
|---|
| 175 |
{ |
|---|
| 176 |
bool b_jpeg = false; |
|---|
| 177 |
int i_pos; |
|---|
| 178 |
char *psz_line; |
|---|
| 179 |
char *p_ch; |
|---|
| 180 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 181 |
|
|---|
| 182 |
if( !Peek( p_demux, true ) ) |
|---|
| 183 |
{ |
|---|
| 184 |
msg_Err( p_demux, "cannot peek" ); |
|---|
| 185 |
*p_header_size = -1; |
|---|
| 186 |
return false; |
|---|
| 187 |
} |
|---|
| 188 |
if( p_sys->i_data_peeked < 3) |
|---|
| 189 |
{ |
|---|
| 190 |
msg_Err( p_demux, "data shortage" ); |
|---|
| 191 |
*p_header_size = -2; |
|---|
| 192 |
return false; |
|---|
| 193 |
} |
|---|
| 194 |
if( strncmp( (char *)p_sys->p_peek, "--", 2 ) ) |
|---|
| 195 |
{ |
|---|
| 196 |
*p_header_size = 0; |
|---|
| 197 |
return false; |
|---|
| 198 |
} |
|---|
| 199 |
i_pos = 2; |
|---|
| 200 |
psz_line = GetLine( p_demux, &i_pos ); |
|---|
| 201 |
if( NULL == psz_line ) |
|---|
| 202 |
{ |
|---|
| 203 |
msg_Err( p_demux, "no EOL" ); |
|---|
| 204 |
*p_header_size = -3; |
|---|
| 205 |
return false; |
|---|
| 206 |
} |
|---|
| 207 |
|
|---|
| 208 |
|
|---|
| 209 |
if( p_sys->psz_separator == NULL ) |
|---|
| 210 |
{ |
|---|
| 211 |
p_sys->psz_separator = psz_line; |
|---|
| 212 |
msg_Dbg( p_demux, "Multipart MIME detected, using separator: %s", |
|---|
| 213 |
p_sys->psz_separator ); |
|---|
| 214 |
} |
|---|
| 215 |
else |
|---|
| 216 |
{ |
|---|
| 217 |
if( strcmp( psz_line, p_sys->psz_separator ) ) |
|---|
| 218 |
{ |
|---|
| 219 |
msg_Warn( p_demux, "separator %s does not match %s", psz_line, |
|---|
| 220 |
p_sys->psz_separator ); |
|---|
| 221 |
} |
|---|
| 222 |
free( psz_line ); |
|---|
| 223 |
} |
|---|
| 224 |
|
|---|
| 225 |
psz_line = GetLine( p_demux, &i_pos ); |
|---|
| 226 |
while( psz_line && *psz_line ) |
|---|
| 227 |
{ |
|---|
| 228 |
if( !strncasecmp( psz_line, "Content-Type:", 13 ) ) |
|---|
| 229 |
{ |
|---|
| 230 |
p_ch = psz_line + 13; |
|---|
| 231 |
while( *p_ch != '\0' && ( *p_ch == ' ' || *p_ch == '\t' ) ) p_ch++; |
|---|
| 232 |
if( strncasecmp( p_ch, "image/jpeg", 10 ) ) |
|---|
| 233 |
{ |
|---|
| 234 |
msg_Warn( p_demux, "%s, image/jpeg is expected", psz_line ); |
|---|
| 235 |
b_jpeg = false; |
|---|
| 236 |
} |
|---|
| 237 |
else |
|---|
| 238 |
{ |
|---|
| 239 |
b_jpeg = true; |
|---|
| 240 |
} |
|---|
| 241 |
} |
|---|
| 242 |
else |
|---|
| 243 |
{ |
|---|
| 244 |
msg_Dbg( p_demux, "discard MIME header: %s", psz_line ); |
|---|
| 245 |
} |
|---|
| 246 |
free( psz_line ); |
|---|
| 247 |
psz_line = GetLine( p_demux, &i_pos ); |
|---|
| 248 |
} |
|---|
| 249 |
|
|---|
| 250 |
if( NULL == psz_line ) |
|---|
| 251 |
{ |
|---|
| 252 |
msg_Err( p_demux, "no EOL" ); |
|---|
| 253 |
*p_header_size = -3; |
|---|
| 254 |
return false; |
|---|
| 255 |
} |
|---|
| 256 |
|
|---|
| 257 |
free( psz_line ); |
|---|
| 258 |
|
|---|
| 259 |
*p_header_size = i_pos; |
|---|
| 260 |
return b_jpeg; |
|---|
| 261 |
} |
|---|
| 262 |
|
|---|
| 263 |
static int SendBlock( demux_t *p_demux, int i ) |
|---|
| 264 |
{ |
|---|
| 265 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 266 |
block_t *p_block; |
|---|
| 267 |
|
|---|
| 268 |
if( ( p_block = stream_Block( p_demux->s, i ) ) == NULL ) |
|---|
| 269 |
{ |
|---|
| 270 |
msg_Warn( p_demux, "cannot read data" ); |
|---|
| 271 |
return 0; |
|---|
| 272 |
} |
|---|
| 273 |
|
|---|
| 274 |
if( !p_sys->i_frame_length || !p_sys->i_time ) |
|---|
| 275 |
{ |
|---|
| 276 |
p_sys->i_time = p_block->i_dts = p_block->i_pts = mdate(); |
|---|
| 277 |
} |
|---|
| 278 |
else |
|---|
| 279 |
{ |
|---|
| 280 |
p_block->i_dts = p_block->i_pts = p_sys->i_time; |
|---|
| 281 |
p_sys->i_time += p_sys->i_frame_length; |
|---|
| 282 |
} |
|---|
| 283 |
|
|---|
| 284 |
|
|---|
| 285 |
es_out_Control( p_demux->out, ES_OUT_SET_PCR, p_block->i_pts ); |
|---|
| 286 |
es_out_Send( p_demux->out, p_sys->p_es, p_block ); |
|---|
| 287 |
|
|---|
| 288 |
if( p_sys->b_still ) |
|---|
| 289 |
{ |
|---|
| 290 |
p_sys->i_still_end = mdate() + p_sys->i_still_length; |
|---|
| 291 |
} |
|---|
| 292 |
|
|---|
| 293 |
return 1; |
|---|
| 294 |
} |
|---|
| 295 |
|
|---|
| 296 |
|
|---|
| 297 |
|
|---|
| 298 |
|
|---|
| 299 |
static int Open( vlc_object_t * p_this ) |
|---|
| 300 |
{ |
|---|
| 301 |
demux_t *p_demux = (demux_t*)p_this; |
|---|
| 302 |
demux_sys_t *p_sys; |
|---|
| 303 |
int i_size; |
|---|
| 304 |
int b_matched = false; |
|---|
| 305 |
vlc_value_t val; |
|---|
| 306 |
|
|---|
| 307 |
p_demux->pf_control = Control; |
|---|
| 308 |
p_demux->p_sys = p_sys = malloc( sizeof( demux_sys_t ) ); |
|---|
| 309 |
p_sys->p_es = NULL; |
|---|
| 310 |
p_sys->i_time = 0; |
|---|
| 311 |
p_sys->i_level = 0; |
|---|
| 312 |
|
|---|
| 313 |
p_sys->psz_separator = NULL; |
|---|
| 314 |
p_sys->i_frame_size_estimate = 15 * 1024; |
|---|
| 315 |
|
|---|
| 316 |
b_matched = CheckMimeHeader( p_demux, &i_size); |
|---|
| 317 |
if( b_matched ) |
|---|
| 318 |
{ |
|---|
| 319 |
p_demux->pf_demux = MimeDemux; |
|---|
| 320 |
stream_Read( p_demux->s, NULL, i_size ); |
|---|
| 321 |
} |
|---|
| 322 |
else if( 0 == i_size ) |
|---|
| 323 |
{ |
|---|
| 324 |
|
|---|
| 325 |
if( p_sys->p_peek[0] == 0xFF && p_sys->p_peek[1] == 0xD8 ) |
|---|
| 326 |
{ |
|---|
| 327 |
msg_Dbg( p_demux, "JPEG SOI marker detected" ); |
|---|
| 328 |
p_demux->pf_demux = MjpgDemux; |
|---|
| 329 |
p_sys->i_level++; |
|---|
| 330 |
} |
|---|
| 331 |
else |
|---|
| 332 |
{ |
|---|
| 333 |
goto error; |
|---|
| 334 |
} |
|---|
| 335 |
} |
|---|
| 336 |
else |
|---|
| 337 |
{ |
|---|
| 338 |
goto error; |
|---|
| 339 |
} |
|---|
| 340 |
|
|---|
| 341 |
|
|---|
| 342 |
var_Create( p_demux, "mjpeg-fps", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT ); |
|---|
| 343 |
var_Get( p_demux, "mjpeg-fps", &val ); |
|---|
| 344 |
p_sys->i_frame_length = 0; |
|---|
| 345 |
|
|---|
| 346 |
|
|---|
| 347 |
p_sys->b_still = false; |
|---|
| 348 |
p_sys->i_still_end = 0; |
|---|
| 349 |
if( demux_IsPathExtension( p_demux, ".jpeg" ) || |
|---|
| 350 |
demux_IsPathExtension( p_demux, ".jpg" ) ) |
|---|
| 351 |
{ |
|---|
| 352 |
p_sys->b_still = true; |
|---|
| 353 |
if( val.f_float) |
|---|
| 354 |
{ |
|---|
| 355 |
p_sys->i_still_length = 1000000.0 / val.f_float; |
|---|
| 356 |
} |
|---|
| 357 |
else |
|---|
| 358 |
{ |
|---|
| 359 |
|
|---|
| 360 |
p_sys->i_still_length = 1000000; |
|---|
| 361 |
} |
|---|
| 362 |
} |
|---|
| 363 |
else if ( val.f_float ) |
|---|
| 364 |
{ |
|---|
| 365 |
p_sys->i_frame_length = 1000000.0 / val.f_float; |
|---|
| 366 |
} |
|---|
| 367 |
|
|---|
| 368 |
es_format_Init( &p_sys->fmt, VIDEO_ES, 0 ); |
|---|
| 369 |
p_sys->fmt.i_codec = VLC_FOURCC('m','j','p','g'); |
|---|
| 370 |
|
|---|
| 371 |
p_sys->p_es = es_out_Add( p_demux->out, &p_sys->fmt ); |
|---|
| 372 |
return VLC_SUCCESS; |
|---|
| 373 |
|
|---|
| 374 |
error: |
|---|
| 375 |
free( p_sys ); |
|---|
| 376 |
return VLC_EGENERIC; |
|---|
| 377 |
} |
|---|
| 378 |
|
|---|
| 379 |
|
|---|
| 380 |
|
|---|
| 381 |
|
|---|
| 382 |
|
|---|
| 383 |
|
|---|
| 384 |
static int MjpgDemux( demux_t *p_demux ) |
|---|
| 385 |
{ |
|---|
| 386 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 387 |
int i; |
|---|
| 388 |
|
|---|
| 389 |
if( p_sys->b_still && p_sys->i_still_end && p_sys->i_still_end < mdate() ) |
|---|
| 390 |
{ |
|---|
| 391 |
|
|---|
| 392 |
p_sys->i_still_end = 0; |
|---|
| 393 |
} |
|---|
| 394 |
else if( p_sys->b_still && p_sys->i_still_end ) |
|---|
| 395 |
{ |
|---|
| 396 |
msleep( 400 ); |
|---|
| 397 |
return 1; |
|---|
| 398 |
} |
|---|
| 399 |
|
|---|
| 400 |
if( !Peek( p_demux, true ) ) |
|---|
| 401 |
{ |
|---|
| 402 |
msg_Warn( p_demux, "cannot peek data" ); |
|---|
| 403 |
return 0; |
|---|
| 404 |
} |
|---|
| 405 |
if( p_sys->i_data_peeked < 4 ) |
|---|
| 406 |
{ |
|---|
| 407 |
msg_Warn( p_demux, "data shortage" ); |
|---|
| 408 |
return 0; |
|---|
| 409 |
} |
|---|
| 410 |
i = 3; |
|---|
| 411 |
FIND_NEXT_EOI: |
|---|
| 412 |
while( !( 0xFF == p_sys->p_peek[i-1] && 0xD9 == p_sys->p_peek[i] ) ) |
|---|
| 413 |
{ |
|---|
| 414 |
if( 0xFF == p_sys->p_peek[i-1] && 0xD8 == p_sys->p_peek[i] ) |
|---|
| 415 |
{ |
|---|
| 416 |
p_sys->i_level++; |
|---|
| 417 |
msg_Dbg( p_demux, "we found another JPEG SOI at %d", i ); |
|---|
| 418 |
} |
|---|
| 419 |
i++; |
|---|
| 420 |
if( i >= p_sys->i_data_peeked ) |
|---|
| 421 |
{ |
|---|
| 422 |
msg_Dbg( p_demux, "did not find JPEG EOI in %d bytes", |
|---|
| 423 |
p_sys->i_data_peeked ); |
|---|
| 424 |
if( !Peek( p_demux, false ) ) |
|---|
| 425 |
{ |
|---|
| 426 |
msg_Warn( p_demux, "no more data is available at the moment" ); |
|---|
| 427 |
return 0; |
|---|
| 428 |
} |
|---|
| 429 |
} |
|---|
| 430 |
} |
|---|
| 431 |
i++; |
|---|
| 432 |
|
|---|
| 433 |
msg_Dbg( p_demux, "JPEG EOI detected at %d", i ); |
|---|
| 434 |
p_sys->i_level--; |
|---|
| 435 |
|
|---|
| 436 |
if( p_sys->i_level > 0 ) |
|---|
| 437 |
goto FIND_NEXT_EOI; |
|---|
| 438 |
return SendBlock( p_demux, i ); |
|---|
| 439 |
} |
|---|
| 440 |
|
|---|
| 441 |
static int MimeDemux( demux_t *p_demux ) |
|---|
| 442 |
{ |
|---|
| 443 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 444 |
int i_size, i; |
|---|
| 445 |
|
|---|
| 446 |
bool b_match = CheckMimeHeader( p_demux, &i_size ); |
|---|
| 447 |
|
|---|
| 448 |
if( i_size > 0 ) |
|---|
| 449 |
{ |
|---|
| 450 |
stream_Read( p_demux->s, NULL, i_size ); |
|---|
| 451 |
} |
|---|
| 452 |
else if( i_size < 0 ) |
|---|
| 453 |
{ |
|---|
| 454 |
return 0; |
|---|
| 455 |
} |
|---|
| 456 |
else |
|---|
| 457 |
{ |
|---|
| 458 |
|
|---|
| 459 |
b_match = true; |
|---|
| 460 |
} |
|---|
| 461 |
|
|---|
| 462 |
if( !Peek( p_demux, true ) ) |
|---|
| 463 |
{ |
|---|
| 464 |
msg_Warn( p_demux, "cannot peek data" ); |
|---|
| 465 |
return 0; |
|---|
| 466 |
} |
|---|
| 467 |
|
|---|
| 468 |
i = 0; |
|---|
| 469 |
i_size = strlen( p_sys->psz_separator ) + 2; |
|---|
| 470 |
if( p_sys->i_data_peeked < i_size ) |
|---|
| 471 |
{ |
|---|
| 472 |
msg_Warn( p_demux, "data shortage" ); |
|---|
| 473 |
return 0; |
|---|
| 474 |
} |
|---|
| 475 |
|
|---|
| 476 |
for( ;; ) |
|---|
| 477 |
{ |
|---|
| 478 |
while( !( p_sys->p_peek[i] == '-' && p_sys->p_peek[i+1] == '-' ) ) |
|---|
| 479 |
{ |
|---|
| 480 |
i++; |
|---|
| 481 |
i_size++; |
|---|
| 482 |
if( i_size >= p_sys->i_data_peeked ) |
|---|
| 483 |
{ |
|---|
| 484 |
msg_Dbg( p_demux, "MIME boundary not found in %d bytes of " |
|---|
| 485 |
"data", p_sys->i_data_peeked ); |
|---|
| 486 |
|
|---|
| 487 |
if( !Peek( p_demux, false ) ) |
|---|
| 488 |
{ |
|---|
| 489 |
msg_Warn( p_demux, "no more data is available at the " |
|---|
| 490 |
"moment" ); |
|---|
| 491 |
return 0; |
|---|
| 492 |
} |
|---|
| 493 |
} |
|---|
| 494 |
} |
|---|
| 495 |
|
|---|
| 496 |
if( !strncmp( p_sys->psz_separator, (char *)(p_sys->p_peek + i + 2), |
|---|
| 497 |
strlen( p_sys->psz_separator ) ) ) |
|---|
| 498 |
{ |
|---|
| 499 |
break; |
|---|
| 500 |
} |
|---|
| 501 |
|
|---|
| 502 |
i++; |
|---|
| 503 |
i_size++; |
|---|
| 504 |
} |
|---|
| 505 |
|
|---|
| 506 |
if( !b_match ) |
|---|
| 507 |
{ |
|---|
| 508 |
msg_Err( p_demux, "discard non-JPEG part" ); |
|---|
| 509 |
stream_Read( p_demux->s, NULL, i ); |
|---|
| 510 |
return 0; |
|---|
| 511 |
} |
|---|
| 512 |
|
|---|
| 513 |
return SendBlock( p_demux, i ); |
|---|
| 514 |
} |
|---|
| 515 |
|
|---|
| 516 |
|
|---|
| 517 |
|
|---|
| 518 |
|
|---|
| 519 |
static void Close ( vlc_object_t * p_this ) |
|---|
| 520 |
{ |
|---|
| 521 |
demux_t *p_demux = (demux_t*)p_this; |
|---|
| 522 |
demux_sys_t *p_sys = p_demux->p_sys; |
|---|
| 523 |
|
|---|
| 524 |
free( p_sys->psz_separator ); |
|---|
| 525 |
free( p_sys ); |
|---|
| 526 |
} |
|---|
| 527 |
|
|---|
| 528 |
|
|---|
| 529 |
|
|---|
| 530 |
|
|---|
| 531 |
static int Control( demux_t *p_demux, int i_query, va_list args ) |
|---|
| 532 |
{ |
|---|
| 533 |
return demux_vaControlHelper( p_demux->s, 0, 0, 0, 0, i_query, args ); |
|---|
| 534 |
} |
|---|