On Tue, Jul 22, 2014 at 03:42:21AM +0200, [email protected] wrote:
> From: ePirat <[email protected]>
Please set your name in ~/.gitconfig.
> Icecast is basically a convenience wrapper around the HTTP protocol.
>
> ---
> Changelog | 1 +
> configure | 1 +
> doc/general.texi | 1 +
> doc/protocols.texi | 40 ++++++++
> libavformat/Makefile | 1 +
> libavformat/allformats.c | 1 +
> libavformat/icecast.c | 238
> +++++++++++++++++++++++++++++++++++++++++++++++
> libavformat/version.h | 2 +-
> 8 files changed, 284 insertions(+), 1 deletion(-)
> create mode 100644 libavformat/icecast.c
You may wish to try compiling with gcc:
diego@lu-playground ~/libav_playground $ make libavformat/icecast.o
CC libavformat/icecast.o
libavformat/icecast.c: In function ‘icecast_open’:
libavformat/icecast.c:152:13: error: ISO C90 forbids mixed declarations and
code [-Werror=declaration-after-statement]
int user_len = p + 1 - auth;
^
libavformat/icecast.c:160:39: warning: cast from pointer to integer of
different size [-Wpointer-to-int-cast]
if (!(s->pass = av_malloc((int)(auth - user_len))))
^
libavformat/icecast.c:162:36: warning: cast from pointer to integer of
different size [-Wpointer-to-int-cast]
av_strlcpy(s->pass, p, (int)(auth - user_len));
^
libavformat/icecast.c:169:39: warning: cast from pointer to integer of
different size [-Wpointer-to-int-cast]
av_strlcpy(s->user, auth, (int) auth);
^
cc1: some warnings being treated as errors
> --- a/doc/protocols.texi
> +++ b/doc/protocols.texi
> @@ -138,6 +138,46 @@ Set initial byte offset.
>
> +@item ice_public
> +Set if the stream should be public or not.
> +The default is 0.
.. and 0 means what?
> --- /dev/null
> +++ b/libavformat/icecast.c
> @@ -0,0 +1,238 @@
> +/*
> + * Icecast protocol for avconv client
Nothing limits this to avconv.
> +#define DEFAULT_USER_AGENT "Lavf/" AV_STRINGIFY(LIBAVFORMAT_VERSION)
This is duplicated from http.c and version.h.
> +static int comp_head(const uint8_t *haystack,
> + int hay_size,
> + const uint8_t *needle,
> + int ne_size)
needle_size? Let's not be too miserly with letters?
Also, this comfortably fits into two lines like this:
static int comp_head(const uint8_t *haystack, int hay_size,
const uint8_t *needle, int needle_size)
> + // Check for auth data in URI
> + if (!EMPTY(auth)) {
> + char *p = strchr(auth, ':');
> + if (p){
> + // Setting user and pass from URI
> + if (s->user != NULL)
> + av_free(s->user);
> + int user_len = p + 1 - auth;
mixed declarations and code
> + s->user = av_malloc(user_len);
> + av_strlcpy(s->user, auth, user_len);
unchecked malloc
> + p++;
> + if (s->pass != NULL) {
> + av_free(s->pass);
> + av_log(h, AV_LOG_WARNING, "Overwriting -password <pass> with
> URI password!\n");
> + }
> + if (!(s->pass = av_malloc((int)(auth - user_len))))
> + return AVERROR(ENOMEM);
Why do you cast to int?
You leak memory from the previous malloc if you just return here.
> + // Free variables
> + if (s->user)
> + av_free(s->user);
unnecessary NULL check
What happens with the s->pass allocation?
> +URLProtocol ff_icecast_protocol = {
> + .name = "icecast",
> + .url_open = icecast_open,
> + .url_write = icecast_write,
> + .url_close = icecast_close,
> + .priv_data_size = sizeof(IcecastContext),
> + .priv_data_class = &icecast_context_class,
> + .flags = URL_PROTOCOL_FLAG_NETWORK,
nit: You could reduce the number of spaces before = here.
Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel