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.
Unified · Split
| @@ -33,6 +33,8 @@ · 32 unmodified lines | |||
| 33 | #include "libavformat/os_support.h" | 33 | #include "libavformat/os_support.h" |
| 34 | #include "libavformat/rtpdec.h" | 34 | #include "libavformat/rtpdec.h" |
| 35 | #include "libavformat/rtsp.h" | 35 | #include "libavformat/rtsp.h" |
| 36 | // XXX for ffio_open_dyn_packet_buffer, to be removed | ||
| 37 | #include "libavformat/avio_internal.h" | ||
| 36 | #include "libavutil/avstring.h" | 38 | #include "libavutil/avstring.h" |
| 37 | #include "libavutil/lfg.h" | 39 | #include "libavutil/lfg.h" |
| 38 | #include "libavutil/random_seed.h" | 40 | #include "libavutil/random_seed.h" |
| @@ -2389,7 +2391,7 @@ static int http_prepare_data(HTTPContext *c) · 2350 unmodified lines | |||
| 2389 | max_packet_size = RTSP_TCP_MAX_PACKET_SIZE; | 2391 | max_packet_size = RTSP_TCP_MAX_PACKET_SIZE; |
| 2390 | else | 2392 | else |
| 2391 | max_packet_size = url_get_max_packet_size(c->rtp_handles[c->packet_stream_index]); | 2393 | max_packet_size = url_get_max_packet_size(c->rtp_handles[c->packet_stream_index]); |
| 2392 | ret = url_open_dyn_packet_buf(&ctx->pb, max_packet_size); | 2394 | ret = ffio_open_dyn_packet_buf(&ctx->pb, max_packet_size); |
| 2393 | } else { | 2395 | } else { |
| 2394 | ret = avio_open_dyn_buf(&ctx->pb); | 2396 | ret = avio_open_dyn_buf(&ctx->pb); |
| 2395 | } | 2397 | } |
| @@ -3444,7 +3446,7 @@ static int rtp_new_av_stream(HTTPContext *c, · 1048 unmodified lines | |||
| 3444 | c->stream->filename, stream_index, c->protocol); | 3446 | c->stream->filename, stream_index, c->protocol); |
| 3445 | 3447 | ||
| 3446 | /* normally, no packets should be output here, but the packet size may be checked */ | 3448 | /* normally, no packets should be output here, but the packet size may be checked */ |
| 3447 | if (url_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) { | 3449 | if (ffio_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) { |
| 3448 | /* XXX: close stream */ | 3450 | /* XXX: close stream */ |
| 3449 | goto fail; | 3451 | goto fail; |
| 3450 | } | 3452 | } |
| @@ -448,6 +448,7 @@ attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...); · 447 unmodified lines | |||
| 448 | #endif | 448 | #endif |
| 449 | attribute_deprecated void put_flush_packet(AVIOContext *s); | 449 | attribute_deprecated void put_flush_packet(AVIOContext *s); |
| 450 | attribute_deprecated int url_open_dyn_buf(AVIOContext **s); | 450 | attribute_deprecated int url_open_dyn_buf(AVIOContext **s); |
| 451 | attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); | ||
| 451 | attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); | 452 | attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); |
| 452 | /** | 453 | /** |
| 453 | * @} | 454 | * @} |
| @@ -684,22 +685,10 @@ attribute_deprecated int url_close_buf(AVIOContext *s); · 230 unmodified lines | |||
| 684 | */ | 685 | */ |
| 685 | int avio_open_dyn_buf(AVIOContext **s); | 686 | int avio_open_dyn_buf(AVIOContext **s); |
| 686 | 687 | ||
| 687 | /** | ||
| 688 | * Open a write only packetized memory stream with a maximum packet | ||
| 689 | * size of 'max_packet_size'. The stream is stored in a memory buffer | ||
| 690 | * with a big endian 4 byte header giving the packet size in bytes. | ||
| 691 | * | ||
| 692 | * @param s new IO context | ||
| 693 | * @param max_packet_size maximum packet size (must be > 0) | ||
| 694 | * @return zero if no error. | ||
| 695 | */ | ||
| 696 | int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); | ||
| 697 | |||
| 698 | /** | 688 | /** |
| 699 | * Return the written size and a pointer to the buffer. The buffer | 689 | * Return the written size and a pointer to the buffer. The buffer |
| 700 | * must be freed with av_free(). If the buffer is opened with | 690 | * must be freed with av_free(). |
| 701 | * avio_open_dyn_buf, then padding of FF_INPUT_BUFFER_PADDING_SIZE is | 691 | * Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer. |
| 702 | * added; if opened with url_open_dyn_packet_buf, no padding is added. | ||
| 703 | * | 692 | * |
| 704 | * @param s IO context | 693 | * @param s IO context |
| 705 | * @param pbuffer pointer to a byte buffer | 694 | * @param pbuffer pointer to a byte buffer |
| @@ -81,4 +81,15 @@ unsigned long ffio_get_checksum(AVIOContext *s); · 80 unmodified lines | |||
| 81 | unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, | 81 | unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, |
| 82 | unsigned int len); | 82 | unsigned int len); |
| 83 | 83 | ||
| 84 | /** | ||
| 85 | * Open a write only packetized memory stream with a maximum packet | ||
| 86 | * size of 'max_packet_size'. The stream is stored in a memory buffer | ||
| 87 | * with a big endian 4 byte header giving the packet size in bytes. | ||
| 88 | * | ||
| 89 | * @param s new IO context | ||
| 90 | * @param max_packet_size maximum packet size (must be > 0) | ||
| 91 | * @return zero if no error. | ||
| 92 | */ | ||
| 93 | int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size); | ||
| 94 | |||
| 84 | #endif // AVFORMAT_AVIO_INTERNAL_H | 95 | #endif // AVFORMAT_AVIO_INTERNAL_H |
| @@ -423,6 +423,10 @@ int url_open_dyn_buf(AVIOContext **s) · 422 unmodified lines | |||
| 423 | { | 423 | { |
| 424 | return avio_open_dyn_buf(s); | 424 | return avio_open_dyn_buf(s); |
| 425 | } | 425 | } |
| 426 | int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) | ||
| 427 | { | ||
| 428 | return ffio_open_dyn_packet_buf(s, max_packet_size); | ||
| 429 | } | ||
| 426 | int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) | 430 | int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) |
| 427 | { | 431 | { |
| 428 | return avio_close_dyn_buf(s, pbuffer); | 432 | return avio_close_dyn_buf(s, pbuffer); |
| @@ -1160,7 +1164,7 @@ int avio_open_dyn_buf(AVIOContext **s) · 731 unmodified lines | |||
| 1160 | return url_open_dyn_buf_internal(s, 0); | 1164 | return url_open_dyn_buf_internal(s, 0); |
| 1161 | } | 1165 | } |
| 1162 | 1166 | ||
| 1163 | int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) | 1167 | int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) |
| 1164 | { | 1168 | { |
| 1165 | if (max_packet_size <= 0) | 1169 | if (max_packet_size <= 0) |
| 1166 | return -1; | 1170 | return -1; |
| @@ -23,6 +23,7 @@ · 22 unmodified lines | |||
| 23 | #include "libavutil/intreadwrite.h" | 23 | #include "libavutil/intreadwrite.h" |
| 24 | #include "internal.h" | 24 | #include "internal.h" |
| 25 | #include "rtpenc_chain.h" | 25 | #include "rtpenc_chain.h" |
| 26 | #include "avio_internal.h" | ||
| 26 | 27 | ||
| 27 | int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index) | 28 | int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index) |
| 28 | { | 29 | { |
| @@ -409,7 +410,7 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, · 380 unmodified lines | |||
| 409 | /* Fetch the output from the RTP muxer, open a new output buffer | 410 | /* Fetch the output from the RTP muxer, open a new output buffer |
| 410 | * for next time. */ | 411 | * for next time. */ |
| 411 | size = avio_close_dyn_buf(rtp_ctx->pb, &buf); | 412 | size = avio_close_dyn_buf(rtp_ctx->pb, &buf); |
| 412 | if ((ret = url_open_dyn_packet_buf(&rtp_ctx->pb, | 413 | if ((ret = ffio_open_dyn_packet_buf(&rtp_ctx->pb, |
| 413 | RTP_MAX_PACKET_SIZE)) < 0) | 414 | RTP_MAX_PACKET_SIZE)) < 0) |
| 414 | goto done; | 415 | goto done; |
| 415 | 416 | ||
| @@ -41,7 +41,7 @@ · 40 unmodified lines | |||
| 41 | buffer to 'rtp_write_packet' contains all the packets for ONE | 41 | buffer to 'rtp_write_packet' contains all the packets for ONE |
| 42 | frame. Each packet should have a four byte header containing | 42 | frame. Each packet should have a four byte header containing |
| 43 | the length in big endian format (same trick as | 43 | the length in big endian format (same trick as |
| 44 | 'url_open_dyn_packet_buf') | 44 | 'ffio_open_dyn_packet_buf') |
| 45 | */ | 45 | */ |
| 46 | 46 | ||
| 47 | static RTPDynamicProtocolHandler ff_realmedia_mp3_dynamic_handler = { | 47 | static RTPDynamicProtocolHandler ff_realmedia_mp3_dynamic_handler = { |
| @@ -21,6 +21,7 @@ · 20 unmodified lines | |||
| 21 | 21 | ||
| 22 | #include "avformat.h" | 22 | #include "avformat.h" |
| 23 | #include "rtpenc_chain.h" | 23 | #include "rtpenc_chain.h" |
| 24 | #include "avio_internal.h" | ||
| 24 | 25 | ||
| 25 | AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, | 26 | AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, |
| 26 | URLContext *handle, int packet_size) | 27 | URLContext *handle, int packet_size) |
| @@ -55,7 +56,7 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, · 28 unmodified lines | |||
| 55 | if (handle) { | 56 | if (handle) { |
| 56 | url_fdopen(&rtpctx->pb, handle); | 57 | url_fdopen(&rtpctx->pb, handle); |
| 57 | } else | 58 | } else |
| 58 | url_open_dyn_packet_buf(&rtpctx->pb, packet_size); | 59 | ffio_open_dyn_packet_buf(&rtpctx->pb, packet_size); |
| 59 | ret = av_write_header(rtpctx); | 60 | ret = av_write_header(rtpctx); |
| 60 | 61 | ||
| 61 | if (ret) { | 62 | if (ret) { |
| @@ -29,6 +29,7 @@ · 28 unmodified lines | |||
| 29 | #include "os_support.h" | 29 | #include "os_support.h" |
| 30 | #include "rtsp.h" | 30 | #include "rtsp.h" |
| 31 | #include "internal.h" | 31 | #include "internal.h" |
| 32 | #include "avio_internal.h" | ||
| 32 | #include "libavutil/intreadwrite.h" | 33 | #include "libavutil/intreadwrite.h" |
| 33 | #include "libavutil/avstring.h" | 34 | #include "libavutil/avstring.h" |
| 34 | 35 | ||
| @@ -142,7 +143,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) · 107 unmodified lines | |||
| 142 | int id; | 143 | int id; |
| 143 | /* The interleaving header is exactly 4 bytes, which happens to be | 144 | /* The interleaving header is exactly 4 bytes, which happens to be |
| 144 | * the same size as the packet length header from | 145 | * the same size as the packet length header from |
| 145 | * url_open_dyn_packet_buf. So by writing the interleaving header | 146 | * ffio_open_dyn_packet_buf. So by writing the interleaving header |
| 146 | * over these bytes, we get a consecutive interleaved packet | 147 | * over these bytes, we get a consecutive interleaved packet |
| 147 | * that can be written in one call. */ | 148 | * that can be written in one call. */ |
| 148 | interleaved_packet = interleave_header = ptr; | 149 | interleaved_packet = interleave_header = ptr; |
| @@ -162,7 +163,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) · 13 unmodified lines | |||
| 162 | size -= packet_len; | 163 | size -= packet_len; |
| 163 | } | 164 | } |
| 164 | av_free(buf); | 165 | av_free(buf); |
| 165 | url_open_dyn_packet_buf(&rtpctx->pb, RTSP_TCP_MAX_PACKET_SIZE); | 166 | ffio_open_dyn_packet_buf(&rtpctx->pb, RTSP_TCP_MAX_PACKET_SIZE); |
| 166 | return 0; | 167 | return 0; |
| 167 | } | 168 | } |
| 168 | 169 | ||