History

Merge remote-tracking branch 'qatar/master'

* qatar/master: (22 commits) configure: add check for w32threads to enable it automatically rtmp: do not hardcode invoke numbers cinepack: return non-generic errors fate-lavf-ts: use -mpegts_transport_stream_id option. Add an APIchanges entry and a minor bump for avio changes. avio: Mark the old interrupt callback mechanism as deprecated avplay: Set the new interrupt callback avconv: Set new interrupt callbacks for all AVFormatContexts, use avio_open2() everywhere cinepak: remove redundant coordinate checks cinepak: check strip_size cinepak, simplify, use AV_RB24() cinepak: simplify, use FFMIN() cinepak: Fix division by zero, ask for sample if encoded_buf_size is 0 applehttp: Fix seeking in streams not starting at DTS=0 http: Don't use the normal http proxy mechanism for https tls: Handle connection via a http proxy http: Reorder two code blocks http: Add a new protocol for opening connections via http proxies http: Split out the non-chunked buffer reading part from http_read segafilm: add support for raw videos ... Conflicts: avconv.c configure doc/APIchanges libavcodec/cinepak.c libavformat/applehttp.c libavformat/version.h tests/lavf-regression.sh tests/ref/lavf/ts

Michael Niedermayer committed 15 years ago

Commit e161b072 parents 36a60fa ff3755c20 files · +284 −87Browse files

Unified · Split

20 files
  1. avconv.c +15 −13
  2. configure +4 −1
  3. doc/APIchanges +10 −0
  4. ffmpeg.c +15 −14
  5. ffplay.c +3 −2
  6. libavcodec/cinepak.c +18 −18
  7. libavformat/allformats.c +1 −0
  8. libavformat/applehttp.c +2 −1
  9. libavformat/avio.c +9 −1
  10. libavformat/avio.h +5 −1
  11. libavformat/http.c +149 −26
  12. libavformat/rtmpproto.c +5 −4
  13. libavformat/rtpdec.c +8 −2
  14. libavformat/rtpdec.h +1 −0
  15. libavformat/rtspdec.c +2 −0
  16. libavformat/segafilm.c +14 −1
  17. libavformat/tls.c +17 −0
  18. libavformat/version.h +4 −1
  19. tests/lavf-regression.sh +1 −1
  20. tests/ref/lavf/ts +1 −1
