Skip to content

Commit c88caa5

Browse files
committed
Merge remote branch 'qatar/master'
* qatar/master: proto: include os_support.h in network.h matroskaenc: don't write an empty Cues element. lavc: add a FF_API_REQUEST_CHANNELS deprecation macro avio: move extern url_interrupt_cb declaration from avio.h to url.h avio: make av_register_protocol2 internal. avio: avio_ prefix for url_set_interrupt_cb. avio: AVIO_ prefixes for URL_ open flags. proto: introduce listen option in tcp doc: clarify configure features proto: factor ff_network_wait_fd and use it on udp Conflicts: ffmpeg.c Merged-by: Michael Niedermayer <[email protected]>
2 parents db95e55 + a203125 commit c88caa5

37 files changed

+222
-136
lines changed

INSTALL

+4
Original file line numberDiff line numberDiff line change
@@ -9,3 +9,7 @@ path when launching 'configure', e.g. '/ffmpegdir/ffmpeg/configure'.
99
2) Then type 'make' to build FFmpeg. GNU Make 3.81 or later is required.
1010

1111
3) Type 'make install' to install all binaries and libraries you built.
12+
13+
NOTICE
14+
15+
- Non system dependencies (e.g. libx264, libvpx) are disabled by default.

doc/protocols.texi

+17
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,23 @@ ffplay sap://[ff0e::2:7ffe]
402402

403403
Trasmission Control Protocol.
404404

405+
The required syntax for a TCP url is:
406+
@example
407+
tcp://@var{hostname}:@var{port}[?@var{options}]
408+
@end example
409+
410+
@table @option
411+
412+
@item listen
413+
Listen for an incoming connection
414+
415+
@example
416+
ffmpeg -i @var{input} -f @var{format} tcp://@var{hostname}:@var{port}?listen
417+
ffplay tcp://@var{hostname}:@var{port}
418+
@end example
419+
420+
@end table
421+
405422
@section udp
406423

407424
User Datagram Protocol.

ffmpeg.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -2569,7 +2569,7 @@ static int transcode(AVFormatContext **output_files,
25692569
if (!using_stdin) {
25702570
if(verbose >= 0)
25712571
fprintf(stderr, "Press [q] to stop encoding\n");
2572-
url_set_interrupt_cb(decode_interrupt_cb);
2572+
avio_set_interrupt_cb(decode_interrupt_cb);
25732573
}
25742574
term_init();
25752575

@@ -3887,7 +3887,7 @@ static void opt_output_file(const char *filename)
38873887
}
38883888

38893889
/* open the file */
3890-
if ((err = avio_open(&oc->pb, filename, URL_WRONLY)) < 0) {
3890+
if ((err = avio_open(&oc->pb, filename, AVIO_WRONLY)) < 0) {
38913891
print_error(filename, err);
38923892
ffmpeg_exit(1);
38933893
}
@@ -4426,7 +4426,7 @@ int main(int argc, char **argv)
44264426

44274427
#if HAVE_ISATTY
44284428
if(isatty(STDIN_FILENO))
4429-
url_set_interrupt_cb(decode_interrupt_cb);
4429+
avio_set_interrupt_cb(decode_interrupt_cb);
44304430
#endif
44314431

44324432
init_opts();

ffplay.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -2406,7 +2406,7 @@ static int decode_thread(void *arg)
24062406
is->subtitle_stream = -1;
24072407

24082408
global_video_state = is;
2409-
url_set_interrupt_cb(decode_interrupt_cb);
2409+
avio_set_interrupt_cb(decode_interrupt_cb);
24102410

24112411
memset(ap, 0, sizeof(*ap));
24122412

@@ -2626,7 +2626,7 @@ static int decode_thread(void *arg)
26262626
av_close_input_file(is->ic);
26272627
is->ic = NULL; /* safety */
26282628
}
2629-
url_set_interrupt_cb(NULL);
2629+
avio_set_interrupt_cb(NULL);
26302630

26312631
if (ret != 0) {
26322632
SDL_Event event;

ffserver.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -3427,7 +3427,7 @@ static int rtp_new_av_stream(HTTPContext *c,
34273427
"rtp://%s:%d", ipaddr, ntohs(dest_addr->sin_port));
34283428
}
34293429

3430-
if (url_open(&h, ctx->filename, URL_WRONLY) < 0)
3430+
if (url_open(&h, ctx->filename, AVIO_WRONLY) < 0)
34313431
goto fail;
34323432
c->rtp_handles[stream_index] = h;
34333433
max_packet_size = url_get_max_packet_size(h);
@@ -3767,7 +3767,7 @@ static void build_feed_streams(void)
37673767
}
37683768

