Mercurial > audlegacy-plugins
comparison src/ffmpeg/libavformat/utils.c @ 825:3cbdc6e19d7c trunk
[svn] - make this compile again
author | nenolod |
---|---|
date | Mon, 12 Mar 2007 14:37:31 -0700 |
parents | 07107d476f32 |
children | 68562d99230f |
comparison
equal
deleted
inserted
replaced
824:420eb823b2d4 | 825:3cbdc6e19d7c |
---|---|
471 } | 471 } |
472 | 472 |
473 if (!fmt || must_open_file) { | 473 if (!fmt || must_open_file) { |
474 /* if no file needed do not try to open one */ | 474 /* if no file needed do not try to open one */ |
475 if (url_fopen(pb, filename, URL_RDONLY) < 0) { | 475 if (url_fopen(pb, filename, URL_RDONLY) < 0) { |
476 err = AVERROR_IO; | |
477 goto fail; | |
478 } | |
479 file_opened = 1; | |
480 if (buf_size > 0) { | |
481 url_setbufsize(pb, buf_size); | |
482 } | |
483 | |
484 for(probe_size= PROBE_BUF_MIN; probe_size<=PROBE_BUF_MAX && !fmt; probe_size<<=1){ | |
485 /* read probe data */ | |
486 pd->buf= av_realloc(pd->buf, probe_size); | |
487 pd->buf_size = get_buffer(pb, pd->buf, probe_size); | |
488 if (url_fseek(pb, 0, SEEK_SET) == (offset_t)-EPIPE) { | |
489 url_fclose(pb); | |
490 if (url_fopen(pb, filename, URL_RDONLY) < 0) { | |
491 file_opened = 0; | |
492 err = AVERROR_IO; | |
493 goto fail; | |
494 } | |
495 } | |
496 /* guess file format */ | |
497 fmt = av_probe_input_format(pd, 1); | |
498 } | |
499 av_freep(&pd->buf); | |
500 } | |
501 | |
502 /* if still no format found, error */ | |
503 if (!fmt) { | |
504 err = AVERROR_NOFMT; | |
505 goto fail; | |
506 } | |
507 | |
508 /* XXX: suppress this hack for redirectors */ | |
509 #ifdef CONFIG_NETWORK | |
510 if (fmt == &redir_demuxer) { | |
511 err = redir_open(ic_ptr, pb); | |
512 url_fclose(pb); | |
513 return err; | |
514 } | |
515 #endif | |
516 | |
517 /* check filename in case of an image number is expected */ | |
518 if (fmt->flags & AVFMT_NEEDNUMBER) { | |
519 if (!av_filename_number_test(filename)) { | |
520 err = AVERROR_NUMEXPECTED; | |
521 goto fail; | |
522 } | |
523 } | |
524 err = av_open_input_stream(ic_ptr, pb, filename, fmt, ap); | |
525 if (err) | |
526 goto fail; | |
527 return 0; | |
528 fail: | |
529 av_freep(&pd->buf); | |
530 if (file_opened) | |
531 url_fclose(pb); | |
532 *ic_ptr = NULL; | |
533 return err; | |
534 | |
535 } | |
536 | |
537 int av_open_input_vfsfile(AVFormatContext **ic_ptr, const char *filename, VFSFile *fd, | |
538 AVInputFormat *fmt, | |
539 int buf_size, | |
540 AVFormatParameters *ap) | |
541 { | |
542 int err, must_open_file, file_opened, probe_size; | |
543 AVProbeData probe_data, *pd = &probe_data; | |
544 ByteIOContext pb1, *pb = &pb1; | |
545 | |
546 file_opened = 0; | |
547 pd->filename = ""; | |
548 if (filename) | |
549 pd->filename = filename; | |
550 pd->buf = NULL; | |
551 pd->buf_size = 0; | |
552 | |
553 if (!fmt) { | |
554 /* guess format if no file can be opened */ | |
555 fmt = av_probe_input_format(pd, 0); | |
556 } | |
557 | |
558 /* do not open file if the format does not need it. XXX: specific | |
559 hack needed to handle RTSP/TCP */ | |
560 must_open_file = 1; | |
561 if (fmt && (fmt->flags & AVFMT_NOFILE)) { | |
562 must_open_file = 0; | |
563 pb= NULL; //FIXME this or memset(pb, 0, sizeof(ByteIOContext)); otherwise its uninitalized | |
564 } | |
565 | |
566 if (!fmt || must_open_file) { | |
567 /* if no file needed do not try to open one */ | |
568 if (url_vfdopen(pb, fd) < 0) { | |
476 err = AVERROR_IO; | 569 err = AVERROR_IO; |
477 goto fail; | 570 goto fail; |
478 } | 571 } |
479 file_opened = 1; | 572 file_opened = 1; |
480 if (buf_size > 0) { | 573 if (buf_size > 0) { |