avconv.c+15−13
@@ -588,12 +588,14 @@ static int read_key(void) · 587 unmodified lines
588588 return -1;
589589 }
590590
591−static int decode_interrupt_cb(void)
591+static int decode_interrupt_cb(void *ctx)
592592 {
593593 q_pressed += read_key() == 'q';
594594 return q_pressed > 1;
595595 }
596596
597+static const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL };
598+
597599 void exit_program(int ret)
598600 {
599601 int i;
@@ -2336,6 +2338,7 @@ static int transcode_init(OutputFile *output_files, · 1736 unmodified lines
23362338 /* open files and write file headers */
23372339 for (i = 0; i < nb_output_files; i++) {
23382340 os = output_files[i].ctx;
2341+ os->interrupt_callback = int_cb;
23392342 if (avformat_write_header(os, &output_files[i].opts) < 0) {
23402343 snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
23412344 ret = AVERROR(EINVAL);
@@ -3010,7 +3013,7 @@ static void dump_attachment(AVStream *st, const char *filename) · 668 unmodified lines
30103013
30113014 assert_file_overwrite(filename);
30123015
3013− if ((ret = avio_open (&out, filename, AVIO_FLAG_WRITE)) < 0) {
3016+ if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, &int_cb, NULL)) < 0) {
30143017 av_log(NULL, AV_LOG_FATAL, "Could not open file %s for writing.\n",
30153018 filename);
30163019 exit_program(1);
@@ -3068,6 +3071,7 @@ static int opt_input_file(OptionsContext *o, const char *opt, const char *filena · 51 unmodified lines
30683071 av_dict_set(&format_opts, "pixel_format", o->frame_pix_fmts[o->nb_frame_pix_fmts - 1].u.str, 0);
30693072
30703073 ic->flags |= AVFMT_FLAG_NONBLOCK;
3074+ ic->interrupt_callback = int_cb;
30713075
30723076 /* open the input file with generic libav function */
30733077 err = avformat_open_input(&ic, filename, file_iformat, &format_opts);
@@ -3197,12 +3201,12 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV · 123 unmodified lines
31973201 if (codec_name) {
31983202 snprintf(filename, sizeof(filename), "%s%s/%s-%s.avpreset", base[i],
31993203 i != 1 ? "" : "/.avconv", codec_name, preset_name);
3200− ret = avio_open(s, filename, AVIO_FLAG_READ);
3204+ ret = avio_open2(s, filename, AVIO_FLAG_READ, &int_cb, NULL);
32013205 }
32023206 if (ret) {
32033207 snprintf(filename, sizeof(filename), "%s%s/%s.avpreset", base[i],
32043208 i != 1 ? "" : "/.avconv", preset_name);
3205− ret = avio_open(s, filename, AVIO_FLAG_READ);
3209+ ret = avio_open2(s, filename, AVIO_FLAG_READ, &int_cb, NULL);
32063210 }
32073211 }
32083212 return ret;
@@ -3588,8 +3592,9 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata) · 379 unmodified lines
35883592 static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const char *filename)
35893593 {
35903594 int i, err;
3591− AVFormatContext *ic = NULL;
3595+ AVFormatContext *ic = avformat_alloc_context();
35923596
3597+ ic->interrupt_callback = int_cb;
35933598 err = avformat_open_input(&ic, filename, NULL, NULL);
35943599 if (err < 0)
35953600 return err;
@@ -3638,6 +3643,7 @@ static void opt_output_file(void *optctx, const char *filename) · 42 unmodified lines
36383643 }
36393644
36403645 file_oformat= oc->oformat;
3646+ oc->interrupt_callback = int_cb;
36413647
36423648 if (!strcmp(file_oformat->name, "ffm") &&
36433649 av_strstart(filename, "http:", NULL)) {
@@ -3729,7 +3735,7 @@ static void opt_output_file(void *optctx, const char *filename) · 85 unmodified lines
37293735 const char *p;
37303736 int64_t len;
37313737
3732− if ((err = avio_open(&pb, o->attachments[i], AVIO_FLAG_READ)) < 0) {
3738+ if ((err = avio_open2(&pb, o->attachments[i], AVIO_FLAG_READ, &int_cb, NULL)) < 0) {
37333739 av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n",
37343740 o->attachments[i]);
37353741 exit_program(1);
@@ -3779,7 +3785,9 @@ static void opt_output_file(void *optctx, const char *filename) · 43 unmodified lines
37793785 assert_file_overwrite(filename);
37803786
37813787 /* open the file */
3782− if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) {
3788+ if ((err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE,
3789+ &oc->interrupt_callback,
3790+ &output_files[nb_output_files - 1].opts)) < 0) {
37833791 print_error(filename, err);
37843792 exit_program(1);
37853793 }
@@ -4350,12 +4358,6 @@ int main(int argc, char **argv) · 564 unmodified lines
43504358 av_register_all();
43514359 avformat_network_init();
43524360
4353−#if HAVE_ISATTY
4354− if(isatty(STDIN_FILENO))
4355− avio_set_interrupt_cb(decode_interrupt_cb);
4356−#endif
4357−
4358− show_banner();
43594361
43604362 /* parse options */
43614363 parse_options(&o, argc, argv, options, opt_output_file);
configure+4−1
@@ -2583,7 +2583,6 @@ case $target_os in · 2582 unmodified lines
25832583 disable network
25842584 else
25852585 target_os=mingw32
2586− enable_weak w32threads
25872586 fi
25882587 LIBTARGET=i386
25892588 if enabled x86_64; then
@@ -2999,6 +2998,10 @@ if ! disabled vda; then · 409 unmodified lines
29992998 fi
30002999 fi
30013000
3001+if ! disabled w32threads && ! enabled pthreads; then
3002+ check_func _beginthreadex && enable w32threads
3003+fi
3004+
30023005 # check for some common methods of building with pthread support
30033006 # do this before the optional library checks as some of them require pthreads
30043007 if ! disabled pthreads && ! enabled w32threads && ! enabled os2threads; then
doc/APIchanges+10−0
@@ -19,6 +19,16 @@ API changes, most recent first: · 18 unmodified lines
1919 2011-10-20 - b35e9e1 - lavu 51.22.0
2020 Add av_strtok() to avstring.h.
2121
22+2011-11-13 - lavf 53.15.0
23+ New interrupt callback API, allowing per-AVFormatContext/AVIOContext
24+ interrupt callbacks.
25+ 6aa0b98 Add AVIOInterruptCB struct and the interrupt_callback field to
26+ AVFormatContext.
27+ 1dee0ac Add avio_open2() with additional parameters. Those are
28+ an interrupt callback and an options AVDictionary.
29+ This will allow passing AVOptions to protocols after lavf
30+ 54.0.
31+
2232 2011-11-xx - xxxxxxx - lavu 51.16.0
2333 Add av_timegm()
2434
ffmpeg.c+15−14
@@ -635,11 +635,13 @@ static int read_key(void) · 634 unmodified lines
635635 return -1;
636636 }
637637
638−static int decode_interrupt_cb(void)
638+static int decode_interrupt_cb(void *ctx)
639639 {
640640 return received_nb_signals > 1;
641641 }
642642
643+static const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL };
644+
643645 void av_noreturn exit_program(int ret)
644646 {
645647 int i;
@@ -2403,6 +2405,7 @@ static int transcode_init(OutputFile *output_files, int nb_output_files, · 1757 unmodified lines
24032405 /* open files and write file headers */
24042406 for (i = 0; i < nb_output_files; i++) {
24052407 os = output_files[i].ctx;
2408+ os->interrupt_callback = int_cb;
24062409 if (avformat_write_header(os, &output_files[i].opts) < 0) {
24072410 snprintf(error, sizeof(error), "Could not write header for output file #%d (incorrect codec parameters ?)", i);
24082411 ret = AVERROR(EINVAL);
@@ -2495,7 +2498,6 @@ static int transcode(OutputFile *output_files, int nb_output_files, · 86 unmodified lines
24952498
24962499 if (!using_stdin) {
24972500 av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n");
2498− avio_set_interrupt_cb(decode_interrupt_cb);
24992501 }
25002502
25012503 timer_start = av_gettime();
@@ -3243,7 +3245,7 @@ static void dump_attachment(AVStream *st, const char *filename) · 741 unmodified lines
32433245
32443246 assert_file_overwrite(filename);
32453247
3246− if ((ret = avio_open (&out, filename, AVIO_FLAG_WRITE)) < 0) {
3248+ if ((ret = avio_open2(&out, filename, AVIO_FLAG_WRITE, &int_cb, NULL)) < 0) {
32473249 av_log(NULL, AV_LOG_FATAL, "Could not open file %s for writing.\n",
32483250 filename);
32493251 exit_program(1);
@@ -3307,6 +3309,7 @@ static int opt_input_file(OptionsContext *o, const char *opt, const char *filena · 57 unmodified lines
33073309 ic->subtitle_codec_id= subtitle_codec_name ?
33083310 find_codec_or_die(subtitle_codec_name, AVMEDIA_TYPE_SUBTITLE, 0)->id : CODEC_ID_NONE;
33093311 ic->flags |= AVFMT_FLAG_NONBLOCK;
3312+ ic->interrupt_callback = int_cb;
33103313
33113314 if (loop_input) {
33123315 av_log(NULL, AV_LOG_WARNING, "-loop_input is deprecated, use -loop 1\n");
@@ -3438,12 +3441,12 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV · 125 unmodified lines
34383441 if (codec_name) {
34393442 snprintf(filename, sizeof(filename), "%s%s/%s-%s.avpreset", base[i],
34403443 i != 1 ? "" : "/.avconv", codec_name, preset_name);
3441− ret = avio_open(s, filename, AVIO_FLAG_READ);
3444+ ret = avio_open2(s, filename, AVIO_FLAG_READ, &int_cb, NULL);
34423445 }
34433446 if (ret) {
34443447 snprintf(filename, sizeof(filename), "%s%s/%s.avpreset", base[i],
34453448 i != 1 ? "" : "/.avconv", preset_name);
3446− ret = avio_open(s, filename, AVIO_FLAG_READ);
3449+ ret = avio_open2(s, filename, AVIO_FLAG_READ, &int_cb, NULL);
34473450 }
34483451 }
34493452 return ret;
@@ -3856,8 +3859,9 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata) · 406 unmodified lines
38563859 static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const char *filename)
38573860 {
38583861 int i, err;
3859− AVFormatContext *ic = NULL;
3862+ AVFormatContext *ic = avformat_alloc_context();
38603863
3864+ ic->interrupt_callback = int_cb;
38613865 err = avformat_open_input(&ic, filename, NULL, NULL);
38623866 if (err < 0)
38633867 return err;
@@ -3908,6 +3912,7 @@ static void opt_output_file(void *optctx, const char *filename) · 44 unmodified lines
39083912 exit_program(1);
39093913 }
39103914 file_oformat= oc->oformat;
3915+ oc->interrupt_callback = int_cb;
39113916
39123917 if (!strcmp(file_oformat->name, "ffm") &&
39133918 av_strstart(filename, "http:", NULL)) {
@@ -4019,7 +4024,7 @@ static void opt_output_file(void *optctx, const char *filename) · 105 unmodified lines
40194024 const char *p;
40204025 int64_t len;
40214026
4022− if ((err = avio_open(&pb, o->attachments[i], AVIO_FLAG_READ)) < 0) {
4027+ if ((err = avio_open2(&pb, o->attachments[i], AVIO_FLAG_READ, &int_cb, NULL)) < 0) {
40234028 av_log(NULL, AV_LOG_FATAL, "Could not open attachment file %s.\n",
40244029 o->attachments[i]);
40254030 exit_program(1);
@@ -4069,7 +4074,9 @@ static void opt_output_file(void *optctx, const char *filename) · 43 unmodified lines
40694074 assert_file_overwrite(filename);
40704075
40714076 /* open the file */
4072− if ((err = avio_open(&oc->pb, filename, AVIO_FLAG_WRITE)) < 0) {
4077+ if ((err = avio_open2(&oc->pb, filename, AVIO_FLAG_WRITE,
4078+ &oc->interrupt_callback,
4079+ &output_files[nb_output_files - 1].opts)) < 0) {
40734080 print_error(filename, err);
40744081 exit_program(1);
40754082 }
@@ -4725,12 +4732,6 @@ int main(int argc, char **argv) · 649 unmodified lines
47254732 av_register_all();
47264733 avformat_network_init();
47274734
4728−#if HAVE_ISATTY
4729− if(isatty(STDIN_FILENO))
4730− avio_set_interrupt_cb(decode_interrupt_cb);
4731−#endif
4732−
4733− show_banner();
47344735
47354736 term_init();
47364737
ffplay.c+3−2
@@ -2414,7 +2414,7 @@ static void stream_component_close(VideoState *is, int stream_index) · 2413 unmodified lines
24142414 variable instead of a thread local variable */
24152415 static VideoState *global_video_state;
24162416
2417−static int decode_interrupt_cb(void)
2417+static int decode_interrupt_cb(void *ctx)
24182418 {
24192419 return (global_video_state && global_video_state->abort_request);
24202420 }
@@ -2439,8 +2439,9 @@ static int read_thread(void *arg) · 18 unmodified lines
24392439 is->subtitle_stream = -1;
24402440
24412441 global_video_state = is;
2442− avio_set_interrupt_cb(decode_interrupt_cb);
24432442
2443+ ic = avformat_alloc_context();
2444+ ic->interrupt_callback.callback = decode_interrupt_cb;
24442445 err = avformat_open_input(&ic, is->filename, is->iformat, &format_opts);
24452446 if (err < 0) {
24462447 print_error(is->filename, err);
libavcodec/cinepak.c+18−18
@@ -147,7 +147,7 @@ static int cinepak_decode_vectors (CinepakContext *s, cvid_strip *strip, · 146 unmodified lines
147147 for (x=strip->x1; x < strip->x2; x+=4) {
148148 if ((chunk_id & 0x01) && !(mask >>= 1)) {
149149 if ((data + 4) > eod)
150− return -1;
150+ return AVERROR_INVALIDDATA;
151151
152152 flag = AV_RB32 (data);
153153 data += 4;
@@ -157,7 +157,7 @@ static int cinepak_decode_vectors (CinepakContext *s, cvid_strip *strip, · 3 unmodified lines
157157 if (!(chunk_id & 0x01) || (flag & mask)) {
158158 if (!(chunk_id & 0x02) && !(mask >>= 1)) {
159159 if ((data + 4) > eod)
160− return -1;
160+ return AVERROR_INVALIDDATA;
161161
162162 flag = AV_RB32 (data);
163163 data += 4;
@@ -166,7 +166,7 @@ static int cinepak_decode_vectors (CinepakContext *s, cvid_strip *strip, · 2 unmodified lines
166166
167167 if ((chunk_id & 0x02) || (~flag & mask)) {
168168 if (data >= eod)
169− return -1;
169+ return AVERROR_INVALIDDATA;
170170
171171 codebook = &strip->v1_codebook[*data++];
172172 s->frame.data[0][iy[0] + 0] = codebook->y0;
@@ -207,7 +207,7 @@ static int cinepak_decode_vectors (CinepakContext *s, cvid_strip *strip, · 34 unmodified lines
207207
208208 } else if (flag & mask) {
209209 if ((data + 4) > eod)
210− return -1;
210+ return AVERROR_INVALIDDATA;
211211
212212 codebook = &strip->v4_codebook[*data++];
213213 s->frame.data[0][iy[0] + 0] = codebook->y0;
@@ -269,16 +269,16 @@ static int cinepak_decode_strip (CinepakContext *s, · 55 unmodified lines
269269 int chunk_id, chunk_size;
270270
271271 /* coordinate sanity checks */
272− if (strip->x2 > s->width ||
273− strip->y2 > s->height ||
272+ if (strip->x2 > s->width ||
273+ strip->y2 > s->height ||
274274 strip->x1 >= strip->x2 || strip->y1 >= strip->y2)
275− return -1;
275+ return AVERROR_INVALIDDATA;
276276
277277 while ((data + 4) <= eod) {
278278 chunk_id = data[0];
279279 chunk_size = AV_RB24 (&data[1]) - 4;
280280 if(chunk_size < 0)
281− return -1;
281+ return AVERROR_INVALIDDATA;
282282
283283 data += 4;
284284 chunk_size = ((data + chunk_size) > eod) ? (eod - data) : chunk_size;
@@ -311,7 +311,7 @@ static int cinepak_decode_strip (CinepakContext *s, · 26 unmodified lines
311311 data += chunk_size;
312312 }
313313
314− return -1;
314+ return AVERROR_INVALIDDATA;
315315 }
316316
317317 static int cinepak_decode (CinepakContext *s)
@@ -322,7 +322,7 @@ static int cinepak_decode (CinepakContext *s) · 4 unmodified lines
322322 int encoded_buf_size;
323323
324324 if (s->size < 10)
325− return -1;
325+ return AVERROR_INVALIDDATA;
326326
327327 frame_flags = s->data[0];
328328 num_strips = AV_RB16 (&s->data[8]);
@@ -330,9 +330,9 @@ static int cinepak_decode (CinepakContext *s) · 1 unmodified line
330330
331331 /* if this is the first frame, check for deviant Sega FILM data */
332332 if (s->sega_film_skip_bytes == -1) {
333− if (!encoded_buf_size){
333+ if (!encoded_buf_size) {
334334 av_log_ask_for_sample(s->avctx, "encoded_buf_size is 0");
335− return -1;
335+ return AVERROR_INVALIDDATA;
336336 }
337337 if (encoded_buf_size != s->size && (s->size % encoded_buf_size) != 0) {
338338 /* If the encoded frame size differs from the frame size as indicated
@@ -363,7 +363,7 @@ static int cinepak_decode (CinepakContext *s) · 24 unmodified lines
363363
364364 for (i=0; i < num_strips; i++) {
365365 if ((s->data + 12) > eod)
366− return -1;
366+ return AVERROR_INVALIDDATA;
367367
368368 s->strips[i].id = s->data[0];
369369 s->strips[i].y1 = y0;
@@ -375,8 +375,8 @@ static int cinepak_decode (CinepakContext *s) · 5 unmodified lines
375375 s->frame.key_frame = 1;
376376
377377 strip_size = AV_RB24 (&s->data[1]) - 12;
378− if(strip_size < 0)
379− return -1;
378+ if (strip_size < 0)
379+ return AVERROR_INVALIDDATA;
380380 s->data += 12;
381381 strip_size = ((s->data + strip_size) > eod) ? (eod - s->data) : strip_size;
382382
@@ -427,7 +427,7 @@ static int cinepak_decode_frame(AVCodecContext *avctx, · 44 unmodified lines
427427 AVPacket *avpkt)
428428 {
429429 const uint8_t *buf = avpkt->data;
430− int buf_size = avpkt->size;
430+ int ret = 0, buf_size = avpkt->size;
431431 CinepakContext *s = avctx->priv_data;
432432
433433 s->data = buf;
@@ -436,9 +436,9 @@ static int cinepak_decode_frame(AVCodecContext *avctx, · 2 unmodified lines
436436 s->frame.reference = 3;
437437 s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE |
438438 FF_BUFFER_HINTS_REUSABLE;
439− if (avctx->reget_buffer(avctx, &s->frame)) {
439+ if ((ret = avctx->reget_buffer(avctx, &s->frame))) {
440440 av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
441− return -1;
441+ return ret;
442442 }
443443
444444 if (s->palette_video) {
libavformat/allformats.c+1−0
@@ -259,6 +259,7 @@ void av_register_all(void) · 258 unmodified lines
259259 REGISTER_PROTOCOL (FILE, file);
260260 REGISTER_PROTOCOL (GOPHER, gopher);
261261 REGISTER_PROTOCOL (HTTP, http);
262+ REGISTER_PROTOCOL (HTTPPROXY, httpproxy);
262263 REGISTER_PROTOCOL (HTTPS, https);
263264 REGISTER_PROTOCOL (MMSH, mmsh);
264265 REGISTER_PROTOCOL (MMST, mmst);
libavformat/applehttp.c+2−1
@@ -644,7 +644,8 @@ static int applehttp_read_seek(AVFormatContext *s, int stream_index, · 643 unmodified lines
644644 for (i = 0; i < c->n_variants; i++) {
645645 /* Reset reading */
646646 struct variant *var = c->variants[i];
647− int64_t pos = av_rescale_rnd(c->first_timestamp, 1, stream_index >= 0 ?
647+ int64_t pos = c->first_timestamp == AV_NOPTS_VALUE ? 0 :
648+ av_rescale_rnd(c->first_timestamp, 1, stream_index >= 0 ?
648649 s->streams[stream_index]->time_base.den :
649650 AV_TIME_BASE, flags & AVSEEK_FLAG_BACKWARD ?
650651 AV_ROUND_DOWN : AV_ROUND_UP);
libavformat/avio.c+9−1
@@ -83,9 +83,11 @@ const AVClass ffurl_context_class = { · 82 unmodified lines
8383 };
8484 /*@}*/
8585
86−static int default_interrupt_cb(void);
8786
87+#if FF_API_OLD_INTERRUPT_CB
88+static int default_interrupt_cb(void);
8889 int (*url_interrupt_cb)(void) = default_interrupt_cb;
90+#endif
8991
9092 URLProtocol *av_protocol_next(URLProtocol *p)
9193 {
@@ -444,6 +446,7 @@ int ffurl_get_file_handle(URLContext *h) · 352 unmodified lines
444446 return h->prot->url_get_file_handle(h);
445447 }
446448
449+#if FF_API_OLD_INTERRUPT_CB
447450 static int default_interrupt_cb(void)
448451 {
449452 return 0;
@@ -455,13 +458,18 @@ void avio_set_interrupt_cb(int (*interrupt_cb)(void)) · 5 unmodified lines
455458 interrupt_cb = default_interrupt_cb;
456459 url_interrupt_cb = interrupt_cb;
457460 }
461+#endif
458462
459463 int ff_check_interrupt(AVIOInterruptCB *cb)
460464 {
461465 int ret;
462466 if (cb && cb->callback && (ret = cb->callback(cb->opaque)))
463467 return ret;
468+#if FF_API_OLD_INTERRUPT_CB
464469 return url_interrupt_cb();
470+#else
471+ return 0;
472+#endif
465473 }
466474
467475 #if FF_API_OLD_AVIO
libavformat/avio.h+5−1
@@ -386,13 +386,17 @@ attribute_deprecated int url_exist(const char *url); · 385 unmodified lines
386386 */
387387 int avio_check(const char *url, int flags);
388388
389+#if FF_API_OLD_INTERRUPT_CB
389390 /**
390391 * The callback is called in blocking functions to test regulary if
391392 * asynchronous interruption is needed. AVERROR_EXIT is returned
392393 * in this case by the interrupted function. 'NULL' means no interrupt
393394 * callback is given.
395+ * @deprecated Use interrupt_callback in AVFormatContext/avio_open2
396+ * instead.
394397 */
395−void avio_set_interrupt_cb(int (*interrupt_cb)(void));
398+attribute_deprecated void avio_set_interrupt_cb(int (*interrupt_cb)(void));
399+#endif
396400
397401 /**
398402 * Allocate and initialize an AVIOContext for buffered I/O. It must be later
libavformat/http.c+149−26
@@ -110,6 +110,15 @@ static int http_open_cnx(URLContext *h) · 109 unmodified lines
110110 path1, sizeof(path1), s->location);
111111 ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
112112
113+ if (!strcmp(proto, "https")) {
114+ lower_proto = "tls";
115+ use_proxy = 0;
116+ if (port < 0)
117+ port = 443;
118+ }
119+ if (port < 0)
120+ port = 80;
121+
113122 if (path1[0] == '\0')
114123 path = "/";
115124 else
@@ -124,13 +133,6 @@ static int http_open_cnx(URLContext *h) · 8 unmodified lines
124133 av_url_split(NULL, 0, proxyauth, sizeof(proxyauth),
125134 hostname, sizeof(hostname), &port, NULL, 0, proxy_path);
126135 }
127− if (!strcmp(proto, "https")) {
128− lower_proto = "tls";
129− if (port < 0)
130− port = 443;
131− }
132− if (port < 0)
133− port = 80;
134136
135137 ff_url_join(buf, sizeof(buf), lower_proto, NULL, hostname, port, NULL);
136138 err = ffurl_open(&hd, buf, AVIO_FLAG_READ_WRITE,
@@ -413,10 +415,33 @@ static int http_connect(URLContext *h, const char *path, const char *local_path, · 276 unmodified lines
413415 }
414416
415417
416−static int http_read(URLContext *h, uint8_t *buf, int size)
418+static int http_buf_read(URLContext *h, uint8_t *buf, int size)
417419 {
418420 HTTPContext *s = h->priv_data;
419421 int len;
422+ /* read bytes from input buffer first */
423+ len = s->buf_end - s->buf_ptr;
424+ if (len > 0) {
425+ if (len > size)
426+ len = size;
427+ memcpy(buf, s->buf_ptr, len);
428+ s->buf_ptr += len;
429+ } else {
430+ if (!s->willclose && s->filesize >= 0 && s->off >= s->filesize)
431+ return AVERROR_EOF;
432+ len = ffurl_read(s->hd, buf, size);
433+ }
434+ if (len > 0) {
435+ s->off += len;
436+ if (s->chunksize > 0)
437+ s->chunksize -= len;
438+ }
439+ return len;
440+}
441+
442+static int http_read(URLContext *h, uint8_t *buf, int size)
443+{
444+ HTTPContext *s = h->priv_data;
420445
421446 if (s->chunksize >= 0) {
422447 if (!s->chunksize) {
@@ -439,24 +464,7 @@ static int http_read(URLContext *h, uint8_t *buf, int size) · 16 unmodified lines
439464 }
440465 size = FFMIN(size, s->chunksize);
441466 }
442− /* read bytes from input buffer first */
443− len = s->buf_end - s->buf_ptr;
444− if (len > 0) {
445− if (len > size)
446− len = size;
447− memcpy(buf, s->buf_ptr, len);
448− s->buf_ptr += len;
449− } else {
450− if (!s->willclose && s->filesize >= 0 && s->off >= s->filesize)
451− return AVERROR_EOF;
452− len = ffurl_read(s->hd, buf, size);
453− }
454− if (len > 0) {
455− s->off += len;
456− if (s->chunksize > 0)
457− s->chunksize -= len;
458− }
459− return len;
467+ return http_buf_read(h, buf, size);
460468 }
461469
462470 /* used only when posting data */
@@ -572,3 +580,118 @@ URLProtocol ff_https_protocol = { · 109 unmodified lines
572580 .priv_data_class = &https_context_class,
573581 };
574582 #endif
583+
584+#if CONFIG_HTTPPROXY_PROTOCOL
585+static int http_proxy_close(URLContext *h)
586+{
587+ HTTPContext *s = h->priv_data;
588+ if (s->hd)
589+ ffurl_close(s->hd);
590+ return 0;
591+}
592+
593+static int http_proxy_open(URLContext *h, const char *uri, int flags)
594+{
595+ HTTPContext *s = h->priv_data;
596+ char hostname[1024], hoststr[1024];
597+ char auth[1024], pathbuf[1024], *path;
598+ char line[1024], lower_url[100];
599+ int port, ret = 0;
600+ HTTPAuthType cur_auth_type;
601+ char *authstr;
602+
603+ h->is_streamed = 1;
604+
605+ av_url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
606+ pathbuf, sizeof(pathbuf), uri);
607+ ff_url_join(hoststr, sizeof(hoststr), NULL, NULL, hostname, port, NULL);
608+ path = pathbuf;
609+ if (*path == '/')
610+ path++;
611+
612+ ff_url_join(lower_url, sizeof(lower_url), "tcp", NULL, hostname, port,
613+ NULL);
614+redo:
615+ ret = ffurl_open(&s->hd, lower_url, AVIO_FLAG_READ_WRITE,
616+ &h->interrupt_callback, NULL);
617+ if (ret < 0)
618+ return ret;
619+
620+ authstr = ff_http_auth_create_response(&s->proxy_auth_state, auth,
621+ path, "CONNECT");
622+ snprintf(s->buffer, sizeof(s->buffer),
623+ "CONNECT %s HTTP/1.1\r\n"
624+ "Host: %s\r\n"
625+ "Connection: close\r\n"
626+ "%s%s"
627+ "\r\n",
628+ path,
629+ hoststr,
630+ authstr ? "Proxy-" : "", authstr ? authstr : "");
631+ av_freep(&authstr);
632+
633+ if ((ret = ffurl_write(s->hd, s->buffer, strlen(s->buffer))) < 0)
634+ goto fail;
635+
636+ s->buf_ptr = s->buffer;
637+ s->buf_end = s->buffer;
638+ s->line_count = 0;
639+ s->filesize = -1;
640+ cur_auth_type = s->proxy_auth_state.auth_type;
641+
642+ for (;;) {
643+ int new_loc;
644+ // Note: This uses buffering, potentially reading more than the
645+ // HTTP header. If tunneling a protocol where the server starts
646+ // the conversation, we might buffer part of that here, too.
647+ // Reading that requires using the proper ffurl_read() function
648+ // on this URLContext, not using the fd directly (as the tls
649+ // protocol does). This shouldn't be an issue for tls though,
650+ // since the client starts the conversation there, so there
651+ // is no extra data that we might buffer up here.
652+ if (http_get_line(s, line, sizeof(line)) < 0) {
653+ ret = AVERROR(EIO);
654+ goto fail;
655+ }
656+
657+ av_dlog(h, "header='%s'\n", line);
658+
659+ ret = process_line(h, line, s->line_count, &new_loc);
660+ if (ret < 0)
661+ goto fail;
662+ if (ret == 0)
663+ break;
664+ s->line_count++;
665+ }
666+ if (s->http_code == 407 && cur_auth_type == HTTP_AUTH_NONE &&
667+ s->proxy_auth_state.auth_type != HTTP_AUTH_NONE) {
668+ ffurl_close(s->hd);
669+ s->hd = NULL;
670+ goto redo;
671+ }
672+
673+ if (s->http_code < 400)
674+ return 0;
675+ ret = AVERROR(EIO);
676+
677+fail:
678+ http_proxy_close(h);
679+ return ret;
680+}
681+
682+static int http_proxy_write(URLContext *h, const uint8_t *buf, int size)
683+{
684+ HTTPContext *s = h->priv_data;
685+ return ffurl_write(s->hd, buf, size);
686+}
687+
688+URLProtocol ff_httpproxy_protocol = {
689+ .name = "httpproxy",
690+ .url_open = http_proxy_open,
691+ .url_read = http_buf_read,
692+ .url_write = http_proxy_write,
693+ .url_close = http_proxy_close,
694+ .url_get_file_handle = http_get_file_handle,
695+ .priv_data_size = sizeof(HTTPContext),
696+};
697+#endif
libavformat/rtmpproto.c+5−4
@@ -74,6 +74,7 @@ typedef struct RTMPContext { · 73 unmodified lines
7474 int skip_bytes; ///< number of bytes to skip from the input FLV stream in the next write call
7575 uint8_t flv_header[11]; ///< partial incoming flv packet header
7676 int flv_header_bytes; ///< number of initialized bytes in flv_header
77+ int nb_invokes; ///< keeps track of invoke messages
7778 } RTMPContext;
7879
7980 #define PLAYER_KEY_OPEN_PART_LEN 30 ///< length of partial key used for first client digest signing
@@ -166,7 +167,7 @@ static void gen_release_stream(URLContext *s, RTMPContext *rt) · 86 unmodified lines
166167 av_log(s, AV_LOG_DEBUG, "Releasing stream...\n");
167168 p = pkt.data;
168169 ff_amf_write_string(&p, "releaseStream");
169− ff_amf_write_number(&p, 2.0);
170+ ff_amf_write_number(&p, ++rt->nb_invokes);
170171 ff_amf_write_null(&p);
171172 ff_amf_write_string(&p, rt->playpath);
172173
@@ -189,7 +190,7 @@ static void gen_fcpublish_stream(URLContext *s, RTMPContext *rt) · 16 unmodified lines
189190 av_log(s, AV_LOG_DEBUG, "FCPublish stream...\n");
190191 p = pkt.data;
191192 ff_amf_write_string(&p, "FCPublish");
192− ff_amf_write_number(&p, 3.0);
193+ ff_amf_write_number(&p, ++rt->nb_invokes);
193194 ff_amf_write_null(&p);
194195 ff_amf_write_string(&p, rt->playpath);
195196
@@ -212,7 +213,7 @@ static void gen_fcunpublish_stream(URLContext *s, RTMPContext *rt) · 16 unmodified lines
212213 av_log(s, AV_LOG_DEBUG, "UnPublishing stream...\n");
213214 p = pkt.data;
214215 ff_amf_write_string(&p, "FCUnpublish");
215− ff_amf_write_number(&p, 5.0);
216+ ff_amf_write_number(&p, ++rt->nb_invokes);
216217 ff_amf_write_null(&p);
217218 ff_amf_write_string(&p, rt->playpath);
218219
@@ -234,7 +235,7 @@ static void gen_create_stream(URLContext *s, RTMPContext *rt) · 15 unmodified lines
234235
235236 p = pkt.data;
236237 ff_amf_write_string(&p, "createStream");
237− ff_amf_write_number(&p, rt->is_input ? 3.0 : 4.0);
238+ ff_amf_write_number(&p, ++rt->nb_invokes);
238239 ff_amf_write_null(&p);
239240
240241 ff_rtmp_packet_write(rt->stream, &pkt, rt->chunk_size, rt->prev_pkt[1]);
libavformat/rtpdec.c+8−2
@@ -429,7 +429,7 @@ static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestam · 428 unmodified lines
429429 if (timestamp == RTP_NOTS_VALUE)
430430 return;
431431
432− if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE) {
432+ if (s->last_rtcp_ntp_time != AV_NOPTS_VALUE && s->ic->nb_streams > 1) {
433433 int64_t addend;
434434 int delta_timestamp;
435435
@@ -444,7 +444,13 @@ static void finalize_packet(RTPDemuxContext *s, AVPacket *pkt, uint32_t timestam · 8 unmodified lines
444444
445445 if (!s->base_timestamp)
446446 s->base_timestamp = timestamp;
447− pkt->pts = s->range_start_offset + timestamp - s->base_timestamp;
447+ /* assume that the difference is INT32_MIN < x < INT32_MAX, but allow the first timestamp to exceed INT32_MAX */
448+ if (!s->timestamp)
449+ s->unwrapped_timestamp += timestamp;
450+ else
451+ s->unwrapped_timestamp += (int32_t)(timestamp - s->timestamp);
452+ s->timestamp = timestamp;
453+ pkt->pts = s->unwrapped_timestamp + s->range_start_offset - s->base_timestamp;
448454 }
449455
450456 static int rtp_parse_packet_internal(RTPDemuxContext *s, AVPacket *pkt,
libavformat/rtpdec.h+1−0
@@ -151,6 +151,7 @@ struct RTPDemuxContext { · 150 unmodified lines
151151 uint32_t timestamp;
152152 uint32_t base_timestamp;
153153 uint32_t cur_timestamp;
154+ int64_t unwrapped_timestamp;
154155 int64_t range_start_offset;
155156 int max_payload_size;
156157 struct MpegTSContext *ts; /* only used for MP2T payloads */
libavformat/rtspdec.c+2−0
@@ -52,6 +52,8 @@ static int rtsp_read_play(AVFormatContext *s) · 51 unmodified lines
5252 rtpctx->last_rtcp_ntp_time = AV_NOPTS_VALUE;
5353 rtpctx->first_rtcp_ntp_time = AV_NOPTS_VALUE;
5454 rtpctx->base_timestamp = 0;
55+ rtpctx->timestamp = 0;
56+ rtpctx->unwrapped_timestamp = 0;
5557 rtpctx->rtcp_ts_offset = 0;
5658 }
5759 }
libavformat/segafilm.c+14−1
@@ -34,6 +34,7 @@ · 33 unmodified lines
3434 #define FDSC_TAG MKBETAG('F', 'D', 'S', 'C')
3535 #define STAB_TAG MKBETAG('S', 'T', 'A', 'B')
3636 #define CVID_TAG MKBETAG('c', 'v', 'i', 'd')
37+#define RAW_TAG MKBETAG('r', 'a', 'w', ' ')
3738
3839 typedef struct {
3940 int stream;
@@ -129,8 +130,11 @@ static int film_read_header(AVFormatContext *s, · 89 unmodified lines
129130
130131 if (AV_RB32(&scratch[8]) == CVID_TAG) {
131132 film->video_type = CODEC_ID_CINEPAK;
132− } else
133+ } else if (AV_RB32(&scratch[8]) == RAW_TAG) {
134+ film->video_type = CODEC_ID_RAWVIDEO;
135+ } else {
133136 film->video_type = CODEC_ID_NONE;
137+ }
134138
135139 /* initialize the decoder streams */
136140 if (film->video_type) {
@@ -143,6 +147,15 @@ static int film_read_header(AVFormatContext *s, · 6 unmodified lines
143147 st->codec->codec_tag = 0; /* no fourcc */
144148 st->codec->width = AV_RB32(&scratch[16]);
145149 st->codec->height = AV_RB32(&scratch[12]);
150+
151+ if (film->video_type == CODEC_ID_RAWVIDEO) {
152+ if (scratch[20] == 24) {
153+ st->codec->pix_fmt = PIX_FMT_RGB24;
154+ } else {
155+ av_log(s, AV_LOG_ERROR, "raw video is using unhandled %dbpp\n", scratch[20]);
156+ return -1;
157+ }
158+ }
146159 }
147160
148161 if (film->audio_type) {
libavformat/tls.c+17−0
@@ -111,9 +111,15 @@ static int tls_open(URLContext *h, const char *uri, int flags) · 110 unmodified lines
111111 char buf[200], host[200];
112112 int numerichost = 0;
113113 struct addrinfo hints = { 0 }, *ai = NULL;
114+ const char *proxy_path;
115+ int use_proxy;
114116
115117 ff_tls_init();
116118
119+ proxy_path = getenv("http_proxy");
120+ use_proxy = (proxy_path != NULL) && !getenv("no_proxy") &&
121+ av_strstart(proxy_path, "http://", NULL);
122+
117123 av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, NULL, 0, uri);
118124 ff_url_join(buf, sizeof(buf), "tcp", NULL, host, port, NULL);
119125
@@ -123,6 +129,17 @@ static int tls_open(URLContext *h, const char *uri, int flags) · 3 unmodified lines
123129 freeaddrinfo(ai);
124130 }
125131
132+ if (use_proxy) {
133+ char proxy_host[200], proxy_auth[200], dest[200];
134+ int proxy_port;
135+ av_url_split(NULL, 0, proxy_auth, sizeof(proxy_auth),
136+ proxy_host, sizeof(proxy_host), &proxy_port, NULL, 0,
137+ proxy_path);
138+ ff_url_join(dest, sizeof(dest), NULL, NULL, host, port, NULL);
139+ ff_url_join(buf, sizeof(buf), "httpproxy", proxy_auth, proxy_host,
140+ proxy_port, "/%s", dest);
141+ }
142+
126143 ret = ffurl_open(&c->tcp, buf, AVIO_FLAG_READ_WRITE,
127144 &h->interrupt_callback, NULL);
128145 if (ret)
libavformat/version.h+4−1
@@ -24,7 +24,7 @@ · 23 unmodified lines
2424 #include "libavutil/avutil.h"
2525
2626 #define LIBAVFORMAT_VERSION_MAJOR 53
27−#define LIBAVFORMAT_VERSION_MINOR 20
27+#define LIBAVFORMAT_VERSION_MINOR 21
2828 #define LIBAVFORMAT_VERSION_MICRO 0
2929
3030 #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
@@ -113,5 +113,8 @@ · 82 unmodified lines
113113 #ifndef FF_API_REORDER_PRIVATE
114114 #define FF_API_REORDER_PRIVATE (LIBAVFORMAT_VERSION_MAJOR < 54)
115115 #endif
116+#ifndef FF_API_OLD_INTERRUPT_CB
117+#define FF_API_OLD_INTERRUPT_CB (LIBAVFORMAT_VERSION_MAJOR < 54)
118+#endif
116119
117120 #endif /* AVFORMAT_VERSION_H */
tests/lavf-regression.sh+1−1
@@ -71,7 +71,7 @@ do_lavf mxf_d10 "-ar 48000 -ac 2 -r 25 -s 720x576 -vf pad=720:608:0:32 -vcodec m · 70 unmodified lines
7171 fi
7272
7373 if [ -n "$do_ts" ] ; then
74−do_lavf ts "-ab 64k"
74+do_lavf ts "-ab 64k -mpegts_transport_stream_id 42"
7575 fi
7676
7777 if [ -n "$do_swf" ] ; then
tests/ref/lavf/ts+1−1
@@ -1,3 +1,3 @@
1−151774afed45b19da9b7e83613a1e72b *./tests/data/lavf/lavf.ts
1+024f0cdd4c51a158b2a38b901d2ed2e5 *./tests/data/lavf/lavf.ts
22 406644 ./tests/data/lavf/lavf.ts
33 ./tests/data/lavf/lavf.ts CRC=0x133216c1

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