Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opus encoder #1386

Merged
merged 11 commits into from
Jan 9, 2019
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ for:

install:
- sudo apt-get update
- sudo apt-get -y install gdb libavformat-dev libchromaprint-dev libfaad-dev libflac-dev libid3tag0-dev libmad0-dev libmodplug-dev libmp3lame-dev libmp4v2-dev libopusfile-dev libportmidi-dev libprotobuf-dev libqt5opengl5-dev libqt5sql5-sqlite libqt5svg5-dev librubberband-dev libshout3-dev libsndfile1-dev libsqlite3-dev libtag1-dev libupower-glib-dev libusb-1.0-0-dev libwavpack-dev portaudio19-dev protobuf-compiler qt5-default qtscript5-dev libqt5x11extras5-dev scons qtkeychain-dev liblilv-dev libsoundtouch-dev
- sudo apt-get -y install gdb libavformat-dev libchromaprint-dev libfaad-dev libflac-dev libid3tag0-dev libmad0-dev libmodplug-dev libmp3lame-dev libmp4v2-dev libopus-dev libopusfile-dev libportmidi-dev libprotobuf-dev libqt5opengl5-dev libqt5sql5-sqlite libqt5svg5-dev librubberband-dev libshout3-dev libsndfile1-dev libsqlite3-dev libtag1-dev libupower-glib-dev libusb-1.0-0-dev libwavpack-dev portaudio19-dev protobuf-compiler qt5-default qtscript5-dev libqt5x11extras5-dev scons qtkeychain-dev liblilv-dev libsoundtouch-dev

build_script:
- scons -j4 test=1 mad=1 faad=1 ffmpeg=1 opus=1 modplug=1 wv=1 hss1394=0 virtualize=0 debug_assertions_fatal=1 verbose=0 localecompare=1
Expand Down
15 changes: 11 additions & 4 deletions build/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -747,20 +747,27 @@ def configure(self, build, conf):

# Support for Opus (RFC 6716)
# More info http://http://www.opus-codec.org/
if not conf.CheckLib(['opusfile', 'libopusfile']):
if not conf.CheckLib(['opusfile', 'libopusfile']) or not conf.CheckLib(['opus', 'libopus']):
if explicit:
raise Exception('Could not find libopusfile.')
raise Exception('Could not find opus or libopusfile.')
else:
build.flags['opus'] = 0
return

build.env.Append(CPPDEFINES='__OPUS__')
if build.platform_is_windows and build.static_dependencies:
for opus_lib in ['celt', 'silk_common', 'silk_float']:
if not conf.CheckLib(opus_lib):
raise Exception('Missing opus static library %s -- exiting' % opus_lib)

if build.platform_is_linux or build.platform_is_bsd:
build.env.ParseConfig('pkg-config opusfile opus --silence-errors --cflags --libs')

build.env.Append(CPPDEFINES='__OPUS__')

def sources(self, build):
return ['src/sources/soundsourceopus.cpp']
return ['src/sources/soundsourceopus.cpp',
'src/encoder/encoderopus.cpp',
'src/encoder/encoderopussettings.cpp']


class FFMPEG(Feature):
Expand Down
1 change: 1 addition & 0 deletions src/broadcast/defs_broadcast.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

#define BROADCAST_FORMAT_MP3 "MP3"
#define BROADCAST_FORMAT_OV "OggVorbis"
#define BROADCAST_FORMAT_OPUS "Opus"

// EngineNetworkStream can't use locking mechanisms to protect its
// internal worker list against concurrency issues, as it is used by
Expand Down
41 changes: 30 additions & 11 deletions src/encoder/encoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,17 @@
#endif
#include "encoder/encoderwave.h"
#include "encoder/encodersndfileflac.h"

#include "encoder/encodermp3settings.h"
#include "encoder/encodervorbissettings.h"
#include "encoder/encoderwavesettings.h"
#include "encoder/encoderflacsettings.h"

#ifdef __OPUS__
#include "encoder/encoderopus.h"
#include "encoder/encoderopussettings.h"
#endif

#include <QList>

EncoderFactory EncoderFactory::factory;
Expand All @@ -38,11 +44,15 @@ const EncoderFactory& EncoderFactory::getFactory()

EncoderFactory::EncoderFactory() {
// Add new supported formats here. Also modify the getNewEncoder/getEncoderSettings method.
m_formats.append(Encoder::Format("WAV PCM",ENCODING_WAVE, true));
m_formats.append(Encoder::Format("AIFF PCM",ENCODING_AIFF, true));
m_formats.append(Encoder::Format("WAV PCM", ENCODING_WAVE, true));
m_formats.append(Encoder::Format("AIFF PCM", ENCODING_AIFF, true));
m_formats.append(Encoder::Format("FLAC", ENCODING_FLAC, true));
m_formats.append(Encoder::Format("MP3",ENCODING_MP3, false));
m_formats.append(Encoder::Format("OGG Vorbis",ENCODING_OGG, false));
m_formats.append(Encoder::Format("MP3", ENCODING_MP3, false));
m_formats.append(Encoder::Format("OGG Vorbis", ENCODING_OGG, false));

#ifdef __OPUS__
m_formats.append(Encoder::Format("Opus", ENCODING_OPUS, false));
#endif
}

const QList<Encoder::Format> EncoderFactory::getFormats() const
Expand Down Expand Up @@ -86,20 +96,27 @@ EncoderPointer EncoderFactory::getNewEncoder(Encoder::Format format,
pEncoder = std::make_shared<EncoderSndfileFlac>(pCallback);
pEncoder->setEncoderSettings(EncoderFlacSettings(pConfig));
} else if (format.internalName == ENCODING_MP3) {
#ifdef __FFMPEGFILE_ENCODERS__
#ifdef __FFMPEGFILE_ENCODERS__
pEncoder = std::make_shared<EncoderFfmpegMp3>(pCallback);
#else
#else
pEncoder = std::make_shared<EncoderMp3>(pCallback);
#endif
#endif
pEncoder->setEncoderSettings(EncoderMp3Settings(pConfig));
} else if (format.internalName == ENCODING_OGG) {
#ifdef __FFMPEGFILE_ENCODERS__
#ifdef __FFMPEGFILE_ENCODERS__
pEncoder = std::make_shared<EncoderFfmpegVorbis>(pCallback);
#else
#else
pEncoder = std::make_shared<EncoderVorbis>(pCallback);
#endif
#endif
pEncoder->setEncoderSettings(EncoderVorbisSettings(pConfig));
} else {
}
#ifdef __OPUS__
else if (format.internalName == ENCODING_OPUS) {
pEncoder = std::make_shared<EncoderOpus>(pCallback);
pEncoder->setEncoderSettings(EncoderOpusSettings(pConfig));
}
#endif
else {
qWarning() << "Unsupported format requested! " << format.internalName;
DEBUG_ASSERT(false);
pEncoder = std::make_shared<EncoderWave>(pCallback);
Expand All @@ -121,6 +138,8 @@ EncoderSettingsPointer EncoderFactory::getEncoderSettings(Encoder::Format format
return std::make_shared<EncoderMp3Settings>(pConfig);
} else if (format.internalName == ENCODING_OGG) {
return std::make_shared<EncoderVorbisSettings>(pConfig);
} else if (format.internalName == ENCODING_OPUS) {
return std::make_shared<EncoderOpusSettings>(pConfig);
} else {
qWarning() << "Unsupported format requested! " << format.internalName;
DEBUG_ASSERT(false);
Expand Down
Loading