Merge remote-tracking branch 'qatar/master'
authorMichael Niedermayer <michaelni@gmx.at>
Wed, 30 Oct 2013 16:48:43 +0000 (17:48 +0100)
committerMichael Niedermayer <michaelni@gmx.at>
Wed, 30 Oct 2013 16:48:47 +0000 (17:48 +0100)
* qatar/master:
  lavf: Remove a now useless parameter to ffurl_register_protocol

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavformat/allformats.c
libavformat/avio.c
libavformat/url.h

diff --combined libavformat/allformats.c
@@@ -2,20 -2,20 +2,20 @@@
   * Register all the formats and protocols
   * Copyright (c) 2000, 2001, 2002 Fabrice Bellard
   *
 - * This file is part of Libav.
 + * This file is part of FFmpeg.
   *
 - * Libav is free software; you can redistribute it and/or
 + * 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.
   *
 - * Libav is distributed in the hope that it will be useful,
 + * 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 Libav; if not, write to the Free Software
 + * License along with FFmpeg; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
@@@ -45,8 -45,7 +45,7 @@@
      {                                                                   \
          extern URLProtocol ff_##x##_protocol;                           \
          if (CONFIG_##X##_PROTOCOL)                                      \
-             ffurl_register_protocol(&ff_##x##_protocol,                 \
-                                     sizeof(ff_##x##_protocol));         \
+             ffurl_register_protocol(&ff_##x##_protocol);                \
      }
  
  void av_register_all(void)
      REGISTER_MUXER   (A64,              a64);
      REGISTER_DEMUXER (AAC,              aac);
      REGISTER_MUXDEMUX(AC3,              ac3);
 +    REGISTER_DEMUXER (ACT,              act);
 +    REGISTER_DEMUXER (ADF,              adf);
 +    REGISTER_DEMUXER (ADP,              adp);
      REGISTER_MUXER   (ADTS,             adts);
      REGISTER_MUXDEMUX(ADX,              adx);
      REGISTER_DEMUXER (AEA,              aea);
 +    REGISTER_DEMUXER (AFC,              afc);
      REGISTER_MUXDEMUX(AIFF,             aiff);
      REGISTER_MUXDEMUX(AMR,              amr);
      REGISTER_DEMUXER (ANM,              anm);
      REGISTER_DEMUXER (APC,              apc);
      REGISTER_DEMUXER (APE,              ape);
 +    REGISTER_DEMUXER (AQTITLE,          aqtitle);
      REGISTER_MUXDEMUX(ASF,              asf);
      REGISTER_MUXDEMUX(ASS,              ass);
 +    REGISTER_MUXDEMUX(AST,              ast);
      REGISTER_MUXER   (ASF_STREAM,       asf_stream);
      REGISTER_MUXDEMUX(AU,               au);
      REGISTER_MUXDEMUX(AVI,              avi);
      REGISTER_DEMUXER (AVISYNTH,         avisynth);
      REGISTER_MUXER   (AVM2,             avm2);
 +    REGISTER_DEMUXER (AVR,              avr);
      REGISTER_DEMUXER (AVS,              avs);
      REGISTER_DEMUXER (BETHSOFTVID,      bethsoftvid);
      REGISTER_DEMUXER (BFI,              bfi);
 +    REGISTER_DEMUXER (BINTEXT,          bintext);
      REGISTER_DEMUXER (BINK,             bink);
 +    REGISTER_MUXDEMUX(BIT,              bit);
      REGISTER_DEMUXER (BMV,              bmv);
 +    REGISTER_DEMUXER (BRSTM,            brstm);
 +    REGISTER_DEMUXER (BOA,              boa);
      REGISTER_DEMUXER (C93,              c93);
 -    REGISTER_DEMUXER (CAF,              caf);
 +    REGISTER_MUXDEMUX(CAF,              caf);
      REGISTER_MUXDEMUX(CAVSVIDEO,        cavsvideo);
      REGISTER_DEMUXER (CDG,              cdg);
      REGISTER_DEMUXER (CDXL,             cdxl);
 +    REGISTER_DEMUXER (CONCAT,           concat);
      REGISTER_MUXER   (CRC,              crc);
 +    REGISTER_MUXDEMUX(DATA,             data);
      REGISTER_MUXDEMUX(DAUD,             daud);
      REGISTER_DEMUXER (DFA,              dfa);
      REGISTER_MUXDEMUX(DIRAC,            dirac);
      REGISTER_MUXDEMUX(DNXHD,            dnxhd);
      REGISTER_DEMUXER (DSICIN,           dsicin);
      REGISTER_MUXDEMUX(DTS,              dts);
 +    REGISTER_DEMUXER (DTSHD,            dtshd);
      REGISTER_MUXDEMUX(DV,               dv);
      REGISTER_DEMUXER (DXA,              dxa);
      REGISTER_DEMUXER (EA,               ea);
      REGISTER_DEMUXER (EA_CDATA,         ea_cdata);
      REGISTER_MUXDEMUX(EAC3,             eac3);
 +    REGISTER_DEMUXER (EPAF,             epaf);
      REGISTER_MUXER   (F4V,              f4v);
      REGISTER_MUXDEMUX(FFM,              ffm);
      REGISTER_MUXDEMUX(FFMETADATA,       ffmetadata);
      REGISTER_DEMUXER (FOURXM,           fourxm);
      REGISTER_MUXER   (FRAMECRC,         framecrc);
      REGISTER_MUXER   (FRAMEMD5,         framemd5);
 +    REGISTER_DEMUXER (FRM,              frm);
      REGISTER_MUXDEMUX(G722,             g722);
 -    REGISTER_DEMUXER (G723_1,           g723_1);
 -    REGISTER_MUXER   (GIF,              gif);
 +    REGISTER_MUXDEMUX(G723_1,           g723_1);
 +    REGISTER_DEMUXER (G729,             g729);
 +    REGISTER_MUXDEMUX(GIF,              gif);
      REGISTER_DEMUXER (GSM,              gsm);
      REGISTER_MUXDEMUX(GXF,              gxf);
      REGISTER_MUXDEMUX(H261,             h261);
      REGISTER_MUXDEMUX(H263,             h263);
      REGISTER_MUXDEMUX(H264,             h264);
 +    REGISTER_DEMUXER (HEVC,             hevc);
      REGISTER_MUXDEMUX(HLS,              hls);
 +    REGISTER_MUXDEMUX(ICO,              ico);
      REGISTER_DEMUXER (IDCIN,            idcin);
 +    REGISTER_DEMUXER (IDF,              idf);
      REGISTER_DEMUXER (IFF,              iff);
      REGISTER_MUXDEMUX(ILBC,             ilbc);
      REGISTER_MUXDEMUX(IMAGE2,           image2);
      REGISTER_DEMUXER (INGENIENT,        ingenient);
      REGISTER_DEMUXER (IPMOVIE,          ipmovie);
      REGISTER_MUXER   (IPOD,             ipod);
 +    REGISTER_MUXDEMUX(IRCAM,            ircam);
      REGISTER_MUXER   (ISMV,             ismv);
      REGISTER_DEMUXER (ISS,              iss);
      REGISTER_DEMUXER (IV8,              iv8);
      REGISTER_MUXDEMUX(IVF,              ivf);
 +    REGISTER_MUXDEMUX(JACOSUB,          jacosub);
      REGISTER_DEMUXER (JV,               jv);
      REGISTER_MUXDEMUX(LATM,             latm);
      REGISTER_DEMUXER (LMLM4,            lmlm4);
 +    REGISTER_DEMUXER (LOAS,             loas);
 +    REGISTER_DEMUXER (LVF,              lvf);
      REGISTER_DEMUXER (LXF,              lxf);
      REGISTER_MUXDEMUX(M4V,              m4v);
      REGISTER_MUXER   (MD5,              md5);
      REGISTER_MUXDEMUX(MATROSKA,         matroska);
      REGISTER_MUXER   (MATROSKA_AUDIO,   matroska_audio);
 +    REGISTER_DEMUXER (MGSTS,            mgsts);
 +    REGISTER_MUXDEMUX(MICRODVD,         microdvd);
      REGISTER_MUXDEMUX(MJPEG,            mjpeg);
      REGISTER_MUXDEMUX(MLP,              mlp);
      REGISTER_DEMUXER (MM,               mm);
      REGISTER_DEMUXER (MPEGTSRAW,        mpegtsraw);
      REGISTER_DEMUXER (MPEGVIDEO,        mpegvideo);
      REGISTER_MUXER   (MPJPEG,           mpjpeg);
 +    REGISTER_DEMUXER (MPL2,             mpl2);
 +    REGISTER_DEMUXER (MPSUB,            mpsub);
      REGISTER_DEMUXER (MSNWC_TCP,        msnwc_tcp);
      REGISTER_DEMUXER (MTV,              mtv);
 +    REGISTER_DEMUXER (MV,               mv);
      REGISTER_DEMUXER (MVI,              mvi);
      REGISTER_MUXDEMUX(MXF,              mxf);
      REGISTER_MUXER   (MXF_D10,          mxf_d10);
      REGISTER_DEMUXER (MXG,              mxg);
      REGISTER_DEMUXER (NC,               nc);
 +    REGISTER_DEMUXER (NISTSPHERE,       nistsphere);
      REGISTER_DEMUXER (NSV,              nsv);
      REGISTER_MUXER   (NULL,             null);
      REGISTER_MUXDEMUX(NUT,              nut);
      REGISTER_DEMUXER (NUV,              nuv);
      REGISTER_MUXDEMUX(OGG,              ogg);
      REGISTER_MUXDEMUX(OMA,              oma);
 +    REGISTER_DEMUXER (PAF,              paf);
      REGISTER_MUXDEMUX(PCM_ALAW,         pcm_alaw);
      REGISTER_MUXDEMUX(PCM_MULAW,        pcm_mulaw);
      REGISTER_MUXDEMUX(PCM_F64BE,        pcm_f64be);
      REGISTER_MUXDEMUX(PCM_U16BE,        pcm_u16be);
      REGISTER_MUXDEMUX(PCM_U16LE,        pcm_u16le);
      REGISTER_MUXDEMUX(PCM_U8,           pcm_u8);
 +    REGISTER_DEMUXER (PJS,              pjs);
      REGISTER_DEMUXER (PMP,              pmp);
      REGISTER_MUXER   (PSP,              psp);
      REGISTER_DEMUXER (PVA,              pva);
 +    REGISTER_DEMUXER (PVF,              pvf);
      REGISTER_DEMUXER (QCP,              qcp);
      REGISTER_DEMUXER (R3D,              r3d);
      REGISTER_MUXDEMUX(RAWVIDEO,         rawvideo);
 +    REGISTER_DEMUXER (REALTEXT,         realtext);
 +    REGISTER_DEMUXER (REDSPARK,         redspark);
      REGISTER_DEMUXER (RL2,              rl2);
      REGISTER_MUXDEMUX(RM,               rm);
      REGISTER_MUXDEMUX(ROQ,              roq);
      REGISTER_DEMUXER (RPL,              rpl);
 +    REGISTER_DEMUXER (RSD,              rsd);
      REGISTER_MUXDEMUX(RSO,              rso);
      REGISTER_MUXDEMUX(RTP,              rtp);
      REGISTER_MUXDEMUX(RTSP,             rtsp);
 +    REGISTER_DEMUXER (SAMI,             sami);
      REGISTER_MUXDEMUX(SAP,              sap);
 +    REGISTER_DEMUXER (SBG,              sbg);
      REGISTER_DEMUXER (SDP,              sdp);
  #if CONFIG_RTPDEC
      ff_register_rtp_dynamic_payload_handlers();
  #endif
      REGISTER_DEMUXER (SEGAFILM,         segafilm);
      REGISTER_MUXER   (SEGMENT,          segment);
 +    REGISTER_MUXER   (SEGMENT,          stream_segment);
      REGISTER_DEMUXER (SHORTEN,          shorten);
      REGISTER_DEMUXER (SIFF,             siff);
      REGISTER_DEMUXER (SMACKER,          smacker);
      REGISTER_MUXDEMUX(SMJPEG,           smjpeg);
      REGISTER_MUXER   (SMOOTHSTREAMING,  smoothstreaming);
 +    REGISTER_DEMUXER (SMUSH,            smush);
      REGISTER_DEMUXER (SOL,              sol);
      REGISTER_MUXDEMUX(SOX,              sox);
      REGISTER_MUXDEMUX(SPDIF,            spdif);
      REGISTER_MUXDEMUX(SRT,              srt);
      REGISTER_DEMUXER (STR,              str);
 +    REGISTER_DEMUXER (SUBVIEWER1,       subviewer1);
 +    REGISTER_DEMUXER (SUBVIEWER,        subviewer);
      REGISTER_MUXDEMUX(SWF,              swf);
      REGISTER_DEMUXER (TAK,              tak);
 +    REGISTER_MUXER   (TEE,              tee);
 +    REGISTER_DEMUXER (TEDCAPTIONS,      tedcaptions);
      REGISTER_MUXER   (TG2,              tg2);
      REGISTER_MUXER   (TGP,              tgp);
      REGISTER_DEMUXER (THP,              thp);
      REGISTER_DEMUXER (TIERTEXSEQ,       tiertexseq);
 +    REGISTER_MUXER   (MKVTIMESTAMP_V2,  mkvtimestamp_v2);
      REGISTER_DEMUXER (TMV,              tmv);
      REGISTER_MUXDEMUX(TRUEHD,           truehd);
      REGISTER_DEMUXER (TTA,              tta);
      REGISTER_DEMUXER (TXD,              txd);
      REGISTER_DEMUXER (TTY,              tty);
 -    REGISTER_DEMUXER (VC1,              vc1);
 +    REGISTER_MUXDEMUX(VC1,              vc1);
      REGISTER_MUXDEMUX(VC1T,             vc1t);
 +    REGISTER_DEMUXER (VIVO,             vivo);
      REGISTER_DEMUXER (VMD,              vmd);
 +    REGISTER_DEMUXER (VOBSUB,           vobsub);
      REGISTER_MUXDEMUX(VOC,              voc);
 +    REGISTER_DEMUXER (VPLAYER,          vplayer);
      REGISTER_DEMUXER (VQF,              vqf);
 -    REGISTER_DEMUXER (W64,              w64);
 +    REGISTER_MUXDEMUX(W64,              w64);
      REGISTER_MUXDEMUX(WAV,              wav);
      REGISTER_DEMUXER (WC3,              wc3);
      REGISTER_MUXER   (WEBM,             webm);
 +    REGISTER_MUXDEMUX(WEBVTT,           webvtt);
      REGISTER_DEMUXER (WSAUD,            wsaud);
      REGISTER_DEMUXER (WSVQA,            wsvqa);
 -    REGISTER_DEMUXER (WTV,              wtv);
 +    REGISTER_MUXDEMUX(WTV,              wtv);
      REGISTER_MUXDEMUX(WV,               wv);
      REGISTER_DEMUXER (XA,               xa);
 +    REGISTER_DEMUXER (XBIN,             xbin);
      REGISTER_DEMUXER (XMV,              xmv);
      REGISTER_DEMUXER (XWMA,             xwma);
      REGISTER_DEMUXER (YOP,              yop);
      REGISTER_MUXDEMUX(YUV4MPEGPIPE,     yuv4mpegpipe);
  
      /* protocols */
 +    REGISTER_PROTOCOL(BLURAY,           bluray);
 +    REGISTER_PROTOCOL(CACHE,            cache);
      REGISTER_PROTOCOL(CONCAT,           concat);
      REGISTER_PROTOCOL(CRYPTO,           crypto);
 +    REGISTER_PROTOCOL(DATA,             data);
      REGISTER_PROTOCOL(FFRTMPCRYPT,      ffrtmpcrypt);
      REGISTER_PROTOCOL(FFRTMPHTTP,       ffrtmphttp);
      REGISTER_PROTOCOL(FILE,             file);
 +    REGISTER_PROTOCOL(FTP,              ftp);
      REGISTER_PROTOCOL(GOPHER,           gopher);
      REGISTER_PROTOCOL(HLS,              hls);
      REGISTER_PROTOCOL(HTTP,             http);
      REGISTER_PROTOCOL(UNIX,             unix);
  
      /* external libraries */
 +    REGISTER_DEMUXER (LIBGME,           libgme);
 +    REGISTER_DEMUXER (LIBMODPLUG,       libmodplug);
 +    REGISTER_MUXDEMUX(LIBNUT,           libnut);
 +    REGISTER_DEMUXER (LIBQUVI,          libquvi);
      REGISTER_PROTOCOL(LIBRTMP,          librtmp);
      REGISTER_PROTOCOL(LIBRTMPE,         librtmpe);
      REGISTER_PROTOCOL(LIBRTMPS,         librtmps);
      REGISTER_PROTOCOL(LIBRTMPT,         librtmpt);
      REGISTER_PROTOCOL(LIBRTMPTE,        librtmpte);
 +    REGISTER_PROTOCOL(LIBSSH,           libssh);
  }
diff --combined libavformat/avio.c
@@@ -2,20 -2,20 +2,20 @@@
   * unbuffered I/O
   * Copyright (c) 2001 Fabrice Bellard
   *
 - * This file is part of Libav.
 + * This file is part of FFmpeg.
   *
 - * Libav is free software; you can redistribute it and/or
 + * 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.
   *
 - * Libav is distributed in the hope that it will be useful,
 + * 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 Libav; if not, write to the Free Software
 + * License along with FFmpeg; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
@@@ -94,14 -94,9 +94,9 @@@ const char *avio_enum_protocols(void **
      return avio_enum_protocols(opaque, output);
  }
  
- int ffurl_register_protocol(URLProtocol *protocol, int size)
+ int ffurl_register_protocol(URLProtocol *protocol)
  {
      URLProtocol **p;
-     if (size < sizeof(URLProtocol)) {
-         URLProtocol *temp = av_mallocz(sizeof(URLProtocol));
-         memcpy(temp, protocol, size);
-         protocol = temp;
-     }
      p = &first_protocol;
      while (*p != NULL)
          p = &(*p)->next;
@@@ -121,16 -116,6 +116,16 @@@ static int url_alloc_for_protocol(URLCo
      if (up->flags & URL_PROTOCOL_FLAG_NETWORK && !ff_network_init())
          return AVERROR(EIO);
  #endif
 +    if ((flags & AVIO_FLAG_READ) && !up->url_read) {
 +        av_log(NULL, AV_LOG_ERROR,
 +               "Impossible to open the '%s' protocol for reading\n", up->name);
 +        return AVERROR(EIO);
 +    }
 +    if ((flags & AVIO_FLAG_WRITE) && !up->url_write) {
 +        av_log(NULL, AV_LOG_ERROR,
 +               "Impossible to open the '%s' protocol for writing\n", up->name);
 +        return AVERROR(EIO);
 +    }
      uc = av_mallocz(sizeof(URLContext) + strlen(filename) + 1);
      if (!uc) {
          err = AVERROR(ENOMEM);
              goto fail;
          }
          if (up->priv_data_class) {
 +            int proto_len= strlen(up->name);
 +            char *start = strchr(uc->filename, ',');
              *(const AVClass **)uc->priv_data = up->priv_data_class;
              av_opt_set_defaults(uc->priv_data);
 +            if(!strncmp(up->name, uc->filename, proto_len) && uc->filename + proto_len == start){
 +                int ret= 0;
 +                char *p= start;
 +                char sep= *++p;
 +                char *key, *val;
 +                p++;
 +                while(ret >= 0 && (key= strchr(p, sep)) && p<key && (val = strchr(key+1, sep))){
 +                    *val= *key= 0;
 +                    ret= av_opt_set(uc->priv_data, p, key+1, 0);
 +                    if (ret == AVERROR_OPTION_NOT_FOUND)
 +                        av_log(uc, AV_LOG_ERROR, "Key '%s' not found.\n", p);
 +                    *val= *key= sep;
 +                    p= val+1;
 +                }
 +                if(ret<0 || p!=key){
 +                    av_log(uc, AV_LOG_ERROR, "Error parsing options string %s\n", start);
 +                    av_freep(&uc->priv_data);
 +                    av_freep(&uc);
 +                    err = AVERROR(EINVAL);
 +                    goto fail;
 +                }
 +                memmove(start, key+1, strlen(key));
 +            }
          }
      }
      if (int_cb)
@@@ -227,21 -187,12 +222,21 @@@ int ffurl_alloc(URLContext **puc, cons
      char proto_str[128], proto_nested[128], *ptr;
      size_t proto_len = strspn(filename, URL_SCHEME_CHARS);
  
 -    if (filename[proto_len] != ':' || is_dos_path(filename))
 +    if (!first_protocol) {
 +        av_log(NULL, AV_LOG_WARNING, "No URL Protocols are registered. "
 +                                     "Missing call to av_register_all()?\n");
 +    }
 +
 +    if (filename[proto_len] != ':' &&
 +        (filename[proto_len] != ',' || !strchr(filename + proto_len + 1, ':')) ||
 +        is_dos_path(filename))
          strcpy(proto_str, "file");
      else
          av_strlcpy(proto_str, filename,
                     FFMIN(proto_len + 1, sizeof(proto_str)));
  
 +    if ((ptr = strchr(proto_str, ',')))
 +        *ptr = '\0';
      av_strlcpy(proto_nested, proto_str, sizeof(proto_nested));
      if ((ptr = strchr(proto_nested, '+')))
          *ptr = '\0';
              return url_alloc_for_protocol(puc, up, filename, flags, int_cb);
      }
      *puc = NULL;
 +    if (!strcmp("https", proto_str))
 +        av_log(NULL, AV_LOG_WARNING, "https protocol not found, recompile with openssl or gnutls enabled.\n");
      return AVERROR_PROTOCOL_NOT_FOUND;
  }
  
@@@ -285,12 -234,9 +280,12 @@@ static inline int retry_transfer_wrappe
  {
      int ret, len;
      int fast_retries = 5;
 +    int64_t wait_since = 0;
  
      len = 0;
      while (len < size_min) {
 +        if (ff_check_interrupt(&h->interrupt_callback))
 +            return AVERROR_EXIT;
          ret = transfer_func(h, buf + len, size - len);
          if (ret == AVERROR(EINTR))
              continue;
              return ret;
          if (ret == AVERROR(EAGAIN)) {
              ret = 0;
 -            if (fast_retries)
 +            if (fast_retries) {
                  fast_retries--;
 -            else
 +            } else {
 +                if (h->rw_timeout) {
 +                    if (!wait_since)
 +                        wait_since = av_gettime();
 +                    else if (av_gettime() > wait_since + h->rw_timeout)
 +                        return AVERROR(EIO);
 +                }
                  av_usleep(1000);
 +            }
          } else if (ret < 1)
              return (ret < 0 && ret != AVERROR_EOF) ? ret : len;
          if (ret)
              fast_retries = FFMAX(fast_retries, 2);
          len += ret;
 -        if (ff_check_interrupt(&h->interrupt_callback))
 -            return AVERROR_EXIT;
      }
      return len;
  }
@@@ -340,7 -281,7 +335,7 @@@ int ffurl_write(URLContext *h, const un
      if (h->max_packet_size && size > h->max_packet_size)
          return AVERROR(EIO);
  
 -    return retry_transfer_wrapper(h, buf, size, size, h->prot->url_write);
 +    return retry_transfer_wrapper(h, (unsigned char *)buf, size, size, (void*)h->prot->url_write);
  }
  
  int64_t ffurl_seek(URLContext *h, int64_t pos, int whence)
      return ret;
  }
  
 -int ffurl_close(URLContext *h)
 +int ffurl_closep(URLContext **hh)
  {
 +    URLContext *h= *hh;
      int ret = 0;
      if (!h)
          return 0;     /* can happen when ffurl_open fails */
      if (h->prot->priv_data_size) {
          if (h->prot->priv_data_class)
              av_opt_free(h->priv_data);
 -        av_free(h->priv_data);
 +        av_freep(&h->priv_data);
      }
 -    av_free(h);
 +    av_freep(hh);
      return ret;
  }
  
 +int ffurl_close(URLContext *h)
 +{
 +    return ffurl_closep(&h);
 +}
 +
 +
  int avio_check(const char *url, int flags)
  {
      URLContext *h;
@@@ -427,7 -361,7 +422,7 @@@ int ffurl_get_multi_file_handle(URLCont
      if (!h->prot->url_get_multi_file_handle) {
          if (!h->prot->url_get_file_handle)
              return AVERROR(ENOSYS);
 -        *handles = av_malloc(sizeof(*handles));
 +        *handles = av_malloc(sizeof(**handles));
          if (!*handles)
              return AVERROR(ENOMEM);
          *numhandles = 1;
diff --combined libavformat/url.h
@@@ -1,19 -1,19 +1,19 @@@
  /*
   *
 - * This file is part of Libav.
 + * This file is part of FFmpeg.
   *
 - * Libav is free software; you can redistribute it and/or
 + * 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.
   *
 - * Libav is distributed in the hope that it will be useful,
 + * 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 Libav; if not, write to the Free Software
 + * License along with FFmpeg; if not, write to the Free Software
   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
   */
  
@@@ -48,7 -48,6 +48,7 @@@ typedef struct URLContext 
      int is_streamed;            /**< true if streamed (no seek possible), default = false */
      int is_connected;
      AVIOInterruptCB interrupt_callback;
 +    int64_t rw_timeout;         /**< maximum time to wait for (network) read/write operation completion, in mcs */
  } URLContext;
  
  typedef struct URLProtocol {
   * is to be opened
   * @param int_cb interrupt callback to use for the URLContext, may be
   * NULL
 - * @return 0 in case of success, a negative value corresponding to an
 + * @return >= 0 in case of success, a negative value corresponding to an
   * AVERROR code in case of failure
   */
  int ffurl_alloc(URLContext **puc, const char *filename, int flags,
@@@ -130,7 -129,7 +130,7 @@@ int ffurl_connect(URLContext *uc, AVDic
   * @param options  A dictionary filled with protocol-private options. On return
   * this parameter will be destroyed and replaced with a dict containing options
   * that were not found. May be NULL.
 - * @return 0 in case of success, a negative value corresponding to an
 + * @return >= 0 in case of success, a negative value corresponding to an
   * AVERROR code in case of failure
   */
  int ffurl_open(URLContext **puc, const char *filename, int flags,
@@@ -182,12 -181,11 +182,12 @@@ int64_t ffurl_seek(URLContext *h, int64
  
  /**
   * Close the resource accessed by the URLContext h, and free the
 - * memory used by it.
 + * memory used by it. Also set the URLContext pointer to NULL.
   *
   * @return a negative value if an error condition occurred, 0
   * otherwise
   */
 +int ffurl_closep(URLContext **h);
  int ffurl_close(URLContext *h);
  
  /**
@@@ -226,10 -224,8 +226,8 @@@ int ffurl_shutdown(URLContext *h, int f
  
  /**
   * Register the URLProtocol protocol.
-  *
-  * @param size the size of the URLProtocol struct referenced
   */
- int ffurl_register_protocol(URLProtocol *protocol, int size);
+ int ffurl_register_protocol(URLProtocol *protocol);
  
  /**
   * Check if the user has requested to interrup a blocking function
@@@ -273,7 -269,7 +271,7 @@@ int ff_url_join(char *str, int size, co
                  const char *authorization, const char *hostname,
                  int port, const char *fmt, ...) av_printf_format(7, 8);
  
 -/*
 +/**
   * Convert a relative url into an absolute url, given a base url.
   *
   * @param buf the buffer where output absolute url is written