Browse code

Merge remote branch 'qatar/master'

* qatar/master:
lavf: bump minor and add an APIChanges entry for avformat cleanup
lavf: get rid of ffm-specific stuff in avformat.h
Not pulled: avio: deprecate av_protocol_next().
avio: add a function for iterating though protocol names.
lavf: rename a parameter of av_sdp_create from buff->buf
lavf: rename avf_sdp_create to av_sdp_create.
lavf: make av_guess_image2_codec internal
avio: make URLProtocol internal.
avio: make URLContext internal.
lavf: mark av_pkt_dump(_log) for remove on $next+1 bump.
lavf: use designated initializers for all protocols
applehttp: don't use deprecated url_ functions.
avio: move two ff_udp_* functions from avio_internal to url.h
asfdec: remove a forgotten declaration of nonexistent function
avio: deprecate the typedef for URLInterruptCB

Merged-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2011/04/09 10:09:49
Showing 34 changed files
... ...
@@ -12,6 +12,11 @@ libavutil:   2009-03-08
12 12
 
13 13
 API changes, most recent first:
14 14
 
15
+2011-04-08 - lavf 52.106.0 - avformat.h
16
+  Minor avformat.h cleanup:
17
+    a9bf9d8 deprecate av_guess_image2_codec
18
+    c3675df rename avf_sdp_create->av_sdp_create
19
+
15 20
 2011-04-03 - lavf 52.105.0 - avio.h
16 21
   Large-scale renaming/deprecating of AVIOContext-related functions:
17 22
     724f6a0 deprecate url_fdopen
... ...
@@ -47,6 +47,8 @@
47 47
 #include "libavutil/libm.h"
48 48
 #include "libavformat/os_support.h"
49 49
 
50
+#include "libavformat/ffm.h" // not public API
51
+
50 52
 #if CONFIG_AVFILTER
51 53
 # include "libavfilter/avfilter.h"
52 54
 # include "libavfilter/avfiltergraph.h"
... ...
@@ -1881,7 +1883,7 @@ static void print_sdp(AVFormatContext **avc, int n)
1881 1881
 {
1882 1882
     char sdp[2048];
1883 1883
 
1884
-    avf_sdp_create(avc, n, sdp, sizeof(sdp));
1884
+    av_sdp_create(avc, n, sdp, sizeof(sdp));
1885 1885
     printf("SDP:\n%s\n", sdp);
1886 1886
     fflush(stdout);
1887 1887
 }
... ...
@@ -29,6 +29,7 @@
29 29
 #include <strings.h>
30 30
 #include <stdlib.h>
31 31
 #include "libavformat/avformat.h"
32
+#include "libavformat/ffm.h"
32 33
 #include "libavformat/network.h"
33 34
 #include "libavformat/os_support.h"
34 35
 #include "libavformat/rtpdec.h"
... ...
@@ -2957,7 +2958,7 @@ static int prepare_sdp_description(FFStream *stream, uint8_t **pbuffer,
2957 2957
         avc->streams[i]->codec = stream->streams[i]->codec;
2958 2958
     }
2959 2959
     *pbuffer = av_mallocz(2048);
2960
-    avf_sdp_create(&avc, 1, *pbuffer, 2048);
2960
+    av_sdp_create(&avc, 1, *pbuffer, 2048);
2961 2961
 
2962 2962
  sdp_done:
2963 2963
 #if !FF_API_MAX_STREAMS
... ...
@@ -113,7 +113,7 @@ static void free_variant_list(AppleHTTPContext *c)
113 113
         av_free_packet(&var->pkt);
114 114
         av_free(var->pb.buffer);
115 115
         if (var->input)
116
-            url_close(var->input);
116
+            ffurl_close(var->input);
117 117
         if (var->ctx) {
118 118
             var->ctx->pb = NULL;
119 119
             av_close_input_file(var->ctx);
... ...
@@ -291,18 +291,18 @@ reload:
291 291
             goto reload;
292 292
         }
293 293
 
294
-        ret = url_open(&v->input,
295
-                       v->segments[v->cur_seq_no - v->start_seq_no]->url,
296
-                       AVIO_RDONLY);
294
+        ret = ffurl_open(&v->input,
295
+                         v->segments[v->cur_seq_no - v->start_seq_no]->url,
296
+                         AVIO_RDONLY);
297 297
         if (ret < 0)
298 298
             return ret;
299 299
     }
300
-    ret = url_read(v->input, buf, buf_size);
300
+    ret = ffurl_read(v->input, buf, buf_size);
301 301
     if (ret > 0)
302 302
         return ret;
303 303
     if (ret < 0 && ret != AVERROR_EOF)
304 304
         return ret;
305
-    url_close(v->input);
305
+    ffurl_close(v->input);
306 306
     v->input = NULL;
307 307
     v->cur_seq_no++;
308 308
 
... ...
@@ -435,7 +435,7 @@ static int recheck_discard_flags(AVFormatContext *s, int first)
435 435
             av_log(s, AV_LOG_INFO, "Now receiving variant %d\n", i);
