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
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 else2392 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 }
libavformat/avio.h+3−14
@@ -448,6 +448,7 @@ attribute_deprecated int url_fprintf(AVIOContext *s, const char *fmt, ...); · 447 unmodified lines
448#endif448#endif
449attribute_deprecated void put_flush_packet(AVIOContext *s);449attribute_deprecated void put_flush_packet(AVIOContext *s);
450attribute_deprecated int url_open_dyn_buf(AVIOContext **s);450attribute_deprecated int url_open_dyn_buf(AVIOContext **s);
451attribute_deprecated int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
451attribute_deprecated int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);452attribute_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 */
685int avio_open_dyn_buf(AVIOContext **s);686int 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 */
696int 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 buffer689 * Return the written size and a pointer to the buffer. The buffer
700 * must be freed with av_free(). If the buffer is opened with690 * must be freed with av_free().
701 * avio_open_dyn_buf, then padding of FF_INPUT_BUFFER_PADDING_SIZE is691 * 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 context693 * @param s IO context
705 * @param pbuffer pointer to a byte buffer694 * @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
81unsigned long ff_crc04C11DB7_update(unsigned long checksum, const uint8_t *buf,81unsigned 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 */
93int ffio_open_dyn_packet_buf(AVIOContext **s, int max_packet_size);
94
84#endif // AVFORMAT_AVIO_INTERNAL_H95#endif // AVFORMAT_AVIO_INTERNAL_H
libavformat/aviobuf.c+5−1
@@ -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}
426int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size)
427{
428 return ffio_open_dyn_packet_buf(s, max_packet_size);
429}
426int url_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer)430int 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
1163int url_open_dyn_packet_buf(AVIOContext **s, int max_packet_size)1167int 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;
libavformat/movenchint.c+2−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
27int ff_mov_init_hinting(AVFormatContext *s, int index, int src_index)28int 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 buffer410 /* 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
libavformat/rtpdec.c+1−1
@@ -41,7 +41,7 @@ · 40 unmodified lines
41 buffer to 'rtp_write_packet' contains all the packets for ONE41 buffer to 'rtp_write_packet' contains all the packets for ONE
42 frame. Each packet should have a four byte header containing42 frame. Each packet should have a four byte header containing
43 the length in big endian format (same trick as43 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
47static RTPDynamicProtocolHandler ff_realmedia_mp3_dynamic_handler = {47static RTPDynamicProtocolHandler ff_realmedia_mp3_dynamic_handler = {
libavformat/rtpenc_chain.c+2−1
@@ -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
25AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,26AVFormatContext *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 } else58 } 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) {
libavformat/rtspenc.c+3−2
@@ -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 be144 /* The interleaving header is exactly 4 bytes, which happens to be
144 * the same size as the packet length header from145 * the same size as the packet length header from
145 * url_open_dyn_packet_buf. So by writing the interleaving header146 * ffio_open_dyn_packet_buf. So by writing the interleaving header
146 * over these bytes, we get a consecutive interleaved packet147 * 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

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