Commit 8cc2cb0f authored by Tristan Matthews's avatar Tristan Matthews

* #8357: daemon builds after ./configure --disable-video

parent 90fe5e2d
......@@ -32,9 +32,11 @@
#include "account.h"
#include "manager.h"
#ifdef SFL_VIDEO
#include "video/video_endpoint.h"
#endif
Account::Account (const std::string& accountID, const std::string &type) :
Account::Account(const std::string& accountID, const std::string &type) :
accountID_(accountID)
, username_()
, hostname_()
......@@ -43,8 +45,10 @@ Account::Account (const std::string& accountID, const std::string &type) :
, enabled_(true)
, type_(type)
, registrationState_(Unregistered)
, codecOrder_()
, videoCodecOrder_()
, codecList_()
#ifdef SFL_VIDEO
, videoCodecList_()
#endif
, codecStr_()
, ringtonePath_("/usr/share/sflphone/ringtones/konga.ul")
, ringtoneEnabled_(true)
......@@ -52,13 +56,12 @@ Account::Account (const std::string& accountID, const std::string &type) :
, userAgent_("SFLphone")
, mailBox_()
{
// Initialize the codec order, used when creating a new account
// Initialize the codec list, used when creating a new account
loadDefaultCodecs();
}
Account::~Account()
{
}
{}
void Account::setRegistrationState(const RegistrationState &state)
{
......@@ -73,7 +76,7 @@ void Account::setRegistrationState(const RegistrationState &state)
void Account::loadDefaultCodecs()
{
// Initialize codec
std::vector <std::string> codecList;
std::vector<std::string> codecList;
codecList.push_back("0");
codecList.push_back("3");
codecList.push_back("8");
......@@ -83,25 +86,29 @@ void Account::loadDefaultCodecs()
codecList.push_back("112");
setActiveCodecs(codecList);
#if SFL_VIDEO
setActiveVideoCodecs(sfl_video::getVideoCodecList());
#endif
}
#if SFL_VIDEO
void Account::setActiveVideoCodecs (const std::vector <std::string> &list)
{
videoCodecOrder_ = !list.empty() ? list : sfl_video::getVideoCodecList();
videoCodecList_ = !list.empty() ? list : sfl_video::getVideoCodecList();
}
#endif
void Account::setActiveCodecs(const std::vector <std::string> &list)
{
// first clear the previously stored codecs
codecOrder_.clear();
codecList_.clear();
// list contains the ordered payload of active codecs picked by the user for this account
// we used the CodecOrder vector to save the order.
// we used the CodecList vector to save the order.
for (std::vector<std::string>::const_iterator iter = list.begin(); iter != list.end();
++iter) {
int payload = std::atoi(iter->c_str());
codecOrder_.push_back((int) payload);
codecList_.push_back(static_cast<int>(payload));
}
// update the codec string according to new codec selection
......
......@@ -140,7 +140,9 @@ static const char * const accountEnableKey = "enable";
static const char * const mailboxKey = "mailbox";
static const char * const codecsKey = "codecs"; // 0/9/110/111/112/
#ifdef SFL_VIDEO
static const char * const videocodecsKey = "videocodecs";
#endif
static const char * const ringtonePathKey = "ringtonePath";
static const char * const ringtoneEnabledKey = "ringtoneEnabled";
static const char * const displayNameKey = "displayName";
......@@ -250,20 +252,22 @@ class Account : public Serializable {
type_ = type;
}
#ifdef SFL_VIDEO
/**
* Accessor to data structures
* @return std::vector<std::string>& The list that reflects the user's choice
*/
const std::vector<std::string>& getActiveVideoCodecs (void) const {
return videoCodecOrder_;
std::vector<std::string> getActiveVideoCodecs() const {
return videoCodecList_;
}
#endif
/**
* Accessor to data structures
* @return CodecOrder& The list that reflects the user's choice
*/
const CodecOrder& getActiveCodecs() const {
return codecOrder_;
std::vector<int> getActiveCodecs() const {
return codecList_;
}
/**
......@@ -271,7 +275,9 @@ class Account : public Serializable {
* SDP offer and configuration respectively
*/
void setActiveCodecs(const std::vector<std::string>& list);
#ifdef SFL_VIDEO
void setActiveVideoCodecs(const std::vector<std::string>& list);
#endif
std::string getRingtonePath() const {
return ringtonePath_;
......@@ -361,12 +367,14 @@ class Account : public Serializable {
/**
* Vector containing the order of the codecs
*/
CodecOrder codecOrder_;
std::vector<int> codecList_;
#ifdef SFL_VIDEO
/**
* Vector containing the order of the video codecs
*/
std::vector<std::string> videoCodecOrder_;
std::vector<std::string> videoCodecList_;
#endif
/**
* List of codec obtained when parsing configuration and used
......
......@@ -38,7 +38,7 @@
#include "fileutils.h"
AudioCodecFactory::AudioCodecFactory() :
codecsMap_(), defaultCodecOrder_(), libCache_(), codecInMemory_()
codecsMap_(), defaultCodecList_(), libCache_(), codecInMemory_()
{
typedef std::vector<sfl::Codec*> CodecVector;
CodecVector codecDynamicList(scanCodecDirectory());
......@@ -46,21 +46,19 @@ AudioCodecFactory::AudioCodecFactory() :
if (codecDynamicList.empty())
ERROR("Error - No codecs available");
else {
for (CodecVector::const_iterator iter = codecDynamicList.begin();
iter != codecDynamicList.end() ; ++iter) {
codecsMap_[(int)(*iter)->getPayloadType()] = *iter;
DEBUG("Loaded codec %s" , (*iter)->getMimeSubtype().c_str());
for (CodecVector::const_iterator i = codecDynamicList.begin();
i != codecDynamicList.end() ; ++i) {
codecsMap_[(int)(*i)->getPayloadType()] = *i;
DEBUG("Loaded codec %s" , (*i)->getMimeSubtype().c_str());
}
}
}
void AudioCodecFactory::setDefaultOrder()
{
defaultCodecOrder_.clear();
CodecsMap::const_iterator iter;
for (iter = codecsMap_.begin(); iter != codecsMap_.end(); ++iter)
defaultCodecOrder_.push_back(iter->first);
defaultCodecList_.clear();
for (CodecsMap::const_iterator i = codecsMap_.begin(); i != codecsMap_.end(); ++i)
defaultCodecList_.push_back(i->first);
}
std::string
......@@ -78,11 +76,11 @@ std::vector<int32_t >
AudioCodecFactory::getAudioCodecList() const
{
std::vector<int32_t> list;
int size = codecsMap_.size();
printf("%d\n",size);
for (CodecsMap::const_iterator iter = codecsMap_.begin(); iter != codecsMap_.end(); ++iter)
if (iter->second)
list.push_back((int32_t)iter->first);
int size = codecsMap_.size();
printf("%d\n",size);
for (CodecsMap::const_iterator i = codecsMap_.begin(); i != codecsMap_.end(); ++i)
if (i->second)
list.push_back((int32_t)i->first);
return list;
}
......@@ -121,24 +119,24 @@ int AudioCodecFactory::getSampleRate(int payload) const
void AudioCodecFactory::saveActiveCodecs(const std::vector<std::string>& list)
{
defaultCodecOrder_.clear();
defaultCodecList_.clear();
// list contains the ordered payload of active codecs picked by the user
// we used the CodecOrder vector to save the order.
// we used the CodecList vector to save the order.
for (std::vector<std::string>::const_iterator iter = list.begin(); iter != list.end(); ++iter) {
int payload = std::atoi(iter->c_str());
if (isCodecLoaded(payload))
defaultCodecOrder_.push_back((int) payload);
defaultCodecList_.push_back(static_cast<int>(payload));
}
}
AudioCodecFactory::~AudioCodecFactory()
{
for (std::vector<CodecHandlePointer>::const_iterator iter =
codecInMemory_.begin(); iter != codecInMemory_.end(); ++iter)
unloadCodec(*iter);
for (std::vector<CodecHandlePointer>::const_iterator i =
codecInMemory_.begin(); i != codecInMemory_.end(); ++i)
unloadCodec(*i);
}
std::vector<sfl::Codec*> AudioCodecFactory::scanCodecDirectory()
......@@ -236,11 +234,9 @@ void AudioCodecFactory::unloadCodec(CodecHandlePointer p)
sfl::Codec* AudioCodecFactory::instantiateCodec(int payload) const
{
std::vector< CodecHandlePointer >::const_iterator iter;
for (iter = codecInMemory_.begin(); iter != codecInMemory_.end(); ++iter) {
if (iter->first->getPayloadType() == payload) {
create_t* createCodec = (create_t*) dlsym(iter->second , CODEC_ENTRY_SYMBOL);
for (std::vector<CodecHandlePointer>::const_iterator i = codecInMemory_.begin(); i != codecInMemory_.end(); ++i) {
if (i->first->getPayloadType() == payload) {
create_t* createCodec = (create_t*) dlsym(i->second , CODEC_ENTRY_SYMBOL);
char *error = dlerror();
......@@ -309,10 +305,8 @@ AudioCodecFactory::alreadyInCache(const std::string &lib)
bool AudioCodecFactory::isCodecLoaded(int payload) const
{
CodecsMap::const_iterator iter;
for (iter = codecsMap_.begin(); iter != codecsMap_.end(); ++iter)
if (iter->first == payload)
for (CodecsMap::const_iterator i = codecsMap_.begin(); i != codecsMap_.end(); ++i)
if (i->first == payload)
return true;
return false;
......
......@@ -168,7 +168,7 @@ class AudioCodecFactory {
/**
* Vector containing a default order for the codecs
*/
CodecOrder defaultCodecOrder_;
std::vector<int> defaultCodecList_;
/**
* Vector containing the complete name of the codec shared library scanned
......
......@@ -239,7 +239,7 @@ void YamlEmitter::serializeAudioPreference(MappingNode *map)
addMappingItem(preferencemapping, iter->first, iter->second);
}
#ifdef SFL_VIDEO
void YamlEmitter::serializeVideoPreference(MappingNode *map)
{
if (map->getType() != MAPPING)
......@@ -262,6 +262,7 @@ void YamlEmitter::serializeVideoPreference(MappingNode *map)
for (Mapping::iterator iter = internalmap->begin(); iter != internalmap->end(); ++iter)
addMappingItem(preferencemapping, iter->first, iter->second);
}
#endif
void YamlEmitter::serializeShortcutPreference(MappingNode *map)
......
......@@ -71,8 +71,9 @@ class YamlEmitter {
void serializeAudioPreference(MappingNode *map);
#ifdef SFL_VIDEO
void serializeVideoPreference(MappingNode *map);
#endif
void serializeShortcutPreference(MappingNode *map);
void writeAudio();
......
......@@ -48,7 +48,9 @@ YamlParser::YamlParser(const char *file) : filename_(file)
, preferenceNode_(NULL)
, addressbookNode_(NULL)
, audioNode_(NULL)
#ifdef SFL_VIDEO
, videoNode_(NULL)
#endif
, hooksNode_(NULL)
, voiplinkNode_(NULL)
, shortcutNode_(NULL)
......@@ -397,7 +399,9 @@ void YamlParser::mainNativeDataMapping(MappingNode *map)
accountSequence_ = (SequenceNode*)(*mapping)["accounts"];
addressbookNode_ = (MappingNode*)(*mapping)["addressbook"];
audioNode_ = (MappingNode*)(*mapping)["audio"];
#ifdef SFL_VIDEO
videoNode_ = (MappingNode*)(*mapping)["video"];
#endif
hooksNode_ = (MappingNode*)(*mapping)["hooks"];
preferenceNode_ = (MappingNode*)(*mapping)["preferences"];
voiplinkNode_ = (MappingNode*)(*mapping)["voipPreferences"];
......
......@@ -82,9 +82,11 @@ class YamlParser {
return audioNode_;
}
#ifdef SFL_VIDEO
MappingNode *getVideoNode() {
return videoNode_;
}
#endif
MappingNode *getHookNode() {
return hooksNode_;
......@@ -151,7 +153,9 @@ class YamlParser {
MappingNode *preferenceNode_;
MappingNode *addressbookNode_;
MappingNode *audioNode_;
#ifdef SFL_VIDEO
MappingNode *videoNode_;
#endif
MappingNode *hooksNode_;
MappingNode *voiplinkNode_;
MappingNode *shortcutNode_;
......
......@@ -118,9 +118,6 @@ enum {
PAYLOAD_CODEC_SPEEX_32000 = 112
};
/** The struct to reflect the order the user wants to use the codecs */
typedef std::vector<int> CodecOrder;
#define IP2IP_PROFILE "IP2IP"
#define DIR_SEPARATOR_STR "/" // Directory separator char
#define DIR_SEPARATOR_CH = '/' /** Directory separator string */
......
......@@ -62,15 +62,16 @@ IAXCall::IAXCall(const std::string& id, Call::CallType type) : Call(id, type),
int IAXCall::getSupportedFormat(const std::string &accountID) const
{
using std::vector;
Account *account = Manager::instance().getAccount(accountID);
int format_mask = 0;
if (account) {
CodecOrder map(account->getActiveCodecs());
vector<int> codecs(account->getActiveCodecs());
for (CodecOrder::const_iterator iter = map.begin(); iter != map.end(); ++iter)
format_mask |= codecToASTFormat(*iter);
for (vector<int>::const_iterator i = codecs.begin(); i != codecs.end(); ++i)
format_mask |= codecToASTFormat(*i);
} else
ERROR("No IAx account could be found");
......@@ -79,13 +80,14 @@ int IAXCall::getSupportedFormat(const std::string &accountID) const
int IAXCall::getFirstMatchingFormat(int needles, const std::string &accountID) const
{
using std::vector;
Account *account = Manager::instance().getAccount(accountID);
if (account != NULL) {
CodecOrder map(account->getActiveCodecs());
vector<int> codecs(account->getActiveCodecs());
for (CodecOrder::const_iterator iter = map.begin(); iter != map.end(); ++iter) {
int format_mask = codecToASTFormat(*iter);
for (vector<int>::const_iterator i = codecs.begin(); i != codecs.end(); ++i) {
int format_mask = codecToASTFormat(*i);
// Return the first that matches
if (format_mask & needles)
......
......@@ -410,11 +410,13 @@ IAXVoIPLink::sendTextMessage(sfl::InstantMessaging *module,
}
}
#ifdef SFL_VIDEO
std::string
IAXVoIPLink::getCurrentVideoCodecName(const std::string& /*id*/)
{
return "";
}
#endif
std::string
IAXVoIPLink::getCurrentCodecName(Call *c) const
......
......@@ -173,7 +173,9 @@ class IAXVoIPLink : public VoIPLink {
* Return the codec protocol used for this call
* @param id The call identifier
*/
#ifdef SFL_VIDEO
virtual std::string getCurrentVideoCodecName(const std::string& id);
#endif
virtual std::string getCurrentCodecName(Call *c) const;
private:
......
......@@ -408,69 +408,6 @@ void AudioPreference::unserialize(Conf::MappingNode *map)
}
}
VideoPreference::VideoPreference() :
v4l2_list_(0), device_(), channel_(), size_(), rate_()
{
v4l2_list_ = new VideoV4l2ListThread();
v4l2_list_->start();
}
VideoPreference::~VideoPreference()
{
delete v4l2_list_;
}
std::map<std::string, std::string> VideoPreference::getVideoSettings()
{
std::map<std::string, std::string> map;
std::stringstream ss;
map["input"] = v4l2_list_->getDeviceNode(device_);
ss << v4l2_list_->getChannelNum(device_, channel_);
map["channel"] = ss.str();
map["video_size"] = size_;
size_t x_pos = size_.find("x");
map["width"] = size_.substr(0, x_pos);
map["height"] = size_.substr(x_pos + 1);
map["framerate"] = rate_;
return map;
}
void VideoPreference::serialize (Conf::YamlEmitter *emitter)
{
if (emitter == NULL) {
ERROR("VideoPreference: Error: emitter is NULL while serializing");
return;
}
Conf::MappingNode preferencemap(NULL);
Conf::ScalarNode device(device_);
Conf::ScalarNode channel(channel_);
Conf::ScalarNode size(size_);
Conf::ScalarNode rate(rate_);
preferencemap.setKeyValue(videoDeviceKey, &device);
preferencemap.setKeyValue(videoChannelKey, &channel);
preferencemap.setKeyValue(videoSizeKey, &size);
preferencemap.setKeyValue(videoRateKey, &rate);
emitter->serializeVideoPreference(&preferencemap);
}
void VideoPreference::unserialize (Conf::MappingNode *map)
{
if (map == NULL) {
ERROR("VideoPreference: Error: Preference map is NULL");
return;
}
map->getValue(videoDeviceKey, &device_);
map->getValue(videoChannelKey, &channel_);
map->getValue(videoSizeKey, &size_);
map->getValue(videoRateKey, &rate_);
}
ShortcutPreferences::ShortcutPreferences() : hangup_(), pickup_(), popup_(),
toggleHold_(), togglePickupHangup_() {}
......@@ -487,7 +424,6 @@ std::map<std::string, std::string> ShortcutPreferences::getShortcuts() const
return shortcutsMap;
}
void ShortcutPreferences::setShortcuts(std::map<std::string, std::string> map)
{
hangup_ = map[hangupShortKey];
......@@ -497,7 +433,6 @@ void ShortcutPreferences::setShortcuts(std::map<std::string, std::string> map)
togglePickupHangup_ = map[togglePickupHangupShortKey];
}
void ShortcutPreferences::serialize(Conf::YamlEmitter *emitter)
{
Conf::MappingNode preferencemap(NULL);
......
......@@ -32,9 +32,6 @@
#define __PREFERENCE_H__
#include "config/serializable.h"
#include "video/video_v4l2_list.h"
#include "video/video_v4l2.h"
using namespace sfl_video;
// general preferences
static const char * const orderKey = "order";
......@@ -93,12 +90,6 @@ static const char * const echoCancelKey = "echoCancel";
static const char * const echoTailKey = "echoTailLength";
static const char * const echoDelayKey = "echoDelayLength";
// video preferences
const std::string videoDeviceKey ("v4l2Dev");
const std::string videoChannelKey ("v4l2Channel");
const std::string videoSizeKey ("v4l2Size");
const std::string videoRateKey ("v4l2Rate");
// shortcut preferences
static const char * const hangupShortKey = "hangUp";
static const char * const pickupShortKey = "pickUp";
......@@ -573,80 +564,6 @@ class AudioPreference : public Serializable {
int echoCancelDelay_;
};
class VideoPreference : public Serializable
{
public:
VideoPreference();
~VideoPreference();
virtual void serialize (Conf::YamlEmitter *emitter);
virtual void unserialize (Conf::MappingNode *map);
std::map<std::string, std::string> getVideoSettings();
std::string getDevice() const {
return device_;
}
void setDevice(const std::string &device) {
device_ = device;
}
std::string getChannel() const {
return channel_;
}
void setChannel(const std::string & input) {
channel_ = input;
}
std::string getSize() const {
return size_;
}
void setSize(const std::string & size) {
size_ = size;
}
const std::string & getRate() const {
return rate_;
}
void setRate(const std::string & rate) {
rate_ = rate;
}
std::vector<std::string> getDeviceList() const {
return v4l2_list_->getDeviceList();
}
std::vector<std::string> getChannelList(const std::string &dev) const {
return v4l2_list_->getChannelList(dev);
}
std::vector<std::string> getSizeList(const std::string &dev, const std::string &channel) const {
return v4l2_list_->getSizeList(dev, channel);
}
std::vector<std::string> getRateList(const std::string &dev, const std::string &channel, const std::string &size) const {
return v4l2_list_->getRateList(dev, channel, size);
}
private:
NON_COPYABLE(VideoPreference);
// V4L2 devices
sfl_video::VideoV4l2ListThread *v4l2_list_;
std::string device_;
std::string channel_;
std::string size_;
std::string rate_;
};
class ShortcutPreferences : public Serializable {
public:
ShortcutPreferences();
......
This diff is collapsed.
......@@ -44,7 +44,7 @@
#include <string>
#include <stdexcept>
#include "global.h" // for CodecOrder
#include "global.h" // for std::vector<int>
#include "noncopyable.h"
namespace sfl {
......@@ -111,18 +111,24 @@ class Sdp {
*/
void setActiveRemoteSdpSession(const pjmedia_sdp_session *sdp);
#ifdef SFL_VIDEO
/**
* Returns a string version of the negotiated SDP fields which pertain
* to video.
* Second member of the vector is the video codec rtp name
*/
std::vector<std::string> getActiveVideoDescription() const;
#endif
/*
* On building an invite outside a dialog, build the local offer and create the
* SDP negotiator instance with it.
*/
void createOffer(const CodecOrder &selectedCodecs, const std::vector<std::string> &videoCodecs);
#ifdef SFL_VIDEO
void createOffer(const std::vector<int> &selectedCodecs, const std::vector<std::string> &videoCodecs);
#else
void createOffer(const std::vector<int> &selectedCodecs);
#endif
/*
* On receiving an invite outside a dialog, build the local offer and create the
......@@ -130,9 +136,14 @@ class Sdp {
*
* @param remote The remote offer
*/
void receiveOffer (const pjmedia_sdp_session* remote,
const CodecOrder &selectedCodecs,
const std::vector<std::string> &videoCodecs);
#ifdef SFL_VIDEO
void receiveOffer(const pjmedia_sdp_session* remote,
const std::vector<int> &selectedCodecs,
const std::vector<std::string> &videoCodecs);
#else
void receiveOffer(const pjmedia_sdp_session* remote,
const std::vector<int> &selectedCodecs);
#endif
/**
* Start the sdp negotiation.
......@@ -167,9 +178,11 @@ class Sdp {
localAudioPort_ = port;
}
#ifdef SFL_VIDEO
void setLocalPublishedVideoPort (int port) {
localVideoPort_ = port;
}
#endif
/**
* Return IP of destination
......@@ -195,6 +208,7 @@ class Sdp {
return remoteAudioPort_;
}
#ifdef SFL_VIDEO
/**
* Return video port at destination
* @return unsigned int The remote video port
......@@ -202,11 +216,14 @@ class Sdp {
unsigned int getRemoteVideoPort() const {
return remoteVideoPort_;
}
#endif
void addAttributeToLocalAudioMedia(const char *attr);
void removeAttributeFromLocalAudioMedia(const char *attr);
#ifdef SFL_VIDEO
void addAttributeToLocalVideoMedia(const char *attr);
void removeAttributeFromLocalVideoMedia(const char *attr);
#endif
/**
* Get SRTP master key
......@@ -240,7 +257,9 @@ class Sdp {
void setMediaTransportInfoFromRemoteSdp();
std::string getAudioCodecName() const;
#ifdef SFL_VIDEO
std::string getSessionVideoCodec() const;
#endif
void receivingAnswerAfterInitialOffer(const pjmedia_sdp_session* remote);
......@@ -288,21 +307,29 @@ class Sdp {
* Codec Map used for offer
*/
std::vector<sfl::Codec *> audio_codec_list_;
#ifdef SFL_VIDEO
std::vector<std::string> video_codec_list_;
#endif
/**
* The codecs that will be used by the session (after the SDP negotiation)
*/
std::vector<sfl::Codec *> sessionAudioMedia_;
#ifdef SFL_VIDEO
std::vector<std::string> sessionVideoMedia_;
#endif
std::string localIpAddr_;
std::string remoteIpAddr_;
int localAudioPort_;
#ifdef SFL_VIDEO
int localVideoPort_;
#endif
unsigned int remoteAudioPort_;