436 436
         } else if (first && !v->cur_needed && v->needed) {
437 437
             if (v->input)
438
-                url_close(v->input);
438
+                ffurl_close(v->input);
439 439
             v->input = NULL;
440 440
             v->needed = 0;
441 441
             changed = 1;
... ...
@@ -517,7 +517,7 @@ static int applehttp_read_seek(AVFormatContext *s, int stream_index,
517 517
         struct variant *var = c->variants[i];
518 518
         int64_t pos = 0;
519 519
         if (var->input) {
520
-            url_close(var->input);
520
+            ffurl_close(var->input);
521 521
             var->input = NULL;
522 522
         }
523 523
         av_free_packet(&var->pkt);
... ...
@@ -298,11 +298,9 @@ static int applehttp_close(URLContext *h)
298 298
 }
299 299
 
300 300
 URLProtocol ff_applehttp_protocol = {
301
-    "applehttp",
302
-    applehttp_open,
303
-    applehttp_read,
304
-    NULL, /* write */
305
-    NULL, /* seek */
306
-    applehttp_close,
307
-    .flags = URL_PROTOCOL_FLAG_NESTED_SCHEME,
301
+    .name      = "applehttp",
302
+    .url_open  = applehttp_open,
303
+    .url_read  = applehttp_read,
304
+    .url_close = applehttp_close,
305
+    .flags     = URL_PROTOCOL_FLAG_NESTED_SCHEME,
308 306
 };
... ...
@@ -31,8 +31,6 @@
31 31
 #include "asfcrypt.h"
32 32
 #include "avlanguage.h"
33 33
 
34
-void ff_mms_set_stream_selection(URLContext *h, AVFormatContext *format);
35
-
36 34
 typedef struct {
37 35
     int asfid2avid[128];                 ///< conversion table from asf ID 2 AVStream ID
38 36
     ASFStream streams[128];              ///< it's max number and it's not that big
... ...
@@ -907,7 +907,9 @@ AVInputFormat  *av_iformat_next(AVInputFormat  *f);
907 907
  */
908 908
 AVOutputFormat *av_oformat_next(AVOutputFormat *f);
909 909
 
910
-enum CodecID av_guess_image2_codec(const char *filename);
910
+#if FF_API_GUESS_IMG2_CODEC
911
+attribute_deprecated enum CodecID av_guess_image2_codec(const char *filename);
912
+#endif
911 913
 
912 914
 /* XXX: Use automatic init with either ELF sections or C file parser */
913 915
 /* modules. */
... ...
@@ -986,7 +988,6 @@ void av_hex_dump_log(void *avcl, int level, uint8_t *buf, int size);
986 986
  */
987 987
 void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st);
988 988
 
989
-attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
990 989
 
991 990
 /**
992 991
  * Send a nice dump of a packet to the log.
... ...
@@ -1002,7 +1003,10 @@ attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
1002 1002
 void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
1003 1003
                       AVStream *st);
1004 1004
 
1005
+#if FF_API_PKT_DUMP
1006
+attribute_deprecated void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload);
1005 1007
 attribute_deprecated void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt,
1008
+#endif
1006 1009
                                           int dump_payload);
1007 1010
 
1008 1011
 /**
... ...
@@ -1521,12 +1525,6 @@ int64_t parse_date(const char *datestr, int duration);
1521 1521
  */
1522 1522
 int64_t av_gettime(void);
1523 1523
 
1524
-/* ffm-specific for ffserver */
1525
-#define FFM_PACKET_SIZE 4096
1526
-int64_t ffm_read_write_index(int fd);
1527
-int ffm_write_write_index(int fd, int64_t pos);
1528
-void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size);
1529
-
1530 1524
 #if FF_API_FIND_INFO_TAG
1531 1525
 /**
1532 1526
  * @deprecated use av_find_info_tag in libavutil instead.
... ...
@@ -1566,12 +1564,16 @@ int av_filename_number_test(const char *filename);
1566 1566
  *           all the contexts in the array (an AVCodecContext per RTP stream)
1567 1567
  *           must contain only one AVStream.
1568 1568
  * @param n_files number of AVCodecContexts contained in ac
1569
- * @param buff buffer where the SDP will be stored (must be allocated by
1570
- *             the caller)
1569
+ * @param buf buffer where the SDP will be stored (must be allocated by
1570
+ *            the caller)
1571 1571
  * @param size the size of the buffer
1572 1572
  * @return 0 if OK, AVERROR_xxx on error
1573 1573
  */
1574
-int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
1574
+int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size);
1575
+
1576
+#if FF_API_SDP_CREATE
1577
+attribute_deprecated int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size);
1578
+#endif
1575 1579
 
