History

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.

Anton Khirnov committed 15 years ago

Commit 403ee831 parent 6dc7d808 files · +31 −22Browse files

Unified · Split

8 files
  1. ffserver.c +4 −2
  2. libavformat/avio.h +3 −14
  3. libavformat/avio_internal.h +11 −0
  4. libavformat/aviobuf.c +5 −1
  5. libavformat/movenchint.c +2 −1
  6. libavformat/rtpdec.c +1 −1
  7. libavformat/rtpenc_chain.c +2 −1
  8. libavformat/rtspenc.c +3 −2
ffserver.c+4−2
@@ -33,6 +33,8 @@ · 32 unmodified lines
3333 #include "libavformat/os_support.h"
3434 #include "libavformat/rtpdec.h"
3535 #include "libavformat/rtsp.h"
36+// XXX for ffio_open_dyn_packet_buffer, to be removed
37+#include "libavformat/avio_internal.h"
3638 #include "libavutil/avstring.h"
3739 #include "libavutil/lfg.h"
3840 #include "libavutil/random_seed.h"
@@ -2389,7 +2391,7 @@ static int http_prepare_data(HTTPContext *c) · 2350 unmodified lines
23892391 max_packet_size = RTSP_TCP_MAX_PACKET_SIZE;
23902392 else
23912393 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);
23932395 } else {
23942396 ret = avio_open_dyn_buf(&ctx->pb);
23952397 }
@@ -3444,7 +3446,7 @@ static int rtp_new_av_stream(HTTPContext *c, · 1048 unmodified lines
34443446 c->stream->filename, stream_index, c->protocol);
34453447
34463448 /* 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) {
34483450 /* XXX: close stream */
34493451 goto fail;
34503452 }
libavformat/avio.h+3−14
@@ -448,6 +448,7 @@ attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...); · 447 unmodified lines
448448 #endif
449449 attribute_deprecated void put_flush_packet(AVIOContext *s);
450450 attribute_deprecated int url_open_dyn_buf(AVIOContext **s);
451+attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
451452 attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
452453 /**
453454 * @}
@@ -684,22 +685,10 @@ attribute_deprecated int url_close_buf(AVIOContext *s); · 230 unmodified lines
684685 */
685686 int avio_open_dyn_buf(AVIOContext **s);
686687
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−
698688 /**
699689 * 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.
690+ * must be freed with av_free().
691+ * Padding of FF_INPUT_BUFFER_PADDING_SIZE is added to the buffer.
703692 *
704693 * @param s IO context
705694 * @param pbuffer pointer to a byte buffer
libavformat/avio_internal.h+11−0
@@ -81,4 +81,15 @@ unsigned long ffio_get_checksum(AVIOContext *s); · 80 unmodified lines
8181 unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,
8282 unsigned int len);
8383
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+
8495 #endif // AVFORMAT_AVIO_INTERNAL_H
libavformat/aviobuf.c+5−1
@@ -423,6 +423,10 @@ int url_open_dyn_buf(AVIOContext **s) · 422 unmodified lines
423423 {
424424 return avio_open_dyn_buf(s);
425425 }
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+}
426430 int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)
427431 {
428432 return avio_close_dyn_buf(s, pbuffer);
@@ -1160,7 +1164,7 @@ int avio_open_dyn_buf(AVIOContext **s) · 731 unmodified lines
11601164 return url_open_dyn_buf_internal(s, 0);
11611165 }
11621166
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)
11641168 {
11651169 if (max_packet_size <= 0)
11661170 return -1;
libavformat/movenchint.c+2−1
@@ -23,6 +23,7 @@ · 22 unmodified lines
2323 #include "libavutil/intreadwrite.h"
2424 #include "internal.h"
2525 #include "rtpenc_chain.h"
26+#include "avio_internal.h"
2627
2728 int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index)
2829 {
@@ -409,7 +410,7 @@ int ff_mov_add_hinted_packet(AVFormatContext *s, AVPacket *pkt, · 380 unmodified lines
409410 /* Fetch the output from the RTP muxer, open a new output buffer
410411 * for next time. */
411412 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,
413414 RTP_MAX_PACKET_SIZE)) < 0)
414415 goto done;
415416
libavformat/rtpdec.c+1−1
@@ -41,7 +41,7 @@ · 40 unmodified lines
4141 buffer to 'rtp_write_packet' contains all the packets for ONE
4242 frame. Each packet should have a four byte header containing
4343 the length in big endian format (same trick as
44− 'url_open_dyn_packet_buf')
44+ 'ffio_open_dyn_packet_buf')
4545 */
4646
4747 static RTPDynamicProtocolHandler ff_realmedia_mp3_dynamic_handler = {
libavformat/rtpenc_chain.c+2−1
@@ -21,6 +21,7 @@ · 20 unmodified lines
2121
2222 #include "avformat.h"
2323 #include "rtpenc_chain.h"
24+#include "avio_internal.h"
2425
2526 AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
2627 URLContext *handle, int packet_size)
@@ -55,7 +56,7 @@ AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st, · 28 unmodified lines
5556 if (handle) {
5657 url_fdopen(&rtpctx->pb, handle);
5758 } else
58− url_open_dyn_packet_buf(&rtpctx->pb, packet_size);
59+ ffio_open_dyn_packet_buf(&rtpctx->pb, packet_size);
5960 ret = av_write_header(rtpctx);
6061
6162 if (ret) {
libavformat/rtspenc.c+3−2
@@ -29,6 +29,7 @@ · 28 unmodified lines
2929 #include "os_support.h"
3030 #include "rtsp.h"
3131 #include "internal.h"
32+#include "avio_internal.h"
3233 #include "libavutil/intreadwrite.h"
3334 #include "libavutil/avstring.h"
3435
@@ -142,7 +143,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) · 107 unmodified lines
142143 int id;
143144 /* The interleaving header is exactly 4 bytes, which happens to be
144145 * 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
146147 * over these bytes, we get a consecutive interleaved packet
147148 * that can be written in one call. */
148149 interleaved_packet = interleave_header = ptr;
@@ -162,7 +163,7 @@ static int tcp_write_packet(AVFormatContext *s, RTSPStream *rtsp_st) · 13 unmodified lines
162163 size -= packet_len;
163164 }
164165 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);
166167 return 0;
167168 }
168169

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t