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.
| ... | ... |
@@ -33,6 +33,8 @@ |
| 33 | 33 |
#include "libavformat/os_support.h" |
| 34 | 34 |
#include "libavformat/rtpdec.h" |
| 35 | 35 |
#include "libavformat/rtsp.h" |
| 36 |
+// XXX for ffio_open_dyn_packet_buffer, to be removed |
|
| 37 |
+#include "libavformat/avio_internal.h" |
|
| 36 | 38 |
#include "libavutil/avstring.h" |
| 37 | 39 |
#include "libavutil/lfg.h" |
| 38 | 40 |
#include "libavutil/random_seed.h" |
| ... | ... |
@@ -2389,7 +2391,7 @@ static int http_prepare_data(HTTPContext *c) |
| 2389 | 2389 |
max_packet_size = RTSP_TCP_MAX_PACKET_SIZE; |
| 2390 | 2390 |
else |
| 2391 | 2391 |
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); |
|
| 2392 |
+ ret = ffio_open_dyn_packet_buf(&ctx->pb, max_packet_size); |
|
| 2393 | 2393 |
} else {
|
| 2394 | 2394 |
ret = avio_open_dyn_buf(&ctx->pb); |
| 2395 | 2395 |
} |
| ... | ... |
@@ -3444,7 +3446,7 @@ static int rtp_new_av_stream(HTTPContext *c, |
| 3444 | 3444 |
c->stream->filename, stream_index, c->protocol); |
| 3445 | 3445 |
|
| 3446 | 3446 |
/* 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) {
|
|
| 3447 |
+ if (ffio_open_dyn_packet_buf(&ctx->pb, max_packet_size) < 0) {
|
|
| 3448 | 3448 |
/* XXX: close stream */ |
| 3449 | 3449 |
goto fail; |
| 3450 | 3450 |
} |
| ... | ... |
@@ -448,6 +448,7 @@ attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...); |
| 448 | 448 |
#endif |
| 449 | 449 |
attribute_deprecated void put_flush_packet(AVIOContext *s); |
| 450 | 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 | 452 |
attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer); |
| 452 | 453 |
/** |
| 453 | 454 |
* @} |
| ... | ... |
@@ -685,21 +686,9 @@ attribute_deprecated int url_close_buf(AVIOContext *s); |
| 685 | 685 |
int avio_open_dyn_buf(AVIOContext **s); |
| 686 | 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 |
-/** |
|
| 699 | 688 |
* 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 |
|
| 701 |
- * avio_open_dyn_buf, then padding of FF_INPUT_BUFFER_PADDING_SIZE is |
|
| 702 |
- * added; if opened with url_open_dyn_packet_buf, no padding is added. |
|
| 689 |
+ * must be freed with av_free(). |
|
| 690 |
+ * Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer. |
|
| 703 | 691 |
* |
| 704 | 692 |
* @param s IO context |
| 705 | 693 |
* @param pbuffer pointer to a byte buffer |
| ... | ... |
@@ -81,4 +81,15 @@ unsigned long ffio_get_checksum(AVIOContext *s); |
| 81 | 81 |
unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf, |
| 82 | 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 | 95 |
#endif // AVFORMAT_AVIO_INTERNAL_H |
| ... | ... |
@@ -423,6 +423,10 @@ int url_open_dyn_buf(AVIOContext **s) |
| 423 | 423 |
{
|
| 424 | 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 | 430 |
int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer) |
| 427 | 431 |
{
|
| 428 | 432 |
return avio_close_dyn_buf(s, pbuffer); |
| ... | ... |
@@ -1160,7 +1164,7 @@ int avio_open_dyn_buf(AVIOContext **s) |
| 1160 | 1160 |
return url_open_dyn_buf_internal(s, 0); |
| 1161 | 1161 |
} |
| 1162 | 1162 |
|
| 1163 |
-int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) |
|
| 1163 |
+int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size) |
|
| 1164 | 1164 |
{
|
| 1165 | 1165 |
if (max_packet_size <= 0) |
| 1166 | 1166 |
return -1; |
| ... | ... |
@@ -23,6 +23,7 @@ |
| 23 | 23 |
#include "libavutil/intreadwrite.h" |
| 24 | 24 |
#include "internal.h" |
| 25 | 25 |
#include "rtpenc_chain.h" |
| 26 |
+#include "avio_internal.h" |
|
| 26 | 27 |
|
| 27 | 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, |
| 409 | 409 |
/* Fetch the output from the RTP muxer, open a new output buffer |
| 410 | 410 |
* for next time. */ |
| 411 | 411 |
size = avio_close_dyn_buf(rtp_ctx->pb, &buf); |
| 412 |
- if ((ret = url_open_dyn_packet_buf(&rtp_ctx->pb, |
|
| 412 |
+ if ((ret = ffio_open_dyn_packet_buf(&rtp_ctx->pb, |
|
| 413 | 413 |
RTP_MAX_PACKET_SIZE)) < 0) |
| 414 | 414 |
goto done; |
| 415 | 415 |
|
| ... | ... |
@@ -41,7 +41,7 @@ |
| 41 | 41 |
buffer to 'rtp_write_packet' contains all the packets for ONE |
| 42 | 42 |
frame. Each packet should have a four byte header containing |
| 43 | 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 | 47 |
static RTPDynamicProtocolHandler ff_realmedia_mp3_dynamic_handler = {
|
| ... | ... |
@@ -21,6 +21,7 @@ |
| 21 | 21 |
|
| 22 | 22 |
#include "avformat.h" |
| 23 | 23 |
#include "rtpenc_chain.h" |
| 24 |
+#include "avio_internal.h" |
|
| 24 | 25 |
|
| 25 | 26 |
AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, |
| 26 | 27 |
URLContext *handle, int packet_size) |
| ... | ... |
@@ -55,7 +56,7 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, |
| 55 | 55 |
if (handle) {
|
| 56 | 56 |
url_fdopen(&rtpctx->pb, handle); |
| 57 | 57 |
} else |
| 58 |
- url_open_dyn_packet_buf(&rtpctx->pb, packet_size); |
|
| 58 |
+ ffio_open_dyn_packet_buf(&rtpctx->pb, packet_size); |
|
| 59 | 59 |
ret = av_write_header(rtpctx); |
| 60 | 60 |
|
| 61 | 61 |
if (ret) {
|
| ... | ... |
@@ -29,6 +29,7 @@ |
| 29 | 29 |
#include "os_support.h" |
| 30 | 30 |
#include "rtsp.h" |
| 31 | 31 |
#include "internal.h" |
| 32 |
+#include "avio_internal.h" |
|
| 32 | 33 |
#include "libavutil/intreadwrite.h" |
| 33 | 34 |
#include "libavutil/avstring.h" |
| 34 | 35 |
|
| ... | ... |
@@ -142,7 +143,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) |
| 142 | 142 |
int id; |
| 143 | 143 |
/* The interleaving header is exactly 4 bytes, which happens to be |
| 144 | 144 |
* the same size as the packet length header from |
| 145 |
- * url_open_dyn_packet_buf. So by writing the interleaving header |
|
| 145 |
+ * ffio_open_dyn_packet_buf. So by writing the interleaving header |
|
| 146 | 146 |
* over these bytes, we get a consecutive interleaved packet |
| 147 | 147 |
* that can be written in one call. */ |
| 148 | 148 |
interleaved_packet = interleave_header = ptr; |
| ... | ... |
@@ -162,7 +163,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) |
| 162 | 162 |
size -= packet_len; |
| 163 | 163 |
} |
| 164 | 164 |
av_free(buf); |
| 165 |
- url_open_dyn_packet_buf(&rtpctx->pb, RTSP_TCP_MAX_PACKET_SIZE); |
|
| 165 |
+ ffio_open_dyn_packet_buf(&rtpctx->pb, RTSP_TCP_MAX_PACKET_SIZE); |
|
| 166 | 166 |
return 0; |
| 167 | 167 |
} |
| 168 | 168 |
|