1576 1580
 /**
1577 1581
  * Return a positive value if the given filename has one of the given
... ...
@@ -49,7 +49,7 @@ static const AVClass urlcontext_class =
49 49
 static int default_interrupt_cb(void);
50 50
 
51 51
 URLProtocol *first_protocol = NULL;
52
-URLInterruptCB *url_interrupt_cb = default_interrupt_cb;
52
+int (*url_interrupt_cb)(void) = default_interrupt_cb;
53 53
 
54 54
 URLProtocol *av_protocol_next(URLProtocol *p)
55 55
 {
... ...
@@ -57,6 +57,16 @@ URLProtocol *av_protocol_next(URLProtocol *p)
57 57
     else  return first_protocol;
58 58
 }
59 59
 
60
+const char *avio_enum_protocols(void **opaque, int output)
61
+{
62
+    URLProtocol **p = opaque;
63
+    *p = *p ? (*p)->next : first_protocol;
64
+    if (!*p) return NULL;
65
+    if ((output && (*p)->url_write) || (!output && (*p)->url_read))
66
+        return (*p)->name;
67
+    return avio_enum_protocols(opaque, output);
68
+}
69
+
60 70
 int ffurl_register_protocol(URLProtocol *protocol, int size)
61 71
 {
62 72
     URLProtocol **p;
... ...
@@ -389,7 +399,7 @@ static int default_interrupt_cb(void)
389 389
     return 0;
390 390
 }
391 391
 
392
-void avio_set_interrupt_cb(URLInterruptCB *interrupt_cb)
392
+void avio_set_interrupt_cb(int (*interrupt_cb)(void))
393 393
 {
394 394
     if (!interrupt_cb)
395 395
         interrupt_cb = default_interrupt_cb;
... ...
@@ -37,12 +37,14 @@
37 37
 
38 38
 /* unbuffered I/O */
39 39
 
40
+#if FF_API_OLD_AVIO
40 41
 /**
41 42
  * URL Context.
42 43
  * New fields can be added to the end with minor version bumps.
43 44
  * Removal, reordering and changes to existing fields require a major
44 45
  * version bump.
45 46
  * sizeof(URLContext) must not be used outside libav*.
47
+ * @deprecated This struct will be made private
46 48
  */
47 49
 typedef struct URLContext {
48 50
 #if FF_API_URL_CLASS
... ...
@@ -57,7 +59,6 @@ typedef struct URLContext {
57 57
     int is_connected;
58 58
 } URLContext;
59 59
 
60
-#if FF_API_OLD_AVIO
61 60
 typedef struct URLPollEntry {
62 61
     URLContext *handle;
63 62
     int events;
... ...
@@ -90,11 +91,9 @@ typedef struct URLPollEntry {
90 90
  * silently ignored.
91 91
  */
92 92
 #define URL_FLAG_NONBLOCK 4
93
-#endif
94 93
 
95 94
 typedef int URLInterruptCB(void);
96 95
 
97
-#if FF_API_OLD_AVIO
98 96
 /**
99 97
  * @defgroup old_url_funcs Old url_* functions
100 98
  * @deprecated use the buffered API based on AVIOContext instead
... ...
@@ -117,7 +116,7 @@ attribute_deprecated void url_get_filename(URLContext *h, char *buf, int buf_siz
117 117
 attribute_deprecated int av_url_read_pause(URLContext *h, int pause);
118 118
 attribute_deprecated int64_t av_url_read_seek(URLContext *h, int stream_index,
119 119
                                               int64_t timestamp, int flags);
120
-attribute_deprecated void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
120
+attribute_deprecated void url_set_interrupt_cb(int (*interrupt_cb)(void));
121 121
 #endif
122 122
 
123 123
 /**
... ...
@@ -132,7 +131,7 @@ int url_exist(const char *url);
132 132
  * in this case by the interrupted function. 'NULL' means no interrupt
133 133
  * callback is given.
134 134
  */
135
-void avio_set_interrupt_cb(URLInterruptCB *interrupt_cb);
135
+void avio_set_interrupt_cb(int (*interrupt_cb)(void));
136 136
 
137 137
 #if FF_API_OLD_AVIO
138 138
 /* not implemented */
... ...
@@ -140,8 +139,11 @@ attribute_deprecated int url_poll(URLPollEntry *poll_table, int n, int timeout);
140 140
 
141 141
 
142 142
 #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
143
-#endif
144 143
 
144
+/**
145
+ * @deprecated This struct is to be made private. Use the higher-level
146
+ *             AVIOContext-based API instead.
147
+ */
145 148
 typedef struct URLProtocol {
146 149
     const char *name;
147 150
     int (*url_open)(URLContext *h, const char *url, int flags);
... ...
@@ -158,6 +160,7 @@ typedef struct URLProtocol {
158 158
     const AVClass *priv_data_class;
159 159
     int flags;
160 160
 } URLProtocol;
161
+#endif
161 162
 
162 163
 #if FF_API_REGISTER_PROTOCOL
163 164
 extern URLProtocol *first_protocol;
... ...
@@ -596,4 +599,18 @@ int avio_close_dyn_buf(AVIOContext *s, uint8_t **pbuffer);
596 596
 int udp_get_file_handle(URLContext *h);
597 597
 #endif
598 598
 
599
+/**
600
+ * Iterate through names of available protocols.
601
+ * @note it is recommanded to use av_protocol_next() instead of this
602
+ *
603
+ * @param opaque A private pointer representing current protocol.
604
+ *        It must be a pointer to NULL on first iteration and will
605
+ *        be updated by successive calls to avio_enum_protocols.
606
+ * @param output If set to 1, iterate over output protocols,
607
+ *               otherwise over input protocols.
608
+ *
609
+ * @return A static string containing the name of current protocol or NULL
610
+ */
611
+const char *avio_enum_protocols(void **opaque, int output);
612
+
599 613
 #endif /* AVFORMAT_AVIO_H */
... ...
@@ -21,6 +21,7 @@
21 21
 #define AVFORMAT_AVIO_INTERNAL_H
22 22
 
23 23
 #include "avio.h"
24
+#include "url.h"
24 25
 
25 26
 int ffio_init_context(AVIOContext *s,
26 27
                   unsigned char *buffer,
... ...
@@ -92,10 +93,6 @@ int     ffio_read_pause(AVIOContext *h,    int pause);
92 92
 int64_t ffio_read_seek (AVIOContext *h,    int stream_index,
93 93
                         int64_t timestamp, int flags);
94 94
 
95
-/* udp.c */
96
-int ff_udp_set_remote_url(URLContext *h, const char *uri);
97
-int ff_udp_get_local_port(URLContext *h);
98
-
99 95
 void ffio_init_checksum(AVIOContext *s,
100 96
                         unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
101 97
                         unsigned long checksum);
... ...
@@ -190,10 +190,9 @@ static int64_t concat_seek(URLContext *h, int64_t pos, int whence)
190 190
 }
191 191
 
192 192
 URLProtocol ff_concat_protocol = {
193
-    "concat",
194
-    concat_open,
195
-    concat_read,
196
-    NULL,
197
-    concat_seek,
198
-    concat_close,
193
+    .name      = "concat",
194
+    .url_open  = concat_open,
195
+    .url_read  = concat_read,
196
+    .url_seek  = concat_seek,
197
+    .url_close = concat_close,
199 198
 };
... ...
@@ -28,6 +28,7 @@
28 28
 
29 29
 /* The FFM file is made of blocks of fixed size */
30 30
 #define FFM_HEADER_SIZE 14
31
+#define FFM_PACKET_SIZE 4096
31 32
 #define PACKET_ID       0x666d
32 33
 
33 34
 /* each packet contains frames (which can span several packets */
... ...
@@ -55,4 +56,8 @@ typedef struct FFMContext {
55 55
     uint8_t packet[FFM_PACKET_SIZE];
56 56
 } FFMContext;
57 57
 
58
+int64_t ffm_read_write_index(int fd);
59
+int ffm_write_write_index(int fd, int64_t pos);
60
+void ffm_set_write_index(AVFormatContext *s, int64_t pos, int64_t file_size);
61
+
58 62
 #endif /* AVFORMAT_FFM_H */
... ...
@@ -29,6 +29,7 @@
29 29
 #include <sys/stat.h>
30 30
 #include <stdlib.h>
31 31
 #include "os_support.h"
32
+#include "url.h"
32 33
 
33 34
 
34 35
 /* standard file protocol */
... ...
@@ -95,12 +96,12 @@ static int file_close(URLContext *h)
95 95
 }
96 96
 
97 97
 URLProtocol ff_file_protocol = {
98
-    "file",
99
-    file_open,
100
-    file_read,
101
-    file_write,
102
-    file_seek,
103
-    file_close,
98
+    .name                = "file",
99
+    .url_open            = file_open,
100
+    .url_read            = file_read,
101
+    .url_write           = file_write,
102
+    .url_seek            = file_seek,
103
+    .url_close           = file_close,
104 104
     .url_get_file_handle = file_get_handle,
105 105
 };
106 106
 
... ...
@@ -131,10 +132,10 @@ static int pipe_open(URLContext *h, const char *filename, int flags)
131 131
 }
132 132
 
133 133
 URLProtocol ff_pipe_protocol = {
134
-    "pipe",
135
-    pipe_open,
136
-    file_read,
137
-    file_write,
134
+    .name                = "pipe",
135
+    .url_open            = pipe_open,
136
+    .url_read            = file_read,
137
+    .url_write           = file_write,
138 138
     .url_get_file_handle = file_get_handle,
139 139
 };
140 140
 
... ...
@@ -121,10 +121,9 @@ static int gopher_read(URLContext *h, uint8_t *buf, int size)
121 121
 
122 122
 
123 123
 URLProtocol ff_gopher_protocol = {
124
-    "gopher",
125
-    gopher_open,
126
-    gopher_read,
127
-    gopher_write,
128
-    NULL, /*seek*/
129
-    gopher_close,
124
+    .name      = "gopher",
125
+    .url_open  = gopher_open,
126
+    .url_read  = gopher_read,
127
+    .url_write = gopher_write,
128
+    .url_close = gopher_close,
130 129
 };
... ...
@@ -505,13 +505,13 @@ http_get_file_handle(URLContext *h)
505 505
 }
506 506
 
507 507
 URLProtocol ff_http_protocol = {
508
-    "http",
509
-    http_open,
510
-    http_read,
511
-    http_write,
512
-    http_seek,
513
-    http_close,
508
+    .name                = "http",
509
+    .url_open            = http_open,
510
+    .url_read            = http_read,
511
+    .url_write           = http_write,
512
+    .url_seek            = http_seek,
513
+    .url_close           = http_close,
514 514
     .url_get_file_handle = http_get_file_handle,
515
-    .priv_data_size = sizeof(HTTPContext),
516
-    .priv_data_class = &httpcontext_class,
515
+    .priv_data_size      = sizeof(HTTPContext),
516
+    .priv_data_class     = &httpcontext_class,
517 517
 };
... ...
@@ -22,7 +22,7 @@
22 22
 #ifndef AVFORMAT_HTTP_H
23 23
 #define AVFORMAT_HTTP_H
24 24
 
25
-#include "avio.h"
25
+#include "url.h"
26 26
 
27 27
 /**
28 28
  * Set custom HTTP headers.
... ...
@@ -24,6 +24,7 @@
24 24
 #include "libavutil/avstring.h"
25 25
 #include "avformat.h"
26 26
 #include "avio_internal.h"
27
+#include "internal.h"
27 28
 #include <strings.h>
28 29
 
29 30
 typedef struct {
... ...
@@ -185,9 +186,16 @@ static int read_probe(AVProbeData *p)
185 185
     return 0;
186 186
 }
187 187
 
188
+enum CodecID ff_guess_image2_codec(const char *filename)
189
+{
190
+    return av_str2id(img_tags, filename);
191
+}
192
+
193
+#if FF_API_GUESS_IMG2_CODEC
188 194
 enum CodecID av_guess_image2_codec(const char *filename){
189 195
     return av_str2id(img_tags, filename);
190 196
 }
197
+#endif
191 198
 
192 199
 static int read_header(AVFormatContext *s1, AVFormatParameters *ap)
193 200
 {
... ...
@@ -250,4 +250,6 @@ void ff_reduce_index(AVFormatContext *s, int stream_index);
250 250
 void ff_make_absolute_url(char *buf, int size, const char *base,
251 251
                           const char *rel);
252 252
 
253
+enum CodecID ff_guess_image2_codec(const char *filename);
254
+
253 255
 #endif /* AVFORMAT_INTERNAL_H */
... ...
@@ -25,6 +25,7 @@
25 25
  */
26 26
 
27 27
 #include "avformat.h"
28
+#include "url.h"
28 29
 
29 30
 #include <librtmp/rtmp.h>
30 31
 #include <librtmp/log.h>
... ...
@@ -158,66 +159,56 @@ static int rtmp_get_file_handle(URLContext *s)
158 158
 }
159 159
 
160 160
 URLProtocol ff_rtmp_protocol = {
161
-    "rtmp",
162
-    rtmp_open,
163
-    rtmp_read,
164
-    rtmp_write,
165
-    NULL,                   /* seek */
166
-    rtmp_close,
167
-    NULL,                   /* next */
168
-    rtmp_read_pause,
169
-    rtmp_read_seek,
170
-    rtmp_get_file_handle
161
+    .name                = "rtmp",
162
+    .url_open            = rtmp_open,
163
+    .url_read            = rtmp_read,
164
+    .url_write           = rtmp_write,
165
+    .url_close           = rtmp_close,
166
+    .url_read_pause      = rtmp_read_pause,
167
+    .url_read_seek       = rtmp_read_seek,
168
+    .url_get_file_handle = rtmp_get_file_handle
171 169
 };
172 170
 
173 171
 URLProtocol ff_rtmpt_protocol = {
174
-    "rtmpt",
175
-    rtmp_open,
176
-    rtmp_read,
177
-    rtmp_write,
178
-    NULL,                   /* seek */
179
-    rtmp_close,
180
-    NULL,                   /* next */
181
-    rtmp_read_pause,
182
-    rtmp_read_seek,
183
-    rtmp_get_file_handle
172
+    .name                = "rtmpt",
173
+    .url_open            = rtmp_open,
174
+    .url_read            = rtmp_read,
175
+    .url_write           = rtmp_write,
176
+    .url_close           = rtmp_close,
177
+    .url_read_pause      = rtmp_read_pause,
178
+    .url_read_seek       = rtmp_read_seek,
179
+    .url_get_file_handle = rtmp_get_file_handle
184 180
 };
185 181
 
186 182
 URLProtocol ff_rtmpe_protocol = {
187
-    "rtmpe",
188
-    rtmp_open,
189
-    rtmp_read,
190
-    rtmp_write,
191
-    NULL,                   /* seek */
192
-    rtmp_close,
193
-    NULL,                   /* next */
194
-    rtmp_read_pause,
195
-    rtmp_read_seek,
196
-    rtmp_get_file_handle
183
+    .name                = "rtmpe",
184
+    .url_open            = rtmp_open,
185
+    .url_read            = rtmp_read,
186
+    .url_write           = rtmp_write,
187
+    .url_close           = rtmp_close,
188
+    .url_read_pause      = rtmp_read_pause,
189
+    .url_read_seek       = rtmp_read_seek,
190
+    .url_get_file_handle = rtmp_get_file_handle
197 191
 };
198 192
 
199 193
 URLProtocol ff_rtmpte_protocol = {
200
-    "rtmpte",
201
-    rtmp_open,
202
-    rtmp_read,
203
-    rtmp_write,
204
-    NULL,                   /* seek */
205
-    rtmp_close,
206
-    NULL,                   /* next */
207
-    rtmp_read_pause,
208
-    rtmp_read_seek,
209
-    rtmp_get_file_handle
194
+    .name                = "rtmpte",
195
+    .url_open            = rtmp_open,
196
+    .url_read            = rtmp_read,
197
+    .url_write           = rtmp_write,
198
+    .url_close           = rtmp_close,
199
+    .url_read_pause      = rtmp_read_pause,
200
+    .url_read_seek       = rtmp_read_seek,
201
+    .url_get_file_handle = rtmp_get_file_handle
210 202
 };
211 203
 
212 204
 URLProtocol ff_rtmps_protocol = {
213
-    "rtmps",
214
-    rtmp_open,
215
-    rtmp_read,
216
-    rtmp_write,
217
-    NULL,                   /* seek */
218
-    rtmp_close,
219
-    NULL,                   /* next */
220
-    rtmp_read_pause,
221
-    rtmp_read_seek,
222
-    rtmp_get_file_handle
205
+    .name                = "rtmps",
206
+    .url_open            = rtmp_open,
207
+    .url_read            = rtmp_read,
208
+    .url_write           = rtmp_write,
209
+    .url_close           = rtmp_close,
210
+    .url_read_pause      = rtmp_read_pause,
211
+    .url_read_seek       = rtmp_read_seek,
212
+    .url_get_file_handle = rtmp_get_file_handle
223 213
 };
... ...
@@ -21,7 +21,7 @@
21 21
 #ifndef AVFORMAT_MMS_H
22 22
 #define AVFORMAT_MMS_H
23 23
 
24
-#include "avformat.h"
24
+#include "url.h"
25 25
 
26 26
 typedef struct {
27 27
     int id;
... ...
@@ -623,10 +623,8 @@ static int mms_read(URLContext *h, uint8_t *buf, int size)
623 623
 }
624 624
 
625 625
 URLProtocol ff_mmst_protocol = {
626
-    "mmst",
627
-    mms_open,
628
-    mms_read,
629
-    NULL, // write
630
-    NULL, // seek
631
-    mms_close,
626
+    .name      = "mmst",
627
+    .url_open  = mms_open,
628
+    .url_read  = mms_read,
629
+    .url_close = mms_close,
632 630
 };
... ...
@@ -23,6 +23,7 @@
23 23
 #define AVFORMAT_RTMPPKT_H
24 24
 
25 25
 #include "avformat.h"
26
+#include "url.h"
26 27
 
27 28
 /** maximum possible number of different RTMP channels */
28 29
 #define RTMP_CHANNELS 65599
... ...
@@ -991,10 +991,9 @@ static int rtmp_write(URLContext *s, const uint8_t *buf, int size)
991 991
 }
992 992
 
993 993
 URLProtocol ff_rtmp_protocol = {
994
-    "rtmp",
995
-    rtmp_open,
996
-    rtmp_read,
997
-    rtmp_write,
998
-    NULL, /* seek */
999
-    rtmp_close,
994
+    .name      = "rtmp",
995
+    .url_open  = rtmp_open,
996
+    .url_read  = rtmp_read,
997
+    .url_write = rtmp_write,
998
+    .url_close = rtmp_close,
1000 999
 };
... ...
@@ -25,6 +25,7 @@
25 25
 #include "libavcodec/avcodec.h"
26 26
 #include "avformat.h"
27 27
 #include "rtp.h"
28
+#include "url.h"
28 29
 
29 30
 typedef struct PayloadContext PayloadContext;
30 31
 typedef struct RTPDynamicProtocolHandler_s RTPDynamicProtocolHandler;
... ...
@@ -23,6 +23,7 @@
23 23
 #define AVFORMAT_RTPENC_CHAIN_H
24 24
 
25 25
 #include "avformat.h"
26
+#include "url.h"
26 27
 
27 28
 AVFormatContext *ff_rtp_chain_mux_open(AVFormatContext *s, AVStream *st,
28 29
                                        URLContext *handle, int packet_size);
... ...
@@ -355,11 +355,10 @@ int rtp_get_rtcp_file_handle(URLContext *h) {
355 355
 }
356 356
 
357 357
 URLProtocol ff_rtp_protocol = {
358
-    "rtp",
359
-    rtp_open,
360
-    rtp_read,
361
-    rtp_write,
362
-    NULL, /* seek */
363
-    rtp_close,
358
+    .name                = "rtp",
359
+    .url_open            = rtp_open,
360
+    .url_read            = rtp_read,
361
+    .url_write           = rtp_write,
362
+    .url_close           = rtp_close,
364 363
     .url_get_file_handle = rtp_get_file_handle,
365 364
 };
... ...
@@ -66,7 +66,7 @@ int ff_rtsp_setup_output_streams(AVFormatContext *s, const char *addr)
66 66
     ff_url_join(sdp_ctx.filename, sizeof(sdp_ctx.filename),
67 67
                 "rtsp", NULL, addr, -1, NULL);
68 68
     ctx_array[0] = &sdp_ctx;
69
-    if (avf_sdp_create(ctx_array, 1, sdp, SDP_MAX_SIZE)) {
69
+    if (av_sdp_create(ctx_array, 1, sdp, SDP_MAX_SIZE)) {
70 70
         av_free(sdp);
71 71
         return AVERROR_INVALIDDATA;
72 72
     }
... ...
@@ -208,7 +208,7 @@ static int sap_write_header(AVFormatContext *s)
208 208
     av_strlcpy(&sap->ann[pos], "application/sdp", sap->ann_size - pos);
209 209
     pos += strlen(&sap->ann[pos]) + 1;
210 210
 
211
-    if (avf_sdp_create(contexts, s->nb_streams, &sap->ann[pos],
211
+    if (av_sdp_create(contexts, s->nb_streams, &sap->ann[pos],
212 212
                        sap->ann_size - pos)) {
213 213
         ret = AVERROR_INVALIDDATA;
214 214
         goto fail;
... ...
@@ -474,14 +474,14 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des
474 474
     sdp_write_media_attributes(buff, size, c, payload_type);
475 475
 }
476 476
 
477
-int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size)
477
+int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
478 478
 {
479 479
     AVMetadataTag *title = av_metadata_get(ac[0]->metadata, "title", NULL, 0);
480 480
     struct sdp_session_level s;
481 481
     int i, j, port, ttl, is_multicast;
482 482
     char dst[32], dst_type[5];
483 483
 
484
-    memset(buff, 0, size);
484
+    memset(buf, 0, size);
485 485
     memset(&s, 0, sizeof(struct sdp_session_level));
486 486
     s.user = "-";
487 487
     s.src_addr = "127.0.0.1";    /* FIXME: Properly set this */
... ...
@@ -506,7 +506,7 @@ int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size)
506 506
             }
507 507
         }
508 508
     }
509
-    sdp_write_header(buff, size, &s);
509
+    sdp_write_header(buf, size, &s);
510 510
 
511 511
     dst[0] = 0;
512 512
     for (i = 0; i < n_files; i++) {
... ...
@@ -518,11 +518,11 @@ int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size)
518 518
                 ttl = 0;
519 519
         }
520 520
         for (j = 0; j < ac[i]->nb_streams; j++) {
521
-            ff_sdp_write_media(buff, size,
521
+            ff_sdp_write_media(buf, size,
522 522
                                   ac[i]->streams[j]->codec, dst[0] ? dst : NULL,
523 523
                                   dst_type, (port > 0) ? port + j * 2 : 0, ttl);
524 524
             if (port <= 0) {
525
-                av_strlcatf(buff, size,
525
+                av_strlcatf(buf, size,
526 526
                                    "a=control:streamid=%d\r\n", i + j);
527 527
             }
528 528
         }
... ...
@@ -531,7 +531,7 @@ int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size)
531 531
     return 0;
532 532
 }
533 533
 #else
534
-int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size)
534
+int av_sdp_create(AVFormatContext *ac[], int n_files, char *buf, int size)
535 535
 {
536 536
     return AVERROR(ENOSYS);
537 537
 }
... ...
@@ -540,3 +540,10 @@ void ff_sdp_write_media(char *buff, int size, AVCodecContext *c, const char *des
540 540
 {
541 541
 }
542 542
 #endif
543
+
544
+#if FF_API_SDP_CREATE
545
+int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size)
546
+{
547
+    return av_sdp_create(ac, n_files, buff, size);
548
+}
549
+#endif
... ...
@@ -202,11 +202,10 @@ static int tcp_get_file_handle(URLContext *h)
202 202
 }
203 203
 
204 204
 URLProtocol ff_tcp_protocol = {
205
-    "tcp",
206
-    tcp_open,
207
-    tcp_read,
208
-    tcp_write,
209
-    NULL, /* seek */
210
-    tcp_close,
205
+    .name                = "tcp",
206
+    .url_open            = tcp_open,
207
+    .url_read            = tcp_read,
208
+    .url_write           = tcp_write,
209
+    .url_close           = tcp_close,
211 210
     .url_get_file_handle = tcp_get_file_handle,
212 211
 };
... ...
@@ -489,11 +489,10 @@ static int udp_close(URLContext *h)
489 489
 }
490 490
 
491 491
 URLProtocol ff_udp_protocol = {
492
-    "udp",
493
-    udp_open,
494
-    udp_read,
495
-    udp_write,
496
-    NULL, /* seek */
497
-    udp_close,
492
+    .name                = "udp",
493
+    .url_open            = udp_open,
494
+    .url_read            = udp_read,
495
+    .url_write           = udp_write,
496
+    .url_close           = udp_close,
498 497
     .url_get_file_handle = udp_get_file_handle,
499 498
 };
... ...
@@ -31,7 +31,35 @@
31 31
 #if !FF_API_OLD_AVIO
32 32
 #define URL_PROTOCOL_FLAG_NESTED_SCHEME 1 /*< The protocol name can be the first part of a nested protocol scheme */
33 33
 
