[FFmpeg-devel] [RFC] possible API for opening external demuxer references
Baptiste Coudurier
baptiste.coudurier
Wed Feb 27 15:25:17 CET 2008
Reimar D?ffinger wrote:
> Hello,
> currently just a flag probably is good enough, but in case someone is
> interested in taking things further (maybe even as a way to implement
> general playlist support in lavf, including rules like "internet
> playlists can only reference internet files and vice versa"?) here is
> a first idea of a possible API.
> Probably it makes little sense without actually implementing things to
> actually see how suitable it is, but since I already got that far...
>
> Greetings,
> Reimar D?ffinger
>
>
> ------------------------------------------------------------------------
>
> diff --git a/libavformat/avformat.h b/libavformat/avformat.h
> index ad186e4..8f0cfa8 100644
> --- a/libavformat/avformat.h
> +++ b/libavformat/avformat.h
> @@ -499,6 +499,12 @@ typedef struct AVFormatContext {
> * demuxing: set by user
> */
> unsigned int max_index_size;
> +
> + //! Callback used to open a substream referenced by a container
> + int (*open_stream)(struct AVFormatContext *, ByteIOContext **s,
> + const uint8_t *resource, int resource_length, int flags);
> + //! Custom user data for use by e.g. open_stream callback
> + void *user_data;
> } AVFormatContext;
Humm not sure, but is AVFormatContext arg needed here ?
Problem is open_stream prototype is incompatible with url_fopen.
> typedef struct AVPacketList {
> diff --git a/libavformat/mov.c b/libavformat/mov.c
> index 0b3c0a4..ba28f39 100644
> --- a/libavformat/mov.c
> +++ b/libavformat/mov.c
> @@ -1534,11 +1534,15 @@ static int mov_read_header(AVFormatContext *s, AVFormatParameters *ap)
> sc->ffindex = i;
> mov_build_index(mov, st);
>
> + sc->pb = NULL;
> if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) {
> - if (url_fopen(&sc->pb, sc->drefs[sc->dref_id-1].path, URL_RDONLY) < 0)
> + if (s->open_stream &&
> + s->open_stream(s, &sc->pb, sc->drefs[sc->dref_id-1].path,
> + strlen(sc->drefs[sc->dref_id-1].path), URL_RDONLY) < 0)
> av_log(s, AV_LOG_ERROR, "stream %d, error opening external essence: %s\n",
> st->index, strerror(errno));
> - } else
> + }
> + if (!sc->pb)
> sc->pb = s->pb;
If stream is detected as external, sc->pb must not be set, else it will
demux garbage data.
Also I'd like url_fopen to be used as a fallback, if the
AVFMT_FLAG_EXTREF flag is set, or another mechanism.
--
Baptiste COUDURIER GnuPG Key Id: 0x5C1ABAAA
SMARTJOG S.A. http://www.smartjog.com
Key fingerprint 8D77134D20CC9220201FC5DB0AC9325C5C1ABAAA
Phone: +33 1 49966312
More information about the ffmpeg-devel
mailing list