X-Git-Url: http://git.videolan.org/?p=ffmpeg.git;a=blobdiff_plain;f=libavformat%2Flibrtmp.c;h=2d028b05e286ba4dc3099e7c7bd116da99cd974a;hp=f98040297c0474a495e153c7d1d18761e9aadc7f;hb=32b83aeec1a129d6eef2e89c7f107c614dfb4574;hpb=f87b1b373a0df55080c1e6a5874f9a0a75c6fee8 diff --git a/libavformat/librtmp.c b/libavformat/librtmp.c index f98040297c..2d028b05e2 100644 --- a/libavformat/librtmp.c +++ b/libavformat/librtmp.c @@ -24,7 +24,9 @@ * RTMP protocol based on http://rtmpdump.mplayerhq.hu/ librtmp */ +#include "libavutil/mathematics.h" #include "avformat.h" +#include "url.h" #include #include @@ -50,7 +52,6 @@ static int rtmp_close(URLContext *s) RTMP *r = s->priv_data; RTMP_Close(r); - av_free(r); return 0; } @@ -68,13 +69,9 @@ static int rtmp_close(URLContext *s) */ static int rtmp_open(URLContext *s, const char *uri, int flags) { - RTMP *r; + RTMP *r = s->priv_data; int rc; - r = av_mallocz(sizeof(RTMP)); - if (!r) - return AVERROR(ENOMEM); - switch (av_log_get_level()) { default: case AV_LOG_FATAL: rc = RTMP_LOGCRIT; break; @@ -93,7 +90,7 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) goto fail; } - if (flags & AVIO_WRONLY) + if (flags & AVIO_FLAG_WRITE) RTMP_EnableWrite(r); if (!RTMP_Connect(r, NULL) || !RTMP_ConnectStream(r, 0)) { @@ -101,11 +98,9 @@ static int rtmp_open(URLContext *s, const char *uri, int flags) goto fail; } - s->priv_data = r; s->is_streamed = 1; return 0; fail: - av_free(r); return rc; } @@ -158,66 +153,66 @@ static int rtmp_get_file_handle(URLContext *s) } URLProtocol ff_rtmp_protocol = { - "rtmp", - rtmp_open, - rtmp_read, - rtmp_write, - NULL, /* seek */ - rtmp_close, - NULL, /* next */ - rtmp_read_pause, - rtmp_read_seek, - rtmp_get_file_handle + .name = "rtmp", + .url_open = rtmp_open, + .url_read = rtmp_read, + .url_write = rtmp_write, + .url_close = rtmp_close, + .url_read_pause = rtmp_read_pause, + .url_read_seek = rtmp_read_seek, + .url_get_file_handle = rtmp_get_file_handle, + .priv_data_size = sizeof(RTMP), + .flags = URL_PROTOCOL_FLAG_NETWORK, }; URLProtocol ff_rtmpt_protocol = { - "rtmpt", - rtmp_open, - rtmp_read, - rtmp_write, - NULL, /* seek */ - rtmp_close, - NULL, /* next */ - rtmp_read_pause, - rtmp_read_seek, - rtmp_get_file_handle + .name = "rtmpt", + .url_open = rtmp_open, + .url_read = rtmp_read, + .url_write = rtmp_write, + .url_close = rtmp_close, + .url_read_pause = rtmp_read_pause, + .url_read_seek = rtmp_read_seek, + .url_get_file_handle = rtmp_get_file_handle, + .priv_data_size = sizeof(RTMP), + .flags = URL_PROTOCOL_FLAG_NETWORK, }; URLProtocol ff_rtmpe_protocol = { - "rtmpe", - rtmp_open, - rtmp_read, - rtmp_write, - NULL, /* seek */ - rtmp_close, - NULL, /* next */ - rtmp_read_pause, - rtmp_read_seek, - rtmp_get_file_handle + .name = "rtmpe", + .url_open = rtmp_open, + .url_read = rtmp_read, + .url_write = rtmp_write, + .url_close = rtmp_close, + .url_read_pause = rtmp_read_pause, + .url_read_seek = rtmp_read_seek, + .url_get_file_handle = rtmp_get_file_handle, + .priv_data_size = sizeof(RTMP), + .flags = URL_PROTOCOL_FLAG_NETWORK, }; URLProtocol ff_rtmpte_protocol = { - "rtmpte", - rtmp_open, - rtmp_read, - rtmp_write, - NULL, /* seek */ - rtmp_close, - NULL, /* next */ - rtmp_read_pause, - rtmp_read_seek, - rtmp_get_file_handle + .name = "rtmpte", + .url_open = rtmp_open, + .url_read = rtmp_read, + .url_write = rtmp_write, + .url_close = rtmp_close, + .url_read_pause = rtmp_read_pause, + .url_read_seek = rtmp_read_seek, + .url_get_file_handle = rtmp_get_file_handle, + .priv_data_size = sizeof(RTMP), + .flags = URL_PROTOCOL_FLAG_NETWORK, }; URLProtocol ff_rtmps_protocol = { - "rtmps", - rtmp_open, - rtmp_read, - rtmp_write, - NULL, /* seek */ - rtmp_close, - NULL, /* next */ - rtmp_read_pause, - rtmp_read_seek, - rtmp_get_file_handle + .name = "rtmps", + .url_open = rtmp_open, + .url_read = rtmp_read, + .url_write = rtmp_write, + .url_close = rtmp_close, + .url_read_pause = rtmp_read_pause, + .url_read_seek = rtmp_read_seek, + .url_get_file_handle = rtmp_get_file_handle, + .priv_data_size = sizeof(RTMP), + .flags = URL_PROTOCOL_FLAG_NETWORK, };