]> git.sesse.net Git - ffmpeg/commitdiff
Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Thu, 28 Feb 2013 12:12:04 +0000 (13:12 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Thu, 28 Feb 2013 12:13:04 +0000 (13:13 +0100)
* qatar/master:
  lavf: Add a fate test for the noproxy pattern matching
  lavf: Handle the environment variable no_proxy more properly

Conflicts:
libavformat/Makefile
libavformat/internal.h
libavformat/tls.c
libavformat/utils.c
libavformat/version.h

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/Makefile
libavformat/http.c
libavformat/internal.h
libavformat/noproxy-test.c
libavformat/tls.c
libavformat/utils.c
libavformat/version.h

index 44456eab6443cbd50548b725064297ac726e909f,110e683b2e3d67992ac6577cad8195ef89cfdffd..03d7e2357bc6d5390c92b6f6e409fc06ab3ba19f
@@@ -441,7 -376,12 +441,8 @@@ OBJS-$(CONFIG_UDP_PROTOCOL
  
  SKIPHEADERS-$(CONFIG_FFRTMPCRYPT_PROTOCOL) += rtmpdh.h
  SKIPHEADERS-$(CONFIG_NETWORK)            += network.h rtsp.h
- TESTPROGS = seek                                                        \
 -
 -EXAMPLES  = metadata                                                    \
 -            output                                                      \
 -
+ TESTPROGS = noproxy                                                     \
+             seek                                                        \
              srtp                                                        \
              url                                                         \
  
Simple merge
index d1bbf33603904f730c87c3a3ce9f5c0a32abe2aa,73673696476f0e23ff3b67706b890b540a22a54e..4d56388312838f1cd35ed079165f41da0c381f7e
@@@ -376,18 -375,6 +376,20 @@@ enum AVCodecID ff_codec_get_id(const AV
   */
  enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags);
  
 +/**
 + * Chooses a timebase for muxing the specified stream.
 + *
 + * The choosen timebase allows sample accurate timestamps based
 + * on the framerate or sample rate for audio streams. It also is
 + * at least as precisse as 1/min_precission would be.
 + */
 +AVRational ff_choose_timebase(AVFormatContext *s, AVStream *st, int min_precission);
 +
 +/**
 + * Generate standard extradata for AVC-Intra based on width/height and field order.
 + */
 +void ff_generate_avci_extradata(AVStream *st);
 +
+ int ff_http_match_no_proxy(const char *no_proxy, const char *hostname);
  #endif /* AVFORMAT_INTERNAL_H */
index 0000000000000000000000000000000000000000,59a435e30a371b3dd4ffd7546e12dbfd72c6a53b..a156620271a9a6984f1c35a4ea2a47c0b8b83028
mode 000000,100644..100644
--- /dev/null
@@@ -1,0 -1,43 +1,43 @@@
 - * This file is part of Libav.
+ /*
+  * Copyright (c) 2013 Martin Storsjo
+  *
 - * Libav is free software; you can redistribute it and/or
++ * This file is part of FFmpeg.
+  *
 - * Libav is distributed in the hope that it will be useful,
++ * FFmpeg is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU Lesser General Public
+  * License as published by the Free Software Foundation; either
+  * version 2.1 of the License, or (at your option) any later version.
+  *
 - * License along with Libav; if not, write to the Free Software
++ * FFmpeg is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+  * Lesser General Public License for more details.
+  *
+  * You should have received a copy of the GNU Lesser General Public
++ * License along with FFmpeg; if not, write to the Free Software
+  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+  */
+ #include "internal.h"
+ static void test(const char *pattern, const char *host)
+ {
+     int res = ff_http_match_no_proxy(pattern, host);
+     printf("The pattern \"%s\" %s the hostname %s\n",
+            pattern ? pattern : "(null)", res ? "matches" : "does not match",
+            host);
+ }
+ int main(void)
+ {
+     test(NULL, "domain.com");
+     test("example.com domain.com", "domain.com");
+     test("example.com other.com", "domain.com");
+     test("example.com,domain.com", "domain.com");
+     test("example.com,domain.com", "otherdomain.com");
+     test("example.com, *.domain.com", "sub.domain.com");
+     test("example.com, *.domain.com", "domain.com");
+     test("example.com, .domain.com", "domain.com");
+     test("*", "domain.com");
+     return 0;
+ }
index 38dd70c9df6fbbb09d4ea9321d114eb9d8179aef,fecf096b021ab2dd52b4dc65d97eff5157bb21a0..2c85d1dedc9884bce21f040f1d75b7d3263f9ffb
@@@ -172,12 -116,8 +172,8 @@@ static int tls_open(URLContext *h, cons
  
      ff_tls_init();
  
-     proxy_path = getenv("http_proxy");
-     use_proxy = (proxy_path != NULL) && !getenv("no_proxy") &&
-         av_strstart(proxy_path, "http://", NULL);
 -    av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, NULL, 0, uri);
 -    ff_url_join(buf, sizeof(buf), "tcp", NULL, host, port, NULL);
 +    av_url_split(NULL, 0, NULL, 0, host, sizeof(host), &port, path, sizeof(path), uri);
 +    ff_url_join(buf, sizeof(buf), "tcp", NULL, host, port, "%s", path);
  
      hints.ai_flags = AI_NUMERICHOST;
      if (!getaddrinfo(host, NULL, &hints, &ai)) {
index 9bd2d0c34b1760ae1a30a37a8cc6e7ef7f88e4b8,be5a5caabfc7b4de607dd815aa8425866d4e5cfc..3df8c51ddd525cdef8cfda12415257665a87bac2
@@@ -4201,181 -3590,56 +4201,235 @@@ const struct AVCodecTag *avformat_get_r
      return ff_codec_wav_tags;
  }
  
 +AVRational av_guess_sample_aspect_ratio(AVFormatContext *format, AVStream *stream, AVFrame *frame)
 +{
 +    AVRational undef = {0, 1};
 +    AVRational stream_sample_aspect_ratio = stream ? stream->sample_aspect_ratio : undef;
 +    AVRational codec_sample_aspect_ratio  = stream && stream->codec ? stream->codec->sample_aspect_ratio : undef;
 +    AVRational frame_sample_aspect_ratio  = frame  ? frame->sample_aspect_ratio  : codec_sample_aspect_ratio;
 +
 +    av_reduce(&stream_sample_aspect_ratio.num, &stream_sample_aspect_ratio.den,
 +               stream_sample_aspect_ratio.num,  stream_sample_aspect_ratio.den, INT_MAX);
 +    if (stream_sample_aspect_ratio.num <= 0 || stream_sample_aspect_ratio.den <= 0)
 +        stream_sample_aspect_ratio = undef;
 +
 +    av_reduce(&frame_sample_aspect_ratio.num, &frame_sample_aspect_ratio.den,
 +               frame_sample_aspect_ratio.num,  frame_sample_aspect_ratio.den, INT_MAX);
 +    if (frame_sample_aspect_ratio.num <= 0 || frame_sample_aspect_ratio.den <= 0)
 +        frame_sample_aspect_ratio = undef;
 +
 +    if (stream_sample_aspect_ratio.num)
 +        return stream_sample_aspect_ratio;
 +    else
 +        return frame_sample_aspect_ratio;
 +}
 +
 +int avformat_match_stream_specifier(AVFormatContext *s, AVStream *st,
 +                                    const char *spec)
 +{
 +    if (*spec <= '9' && *spec >= '0') /* opt:index */
 +        return strtol(spec, NULL, 0) == st->index;
 +    else if (*spec == 'v' || *spec == 'a' || *spec == 's' || *spec == 'd' ||
 +             *spec == 't') { /* opt:[vasdt] */
 +        enum AVMediaType type;
 +
 +        switch (*spec++) {
 +        case 'v': type = AVMEDIA_TYPE_VIDEO;      break;
 +        case 'a': type = AVMEDIA_TYPE_AUDIO;      break;
 +        case 's': type = AVMEDIA_TYPE_SUBTITLE;   break;
 +        case 'd': type = AVMEDIA_TYPE_DATA;       break;
 +        case 't': type = AVMEDIA_TYPE_ATTACHMENT; break;
 +        default:  av_assert0(0);
 +        }
 +        if (type != st->codec->codec_type)
 +            return 0;
 +        if (*spec++ == ':') { /* possibly followed by :index */
 +            int i, index = strtol(spec, NULL, 0);
 +            for (i = 0; i < s->nb_streams; i++)
 +                if (s->streams[i]->codec->codec_type == type && index-- == 0)
 +                   return i == st->index;
 +            return 0;
 +        }
 +        return 1;
 +    } else if (*spec == 'p' && *(spec + 1) == ':') {
 +        int prog_id, i, j;
 +        char *endptr;
 +        spec += 2;
 +        prog_id = strtol(spec, &endptr, 0);
 +        for (i = 0; i < s->nb_programs; i++) {
 +            if (s->programs[i]->id != prog_id)
 +                continue;
 +
 +            if (*endptr++ == ':') {
 +                int stream_idx = strtol(endptr, NULL, 0);
 +                return stream_idx >= 0 &&
 +                    stream_idx < s->programs[i]->nb_stream_indexes &&
 +                    st->index == s->programs[i]->stream_index[stream_idx];
 +            }
 +
 +            for (j = 0; j < s->programs[i]->nb_stream_indexes; j++)
 +                if (st->index == s->programs[i]->stream_index[j])
 +                    return 1;
 +        }
 +        return 0;
 +    } else if (*spec == '#') {
 +        int sid;
 +        char *endptr;
 +        sid = strtol(spec + 1, &endptr, 0);
 +        if (!*endptr)
 +            return st->id == sid;
 +    } else if (!*spec) /* empty specifier, matches everything */
 +        return 1;
 +
 +    av_log(s, AV_LOG_ERROR, "Invalid stream specifier: %s.\n", spec);
 +    return AVERROR(EINVAL);
 +}
 +
 +void ff_generate_avci_extradata(AVStream *st)
 +{
 +    static const uint8_t avci100_1080p_extradata[] = {
 +        // SPS
 +        0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
 +        0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
 +        0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
 +        0x18, 0x21, 0x02, 0x56, 0xb9, 0x3d, 0x7d, 0x7e,
 +        0x4f, 0xe3, 0x3f, 0x11, 0xf1, 0x9e, 0x08, 0xb8,
 +        0x8c, 0x54, 0x43, 0xc0, 0x78, 0x02, 0x27, 0xe2,
 +        0x70, 0x1e, 0x30, 0x10, 0x10, 0x14, 0x00, 0x00,
 +        0x03, 0x00, 0x04, 0x00, 0x00, 0x03, 0x00, 0xca,
 +        0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
 +        // PPS
 +        0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
 +        0xd0
 +    };
 +    static const uint8_t avci100_1080i_extradata[] = {
 +        // SPS
 +        0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
 +        0xb6, 0xd4, 0x20, 0x22, 0x33, 0x19, 0xc6, 0x63,
 +        0x23, 0x21, 0x01, 0x11, 0x98, 0xce, 0x33, 0x19,
 +        0x18, 0x21, 0x03, 0x3a, 0x46, 0x65, 0x6a, 0x65,
 +        0x24, 0xad, 0xe9, 0x12, 0x32, 0x14, 0x1a, 0x26,
 +        0x34, 0xad, 0xa4, 0x41, 0x82, 0x23, 0x01, 0x50,
 +        0x2b, 0x1a, 0x24, 0x69, 0x48, 0x30, 0x40, 0x2e,
 +        0x11, 0x12, 0x08, 0xc6, 0x8c, 0x04, 0x41, 0x28,
 +        0x4c, 0x34, 0xf0, 0x1e, 0x01, 0x13, 0xf2, 0xe0,
 +        0x3c, 0x60, 0x20, 0x20, 0x28, 0x00, 0x00, 0x03,
 +        0x00, 0x08, 0x00, 0x00, 0x03, 0x01, 0x94, 0x00,
 +        // PPS
 +        0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x33, 0x48,
 +        0xd0
 +    };
 +    static const uint8_t avci50_1080i_extradata[] = {
 +        // SPS
 +        0x00, 0x00, 0x00, 0x01, 0x67, 0x6e, 0x10, 0x28,
 +        0xa6, 0xd4, 0x20, 0x32, 0x33, 0x0c, 0x71, 0x18,
 +        0x88, 0x62, 0x10, 0x19, 0x19, 0x86, 0x38, 0x8c,
 +        0x44, 0x30, 0x21, 0x02, 0x56, 0x4e, 0x6e, 0x61,
 +        0x87, 0x3e, 0x73, 0x4d, 0x98, 0x0c, 0x03, 0x06,
 +        0x9c, 0x0b, 0x73, 0xe6, 0xc0, 0xb5, 0x18, 0x63,
 +        0x0d, 0x39, 0xe0, 0x5b, 0x02, 0xd4, 0xc6, 0x19,
 +        0x1a, 0x79, 0x8c, 0x32, 0x34, 0x24, 0xf0, 0x16,
 +        0x81, 0x13, 0xf7, 0xff, 0x80, 0x02, 0x00, 0x01,
 +        0xf1, 0x80, 0x80, 0x80, 0xa0, 0x00, 0x00, 0x03,
 +        0x00, 0x20, 0x00, 0x00, 0x06, 0x50, 0x80, 0x00,
 +        // PPS
 +        0x00, 0x00, 0x00, 0x01, 0x68, 0xee, 0x31, 0x12,
 +        0x11
 +    };
 +    static const uint8_t avci100_720p_extradata[] = {
 +        // SPS
 +        0x00, 0x00, 0x00, 0x01, 0x67, 0x7a, 0x10, 0x29,
 +        0xb6, 0xd4, 0x20, 0x2a, 0x33, 0x1d, 0xc7, 0x62,
 +        0xa1, 0x08, 0x40, 0x54, 0x66, 0x3b, 0x8e, 0xc5,
 +        0x42, 0x02, 0x10, 0x25, 0x64, 0x2c, 0x89, 0xe8,
 +        0x85, 0xe4, 0x21, 0x4b, 0x90, 0x83, 0x06, 0x95,
 +        0xd1, 0x06, 0x46, 0x97, 0x20, 0xc8, 0xd7, 0x43,
 +        0x08, 0x11, 0xc2, 0x1e, 0x4c, 0x91, 0x0f, 0x01,
 +        0x40, 0x16, 0xec, 0x07, 0x8c, 0x04, 0x04, 0x05,
 +        0x00, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x03,
 +        0x00, 0x64, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00,
 +        // PPS
 +        0x00, 0x00, 0x00, 0x01, 0x68, 0xce, 0x31, 0x12,
 +        0x11
 +    };
 +    int size = 0;
 +    const uint8_t *data = 0;
 +    if (st->codec->width == 1920) {
 +        if (st->codec->field_order == AV_FIELD_PROGRESSIVE) {
 +            data = avci100_1080p_extradata;
 +            size = sizeof(avci100_1080p_extradata);
 +        } else {
 +            data = avci100_1080i_extradata;
 +            size = sizeof(avci100_1080i_extradata);
 +        }
 +    } else if (st->codec->width == 1440) {
 +        data = avci50_1080i_extradata;
 +        size = sizeof(avci50_1080i_extradata);
 +    } else if (st->codec->width == 1280) {
 +        data = avci100_720p_extradata;
 +        size = sizeof(avci100_720p_extradata);
 +    }
 +    if (!size)
 +        return;
 +    av_freep(&st->codec->extradata);
 +    st->codec->extradata_size = 0;
 +    st->codec->extradata = av_mallocz(size + FF_INPUT_BUFFER_PADDING_SIZE);
 +    if (!st->codec->extradata)
 +        return;
 +    memcpy(st->codec->extradata, data, size);
 +    st->codec->extradata_size = size;
 +}
++
+ static int match_host_pattern(const char *pattern, const char *hostname)
+ {
+     int len_p, len_h;
+     if (!strcmp(pattern, "*"))
+         return 1;
+     // Skip a possible *. at the start of the pattern
+     if (pattern[0] == '*')
+         pattern++;
+     if (pattern[0] == '.')
+         pattern++;
+     len_p = strlen(pattern);
+     len_h = strlen(hostname);
+     if (len_p > len_h)
+         return 0;
+     // Simply check if the end of hostname is equal to 'pattern'
+     if (!strcmp(pattern, &hostname[len_h - len_p])) {
+         if (len_h == len_p)
+             return 1; // Exact match
+         if (hostname[len_h - len_p - 1] == '.')
+             return 1; // The matched substring is a domain and not just a substring of a domain
+     }
+     return 0;
+ }
+ int ff_http_match_no_proxy(const char *no_proxy, const char *hostname)
+ {
+     char *buf, *start;
+     int ret = 0;
+     if (!no_proxy)
+         return 0;
+     if (!hostname)
+         return 0;
+     buf = av_strdup(no_proxy);
+     if (!buf)
+         return 0;
+     start = buf;
+     while (start) {
+         char *sep, *next = NULL;
+         start += strspn(start, " ,");
+         sep = start + strcspn(start, " ,");
+         if (*sep) {
+             next = sep + 1;
+             *sep = '\0';
+         }
+         if (match_host_pattern(start, hostname)) {
+             ret = 1;
+             break;
+         }
+         start = next;
+     }
+     av_free(buf);
+     return ret;
+ }
index 2136e3f415c68bf9f04fa84fdeba110a40bac3a3,763c9df30381e35494773539ccb28354e7405c48..082ab9911f346c85ed8e1d7a336b6a048f7c3573
@@@ -30,8 -30,8 +30,8 @@@
  #include "libavutil/avutil.h"
  
  #define LIBAVFORMAT_VERSION_MAJOR 54
 -#define LIBAVFORMAT_VERSION_MINOR 21
 -#define LIBAVFORMAT_VERSION_MICRO  3
 +#define LIBAVFORMAT_VERSION_MINOR 63
- #define LIBAVFORMAT_VERSION_MICRO 101
++#define LIBAVFORMAT_VERSION_MICRO 102
  
  #define LIBAVFORMAT_VERSION_INT AV_VERSION_INT(LIBAVFORMAT_VERSION_MAJOR, \
                                                 LIBAVFORMAT_VERSION_MINOR, \