Mercurial > mplayer.hg
changeset 26816:e77942d2d664
Use av_alloc_put_byte instead of custom protocol.
This needs less code and less hacks.
author | reimar |
---|---|
date | Wed, 21 May 2008 18:21:05 +0000 |
parents | fd3b28579cee |
children | a0c157a99aac |
files | libmpdemux/muxer_lavf.c |
diffstat | 1 files changed, 11 insertions(+), 48 deletions(-) [+] |
line wrap: on
line diff
--- a/libmpdemux/muxer_lavf.c Wed May 21 17:12:57 2008 +0000 +++ b/libmpdemux/muxer_lavf.c Wed May 21 18:21:05 2008 +0000 @@ -32,6 +32,8 @@ extern char *info_sourceform; extern char *info_comment; +#define BIO_BUFFER_SIZE 32768 + typedef struct { //AVInputFormat *avif; AVFormatContext *oc; @@ -39,6 +41,7 @@ int audio_streams; int video_streams; int64_t last_pts; + uint8_t buffer[BIO_BUFFER_SIZE]; } muxer_priv_t; typedef struct { @@ -64,39 +67,15 @@ {NULL, NULL, 0, 0, 0, 0, NULL} }; -/* This should be transmitted to mp_open() through the filename when - * thread safety is needed but MPlayer == no threads and especially - * not multiple muxers being initialized at once so there is no - * point in the extra complexity, a static is simpler. */ -static muxer_t *priv_data; - -static int mp_open(URLContext *h, const char *filename, int flags) -{ - h->priv_data= priv_data; - return 0; -} - -static int mp_close(URLContext *h) +static int mp_write(void *opaque, uint8_t *buf, int size) { - return 0; -} - - -static int mp_read(URLContext *h, unsigned char *buf, int size) -{ - mp_msg(MSGT_MUXER, MSGL_WARN, "READ %d\n", size); - return -1; -} - -static int mp_write(URLContext *h, unsigned char *buf, int size) -{ - muxer_t *muxer = (muxer_t*)h->priv_data; + muxer_t *muxer = opaque; return stream_write_buffer(muxer->stream, buf, size); } -static offset_t mp_seek(URLContext *h, offset_t pos, int whence) +static offset_t mp_seek(void *opaque, offset_t pos, int whence) { - muxer_t *muxer = (muxer_t*)h->priv_data; + muxer_t *muxer = opaque; if(whence == SEEK_CUR) { off_t cur = stream_tell(muxer->stream); @@ -118,16 +97,6 @@ } -static URLProtocol mp_protocol = { - "menc", - mp_open, - mp_read, - mp_write, - mp_seek, - mp_close, - NULL -}; - static muxer_stream_t* lavf_new_stream(muxer_t *muxer, int type) { muxer_priv_t *priv = muxer->priv; @@ -321,7 +290,7 @@ av_freep(&(priv->oc->streams[i])); } - url_fclose(priv->oc->pb); + av_freep(&priv->oc->pb); av_free(priv->oc); } @@ -338,7 +307,6 @@ { muxer_priv_t *priv; AVOutputFormat *fmt = NULL; - char mp_filename[256] = "menc://stream.dummy"; av_register_all(); @@ -404,14 +372,9 @@ } } - register_protocol(&mp_protocol); - - priv_data= muxer; - if(url_fopen(&priv->oc->pb, mp_filename, URL_WRONLY)) - { - mp_msg(MSGT_MUXER, MSGL_FATAL, "Could not open outfile.\n"); - goto fail; - } + priv->oc->pb = av_alloc_put_byte(priv->buffer, BIO_BUFFER_SIZE, 1, muxer, NULL, mp_write, mp_seek); + if ((muxer->stream->flags & STREAM_SEEK) != STREAM_SEEK) + priv->oc->pb->is_streamed = 1; muxer->priv = (void *) priv; muxer->cont_new_stream = &lavf_new_stream;