summaryrefslogtreecommitdiffstats
path: root/libmpdemux
diff options
context:
space:
mode:
authorreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-05-21 18:21:05 +0000
committerreimar <reimar@b3059339-0415-0410-9bf9-f77b7e298cf2>2008-05-21 18:21:05 +0000
commit2bdedd33ed2636bff2fb8cfae9c43cae3cd9b5f8 (patch)
tree5f6f59f3b69241d6ed29ae99df6ffcf0262250e8 /libmpdemux
parenta248cd8b68efadec646939f5112e9815bb4f4fdc (diff)
downloadmpv-2bdedd33ed2636bff2fb8cfae9c43cae3cd9b5f8.tar.bz2
mpv-2bdedd33ed2636bff2fb8cfae9c43cae3cd9b5f8.tar.xz
Use av_alloc_put_byte instead of custom protocol.
This needs less code and less hacks. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@26848 b3059339-0415-0410-9bf9-f77b7e298cf2
Diffstat (limited to 'libmpdemux')
-rw-r--r--libmpdemux/muxer_lavf.c59
1 files changed, 11 insertions, 48 deletions
diff --git a/libmpdemux/muxer_lavf.c b/libmpdemux/muxer_lavf.c
index 12410f542e..fe7f5715fc 100644
--- a/libmpdemux/muxer_lavf.c
+++ b/libmpdemux/muxer_lavf.c
@@ -32,6 +32,8 @@ extern char *info_copyright;
extern char *info_sourceform;
extern char *info_comment;
+#define BIO_BUFFER_SIZE 32768
+
typedef struct {
//AVInputFormat *avif;
AVFormatContext *oc;
@@ -39,6 +41,7 @@ typedef struct {
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 @@ m_option_t lavfopts_conf[] = {
{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)
-{
- return 0;
-}
-
-
-static int mp_read(URLContext *h, unsigned char *buf, int size)
+static int mp_write(void *opaque, uint8_t *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 offset_t mp_seek(URLContext *h, offset_t pos, int whence)
}
-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 @@ static void write_trailer(muxer_t *muxer)
av_freep(&(priv->oc->streams[i]));
}
- url_fclose(priv->oc->pb);
+ av_freep(&priv->oc->pb);
av_free(priv->oc);
}
@@ -338,7 +307,6 @@ int muxer_init_muxer_lavf(muxer_t *muxer)
{
muxer_priv_t *priv;
AVOutputFormat *fmt = NULL;
- char mp_filename[256] = "menc://stream.dummy";
av_register_all();
@@ -404,14 +372,9 @@ int muxer_init_muxer_lavf(muxer_t *muxer)
}
}
- 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;