34
-extern URLInterruptCB *url_interrupt_cb;
34
+extern int (*url_interrupt_cb)(void);
35
+
36
+typedef struct URLContext {
37
+    const AVClass *av_class;    /**< information for av_log(). Set by url_open(). */
38
+    struct URLProtocol *prot;
39
+    void *priv_data;
40
+    char *filename;             /**< specified URL */
41
+    int flags;
42
+    int max_packet_size;        /**< if non zero, the stream is packetized with this max packet size */
43
+    int is_streamed;            /**< true if streamed (no seek possible), default = false */
44
+    int is_connected;
45
+} URLContext;
46
+
47
+typedef struct URLProtocol {
48
+    const char *name;
49
+    int     (*url_open)( URLContext *h, const char *url, int flags);
50
+    int     (*url_read)( URLContext *h, unsigned char *buf, int size);
51
+    int     (*url_write)(URLContext *h, const unsigned char *buf, int size);
52
+    int64_t (*url_seek)( URLContext *h, int64_t pos, int whence);
53
+    int     (*url_close)(URLContext *h);
54
+    struct URLProtocol *next;
55
+    int (*url_read_pause)(URLContext *h, int pause);
56
+    int64_t (*url_read_seek)(URLContext *h, int stream_index,
57
+                             int64_t timestamp, int flags);
58
+    int (*url_get_file_handle)(URLContext *h);
59
+    int priv_data_size;
60
+    const AVClass *priv_data_class;
61
+    int flags;
62
+} URLProtocol;
35 63
 #endif
36 64
 
37 65
 /**
... ...
@@ -140,4 +168,8 @@ int ffurl_get_file_handle(URLContext *h);
140 140
  */
141 141
 int ffurl_register_protocol(URLProtocol *protocol, int size);
142 142
 
143
+/* udp.c */
144
+int ff_udp_set_remote_url(URLContext *h, const char *uri);
145
+int ff_udp_get_local_port(URLContext *h);
146
+
143 147
 #endif //AVFORMAT_URL_H
... ...
@@ -219,7 +219,7 @@ AVOutputFormat *av_guess_format(const char *short_name, const char *filename,
219 219
 #if CONFIG_IMAGE2_MUXER
220 220
     if (!short_name && filename &&
221 221
         av_filename_number_test(filename) &&
222
-        av_guess_image2_codec(filename) != CODEC_ID_NONE) {
222
+        ff_guess_image2_codec(filename) != CODEC_ID_NONE) {
223 223
         return av_guess_format("image2", NULL, NULL);
224 224
     }
225 225
 #endif
... ...
@@ -272,7 +272,7 @@ enum CodecID av_guess_codec(AVOutputFormat *fmt, const char *short_name,
272 272
 
273 273
 #if CONFIG_IMAGE2_MUXER
274 274
         if(!strcmp(fmt->name, "image2") || !strcmp(fmt->name, "image2pipe")){
275
-            codec_id= av_guess_image2_codec(filename);
275
+            codec_id= ff_guess_image2_codec(filename);
276 276
         }
277 277
 #endif
278 278
         if(codec_id == CODEC_ID_NONE)
... ...
@@ -3574,22 +3574,26 @@ static void pkt_dump_internal(void *avcl, FILE *f, int level, AVPacket *pkt, int
3574 3574
         av_hex_dump(f, pkt->data, pkt->size);
3575 3575
 }
3576 3576
 
3577
+#if FF_API_PKT_DUMP
3577 3578
 void av_pkt_dump(FILE *f, AVPacket *pkt, int dump_payload)
3578 3579
 {
3579 3580
     AVRational tb = { 1, AV_TIME_BASE };
3580 3581
     pkt_dump_internal(NULL, f, 0, pkt, dump_payload, tb);
3581 3582
 }
3583
+#endif
3582 3584
 
3583 3585
 void av_pkt_dump2(FILE *f, AVPacket *pkt, int dump_payload, AVStream *st)
3584 3586
 {
3585 3587
     pkt_dump_internal(NULL, f, 0, pkt, dump_payload, st->time_base);
3586 3588
 }
3587 3589
 
3590
+#if FF_API_PKT_DUMP
3588 3591
 void av_pkt_dump_log(void *avcl, int level, AVPacket *pkt, int dump_payload)
3589 3592
 {
3590 3593
     AVRational tb = { 1, AV_TIME_BASE };
3591 3594
     pkt_dump_internal(avcl, NULL, level, pkt, dump_payload, tb);
3592 3595
 }
3596
+#endif
3593 3597
 
3594 3598
 void av_pkt_dump_log2(void *avcl, int level, AVPacket *pkt, int dump_payload,
3595 3599
                       AVStream *st)
... ...
@@ -104,5 +104,14 @@
104 104
 #ifndef FF_API_FIND_INFO_TAG
105 105
 #define FF_API_FIND_INFO_TAG           (LIBAVFORMAT_VERSION_MAJOR < 54)
106 106
 #endif
107
+#ifndef FF_API_PKT_DUMP
108
+#define FF_API_PKT_DUMP                (LIBAVFORMAT_VERSION_MAJOR < 54)
109
+#endif
110
+#ifndef FF_API_GUESS_IMG2_CODEC
111
+#define FF_API_GUESS_IMG2_CODEC        (LIBAVFORMAT_VERSION_MAJOR < 54)
112
+#endif
113
+#ifndef FF_API_SDP_CREATE
114
+#define FF_API_SDP_CREATE              (LIBAVFORMAT_VERSION_MAJOR < 54)
115
+#endif
107 116
 
108 117
 #endif //AVFORMAT_VERSION_H