[FFmpeg-devel] [PATCH] Gopher client support

Michael Niedermayer michaelni
Sat Jan 31 14:05:43 CET 2009


pOn Sat, Jan 31, 2009 at 05:33:39PM +0900, nazo wrote:
> Michael Niedermayer ????????:
>> On Sun, Jan 25, 2009 at 01:33:48PM +0900, nazo wrote:
>> [...]
>>> attached new patch
>> [...]
>>> +/* used only when posting data */
>>> +static int gopher_write(URLContext *h, uint8_t *buf, int size)
>>> +{
>> comment is not doxygen compatible
>
> I think this is useless comment. just removed.
>
>>> +/**
>>> + * Open gopher URI handle via TCP
>>> + * @param h media file context
>>> + * @param uri of the remote server
>>> + * @returns 0 if OK, AVERROR_xxx otherwise
>>> + */
>>> +static int gopher_open_cnx(URLContext *h, const char *uri)
>> this is called just from one point and thus doesnt need to be in its
>> own function unless you plan to add some further calls to it in the
>> future?
>> [...]
>
> sure, merged.
>
> new patch attached.
>
> -- 
> Nazo (T.K.) <lovesyao at gmail.com>

[...]
> +static int gopher_open(URLContext *h, const char *uri, int flags)
> +{
> +    GopherContext *s;
> +    char hostname[1024], auth[1024], path[1024], buf[1024];
> +    int port, err;
> +    URLContext *hd = NULL;
> +
> +    h->is_streamed = 1;
> +
> +    s = av_malloc(sizeof(GopherContext));
> +    if (!s) {
> +        return AVERROR(ENOMEM);
> +    }
> +    h->priv_data = s;
> +
> +    /* needed in any case to build the host string */
> +    url_split(NULL, 0, auth, sizeof(auth), hostname, sizeof(hostname), &port,
> +              path, sizeof(path), uri);
> +
> +    if (port < 0)
> +        port = 70;
> +
> +    snprintf(buf, sizeof(buf), "tcp://%s:%d", hostname, port);
> +    err = url_open(&hd, buf, URL_RDWR);
> +    if (err < 0)
> +        goto fail;
> +
> +    s->hd = hd;
> +    if ((err = gopher_connect(h, path)) < 0)
> +        goto fail;
> +    return 0;
> + fail:

> +    if (hd)
> +        url_close(hd);
> +    av_free (s);

gopher_close()could be called here instead

> +    return err;
> +}
> +
[...]
> +static int gopher_close(URLContext *h)
> +{
> +    GopherContext *s = h->priv_data;

> +    url_close(s->hd);

s->hd should be set to NULL for saftey, in case gopher_close() is called
twice by mistake


> +    av_free(s);

av_freep(&h->priv_data);


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

It is not what we do, but why we do it that matters.
-------------- 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/20090131/f0f6f393/attachment.pgp>



More information about the ffmpeg-devel mailing list