Commit 62b703a8 authored by Alexandre Lision's avatar Alexandre Lision Committed by Alexandre Lision

Fix audio only with libav

Refs #64597

Change-Id: Idc7eb4450d732258afb34dee75ec2f72b00f9997
parent 1b48a480
......@@ -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 \
......
......@@ -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;
......
......@@ -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;
......
......@@ -55,6 +55,7 @@ class AudioZrtpSession;
class CallManager
{
public:
CallManager();
void registerEvHandlers(struct ring_call_ev_handlers* evHandlers);
// Methods
......
......@@ -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;
......
......@@ -61,7 +61,6 @@ class VideoManager
ring::video::VideoDeviceMonitor videoDeviceMonitor_ = {};
public:
VideoManager();
void registerEvHandlers(struct ring_video_ev_handlers* evHandlers);
ring::video::VideoDeviceMonitor& getVideoDeviceMonitor();
......
......@@ -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
......
......@@ -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 {
......
......@@ -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)
{
......
......@@ -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";
......
......@@ -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;
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment