- Update for newer FFmpeg API

- Sync in arc4random diff submitted
- Garbage collect a patch no longer necessary to build
- Remove use of PTHREAD_LIBS in the Makefile

ok sthen@
This commit is contained in:
brad 2013-01-27 14:13:30 +00:00
parent 6f3b9a9921
commit a3fb18d748
5 changed files with 141 additions and 68 deletions

View File

@ -1,10 +1,10 @@
# $OpenBSD: Makefile,v 1.16 2013/01/27 10:06:50 sthen Exp $
# $OpenBSD: Makefile,v 1.17 2013/01/27 14:13:30 brad Exp $
COMMENT = UPnP media server
VER = 0.12.1
DISTNAME = mediatomb-${VER}
REVISION = 10
REVISION = 11
CATEGORIES = multimedia
@ -33,16 +33,15 @@ LIB_DEPENDS = audio/taglib \
multimedia/libmp4v2
CONFIGURE_STYLE = autoconf
CONFIGURE_ARGS += --disable-inotify \
AUTOCONF_VERSION = 2.63
CONFIGURE_ARGS = --disable-inotify \
--disable-lastfmlib \
--disable-mysql \
PTHREAD_LIBS="-pthread"
--disable-mysql
# Add "-I${WRKSRC}/src" to make mediatomb find its own dictionary.h first.
CONFIGURE_ENV = CPPFLAGS="-I${WRKSRC}/src -I${LOCALBASE}/include" \
LDFLAGS="-L${LOCALBASE}/lib" \
ac_cv_header_execinfo_h=no \
ac_cv_header_lwres_netdb_h=no
AUTOCONF_VERSION = 2.63
post-install:
${INSTALL_DATA_DIR} ${PREFIX}/share/examples/mediatomb/

View File

@ -1,7 +1,16 @@
$OpenBSD: patch-configure_ac,v 1.2 2010/11/09 13:26:31 jasper Exp $
$OpenBSD: patch-configure_ac,v 1.3 2013/01/27 14:13:30 brad Exp $
--- configure.ac.orig Wed Apr 7 18:38:51 2010
+++ configure.ac Sun Nov 7 13:02:11 2010
@@ -342,8 +342,13 @@ AC_CHECK_HEADERS([langinfo.h locale.h],[],[AC_MSG_WARN
+++ configure.ac Sun Jan 27 08:44:06 2013
@@ -327,6 +327,8 @@ AC_HEADER_STAT
AC_LANG_C
AM_PROG_CC_C_O
+AC_CHECK_FUNCS([arc4random],[],[])
+
AC_CHECK_HEADERS([time.h syslog.h stddef.h unistd.h arpa/inet.h fcntl.h], [],
[AC_MSG_ERROR(required header not found)])
@@ -342,8 +344,13 @@ AC_CHECK_HEADERS([langinfo.h locale.h],[],[AC_MSG_WARN
AC_CHECK_HEADERS([sys/utsname.h])
AC_CHECK_HEADERS([sched.h ctype.h],[],[])
@ -16,7 +25,7 @@ $OpenBSD: patch-configure_ac,v 1.2 2010/11/09 13:26:31 jasper Exp $
AC_CHECK_FUNCS([mkdir], [],
[AC_MSG_ERROR(required function not found)])
@@ -692,6 +697,8 @@ if test $DARWIN_OS -eq 1 ; then
@@ -692,6 +699,8 @@ if test $DARWIN_OS -eq 1 ; then
AC_MSG_NOTICE([You are running OSX, assuming threadsafe gethostbyname version])
elif test $CYGWIN_OS -eq 1; then
AC_MSG_NOTICE([Your are building under Cygwin, assuming threadsafe gethostbyname implementation])
@ -25,7 +34,7 @@ $OpenBSD: patch-configure_ac,v 1.2 2010/11/09 13:26:31 jasper Exp $
fi
AC_CHECK_FUNCS([gethostbyname_r],[],
@@ -758,7 +765,7 @@ if test "x$PTHREAD_LIB_OPTION_ENABLED" = xyes; then
@@ -758,7 +767,7 @@ if test "x$PTHREAD_LIB_OPTION_ENABLED" = xyes; then
else
ACX_PTHREAD(,AC_MSG_ERROR(POSIX threads missing))

View File

@ -1,18 +1,43 @@
$OpenBSD: patch-src_metadata_ffmpeg_handler_cc,v 1.1 2012/04/29 07:11:23 ajacoutot Exp $
$OpenBSD: patch-src_metadata_ffmpeg_handler_cc,v 1.2 2013/01/27 14:13:30 brad Exp $
Update for newer FFmpeg API.
--- src/metadata/ffmpeg_handler.cc.orig Sun Apr 29 00:44:56 2012
+++ src/metadata/ffmpeg_handler.cc Sun Apr 29 00:46:13 2012
@@ -86,51 +86,33 @@ FfmpegHandler::FfmpegHandler() : MetadataHandler()
--- src/metadata/ffmpeg_handler.cc.orig Thu Mar 25 10:58:10 2010
+++ src/metadata/ffmpeg_handler.cc Sun Jan 27 07:40:59 2013
@@ -51,16 +51,13 @@
// macro defines included via autoconfig.h
#include <stdint.h>
-//#ifdef FFMPEG_NEEDS_EXTERN_C
extern "C"
{
-//#endif
-#include AVFORMAT_INCLUDE
+#include <libavformat/avformat.h>
+#include <libavutil/avutil.h>
-//#ifdef FFMPEG_NEEDS_EXTERN_C
} // extern "C"
-//#endif
#ifdef HAVE_FFMPEGTHUMBNAILER
#include <libffmpegthumbnailer/videothumbnailerc.h>
@@ -86,51 +83,63 @@ FfmpegHandler::FfmpegHandler() : MetadataHandler()
static void addFfmpegMetadataFields(Ref<CdsItem> item, AVFormatContext *pFormatCtx)
{
-
+ AVDictionaryEntry *e = NULL;
Ref<StringConverter> sc = StringConverter::m2i();
-
- if (strlen(pFormatCtx->title) > 0)
- {
+
+ metadata_fields_t field;
+ String value;
+
+ while ((e = av_dict_get(pFormatCtx->metadata, "", e,AV_DICT_IGNORE_SUFFIX)))
{
- log_debug("Added metadata title: %s\n", pFormatCtx->title);
- item->setMetadata(MT_KEYS[M_TITLE].upnp,
- sc->convert(pFormatCtx->title));
@ -53,36 +78,59 @@ Update for newer FFmpeg API.
- item->setMetadata(MT_KEYS[M_TRACKNUMBER].upnp,
- sc->convert(String::from(pFormatCtx->track)));
- }
+
+ typedef struct {const char *avname; metadata_fields_t field;} mapping_t;
+ static const mapping_t mapping[] =
+ {
+ {"title", M_TITLE},
+ {"artist", M_ARTIST},
+ {"album", M_ALBUM},
+ {"date", M_DATE},
+ {"genre", M_GENRE},
+ {"comment", M_DESCRIPTION},
+ {"track", M_TRACKNUMBER},
+ {NULL, M_MAX},
+ };
+ value = e->value;
+
+ if (!pFormatCtx->metadata)
+ return;
+ for (const mapping_t *m = mapping; m->avname != NULL; m++)
+ {
+ AVMetadataTag *tag = NULL;
+ tag = av_metadata_get(pFormatCtx->metadata, m->avname, NULL, 0);
+ if (tag && tag->value && tag->value[0])
+ {
+ log_debug("Added metadata %s: %s\n", m->avname, tag->value);
+ item->setMetadata(MT_KEYS[m->field].upnp, sc->convert(tag->value));
+ }
+ }
+ if (strcmp(e->key, "title") == 0)
+ {
+ log_debug("Identified metadata title: %s\n", e->value);
+ field = M_TITLE;
+ }
+ else if (strcmp(e->key, "artist") == 0)
+ {
+ log_debug("Identified metadata artist: %s\n", e->value);
+ field = M_ARTIST;
+ }
+ else if (strcmp(e->key, "album") == 0)
+ {
+ log_debug("Identified metadata album: %s\n", e->value);
+ field = M_ALBUM;
+ }
+ else if (strcmp(e->key, "date") == 0)
+ {
+ if ((value.length() == 4) && (value.toInt() > 0))
+ {
+ value = value + _("-01-01");
+ log_debug("Identified metadata date: %s\n", value.c_str());
+ }
+ /// \toto parse possible ISO8601 timestamp
+ field = M_DATE;
+ }
+ else if (strcmp(e->key, "genre") == 0)
+ {
+ log_debug("Identified metadata genre: %s\n", e->value);
+ field = M_GENRE;
+ }
+ else if (strcmp(e->key, "comment") == 0)
+ {
+ log_debug("Identified metadata comment: %s\n", e->value);
+ field = M_DESCRIPTION;
+ }
+ else if (strcmp(e->key, "track") == 0)
+ {
+ log_debug("Identified metadata track: %d\n", e->value);
+ field = M_TRACKNUMBER;
+ }
+ else
+ {
+ continue;
+ }
+
+ item->setMetadata(MT_KEYS[field].upnp, sc->convert(trim_string(value)));
+ }
}
// ffmpeg library calls
@@ -178,7 +160,7 @@ static void addFfmpegResourceFields(Ref<CdsItem> item,
@@ -178,7 +187,7 @@ static void addFfmpegResourceFields(Ref<CdsItem> item,
for(i=0; i<pFormatCtx->nb_streams; i++)
{
AVStream *st = pFormatCtx->streams[i];
@ -91,7 +139,7 @@ Update for newer FFmpeg API.
{
if (st->codec->codec_tag > 0)
{
@@ -209,7 +191,7 @@ static void addFfmpegResourceFields(Ref<CdsItem> item,
@@ -209,7 +218,7 @@ static void addFfmpegResourceFields(Ref<CdsItem> item,
*y = st->codec->height;
}
}
@ -100,3 +148,40 @@ Update for newer FFmpeg API.
{
// Increase number of audiochannels
audioch++;
@@ -251,7 +260,7 @@ void FfmpegHandler::fillMetadata(Ref<CdsItem> item)
int x = 0;
int y = 0;
- AVFormatContext *pFormatCtx;
+ AVFormatContext *pFormatCtx = NULL;
// Suppress all log messages
av_log_set_callback(FfmpegNoOutputStub);
@@ -260,14 +269,14 @@ void FfmpegHandler::fillMetadata(Ref<CdsItem> item)
av_register_all();
// Open video file
- if (av_open_input_file(&pFormatCtx,
- item->getLocation().c_str(), NULL, 0, NULL) != 0)
+ if (avformat_open_input(&pFormatCtx,
+ item->getLocation().c_str(), NULL, NULL) != 0)
return; // Couldn't open file
// Retrieve stream information
- if (av_find_stream_info(pFormatCtx) < 0)
+ if (avformat_find_stream_info(pFormatCtx, NULL) < 0)
{
- av_close_input_file(pFormatCtx);
+ avformat_close_input(&pFormatCtx);
return; // Couldn't find stream information
}
// Add metadata using ffmpeg library calls
@@ -276,7 +285,7 @@ void FfmpegHandler::fillMetadata(Ref<CdsItem> item)
addFfmpegResourceFields(item, pFormatCtx, &x, &y);
// Close the video file
- av_close_input_file(pFormatCtx);
+ avformat_close_input(&pFormatCtx);
}
Ref<IOHandler> FfmpegHandler::serveContent(Ref<CdsItem> item, int resNum, off_t *data_size)

View File

@ -1,6 +1,6 @@
$OpenBSD: patch-tombupnp_threadutil_src_ThreadPool_c,v 1.3 2013/01/27 10:06:50 sthen Exp $
$OpenBSD: patch-tombupnp_threadutil_src_ThreadPool_c,v 1.4 2013/01/27 14:13:30 brad Exp $
--- tombupnp/threadutil/src/ThreadPool.c.orig Thu Mar 25 10:58:13 2010
+++ tombupnp/threadutil/src/ThreadPool.c Fri May 18 13:19:05 2012
+++ tombupnp/threadutil/src/ThreadPool.c Sun Jan 27 08:51:59 2013
@@ -141,7 +141,8 @@ SetPolicyType( PolicyType in )
static int
SetPriority( ThreadPriority priority )
@ -11,14 +11,13 @@ $OpenBSD: patch-tombupnp_threadutil_src_ThreadPool_c,v 1.3 2013/01/27 10:06:50 s
int currentPolicy;
int minPriority = 0;
int maxPriority = 0;
@@ -372,8 +373,10 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff
@@ -372,8 +373,8 @@ tp->stats.totalJobsLQ++; tp->stats.totalTimeLQ += diff
gettimeofday( &t, NULL );
#if defined(WIN32)
srand( ( unsigned int )(t.tv_usec/1000) + (unsigned int)ithread_get_current_thread_id( ).p );
-#elif defined(__FreeBSD__) || defined (__APPLE__) || defined(__OpenBSD__) || defined(__NetBSD__)
+#elif defined(__FreeBSD__) || defined (__APPLE__) || defined(__NetBSD__)
srand( ( unsigned int )(t.tv_usec/1000) + (unsigned int)ithread_get_current_thread_id( ) );
+#elif defined(__OpenBSD__)
- srand( ( unsigned int )(t.tv_usec/1000) + (unsigned int)ithread_get_current_thread_id( ) );
+#elif defined(HAVE_ARC4RANDOM)
+ srand( arc4random() );
#else
srand( ( unsigned int )(t.tv_usec/1000) + ithread_get_current_thread_id( ) );

View File

@ -1,19 +0,0 @@
$OpenBSD: patch-tombupnp_upnp_src_genlib_miniserver_miniserver_c,v 1.2 2012/08/07 10:18:47 naddy Exp $
--- tombupnp/upnp/src/genlib/miniserver/miniserver.c.orig Thu Mar 25 15:58:11 2010
+++ tombupnp/upnp/src/genlib/miniserver/miniserver.c Mon Aug 6 22:12:30 2012
@@ -61,6 +61,7 @@
#include "config.h"
+#include <sys/types.h>
#ifndef WIN32
#include <arpa/inet.h>
#include <netinet/in.h>
@@ -82,7 +83,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include <sys/types.h>
#include "ssdplib.h"