mirror of
https://github.com/owntone/owntone-server.git
synced 2025-03-13 21:12:56 -04:00
Drop support for libavformat versions < 53 (issue #128)
This commit is contained in:
parent
8a0994860f
commit
2d8a6a7102
@ -154,14 +154,6 @@ AC_CHECK_LIB([avcodec], [avcodec_find_best_pix_fmt_of_list],
|
||||
AC_DEFINE(HAVE_FFMPEG, 1, [Define to 1 if you have ffmpeg (and not libav).]))
|
||||
LIBS="$save_LIBS"
|
||||
|
||||
# Check for libavformat >= 53; url -> avio switch
|
||||
_PKG_CONFIG([libavformat_VERSION], [atleast-version=53], [libavformat])
|
||||
if test $pkg_failed = yes; then
|
||||
AM_CONDITIONAL(COND_AVIO, false)
|
||||
else
|
||||
AM_CONDITIONAL(COND_AVIO, true)
|
||||
fi
|
||||
|
||||
PKG_CHECK_MODULES(MINIXML, [ mxml ])
|
||||
|
||||
PKG_CHECK_MODULES(LIBEVENT, [ libevent >= 2 ],
|
||||
|
@ -33,12 +33,6 @@ if COND_OSS4
|
||||
OSS4_SRC=laudio_oss4.c
|
||||
endif
|
||||
|
||||
if COND_AVIO
|
||||
AVIO_SRC=avio_evbuffer.c avio_evbuffer.h
|
||||
else
|
||||
FFURL_SRC=ffmpeg_url_evbuffer.c ffmpeg_url_evbuffer.h
|
||||
endif
|
||||
|
||||
if COND_LIBEVENT1
|
||||
EVHTTP_SRC=evhttp/http.c evhttp/evhttp.h evhttp/evhttp_compat.c evhttp/evhttp_compat.h evhttp/http-internal.h evhttp/log.h
|
||||
RTSP_SRC=evrtsp/rtsp-libevent1.c evrtp/evrtsp.h evrtsp/rtsp-internal.h evrtsp/log.h
|
||||
@ -105,7 +99,7 @@ forked_daapd_SOURCES = main.c \
|
||||
mdns_avahi.c mdns.h \
|
||||
remote_pairing.c remote_pairing.h \
|
||||
$(EVHTTP_SRC) \
|
||||
$(FFURL_SRC) $(AVIO_SRC) \
|
||||
avio_evbuffer.c avio_evbuffer.h \
|
||||
httpd.c httpd.h \
|
||||
httpd_rsp.c httpd_rsp.h \
|
||||
httpd_daap.c httpd_daap.h \
|
||||
|
@ -41,9 +41,7 @@
|
||||
#include "player.h"
|
||||
#include "http.h"
|
||||
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 53
|
||||
# include "avio_evbuffer.h"
|
||||
#endif
|
||||
#include "avio_evbuffer.h"
|
||||
#include "artwork.h"
|
||||
|
||||
#ifndef HAVE_LIBEVENT2
|
||||
@ -207,12 +205,7 @@ artwork_rescale(struct evbuffer *evbuf, AVFormatContext *src_ctx, int s, int out
|
||||
}
|
||||
|
||||
/* Set up output */
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 52 && LIBAVFORMAT_VERSION_MINOR >= 45)
|
||||
/* FFmpeg 0.6 */
|
||||
dst_fmt = av_guess_format("image2", NULL, NULL);
|
||||
#else
|
||||
dst_fmt = guess_format("image2", NULL, NULL);
|
||||
#endif
|
||||
if (!dst_fmt)
|
||||
{
|
||||
DPRINTF(E_LOG, L_ART, "ffmpeg image2 muxer not available\n");
|
||||
@ -255,18 +248,7 @@ artwork_rescale(struct evbuffer *evbuf, AVFormatContext *src_ctx, int s, int out
|
||||
|
||||
dst_ctx->oformat = dst_fmt;
|
||||
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 53
|
||||
dst_fmt->flags &= ~AVFMT_NOFILE;
|
||||
#else
|
||||
ret = snprintf(dst_ctx->filename, sizeof(dst_ctx->filename), "evbuffer:%p", evbuf);
|
||||
if ((ret < 0) || (ret >= sizeof(dst_ctx->filename)))
|
||||
{
|
||||
DPRINTF(E_LOG, L_ART, "Output artwork URL too long\n");
|
||||
|
||||
ret = -1;
|
||||
goto out_free_dst_ctx;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 54 || (LIBAVFORMAT_VERSION_MAJOR == 53 && LIBAVFORMAT_VERSION_MINOR >= 21)
|
||||
dst_st = avformat_new_stream(dst_ctx, NULL);
|
||||
@ -445,11 +427,7 @@ artwork_rescale(struct evbuffer *evbuf, AVFormatContext *src_ctx, int s, int out
|
||||
av_free_packet(&pkt);
|
||||
|
||||
/* Open output file */
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 53
|
||||
dst_ctx->pb = avio_evbuffer_open(evbuf);
|
||||
#else
|
||||
ret = url_fopen(&dst_ctx->pb, dst_ctx->filename, URL_WRONLY);
|
||||
#endif
|
||||
if (ret < 0)
|
||||
{
|
||||
DPRINTF(E_LOG, L_ART, "Could not open artwork destination buffer\n");
|
||||
@ -468,11 +446,7 @@ artwork_rescale(struct evbuffer *evbuf, AVFormatContext *src_ctx, int s, int out
|
||||
{
|
||||
DPRINTF(E_LOG, L_ART, "Out of memory for encoded artwork buffer\n");
|
||||
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 53
|
||||
avio_evbuffer_close(dst_ctx->pb);
|
||||
#else
|
||||
url_fclose(dst_ctx->pb);
|
||||
#endif
|
||||
|
||||
ret = -1;
|
||||
goto out_free_buf;
|
||||
@ -560,11 +534,7 @@ artwork_rescale(struct evbuffer *evbuf, AVFormatContext *src_ctx, int s, int out
|
||||
}
|
||||
|
||||
out_fclose_dst:
|
||||
#if LIBAVFORMAT_VERSION_MAJOR >= 53
|
||||
avio_evbuffer_close(dst_ctx->pb);
|
||||
#else
|
||||
url_fclose(dst_ctx->pb);
|
||||
#endif
|
||||
av_free(outbuf);
|
||||
|
||||
out_free_buf:
|
||||
|
@ -1,137 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Julien BLACHE <jb@jblache.org>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program 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 General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
# include <config.h>
|
||||
#endif
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <libavformat/avformat.h>
|
||||
|
||||
#include <event.h>
|
||||
|
||||
#include "logger.h"
|
||||
#include "ffmpeg_url_evbuffer.h"
|
||||
|
||||
/*
|
||||
* FFmpeg URL Protocol handler for evbuffers
|
||||
*
|
||||
* URL: evbuffer:0x03FB33DA ("evbuffer:%p")
|
||||
*/
|
||||
|
||||
|
||||
static int
|
||||
url_evbuffer_open(URLContext *h, const char *filename, int flags)
|
||||
{
|
||||
const char *p;
|
||||
char *end;
|
||||
unsigned long evbuffer_addr;
|
||||
|
||||
if (flags != URL_WRONLY)
|
||||
{
|
||||
DPRINTF(E_LOG, L_FFMPEG, "Flags other than URL_WRONLY not supported while opening '%s'\n", filename);
|
||||
|
||||
return AVERROR(EIO);
|
||||
}
|
||||
|
||||
p = strchr(filename, ':');
|
||||
if (!p)
|
||||
{
|
||||
DPRINTF(E_LOG, L_FFMPEG, "Malformed evbuffer URL: '%s'\n", filename);
|
||||
|
||||
return AVERROR(EIO);
|
||||
}
|
||||
|
||||
p++;
|
||||
|
||||
errno = 0;
|
||||
evbuffer_addr = strtoul(p, &end, 16);
|
||||
if (((errno == ERANGE) && (evbuffer_addr == ULONG_MAX))
|
||||
|| ((errno != 0) && (evbuffer_addr == 0)))
|
||||
{
|
||||
DPRINTF(E_LOG, L_FFMPEG, "Invalid buffer address in URL: '%s'\n", filename);
|
||||
|
||||
return AVERROR(EIO);
|
||||
}
|
||||
|
||||
if (end == p)
|
||||
{
|
||||
DPRINTF(E_LOG, L_FFMPEG, "No buffer address found in URL: '%s'\n", filename);
|
||||
|
||||
return AVERROR(EIO);
|
||||
}
|
||||
|
||||
h->priv_data = (void *)evbuffer_addr;
|
||||
if (!h->priv_data)
|
||||
{
|
||||
DPRINTF(E_LOG, L_FFMPEG, "Got a NULL buffer address from URL '%s'\n", filename);
|
||||
|
||||
return AVERROR(EIO);
|
||||
}
|
||||
|
||||
/* Seek not supported */
|
||||
h->is_streamed = 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
url_evbuffer_close(URLContext *h)
|
||||
{
|
||||
h->priv_data = NULL;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
url_evbuffer_write(URLContext *h, unsigned char *buf, int size)
|
||||
{
|
||||
struct evbuffer *evbuf;
|
||||
int ret;
|
||||
|
||||
evbuf = (struct evbuffer *)h->priv_data;
|
||||
|
||||
if (!evbuf)
|
||||
{
|
||||
DPRINTF(E_LOG, L_FFMPEG, "Write called on evbuffer URL with priv_data = NULL!\n");
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = evbuffer_add(evbuf, buf, size);
|
||||
|
||||
return (ret == 0) ? size : -1;
|
||||
}
|
||||
|
||||
URLProtocol evbuffer_protocol = {
|
||||
.name = "evbuffer",
|
||||
.url_open = url_evbuffer_open,
|
||||
.url_close = url_evbuffer_close,
|
||||
.url_write = url_evbuffer_write,
|
||||
};
|
||||
|
||||
int
|
||||
register_ffmpeg_evbuffer_url_protocol(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = av_register_protocol(&evbuffer_protocol);
|
||||
|
||||
return ret;
|
||||
}
|
@ -1,8 +0,0 @@
|
||||
|
||||
#ifndef __FFMPEG_URL_EVBUFFER_H__
|
||||
#define __FFMPEG_URL_EVBUFFER_H__
|
||||
|
||||
int
|
||||
register_ffmpeg_evbuffer_url_protocol(void);
|
||||
|
||||
#endif /* !__FFMPEG_URL_EVBUFFER_H__ */
|
@ -400,11 +400,7 @@ scan_metadata_ffmpeg(char *file, struct media_file_info *mfi)
|
||||
|
||||
#if 0
|
||||
/* Dump input format as determined by ffmpeg */
|
||||
# if LIBAVFORMAT_VERSION_MAJOR >= 53 || (LIBAVFORMAT_VERSION_MAJOR == 52 && LIBAVFORMAT_VERSION_MINOR >= 101)
|
||||
av_dump_format(ctx, 0, file, 0);
|
||||
# else
|
||||
dump_format(ctx, 0, file, FALSE);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
DPRINTF(E_DBG, L_SCAN, "File has %d streams\n", ctx->nb_streams);
|
||||
@ -748,10 +744,6 @@ scan_metadata_ffmpeg(char *file, struct media_file_info *mfi)
|
||||
DPRINTF(E_DBG, L_SCAN, "Picked up %d tags with extra md_map\n", ret);
|
||||
}
|
||||
|
||||
#if LIBAVFORMAT_VERSION_MAJOR < 53
|
||||
av_metadata_conv(ctx, NULL, ctx->iformat->metadata_conv);
|
||||
#endif
|
||||
|
||||
ret = extract_metadata(mfi, ctx, audio_stream, video_stream, md_map_generic);
|
||||
mdcount += ret;
|
||||
|
||||
|
@ -66,9 +66,6 @@ GCRY_THREAD_OPTION_PTHREAD_IMPL;
|
||||
#include "remote_pairing.h"
|
||||
#include "player.h"
|
||||
#include "worker.h"
|
||||
#if LIBAVFORMAT_VERSION_MAJOR < 53
|
||||
# include "ffmpeg_url_evbuffer.h"
|
||||
#endif
|
||||
|
||||
#ifdef LASTFM
|
||||
# include "lastfm.h"
|
||||
@ -592,9 +589,6 @@ main(int argc, char **argv)
|
||||
avformat_network_init();
|
||||
#endif
|
||||
av_log_set_callback(logger_ffmpeg);
|
||||
#if LIBAVFORMAT_VERSION_MAJOR < 53
|
||||
register_ffmpeg_evbuffer_url_protocol();
|
||||
#endif
|
||||
|
||||
/* Initialize libgcrypt */
|
||||
gcry_control(GCRYCTL_SET_THREAD_CBS, &gcry_threads_pthread);
|
||||
|
Loading…
x
Reference in New Issue
Block a user