Mercurial > audlegacy-plugins
changeset 508:1e5df88b631d trunk
[svn] - newvfs probing
author | nenolod |
---|---|
date | Mon, 22 Jan 2007 01:00:29 -0800 |
parents | 0155ad752279 |
children | f862cf17b34a |
files | ChangeLog src/wma/libffwma/avformat.h src/wma/libffwma/avio.c src/wma/libffwma/avio.h src/wma/libffwma/aviobuf.c src/wma/libffwma/futils.c src/wma/wma.c |
diffstat | 7 files changed, 152 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Sun Jan 21 22:18:40 2007 -0800 +++ b/ChangeLog Mon Jan 22 01:00:29 2007 -0800 @@ -1,3 +1,12 @@ +2007-01-22 06:18:40 +0000 Daniel Barkalow <barkalow@iabervon.org> + revision [1100] + Fix case in curl where icecast metadata is wrapped around the end of + the ring buffer. + + trunk/src/curl/curl.c | 42 ++++++++++++++++++++++++++++++++++-------- + 1 file changed, 34 insertions(+), 8 deletions(-) + + 2007-01-22 06:15:24 +0000 William Pitcock <nenolod@sacredspiral.co.uk> revision [1098] - don't depend on feof here, as it's reliability is not guaranteed.
--- a/src/wma/libffwma/avformat.h Sun Jan 21 22:18:40 2007 -0800 +++ b/src/wma/libffwma/avformat.h Mon Jan 22 01:00:29 2007 -0800 @@ -526,6 +526,10 @@ AVInputFormat *fmt, int buf_size, AVFormatParameters *ap); +int av_open_input_vfsfile(AVFormatContext **ic_ptr, const char *fn, VFSFile *fd, + AVInputFormat *fmt, + int buf_size, + AVFormatParameters *ap); #define AVERROR_UNKNOWN (-1) /* unknown error */ #define AVERROR_IO (-2) /* i/o error */
--- a/src/wma/libffwma/avio.c Sun Jan 21 22:18:40 2007 -0800 +++ b/src/wma/libffwma/avio.c Mon Jan 22 01:00:29 2007 -0800 @@ -34,6 +34,38 @@ return 0; } +int url_vopen(URLContext **puc, VFSFile *fd) +{ + URLContext *uc; + URLProtocol *up; + const char *p; + char proto_str[128], *q; + int err; + + up = first_protocol; + uc = av_malloc(sizeof(URLContext) + strlen(fd->uri ? fd->uri : "")); + if (!uc) { + err = -ENOMEM; + goto fail; + } + strcpy(uc->filename, fd->uri ? fd->uri : ""); + uc->prot = up; + uc->flags = URL_RDONLY; + uc->is_streamed = 0; /* default = not streamed */ + uc->max_packet_size = 0; /* default: stream file */ + uc->priv_data = fd; + if (err < 0) { + free(uc); + *puc = NULL; + return err; + } + *puc = uc; + return 0; + fail: + *puc = NULL; + return err; +} + int url_open(URLContext **puc, const char *filename, int flags) { URLContext *uc;
--- a/src/wma/libffwma/avio.h Sun Jan 21 22:18:40 2007 -0800 +++ b/src/wma/libffwma/avio.h Mon Jan 22 01:00:29 2007 -0800 @@ -1,6 +1,8 @@ #ifndef AVIO_H #define AVIO_H +#include <audacious/vfs.h> + /* output byte stream handling */ typedef int64_t offset_t; @@ -30,6 +32,7 @@ typedef int URLInterruptCB(void); +int url_vopen(URLContext **h, VFSFile *fd); int url_open(URLContext **h, const char *filename, int flags); int url_read(URLContext *h, unsigned char *buf, int size); int url_write(URLContext *h, unsigned char *buf, int size); @@ -135,6 +138,7 @@ return s->is_streamed; } +int url_vfdopen(ByteIOContext *s, VFSFile *f); int url_fdopen(ByteIOContext *s, URLContext *h); int url_setbufsize(ByteIOContext *s, int buf_size); int url_fopen(ByteIOContext *s, const char *filename, int flags);
--- a/src/wma/libffwma/aviobuf.c Sun Jan 21 22:18:40 2007 -0800 +++ b/src/wma/libffwma/aviobuf.c Mon Jan 22 01:00:29 2007 -0800 @@ -271,7 +271,6 @@ { uint8_t *buffer; int buffer_size, max_packet_size; - max_packet_size = url_get_max_packet_size(h); if (max_packet_size) { @@ -279,7 +278,7 @@ } else { buffer_size = IO_BUFFER_SIZE; } - buffer = av_malloc(buffer_size); + buffer = av_mallocz(buffer_size); if (!buffer) return -ENOMEM; @@ -331,6 +330,21 @@ return 0; } +int url_vfdopen(ByteIOContext *s, VFSFile *fd) +{ + URLContext *h; + int err; + + err = url_vopen(&h, fd); + if (err < 0) + return err; + err = url_fdopen(s, h); + if (err < 0) { + return err; + } + return 0; +} + int url_fclose(ByteIOContext *s) { URLContext *h = s->opaque;
--- a/src/wma/libffwma/futils.c Sun Jan 21 22:18:40 2007 -0800 +++ b/src/wma/libffwma/futils.c Mon Jan 22 01:00:29 2007 -0800 @@ -438,6 +438,73 @@ } +int av_open_input_vfsfile(AVFormatContext **ic_ptr, const char *filename, VFSFile *fd, + AVInputFormat *fmt, + int buf_size, + AVFormatParameters *ap) +{ + int err, must_open_file, file_opened; + uint8_t buf[PROBE_BUF_SIZE]; + AVProbeData probe_data, *pd = &probe_data; + ByteIOContext pb1, *pb = &pb1; + + file_opened = 0; + pd->filename = ""; + if (filename) + pd->filename = filename; + pd->buf = buf; + pd->buf_size = 0; + + if (!fmt) { + /* guess format if no file can be opened */ + fmt = av_probe_input_format(pd, 0); + } + + /* do not open file if the format does not need it. XXX: specific + hack needed to handle RTSP/TCP */ + must_open_file = 1; + if (fmt && (fmt->flags & AVFMT_NOFILE)) { + must_open_file = 0; + } + + if (!fmt || must_open_file) { + /* if no file needed do not try to open one */ + if (url_vfdopen(pb, fd) < 0) { + err = AVERROR_IO; + goto fail; + } + file_opened = 1; + if (buf_size > 0) { + url_setbufsize(pb, buf_size); + } + if (!fmt) { + /* read probe data */ + pd->buf_size = get_buffer(pb, buf, PROBE_BUF_SIZE); + url_fseek(pb, 0, SEEK_SET); + } + } + + /* guess file format */ + if (!fmt) { + fmt = av_probe_input_format(pd, 1); + } + + /* if still no format found, error */ + if (!fmt) { + err = AVERROR_NOFMT; + goto fail; + } + + err = av_open_input_stream(ic_ptr, pb, filename, fmt, ap); + if (err) + goto fail; + return 0; + fail: + *ic_ptr = NULL; + return err; + +} + /*******************************************************/ /**
--- a/src/wma/wma.c Sun Jan 21 22:18:40 2007 -0800 +++ b/src/wma/wma.c Mon Jan 22 01:00:29 2007 -0800 @@ -76,6 +76,7 @@ static void wma_about(void); static void wma_init(void); static int wma_is_our_file(char *filename); +static int wma_is_our_fd(char *filename, VFSFile *fd); static void wma_play_file(char *filename); static void wma_stop(void); static void wma_seek(int time); @@ -121,7 +122,7 @@ wma_get_song_tuple, // Tuple builder NULL, NULL, - NULL, // vfs + wma_is_our_fd, // vfs wma_fmts }; @@ -219,6 +220,24 @@ return 1; } +static int wma_is_our_fd(char *filename, VFSFile *fd) +{ + AVCodec *codec2; + + if(av_open_input_vfsfile(&ic2, filename, fd, NULL, 0, NULL) < 0) return 0; + + for(wma_idx2 = 0; wma_idx2 < ic2->nb_streams; wma_idx2++) { + c2 = &ic2->streams[wma_idx2]->codec; + if(c2->codec_type == CODEC_TYPE_AUDIO) break; + } + + av_find_stream_info(ic2); + + codec2 = avcodec_find_decoder(c2->codec_id); + + return 1; +} + static void wma_do_pause(short p) { wma_pause = p;