[FFmpeg-devel] [PATCH] Allow setting options on URLContexts before opening the connection

Michael Niedermayer michaelni
Tue Jun 22 00:44:33 CEST 2010


On Mon, Jun 21, 2010 at 12:24:16PM +0300, Martin Storsj? wrote:
> On Mon, 21 Jun 2010, Michael Niedermayer wrote:
> 
> > On Mon, Jun 21, 2010 at 11:36:58AM +0300, Martin Storsj? wrote:
[...]
> +int url_open_protocol (URLContext **puc, struct URLProtocol *up,
> +                       const char *filename, int flags)
> +{
> +    int ret;
> +
> +    ret = url_alloc_for_protocol(puc, up, filename, flags);
> +    if (ret)
> +        goto fail;
> +    ret = url_connect(*puc);

> +    if (ret)
> +        goto fail;
> +    return ret;
> + fail:

dejavu ...


> +    url_close(*puc);
> +    *puc = NULL;
> +    return ret;
> +}
> +
> +int url_alloc(URLContext **puc, const char *filename, int flags)
>  {
>      URLProtocol *up;
>      const char *p;
> @@ -166,13 +188,27 @@ int url_open(URLContext **puc, const char *filename, int flags)
>      up = first_protocol;
>      while (up != NULL) {
>          if (!strcmp(proto_str, up->name))
> -            return url_open_protocol (puc, up, filename, flags);
> +            return url_alloc_for_protocol (puc, up, filename, flags);
>          up = up->next;
>      }
>      *puc = NULL;
>      return AVERROR(ENOENT);
>  }
>  
> +int url_open(URLContext **puc, const char *filename, int flags)
> +{
> +    int ret = url_alloc(puc, filename, flags);
> +    if (ret)
> +        return ret;
> +    ret = url_connect(*puc);
> +    if (!ret)
> +        return 0;
> + fail:
> +    url_close(*puc);
> +    *puc = NULL;
> +    return ret;
> +}
> +
>  int url_read(URLContext *h, unsigned char *buf, int size)
>  {
>      int ret;
> @@ -232,7 +268,7 @@ int url_close(URLContext *h)
>      int ret = 0;
>      if (!h) return 0; /* can happen when url_open fails */
>  
> -    if (h->prot->url_close)
> +    if (h->is_connected && h->prot->url_close)
>          ret = h->prot->url_close(h);
>  #if CONFIG_NETWORK
>      ff_network_close();
> diff --git a/libavformat/avio.h b/libavformat/avio.h
> index 7aefe1a..752f6e2 100644
> --- a/libavformat/avio.h
> +++ b/libavformat/avio.h
> @@ -51,6 +51,7 @@ typedef struct URLContext {
>      int max_packet_size;  /**< if non zero, the stream is packetized with this max packet size */
>      void *priv_data;
>      char *filename; /**< specified URL */
> +    int is_connected;
>  } URLContext;
>  
>  typedef struct URLPollEntry {
> @@ -81,6 +82,24 @@ int url_open_protocol (URLContext **puc, struct URLProtocol *up,
>  
>  /**
>   * Creates an URLContext for accessing to the resource indicated by
> + * url, but doesn't initiate the connection yet.
> + *
> + * @param puc pointer to the location where, in case of success, the
> + * function puts the pointer to the created URLContext
> + * @param flags flags which control how the resource indicated by url
> + * is to be opened
> + * @return 0 in case of success, a negative value corresponding to an
> + * AVERROR code in case of failure

i think this would be more readable with empty lines or some other form of
seperation between 2 @tags

except these ok
also update to APIChanges and minor bump may be wanted at some point

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20100622/69e26b1a/attachment.pgp>



More information about the ffmpeg-devel mailing list