diff --git a/daemon/contrib/src/libav/rules.mak b/daemon/contrib/src/libav/rules.mak index 42962e38d10a97d14acf55a9df181358aa071311..c7ee60a32555adcfd292a7ca4d5447b3bd186094 100644 --- a/daemon/contrib/src/libav/rules.mak +++ b/daemon/contrib/src/libav/rules.mak @@ -18,6 +18,12 @@ LIBAVCONF = \ #encoders LIBAVCONF += \ --enable-libx264 \ + --enable-encoder=g722 \ + --enable-encoder=libx264 \ + --enable-encoder=pcm_alaw \ + --enable-encoder=pcm_mulaw \ + --enable-encoder=libopus \ + --enable-encoder=libspeex \ --enable-encoder=libvpx \ --disable-decoder=libvpx \ --disable-decoder=libvpx_vp8 \ diff --git a/daemon/src/account.cpp b/daemon/src/account.cpp index 78c014b0c9615c247c1c6d856f2474535e00f3a7..a23a6e14cbeb26b706a35793b213cde9d8835206 100644 --- a/daemon/src/account.cpp +++ b/daemon/src/account.cpp @@ -166,7 +166,7 @@ void Account::loadDefaultCodecs() setActiveAudioCodecs(result); #ifdef RING_VIDEO // we don't need to validate via setVideoCodecs, since these are defaults - videoCodecList_ = libav_utils::getDefaultCodecs(); + videoCodecList_ = libav_utils::getDefaultVideoCodecs(); #endif } @@ -314,7 +314,7 @@ isCodecValid(const map<string, string> &codec, const vector<map<string, string> static bool isCodecListValid(const vector<map<string, string> > &list) { - const auto defaults(libav_utils::getDefaultCodecs()); + const auto defaults(libav_utils::getDefaultVideoCodecs()); if (list.size() != defaults.size()) { RING_ERR("New codec list has a different length than the list of supported codecs"); return false; diff --git a/daemon/src/client/callmanager.cpp b/daemon/src/client/callmanager.cpp index 718415398af3995b57aed723f635dbc23a3a303c..42450ed2bf9252ff4409e36e00d1cd8adf85d918 100644 --- a/daemon/src/client/callmanager.cpp +++ b/daemon/src/client/callmanager.cpp @@ -32,6 +32,7 @@ #include <cstring> #include "callmanager.h" +#include "libav_utils.h" #include "call_factory.h" #include "sip/sipcall.h" @@ -41,6 +42,11 @@ #include "logger.h" #include "manager.h" +CallManager::CallManager() +{ + libav_utils::sfl_avcodec_init(); +} + void CallManager::registerEvHandlers(struct ring_call_ev_handlers* evHandlers) { evHandlers_ = *evHandlers; diff --git a/daemon/src/client/callmanager.h b/daemon/src/client/callmanager.h index 5990aabb86155f9b679827a560bc3ef853cfdbe9..004321a035611e4a29a69c17b555fce53843b7c4 100644 --- a/daemon/src/client/callmanager.h +++ b/daemon/src/client/callmanager.h @@ -55,6 +55,7 @@ class AudioZrtpSession; class CallManager { public: + CallManager(); void registerEvHandlers(struct ring_call_ev_handlers* evHandlers); // Methods diff --git a/daemon/src/client/videomanager.cpp b/daemon/src/client/videomanager.cpp index 7b9827103cdb5a1e6975e1933dac988784eb7660..f1b30dc5aa2005c4bdc9a60d3e52c30ab22e9981 100644 --- a/daemon/src/client/videomanager.cpp +++ b/daemon/src/client/videomanager.cpp @@ -38,11 +38,6 @@ #include "logger.h" #include "manager.h" -VideoManager::VideoManager() -{ - libav_utils::sfl_avcodec_init(); -} - void VideoManager::registerEvHandlers(struct ring_video_ev_handlers* evHandlers) { evHandlers_ = *evHandlers; diff --git a/daemon/src/client/videomanager.h b/daemon/src/client/videomanager.h index a455ae960ec2c4a8cea5217c27d6e92e5773e91f..c6c21f48ccc78cb4038df1198900c326d384dbd8 100644 --- a/daemon/src/client/videomanager.h +++ b/daemon/src/client/videomanager.h @@ -61,7 +61,6 @@ class VideoManager ring::video::VideoDeviceMonitor videoDeviceMonitor_ = {}; public: - VideoManager(); void registerEvHandlers(struct ring_video_ev_handlers* evHandlers); ring::video::VideoDeviceMonitor& getVideoDeviceMonitor(); diff --git a/daemon/src/media/audio/audiortp/avformat_rtp_session.cpp b/daemon/src/media/audio/audiortp/avformat_rtp_session.cpp index 17396842c2f77ffb64af64d944242291e08ac033..3f26ef5f405bd22d055c0882d2b593b43e9fafae 100644 --- a/daemon/src/media/audio/audiortp/avformat_rtp_session.cpp +++ b/daemon/src/media/audio/audiortp/avformat_rtp_session.cpp @@ -72,9 +72,7 @@ class AudioSender { std::map<std::string, std::string> args_; const AudioFormat format_; std::unique_ptr<ring::MediaEncoder> audioEncoder_; -#ifdef RING_VIDEO std::unique_ptr<ring::MediaIOHandle> muxContext_; -#endif std::unique_ptr<ring::Resampler> resampler_; const double secondsPerPacket_ {0.02}; // 20 ms @@ -110,17 +108,13 @@ AudioSender::setup(SocketPair& socketPair) auto dest = args_["destination"].c_str(); audioEncoder_.reset(new MediaEncoder); -#ifdef RING_VIDEO muxContext_.reset(socketPair.createIOContext()); -#endif // RING_VIDEO try { /* Encoder setup */ audioEncoder_->setOptions(args_); audioEncoder_->openOutput(enc_name, "rtp", dest, NULL, false); -#ifdef RING_VIDEO audioEncoder_->setIOContext(muxContext_); -#endif // RING_VIDEO audioEncoder_->startIO(); } catch (const MediaEncoderException &e) { RING_ERR("%s", e.what()); @@ -138,9 +132,7 @@ void AudioSender::cleanup() { audioEncoder_.reset(); -#ifdef RING_VIDEO muxContext_.reset(); -#endif // RING_VIDEO } void diff --git a/daemon/src/media/audio/coreaudio/corelayer.cpp b/daemon/src/media/audio/coreaudio/corelayer.cpp index 3deb9c8823ffe74d483a604de8e0062ff8590517..5cbcf25a843dc51c2f76e0ccc87c89910922fdfc 100644 --- a/daemon/src/media/audio/coreaudio/corelayer.cpp +++ b/daemon/src/media/audio/coreaudio/corelayer.cpp @@ -429,12 +429,10 @@ void CoreLayer::write(AudioUnitRenderActionFlags* ioActionFlags, playbackBuff_.resize(inNumberFrames); if (tone) { - RING_WARN("TONE"); tone->getNext(playbackBuff_, playbackGain_); } else if (file_tone) { - RING_WARN("FILE TONE"); file_tone->getNext(playbackBuff_, playbackGain_); } else { diff --git a/daemon/src/media/libav_utils.cpp b/daemon/src/media/libav_utils.cpp index 261e58c4bdb9d87ef5b9ae72b5e42e2f90de72a3..4a22348cfa0278fece5498bdfc2099d63b80cfa9 100644 --- a/daemon/src/media/libav_utils.cpp +++ b/daemon/src/media/libav_utils.cpp @@ -30,6 +30,7 @@ * as that of the covered work. */ +#include "config.h" #include "libav_deps.h" #include "video/video_base.h" #include "logger.h" @@ -43,6 +44,8 @@ #include <exception> std::map<std::string, std::string> encoders_; + +#ifdef RING_VIDEO std::vector<std::string> installed_video_codecs_; static void @@ -61,15 +64,18 @@ findInstalledVideoCodecs() RING_ERR("Didn't find \"%s\" encoder", it.second.c_str()); } } +#endif // RING_VIDEO namespace libav_utils { +#ifdef RING_VIDEO std::vector<std::string> getVideoCodecList() { if (installed_video_codecs_.empty()) findInstalledVideoCodecs(); return installed_video_codecs_; } +#endif // RING_VIDEO // protect libav/ffmpeg access static int @@ -145,8 +151,9 @@ static void init_once() // ffmpeg doesn't know RTP format for H263 (payload type = 34) //encoders["H263"] = "h263"; - +#ifdef RING_VIDEO findInstalledVideoCodecs(); +#endif // RING_VIDEO } static std::once_flag already_called; @@ -156,8 +163,9 @@ void sfl_avcodec_init() std::call_once(already_called, init_once); } +#ifdef RING_VIDEO std::vector<std::map<std::string, std::string> > -getDefaultCodecs() +getDefaultVideoCodecs() { const char * const DEFAULT_BITRATE = "400"; sfl_avcodec_init(); @@ -175,6 +183,7 @@ getDefaultCodecs() } return result; } +#endif // RING_VIDEO int libav_pixel_format(int fmt) { diff --git a/daemon/src/media/libav_utils.h b/daemon/src/media/libav_utils.h index 2327c086155b74cef652c063ceb363817e896e45..91f17844afd3ab63e2a598bb0ce0356a0eef0a79 100644 --- a/daemon/src/media/libav_utils.h +++ b/daemon/src/media/libav_utils.h @@ -46,7 +46,9 @@ namespace libav_utils { std::vector<std::string> getVideoCodecList(); - std::vector<std::map <std::string, std::string> > getDefaultCodecs(); +#ifdef RING_VIDEO + std::vector<std::map <std::string, std::string> > getDefaultVideoCodecs(); +#endif // RING_VIDEO const char *const DEFAULT_H264_PROFILE_LEVEL_ID = "profile-level-id=428014"; const char *const MAX_H264_PROFILE_LEVEL_ID = "profile-level-id=640034"; diff --git a/daemon/src/sip/sdp.cpp b/daemon/src/sip/sdp.cpp index 1dbd30537b89c3ef6f141d2a53721095335fb5a4..136bef2c0e63d8ca81f9c3297a4a526782a5529f 100644 --- a/daemon/src/sip/sdp.cpp +++ b/daemon/src/sip/sdp.cpp @@ -1115,7 +1115,7 @@ bool Sdp::getOutgoingVideoSettings(map<string, string> &args) const if (not codec.empty()) { const string encoder(libav_utils::encodersMap()[codec]); if (encoder.empty()) { - RING_DBG("Couldn't find encoder for \"%s\"\n", codec.c_str()); + RING_DBG("Couldn't find video encoder for \"%s\"\n", codec.c_str()); return false; } else { args["codec"] = encoder; @@ -1141,7 +1141,7 @@ bool Sdp::getOutgoingAudioSettings(map<string, string> &args) const if (not codec.empty()) { const string encoder(libav_utils::encodersMap()[codec]); if (encoder.empty()) { - RING_DBG("Couldn't find encoder for \"%s\"\n", codec.c_str()); + RING_DBG("Couldn't find audio encoder for \"%s\"\n", codec.c_str()); return false; } else { args["codec"] = encoder; diff --git a/daemon/src/sip/sipaccountbase.cpp b/daemon/src/sip/sipaccountbase.cpp index 91a991c4de7ee551d5a3de05d14e3810c4693479..36b07ee3138936ea6b33d5735b1175f7ed79be23 100644 --- a/daemon/src/sip/sipaccountbase.cpp +++ b/daemon/src/sip/sipaccountbase.cpp @@ -133,7 +133,7 @@ void SIPAccountBase::unserialize(const YAML::Node &node) if (tmp.empty()) { // Video codecs are an empty list RING_WARN("Loading default video codecs"); - tmp = libav_utils::getDefaultCodecs(); + tmp = libav_utils::getDefaultVideoCodecs(); } #endif // validate it