37693769
/* only write the header of the ffm file */
3770-
if (avio_open(&s->pb, feed->feed_filename, URL_WRONLY) < 0) {
3770+
if (avio_open(&s->pb, feed->feed_filename, AVIO_WRONLY) < 0) {
37713771
http_log("Could not open output feed file '%s'\n",
37723772
feed->feed_filename);
37733773
exit(1);

libavcodec/avcodec.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -2601,7 +2601,7 @@ typedef struct AVCodecContext {
26012601
*/
26022602
int64_t timecode_frame_start;
26032603

2604-
#if LIBAVCODEC_VERSION_MAJOR < 53
2604+
#if FF_API_REQUEST_CHANNELS
26052605
/**
26062606
* Decoder should decode to this many channels if it can (0 for default)
26072607
* - encoding: unused

libavcodec/options.c

+2
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,9 @@ static const AVOption options[]={
408408
{"timecode_frame_start", "GOP timecode frame start number, in non drop frame format", OFFSET(timecode_frame_start), FF_OPT_TYPE_INT64, 0, 0, INT64_MAX, V|E},
409409
{"drop_frame_timecode", NULL, 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_DROP_FRAME_TIMECODE, INT_MIN, INT_MAX, V|E, "flags2"},
410410
{"non_linear_q", "use non linear quantizer", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_NON_LINEAR_QUANT, INT_MIN, INT_MAX, V|E, "flags2"},
411+
#if FF_API_REQUEST_CHANNELS
411412
{"request_channels", "set desired number of audio channels", OFFSET(request_channels), FF_OPT_TYPE_INT, DEFAULT, 0, INT_MAX, A|D},
413+
#endif
412414
{"drc_scale", "percentage of dynamic range compression to apply", OFFSET(drc_scale), FF_OPT_TYPE_FLOAT, 1.0, 0.0, 1.0, A|D},
413415
{"reservoir", "use bit reservoir", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_BIT_RESERVOIR, INT_MIN, INT_MAX, A|E, "flags2"},
414416
{"mbtree", "use macroblock tree ratecontrol (x264 only)", 0, FF_OPT_TYPE_CONST, CODEC_FLAG2_MBTREE, INT_MIN, INT_MAX, V|E, "flags2"},

libavcodec/version.h

+3
Original file line numberDiff line numberDiff line change
@@ -83,5 +83,8 @@
8383
#ifndef FF_API_ANTIALIAS_ALGO
8484
#define FF_API_ANTIALIAS_ALGO (LIBAVCODEC_VERSION_MAJOR < 54)
8585
#endif
86+
#ifndef FF_API_REQUEST_CHANNELS
87+
#define FF_API_REQUEST_CHANNELS (LIBAVCODEC_VERSION_MAJOR < 53)
88+
#endif
8689

8790
#endif /* AVCODEC_VERSION_H */

libavformat/allformats.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "avformat.h"
2222
#include "rtp.h"
2323
#include "rdt.h"
24+
#include "url.h"
2425

2526
#define REGISTER_MUXER(X,x) { \
2627
extern AVOutputFormat ff_##x##_muxer; \
@@ -34,7 +35,7 @@
3435

3536
#define REGISTER_PROTOCOL(X,x) { \
3637
extern URLProtocol ff_##x##_protocol; \
37-
if(CONFIG_##X##_PROTOCOL) av_register_protocol2(&ff_##x##_protocol, sizeof(ff_##x##_protocol)); }
38+
if(CONFIG_##X##_PROTOCOL) ffurl_register_protocol(&ff_##x##_protocol, sizeof(ff_##x##_protocol)); }
3839

3940
void av_register_all(void)
4041
{

libavformat/applehttp.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "internal.h"
3232
#include <unistd.h>
3333
#include "avio_internal.h"
34+
#include "url.h"
3435

3536
#define INITIAL_BUFFER_SIZE 32768
3637

@@ -169,7 +170,7 @@ static int parse_playlist(AppleHTTPContext *c, const char *url,
169170

170171
if (!in) {
171172
close_in = 1;
172-
if ((ret = avio_open(&in, url, URL_RDONLY)) < 0)
173+
if ((ret = avio_open(&in, url, AVIO_RDONLY)) < 0)
173174
return ret;
174175
}
175176

@@ -292,7 +293,7 @@ static int read_data(void *opaque, uint8_t *buf, int buf_size)
292293

293294
ret = url_open(&v->input,
294295
v->segments[v->cur_seq_no - v->start_seq_no]->url,
295-
URL_RDONLY);
296+
AVIO_RDONLY);
296297
if (ret < 0)
297298
return ret;
298299
}

libavformat/applehttpproto.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static int parse_playlist(URLContext *h, const char *url)
115115
char line[1024];
116116
const char *ptr;
117117

118-
if ((ret = avio_open(&in, url, URL_RDONLY)) < 0)
118+
if ((ret = avio_open(&in, url, AVIO_RDONLY)) < 0)
119119
return ret;
120120

121121
read_chomp_line(in, line, sizeof(line));
@@ -180,7 +180,7 @@ static int applehttp_open(URLContext *h, const char *uri, int flags)
180180
int ret, i;
181181
const char *nested_url;
182182

183-
if (flags & (URL_WRONLY | URL_RDWR))
183+
if (flags & (AVIO_WRONLY | AVIO_RDWR))
184184
return AVERROR(ENOSYS);
185185

186186
s = av_mallocz(sizeof(AppleHTTPContext));
@@ -275,7 +275,7 @@ static int applehttp_read(URLContext *h, uint8_t *buf, int size)
275275
}
276276
url = s->segments[s->cur_seq_no - s->start_seq_no]->url,
277277
av_log(NULL, AV_LOG_DEBUG, "opening %s\n", url);
278-
ret = ffurl_open(&s->seg_hd, url, URL_RDONLY);
278+
ret = ffurl_open(&s->seg_hd, url, AVIO_RDONLY);
279279
if (ret < 0) {
280280
if (url_interrupt_cb())
281281
return AVERROR_EXIT;

libavformat/avio.c

+18-10
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ URLProtocol *av_protocol_next(URLProtocol *p)
5757
else return first_protocol;
5858
}
5959

60-
int av_register_protocol2(URLProtocol *protocol, int size)
60+
int ffurl_register_protocol(URLProtocol *protocol, int size)
6161
{
6262
URLProtocol **p;
6363
if (size < sizeof(URLProtocol)) {
@@ -86,12 +86,12 @@ struct URLProtocol_compat {
8686

8787
int av_register_protocol(URLProtocol *protocol)
8888
{
89-
return av_register_protocol2(protocol, sizeof(struct URLProtocol_compat));
89+
return ffurl_register_protocol(protocol, sizeof(struct URLProtocol_compat));
9090
}
9191

9292
int register_protocol(URLProtocol *protocol)
9393
{
94-
return av_register_protocol2(protocol, sizeof(struct URLProtocol_compat));
94+
return ffurl_register_protocol(protocol, sizeof(struct URLProtocol_compat));
9595
}
9696
#endif
9797

@@ -144,7 +144,7 @@ int ffurl_connect(URLContext* uc)
144144
return err;
145145
uc->is_connected = 1;
146146
//We must be careful here as ffurl_seek() could be slow, for example for http
147-
if( (uc->flags & (URL_WRONLY | URL_RDWR))
147+
if( (uc->flags & (AVIO_WRONLY | AVIO_RDWR))
148148
|| !strcmp(uc->prot->name, "file"))
149149
if(!uc->is_streamed && ffurl_seek(uc, 0, SEEK_SET) < 0)
150150
uc->is_streamed= 1;
@@ -216,6 +216,14 @@ void url_get_filename(URLContext *h, char *buf, int buf_size)
216216
{
217217
av_strlcpy(buf, h->filename, buf_size);
218218
}
219+
void url_set_interrupt_cb(URLInterruptCB *interrupt_cb)
220+
{
221+
avio_set_interrupt_cb(interrupt_cb);
222+
}
223+
int av_register_protocol2(URLProtocol *protocol, int size)
224+
{
225+
return ffurl_register_protocol(protocol, size);
226+
}
219227
#endif
220228

221229
#define URL_SCHEME_CHARS \
@@ -275,7 +283,7 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
275283
ret = transfer_func(h, buf+len, size-len);
276284
if (ret == AVERROR(EINTR))
277285
continue;
278-
if (h->flags & URL_FLAG_NONBLOCK)
286+
if (h->flags & AVIO_FLAG_NONBLOCK)
279287
return ret;
280288
if (ret == AVERROR(EAGAIN)) {
281289
ret = 0;
@@ -296,21 +304,21 @@ static inline int retry_transfer_wrapper(URLContext *h, unsigned char *buf, int
296304

297305
int ffurl_read(URLContext *h, unsigned char *buf, int size)
298306
{
299-
if (h->flags & URL_WRONLY)
307+
if (h->flags & AVIO_WRONLY)
300308
return AVERROR(EIO);
301309
return retry_transfer_wrapper(h, buf, size, 1, h->prot->url_read);
302310
}
303311

304312
int ffurl_read_complete(URLContext *h, unsigned char *buf, int size)
305313
{
306-
if (h->flags & URL_WRONLY)
314+
if (h->flags & AVIO_WRONLY)
307315
return AVERROR(EIO);
308316
return retry_transfer_wrapper(h, buf, size, size, h->prot->url_read);
309317
}
310318

311319
int ffurl_write(URLContext *h, const unsigned char *buf, int size)
312320
{
313-
if (!(h->flags & (URL_WRONLY | URL_RDWR)))
321+
if (!(h->flags & (AVIO_WRONLY | AVIO_RDWR)))
314322
return AVERROR(EIO);
315323
/* avoid sending too big packets */
316324
if (h->max_packet_size && size > h->max_packet_size)
@@ -348,7 +356,7 @@ int ffurl_close(URLContext *h)
348356
int url_exist(const char *filename)
349357
{
350358
URLContext *h;
351-
if (ffurl_open(&h, filename, URL_RDONLY) < 0)
359+
if (ffurl_open(&h, filename, AVIO_RDONLY) < 0)
352360
return 0;
353361
ffurl_close(h);
354362
return 1;
@@ -381,7 +389,7 @@ static int default_interrupt_cb(void)
381389
return 0;
382390
}
383391

384-
void url_set_interrupt_cb(URLInterruptCB *interrupt_cb)
392+
void avio_set_interrupt_cb(URLInterruptCB *interrupt_cb)
385393
{
386394
if (!interrupt_cb)
387395
interrupt_cb = default_interrupt_cb;

libavformat/avio.h

+35-3
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@ typedef struct URLPollEntry {
6363
int events;
6464
int revents;
6565
} URLPollEntry;
66-
#endif
6766

6867
/**
6968
* @defgroup open_modes URL open modes
@@ -91,6 +90,7 @@ typedef struct URLPollEntry {
9190
* silently ignored.
9291
*/
9392
#define URL_FLAG_NONBLOCK 4
93+
#endif
9494

9595
typedef int URLInterruptCB(void);
9696

@@ -117,6 +117,7 @@ attribute_deprecated void url_get_filename(URLContext *h, char *buf, int buf_siz
117117
attribute_deprecated int av_url_read_pause(URLContext *h, int pause);
118118
attribute_deprecated int64_t av_url_read_seek(URLContext *h, int stream_index,
119119
int64_t timestamp, int flags);
120+
attribute_deprecated void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
120121
#endif
121122

122123
/**
@@ -131,7 +132,7 @@ int url_exist(const char *url);
131132
* in this case by the interrupted function. 'NULL' means no interrupt
132133
* callback is given.
133134
*/
134-
void url_set_interrupt_cb(URLInterruptCB *interrupt_cb);
135+
void avio_set_interrupt_cb(URLInterruptCB *interrupt_cb);
135136

136137
#if FF_API_OLD_AVIO
137138
/* not implemented */
@@ -162,7 +163,9 @@ typedef struct URLProtocol {
162163
extern URLProtocol *first_protocol;
163164
#endif
164165

166+
#if FF_API_OLD_AVIO
165167
extern URLInterruptCB *url_interrupt_cb;
168+
#endif
166169

167170
/**
168171
* If protocol is NULL, returns the first registered protocol,
@@ -183,12 +186,14 @@ attribute_deprecated int register_protocol(URLProtocol *protocol);
183186
attribute_deprecated int av_register_protocol(URLProtocol *protocol);
184187
#endif
185188

189+
#if FF_API_OLD_AVIO
186190
/**
187191
* Register the URLProtocol protocol.
188192
*
189193
* @param size the size of the URLProtocol struct referenced
190194
*/
191-
int av_register_protocol2(URLProtocol *protocol, int size);
195+
attribute_deprecated int av_register_protocol2(URLProtocol *protocol, int size);
196+
#endif
192197

193198
#define AVIO_SEEKABLE_NORMAL 0x0001 /**< Seeking works like for a local file */
194199

@@ -510,6 +515,33 @@ attribute_deprecated static inline int url_is_streamed(AVIOContext *s)
510515
int url_resetbuf(AVIOContext *s, int flags);
511516
#endif
512517

518+
/**
519+
* @defgroup open_modes URL open modes
520+
* The flags argument to avio_open must be one of the following
521+
* constants, optionally ORed with other flags.
522+
* @{
523+
*/
524+
#define AVIO_RDONLY 0 /**< read-only */
525+
#define AVIO_WRONLY 1 /**< write-only */
526+
#define AVIO_RDWR 2 /**< read-write */
527+
/**
528+
* @}
529+
*/
530+
531+
/**
532+
* Use non-blocking mode.
533+
* If this flag is set, operations on the context will return
534+
* AVERROR(EAGAIN) if they can not be performed immediately.
535+
* If this flag is not set, operations on the context will never return
536+
* AVERROR(EAGAIN).
537+
* Note that this flag does not affect the opening/connecting of the
538+
* context. Connecting a protocol will always block if necessary (e.g. on
539+
* network protocols) but never hang (e.g. on busy devices).
540+
* Warning: non-blocking protocols is work-in-progress; this flag may be
541+
* silently ignored.
542+
*/
543+
#define AVIO_FLAG_NONBLOCK 4
544+
513545
/**
514546
* Create and initialize a AVIOContext for accessing the
515547
* resource indicated by url.

0 commit comments

Comments
 (0)