From 6dc7d80de7236d04a6ee30f0e4cd03f055893bcf Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 17 Mar 2011 08:16:07 +0100 Subject: avio: avio_ prefix for url_close_dyn_buf --- libavformat/rtpenc_chain.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libavformat/rtpenc_chain.c') diff --git a/libavformat/rtpenc_chain.c b/libavformat/rtpenc_chain.c index a22804130f..77633ed53e 100644 --- a/libavformat/rtpenc_chain.c +++ b/libavformat/rtpenc_chain.c @@ -63,7 +63,7 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, avio_close(rtpctx->pb); } else { uint8_t *ptr; - url_close_dyn_buf(rtpctx->pb, &ptr); + avio_close_dyn_buf(rtpctx->pb, &ptr); av_free(ptr); } avformat_free_context(rtpctx); -- cgit v1.2.3 From 403ee835e7913eb9536b22c2b22edfdd700166a9 Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 17 Mar 2011 08:19:54 +0100 Subject: avio: make url_open_dyn_packet_buf internal. It doesn't look fit to be a part of the public API. Adding a temporary hack to ffserver to be able to use it, should be cleaned up when somebody is up for it. --- ffserver.c | 6 ++++-- libavformat/avio.h | 17 +++-------------- libavformat/avio_internal.h | 11 +++++++++++ libavformat/aviobuf.c | 6 +++++- libavformat/movenchint.c | 3 ++- libavformat/rtpdec.c | 2 +- libavformat/rtpenc_chain.c | 3 ++- libavformat/rtspenc.c | 5 +++-- 8 files changed, 31 insertions(+), 22 deletions(-) (limited to 'libavformat/rtpenc_chain.c') diff --git a/ffserver.c b/ffserver.c index 0ee61e2e50..3ad40e9bfb 100644 --- a/ffserver.c +++ b/ffserver.c @@ -33,6 +33,8 @@ #include "libavformat/os_support.h" #include "libavformat/rtpdec.h" #include "libavformat/rtsp.h" +// XXX for ffio_open_dyn_packet_buffer, to be removed +#include "libavformat/avio_internal.h" #include "libavutil/avstring.h" #include "libavutil/lfg.h" #include "libavutil/random_seed.h" @@ -2389,7 +2391,7 @@ static int http_prepare_data(HTTPContext *c) max_packet_size = RTSP_TCP_MAX_PACKET_SIZE; else max_packet_size = url_get_max_packet_size(c->rtp_handles[c->packet_stream_index]); - ret = url_open_dyn_packet_buf(&ctx->pb, max_packet_size); + ret = ffio_open_dyn_packet_buf(&ctx->pb, max_packet_size); } else { ret = avio_open_dyn_buf(&ctx->pb); } @@ -3444,7 +3446,7 @@ static int rtp_new_av_stream(HTTPContext *c, c->stream->filename, stream_index, c->protocol); /* normally, no packets should be output here, but the packet size may be checked */ - if (url_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) { + if (ffio_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) { /* XXX: close stream */ goto fail; } diff --git a/libavformat/avio.h b/libavformat/avio.h index 5bc85827d1..69896d1404 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -448,6 +448,7 @@ attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...); #endif attribute_deprecated void put_flush_packet(AVIOContext *s); attribute_deprecated int url_open_dyn_buf(AVIOContext **s); +attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); /** * @} @@ -684,22 +685,10 @@ attribute_deprecated int url_close_buf(AVIOContext *s); */ int avio_open_dyn_buf(AVIOContext **s); -/** - * Open a write only packetized memory stream with a maximum packet - * size of 'max_packet_size'. The stream is stored in a memory buffer - * with a big endian 4 byte header giving the packet size in bytes. - * - * @param s new IO context - * @param max_packet_size maximum packet size (must be > 0) - * @return zero if no error. - */ -int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); - /** * Return the written size and a pointer to the buffer. The buffer - * must be freed with av_free(). If the buffer is opened with - * avio_open_dyn_buf, then padding of FF_INPUT_BUFFER_PADDING_SIZE is - * added; if opened with url_open_dyn_packet_buf, no padding is added. + * must be freed with av_free(). + * Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer. * * @param s IO context * @param pbuffer pointer to a byte buffer diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 916de8fcc7..29553ed614 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -81,4 +81,15 @@ unsigned long ffio_get_checksum(AVIOContext *s); unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, unsigned int len); +/** + * Open a write only packetized memory stream with a maximum packet + * size of 'max_packet_size'. The stream is stored in a memory buffer + * with a big endian 4 byte header giving the packet size in bytes. + * + * @param s new IO context + * @param max_packet_size maximum packet size (must be > 0) + * @return zero if no error. + */ +int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); + #endif // AVFORMAT_AVIO_INTERNAL_H diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index cb5f2790f7..73045e6599 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -423,6 +423,10 @@ int url_open_dyn_buf(AVIOContext **s) { return avio_open_dyn_buf(s); } +int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) +{ + return ffio_open_dyn_packet_buf(s, max_packet_size); +} int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) { return avio_close_dyn_buf(s, pbuffer); @@ -1160,7 +1164,7 @@ int avio_open_dyn_buf(AVIOContext **s) return url_open_dyn_buf_internal(s, 0); } -int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) +int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) { if (max_packet_size <= 0) return -1; diff --git a/libavformat/movenchint.c b/libavformat/movenchint.c index eb93ef8d7e..615714627c 100644 --- a/libavformat/movenchint.c +++ b/libavformat/movenchint.c @@ -23,6 +23,7 @@ #include "libavutil/intreadwrite.h" #include "internal.h" #include "rtpenc_chain.h" +#include "avio_internal.h" int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index) { @@ -409,7 +410,7 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, /* Fetch the output from the RTP muxer, open a new output buffer * for next time. */ size = avio_close_dyn_buf(rtp_ctx->pb, &buf); - if ((ret = url_open_dyn_packet_buf(&rtp_ctx->pb, + if ((ret = ffio_open_dyn_packet_buf(&rtp_ctx->pb, RTP_MAX_PACKET_SIZE)) < 0) goto done; diff --git a/libavformat/rtpdec.c b/libavformat/rtpdec.c index bbd5f338ed..281f51c443 100644 --- a/libavformat/rtpdec.c +++ b/libavformat/rtpdec.c @@ -41,7 +41,7 @@ buffer to 'rtp_write_packet' contains all the packets for ONE frame. Each packet should have a four byte header containing the length in big endian format (same trick as - 'url_open_dyn_packet_buf') + 'ffio_open_dyn_packet_buf') */ static RTPDynamicProtocolHandler ff_realmedia_mp3_dynamic_handler = { diff --git a/libavformat/rtpenc_chain.c b/libavformat/rtpenc_chain.c index 77633ed53e..a923b2deb6 100644 --- a/libavformat/rtpenc_chain.c +++ b/libavformat/rtpenc_chain.c @@ -21,6 +21,7 @@ #include "avformat.h" #include "rtpenc_chain.h" +#include "avio_internal.h" AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, URLContext *handle, int packet_size) @@ -55,7 +56,7 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, if (handle) { url_fdopen(&rtpctx->pb, handle); } else - url_open_dyn_packet_buf(&rtpctx->pb, packet_size); + ffio_open_dyn_packet_buf(&rtpctx->pb, packet_size); ret = av_write_header(rtpctx); if (ret) { diff --git a/libavformat/rtspenc.c b/libavformat/rtspenc.c index e3631c4290..7f52b1fdb1 100644 --- a/libavformat/rtspenc.c +++ b/libavformat/rtspenc.c @@ -29,6 +29,7 @@ #include "os_support.h" #include "rtsp.h" #include "internal.h" +#include "avio_internal.h" #include "libavutil/intreadwrite.h" #include "libavutil/avstring.h" @@ -142,7 +143,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) int id; /* The interleaving header is exactly 4 bytes, which happens to be * the same size as the packet length header from - * url_open_dyn_packet_buf. So by writing the interleaving header + * ffio_open_dyn_packet_buf. So by writing the interleaving header * over these bytes, we get a consecutive interleaved packet * that can be written in one call. */ interleaved_packet = interleave_header = ptr; @@ -162,7 +163,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) size -= packet_len; } av_free(buf); - url_open_dyn_packet_buf(&rtpctx->pb, RTSP_TCP_MAX_PACKET_SIZE); + ffio_open_dyn_packet_buf(&rtpctx->pb, RTSP_TCP_MAX_PACKET_SIZE); return 0; } -- cgit v1.2.3 From 724f6a0fa43f615dcebb2cb16ccb7c60ef7ec95c Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 17 Mar 2011 08:44:44 +0100 Subject: avio: make url_fdopen internal. The unbuffered URLContext API will be made private, so there's no point in this function being public. --- libavformat/avio.h | 14 +------------- libavformat/avio_internal.h | 13 +++++++++++++ libavformat/aviobuf.c | 8 ++++++-- libavformat/rtpenc_chain.c | 3 ++- 4 files changed, 22 insertions(+), 16 deletions(-) (limited to 'libavformat/rtpenc_chain.c') diff --git a/libavformat/avio.h b/libavformat/avio.h index 69896d1404..ce6429cef5 100644 --- a/libavformat/avio.h +++ b/libavformat/avio.h @@ -450,6 +450,7 @@ attribute_deprecated void put_flush_packet(AVIOContext *s); attribute_deprecated int url_open_dyn_buf(AVIOContext **s); attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); +attribute_deprecated int url_fdopen(AVIOContext **s, URLContext *h); /** * @} */ @@ -625,19 +626,6 @@ attribute_deprecated static inline int url_is_streamed(AVIOContext *s) } #endif -/** - * Create and initialize a AVIOContext for accessing the - * resource referenced by the URLContext h. - * @note When the URLContext h has been opened in read+write mode, the - * AVIOContext can be used only for writing. - * - * @param s Used to return the pointer to the created AVIOContext. - * In case of failure the pointed to value is set to NULL. - * @return 0 in case of success, a negative value corresponding to an - * AVERROR code in case of failure - */ -int url_fdopen(AVIOContext **s, URLContext *h); - #if FF_API_URL_RESETBUF /** Reset the buffer for reading or writing. * @note Will drop any data currently in the buffer without transmitting it. diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h index 29553ed614..b0f96cfa53 100644 --- a/libavformat/avio_internal.h +++ b/libavformat/avio_internal.h @@ -92,4 +92,17 @@ unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, */ int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); +/** + * Create and initialize a AVIOContext for accessing the + * resource referenced by the URLContext h. + * @note When the URLContext h has been opened in read+write mode, the + * AVIOContext can be used only for writing. + * + * @param s Used to return the pointer to the created AVIOContext. + * In case of failure the pointed to value is set to NULL. + * @return 0 in case of success, a negative value corresponding to an + * AVERROR code in case of failure + */ +int ffio_fdopen(AVIOContext **s, URLContext *h); + #endif // AVFORMAT_AVIO_INTERNAL_H diff --git a/libavformat/aviobuf.c b/libavformat/aviobuf.c index 73045e6599..ad969ae72e 100644 --- a/libavformat/aviobuf.c +++ b/libavformat/aviobuf.c @@ -431,6 +431,10 @@ int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) { return avio_close_dyn_buf(s, pbuffer); } +int url_fdopen(AVIOContext **s, URLContext *h) +{ + return ffio_fdopen(s, h); +} #endif int avio_put_str(AVIOContext *s, const char *str) @@ -818,7 +822,7 @@ uint64_t ffio_read_varlen(AVIOContext *bc){ return val; } -int url_fdopen(AVIOContext **s, URLContext *h) +int ffio_fdopen(AVIOContext **s, URLContext *h) { uint8_t *buffer; int buffer_size, max_packet_size; @@ -943,7 +947,7 @@ int avio_open(AVIOContext **s, const char *filename, int flags) err = url_open(&h, filename, flags); if (err < 0) return err; - err = url_fdopen(s, h); + err = ffio_fdopen(s, h); if (err < 0) { url_close(h); return err; diff --git a/libavformat/rtpenc_chain.c b/libavformat/rtpenc_chain.c index a923b2deb6..1727740f0f 100644 --- a/libavformat/rtpenc_chain.c +++ b/libavformat/rtpenc_chain.c @@ -20,6 +20,7 @@ */ #include "avformat.h" +#include "avio_internal.h" #include "rtpenc_chain.h" #include "avio_internal.h" @@ -54,7 +55,7 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, avcodec_copy_context(rtpctx->streams[0]->codec, st->codec); if (handle) { - url_fdopen(&rtpctx->pb, handle); + ffio_fdopen(&rtpctx->pb, handle); } else ffio_open_dyn_packet_buf(&rtpctx->pb, packet_size); ret = av_write_header(rtpctx); -- cgit v1.2.3