Attempt to add opus support.

This commit is contained in:
Storm Dragon 2025-04-05 02:02:50 -04:00
parent 1a9b32ee7a
commit 326b491fde
8 changed files with 792 additions and 524 deletions

View File

@ -15,7 +15,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
# USA.
AM_CFLAGS = -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
AM_CFLAGS = -Wall -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 @libpng_CFLAGS@ @opus_CFLAGS@
SUBDIRS=po
@ -62,7 +62,8 @@ minidlnad_LDADD = \
@LIBEXIF_LIBS@ \
@LIBINTL@ \
@LIBICONV@ \
-lFLAC $(flacogglibs) $(vorbislibs) $(avahilibs)
-lFLAC $(flacogglibs) $(vorbislibs) $(avahilibs) \
@opus_LIBS@
testupnpdescgen_SOURCES = testupnpdescgen.c upnpdescgen.c
testupnpdescgen_LDADD = \

View File

@ -462,6 +462,12 @@ AC_CHECK_LIB(vorbisfile, ov_open_callbacks,
AM_CONDITIONAL(HAVE_VORBISFILE, false))],
AM_CONDITIONAL(HAVE_VORBISFILE, false),
-lvorbis -logg)
#test if we have opus/opusfile
PKG_CHECK_MODULES([opus], [opus opusfile],
AM_CONDITIONAL(HAVE_OPUS, true)
AC_DEFINE(HAVE_OPUS,1,[Define to 1 if you have opus/opusfile]),
AM_CONDITIONAL(HAVE_OPUS, false))
AC_CHECK_LIB(FLAC, FLAC__stream_decoder_init_stream,
[AC_CHECK_HEADERS([FLAC/all.h],
AM_CONDITIONAL(HAVE_FLAC, true)

131
filestructure.txt Normal file
View File

@ -0,0 +1,131 @@
./upnpreplyparse.h
./clients.h
./log.h
./playlist.h
./upnphttp.c
./albumart.c
./containers.h
./monitor.h
./tivo_commands.h
./minidlna.c
./02_minidlna-xiph.patch
./icons.c
./ChangeLog
./upnpreplyparse.c
./minidlna.conf.5
./minixml.h
./sql.h
./TODO
./monitor.c
./playlist.c
./linux/inotify.h
./linux/minidlna.init.d.script.tmpl
./linux/inotify-syscalls.h
./select.c
./buildroot/readymedia/Config.in
./buildroot/readymedia/readymedia.mk
./buildroot/external.desc
./buildroot/Config.in
./buildroot/external.mk
./buildroot/readymedia_defconfig
./buildroot/build-static.sh
./upnpevents.h
./scanner.c
./upnpglobalvars.h
./avahi.h
./tivo_utils.c
./upnpdescgen.c
./clients.c
./options.c
./NEWS
./COPYING
./tivo_commands.c
./tivo_beacon.c
./Makefile.am
./getifaddr.c
./metadata.c
./log.c
./image_utils.h
./kqueue.c
./testupnpdescgen.c
./uuid.c
./minidlnad.8
./LICENCE.miniupnpd
./upnpsoap.c
./avahi.c
./libav.h
./albumart.h
./sendfile.h
./tivo_beacon.h
./po/es.po
./po/it.po
./po/nl.po
./po/ko.po
./po/ja.po
./po/sv.po
./po/nb.po
./po/POTFILES.in
./po/pl.po
./po/minidlna.pot
./po/LINGUAS
./po/ru.po
./po/sl.po
./po/Makevars
./po/de.po
./po/fr.po
./po/da.po
./README
./tagutils/tagutils-plist.c
./tagutils/tagutils-aac.h
./tagutils/tagutils-ogg.h
./tagutils/tagutils-pcm.h
./tagutils/tagutils-mp3.c
./tagutils/tagutils-flc.c
./tagutils/tagutils-aac.c
./tagutils/tagutils-flc.h
./tagutils/tagutils-dsf.c
./tagutils/tagutils-asf.h
./tagutils/tagutils-wav.h
./tagutils/tagutils-misc.c
./tagutils/tagutils-dff.h
./tagutils/tagutils-dff.c
./tagutils/tagutils-pcm.c
./tagutils/tagutils.c
./tagutils/tagutils.h
./tagutils/tagutils-asf.c
./tagutils/tagutils-wav.c
./tagutils/tagutils-dsf.h
./tagutils/tagutils-mp3.h
./tagutils/tagutils-ogg.c
./autogen.sh
./upnpdescgen.h
./upnpglobalvars.c
./minidlna.conf
./minidlnatypes.h
./scanner_sqlite.h
./getifaddr.h
./minidlnapath.h
./scanner.h
./image_utils.c
./process.c
./minissdp.h
./monitor_inotify.c
./monitor_kqueue.c
./upnphttp.h
./AUTHORS
./sql.c
./minixml.c
./uuid.h
./configure.ac
./utils.c
./upnpevents.c
./minissdp.c
./event.h
./tivo_utils.h
./metadata.h
./process.h
./codelength.h
./utils.h
./upnpsoap.h
./options.h
./containers.c

View File

@ -343,11 +343,55 @@ GetAudioMetadata(const char *path, const char *name)
strcpy(type, "wav");
m.mime = strdup("audio/x-wav");
}
else if( ends_with(path, ".ogg") || ends_with(path, ".oga") )
else if( ends_with(path,".oga") || ends_with(path,".ogg"))
{
strcpy(type, "ogg");
m.mime = strdup("audio/ogg");
/* The .ogg/.oga file extensions present something of a problem.
* ".ogg" has been deprecated in favor of ".oga" for some time, but
* many applications still only recognize ".ogg".
*
* This examines the file and causes .ogg to be presented for any naked
* Vorbis file (MIME type audio/ogg; codecs=vorbis) and .oga
* (audio/ogg) to be used for everything else. This is in line with
* the official ogg naming conventions and, hopefully, makes for a
* resonable compromise.
*/
uint8_t oggtestbuf[35];
FILE *oggfile = fopen (path, "rb");
if (oggfile == (FILE *)NULL)
{
DPRINTF(E_ERROR, L_METADATA, "Error opening %s\n", path);
return 0;
}
if (fread (oggtestbuf, 1, 35, oggfile) != 35)
{
DPRINTF(E_WARN, L_METADATA, "Premature EOF on %s\n", path);
fclose (oggfile);
return 0;
}
fclose (oggfile);
if (memcmp (&oggtestbuf[28], "\x01vorbis", 7))
m.mime = strdup ("audio/ogg");
else
m.mime = strdup ("audio/ogg; codecs=vorbis");
strcpy(type, "ogg");
}
else if ( ends_with(path, ".opus") )
{
strcpy(type,"ops");
m.mime = strdup("audio/ogg; codecs=opus");
}
#if 0
/* Not supported yet, and probably won't be. */
else if( ends_with(path, ".ogx") )
{
strcpy(type, "ogx");
m.mime = strdup("application/ogg");
}
#endif
else if( ends_with(path, ".pcm") )
{
strcpy(type, "pcm");

59
tagutils/opus.c Normal file
View File

@ -0,0 +1,59 @@
//=========================================================================
// FILENAME : tagutils-opus.c
// DESCRIPTION : Opus metadata reader
//=========================================================================
static int
_get_opusfileinfo(char *filename, struct song_metadata *psong)
{
OggOpusFile *opusfile;
const OpusTags *tags;
char **comment;
int *commentlen;
int j, e;
opusfile = op_open_file (filename, &e);
if(!opusfile)
{
DPRINTF(E_WARN, L_SCANNER,
"Error opening input file \"%s\": %s\n", filename, opus_strerror(e));
return -1;
}
DPRINTF(E_MAXDEBUG, L_SCANNER, "Processing file \"%s\"...\n", filename);
psong->song_length = op_pcm_total (opusfile, -1);
if (psong->song_length < 0)
{
DPRINTF(E_WARN, L_SCANNER,
"Unable to obtain length of %s\n", filename);
psong->song_length = 0;
} else
/* Sample rate is always 48k, so length in ms is just samples/48 */
psong->song_length /= 48;
/* Note that this gives only the first link's channel count. */
psong->channels = op_channel_count (opusfile, -1);
psong->samplerate = 48000;
psong->bitrate = op_bitrate (opusfile, -1);
tags = op_tags (opusfile, -1);
if (!tags)
{
DPRINTF(E_WARN, L_SCANNER, "Unable to obtain tags from %s\n",
filename);
return -1;
}
comment = tags->user_comments;
commentlen = tags->comment_lengths;
for (j = 0; j < tags->comments; j++)
vc_scan (psong, *(comment++), *(commentlen++));
op_free (opusfile);
return 0;
}

6
tagutils/opus.h Normal file
View File

@ -0,0 +1,6 @@
//=========================================================================
// FILENAME : tagutils-opus.h
// DESCRIPTION : Opus metadata reader
//=========================================================================
static int _get_opusfileinfo(char *filename, struct song_metadata *psong);

View File

@ -42,6 +42,10 @@
#ifdef HAVE_ICONV
#include <iconv.h>
#endif
/* ADD THIS INCLUDE FOR OPUS */
#ifdef HAVE_OPUS
#include <opusfile.h>
#endif
#include <sqlite3.h>
#include "tagutils.h"
#include "../metadata.h"
@ -104,8 +108,9 @@ char *winamp_genre[] = {
*/
#include "tagutils-mp3.h"
#include "tagutils-aac.h"
#ifdef HAVE_VORBISFILE
#include "tagutils-ogg.h"
#ifdef HAVE_OPUS
#include "tagutils-opus.h"
#endif
#include "tagutils-flc.h"
#include "tagutils-asf.h"
@ -132,14 +137,15 @@ static taghandler taghandlers[] = {
{ "aac", _get_aactags, _get_aacfileinfo },
{ "mp3", _get_mp3tags, _get_mp3fileinfo },
{ "flc", _get_flctags, _get_flcfileinfo },
#ifdef HAVE_VORBISFILE
{ "ogg", NULL, _get_oggfileinfo },
{ "ogg", 0, _get_oggfileinfo },
#ifdef HAVE_OPUS
{ "ops", 0, _get_opusfileinfo },
#endif
{ "asf", NULL, _get_asffileinfo },
{ "asf", 0, _get_asffileinfo },
{ "wav", _get_wavtags, _get_wavfileinfo },
{ "pcm", NULL, _get_pcmfileinfo },
{ "pcm", 0, _get_pcmfileinfo },
{ "dsf", _get_dsftags, _get_dsffileinfo },
{ "dff", NULL, _get_dfffileinfo },
{ "dff", 0, _get_dfffileinfo },
{ NULL, NULL, NULL }
};
@ -149,8 +155,9 @@ static taghandler taghandlers[] = {
#include "tagutils-misc.c"
#include "tagutils-mp3.c"
#include "tagutils-aac.c"
#ifdef HAVE_VORBISFILE
#include "tagutils-ogg.c"
#ifdef HAVE_OPUS
#include "tagutils-opus.c"
#endif
#include "tagutils-flc.c"
#include "tagutils-asf.c"

16
utils.c
View File

@ -345,8 +345,15 @@ mime_to_ext(const char * mime)
return "pcm";
else if( strcmp(mime+6, "3gpp") == 0 )
return "3gp";
else if( strcmp(mime, "application/ogg") == 0 )
else if( strncmp(mime+6, "ogg", 3) == 0 )
{
if( strstr(mime+9, "opus" ) != (char *)NULL )
return "opus";
else if( strstr (mime+9, "vorbis" ) != (char *)NULL )
return "ogg";
return "oga";
}
else if( strcmp(mime+6, "x-dsd") == 0 )
return "dsd";
break;
@ -377,6 +384,8 @@ mime_to_ext(const char * mime)
return "3gp";
else if( strncmp(mime+6, "x-tivo-mpeg", 11) == 0 )
return "TiVo";
else if ( strcmp(mime+6, "ogg") == 0 )
return "ogv";
break;
case 'i':
if( strcmp(mime+6, "jpeg") == 0 )
@ -401,6 +410,7 @@ is_video(const char * file)
ends_with(file, ".m2t") || ends_with(file, ".mkv") ||
ends_with(file, ".vob") || ends_with(file, ".ts") ||
ends_with(file, ".flv") || ends_with(file, ".xvid") ||
ends_with(file, ".ogv") ||
#ifdef TIVO_SUPPORT
ends_with(file, ".TiVo") ||
#endif
@ -418,6 +428,10 @@ is_audio(const char * file)
ends_with(file, ".m4a") || ends_with(file, ".aac") ||
ends_with(file, ".mp4") || ends_with(file, ".m4p") ||
ends_with(file, ".wav") || ends_with(file, ".ogg") ||
ends_with(file, ".oga") ||
#ifdef HAVE_OPUS
ends_with(file, ".opus") ||
#endif
ends_with(file, ".pcm") || ends_with(file, ".3gp") ||
ends_with(file, ".dsf") || ends_with(file, ".dff"));
}