diff --git a/daemon/src/account.cpp b/daemon/src/account.cpp index af5a21244683bc30975d1205634da3d85a512034..e9c6d9d70dc3f3032e8541bd3440829990fae5de 100644 --- a/daemon/src/account.cpp +++ b/daemon/src/account.cpp @@ -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 diff --git a/daemon/src/account.h b/daemon/src/account.h index 09da12f3e96f35424c14a3aec88ef4d391def28a..6e79e79e9acac62cb33a4218ed5906e1b26de77d 100644 --- a/daemon/src/account.h +++ b/daemon/src/account.h @@ -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 diff --git a/daemon/src/audio/codecs/audiocodecfactory.cpp b/daemon/src/audio/codecs/audiocodecfactory.cpp index 95a4598caa17efc2ac103969adb5044bb06ce36d..6d3e30987c3788d415503ad6c17e777da503811d 100644 --- a/daemon/src/audio/codecs/audiocodecfactory.cpp +++ b/daemon/src/audio/codecs/audiocodecfactory.cpp @@ -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; diff --git a/daemon/src/audio/codecs/audiocodecfactory.h b/daemon/src/audio/codecs/audiocodecfactory.h index 1b4e7a4396183903a77521b6106d5070a9e81af7..169b337a3c4947be6cc4488b67ecc0df03dbc0c5 100644 --- a/daemon/src/audio/codecs/audiocodecfactory.h +++ b/daemon/src/audio/codecs/audiocodecfactory.h @@ -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 diff --git a/daemon/src/config/yamlemitter.cpp b/daemon/src/config/yamlemitter.cpp index 879b45d69a2b9484322e5765da183d8f63d636c2..56de17e8ae87a9d194f3e56069724aa1514d07fd 100644 --- a/daemon/src/config/yamlemitter.cpp +++ b/daemon/src/config/yamlemitter.cpp @@ -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) diff --git a/daemon/src/config/yamlemitter.h b/daemon/src/config/yamlemitter.h index bbd254951340d8321744e24e884ae90c63a7653d..0915e7764f547318fb80058b68487d72e09c96a9 100644 --- a/daemon/src/config/yamlemitter.h +++ b/daemon/src/config/yamlemitter.h @@ -71,8 +71,9 @@ class YamlEmitter { void serializeAudioPreference(MappingNode *map); +#ifdef SFL_VIDEO void serializeVideoPreference(MappingNode *map); - +#endif void serializeShortcutPreference(MappingNode *map); void writeAudio(); diff --git a/daemon/src/config/yamlparser.cpp b/daemon/src/config/yamlparser.cpp index 91a492ef51e0a3e56985e3b998eb459226ae4095..dc952c887236caba1ed345012f9bb13598ee57c6 100644 --- a/daemon/src/config/yamlparser.cpp +++ b/daemon/src/config/yamlparser.cpp @@ -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"]; diff --git a/daemon/src/config/yamlparser.h b/daemon/src/config/yamlparser.h index 313c5934673457cef53e95f4243611f757c1590d..bdd828f2b033368b5ee93013f44167f2c11fa94c 100644 --- a/daemon/src/config/yamlparser.h +++ b/daemon/src/config/yamlparser.h @@ -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_; diff --git a/daemon/src/global.h b/daemon/src/global.h index ef8b085fe4dcce223cc4c254cd4007aae3149ceb..09f35e6006f40964fe736713da4f8c9762515378 100644 --- a/daemon/src/global.h +++ b/daemon/src/global.h @@ -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 */ diff --git a/daemon/src/iax/iaxcall.cpp b/daemon/src/iax/iaxcall.cpp index a1eb21ec93ac7f467f43094922af9eb1d4301402..2d0d2c0f0813f33259d44a40fd40ce36f7274a53 100644 --- a/daemon/src/iax/iaxcall.cpp +++ b/daemon/src/iax/iaxcall.cpp @@ -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) diff --git a/daemon/src/iax/iaxvoiplink.cpp b/daemon/src/iax/iaxvoiplink.cpp index 7eb329d3262ad526958d48bac274410ac7afea1c..d3275c0c8a1a1b3c3238aac026bc18724e88fbbc 100644 --- a/daemon/src/iax/iaxvoiplink.cpp +++ b/daemon/src/iax/iaxvoiplink.cpp @@ -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 diff --git a/daemon/src/iax/iaxvoiplink.h b/daemon/src/iax/iaxvoiplink.h index a46181ac163238d70517ade525bce8a087799488..8e906c8acc1ac9082a9eec68807c1af77bfb95c0 100644 --- a/daemon/src/iax/iaxvoiplink.h +++ b/daemon/src/iax/iaxvoiplink.h @@ -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: diff --git a/daemon/src/preferences.cpp b/daemon/src/preferences.cpp index 2f1ca1e53f9abc08ba43dfe4958f6db8bbec54a2..c5c12872c15a111d1f1645094821c08e006f310a 100644 --- a/daemon/src/preferences.cpp +++ b/daemon/src/preferences.cpp @@ -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); diff --git a/daemon/src/preferences.h b/daemon/src/preferences.h index 3f072dddda30fd5a21598358d92a41ea3d8394fe..b056527825de51bd6728ec758bfc04173cdfe4c1 100644 --- a/daemon/src/preferences.h +++ b/daemon/src/preferences.h @@ -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(); diff --git a/daemon/src/sip/sdp.cpp b/daemon/src/sip/sdp.cpp index f7684feeb7f53ad6845b67d634982b10cd0d3d52..2304b029fd4c59f79ff259fa47d06e2edab90e36 100644 --- a/daemon/src/sip/sdp.cpp +++ b/daemon/src/sip/sdp.cpp @@ -30,6 +30,10 @@ * as that of the covered work. */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include "sdp.h" #include "global.h" #include "manager.h" @@ -44,15 +48,23 @@ Sdp::Sdp(pj_pool_t *pool) , activeLocalSession_(NULL) , activeRemoteSession_(NULL) , audio_codec_list_() +#ifdef SFL_VIDEO , video_codec_list_() +#endif , sessionAudioMedia_() +#ifdef SFL_VIDEO , sessionVideoMedia_() +#endif , localIpAddr_() , remoteIpAddr_() , localAudioPort_(1234) +#ifdef SFL_VIDEO , localVideoPort_(1235) +#endif , remoteAudioPort_(1236) +#ifdef SFL_VIDEO , remoteVideoPort_(1237) +#endif , zrtpHelloHash_() , srtpCrypto_() , telephoneEventPayload_(101) // same as asterisk @@ -80,9 +92,12 @@ void Sdp::setActiveLocalSdpSession(const pjmedia_sdp_session *sdp) sfl::Codec *codec = Manager::instance().audioCodecFactory.getCodec((int) pj_strtoul (&rtpmap->pt)); if (codec) sessionAudioMedia_.push_back(codec); - } else if (type == "video") { + } +#ifdef SFL_VIDEO + else if (type == "video") { sessionVideoMedia_.push_back(std::string(rtpmap->enc_name.ptr, rtpmap->enc_name.slen)); } +#endif } } @@ -115,12 +130,14 @@ void Sdp::setActiveRemoteSdpSession(const pjmedia_sdp_session *sdp) ERROR("Sdp: Error: Could not found dtmf event from remote sdp"); } +#ifdef SFL_VIDEO std::string Sdp::getSessionVideoCodec() const { - if (sessionVideoMedia_.size() < 1) + if (sessionVideoMedia_.size().empty()) return ""; return sessionVideoMedia_[0]; } +#endif std::string Sdp::getAudioCodecName() const { @@ -141,20 +158,21 @@ sfl::AudioCodec* Sdp::getSessionAudioMedia() const } +#ifdef SFL_VIDEO pjmedia_sdp_media *Sdp::setMediaDescriptorLine(bool audio) { pjmedia_sdp_media *med = PJ_POOL_ZALLOC_T(memPool_, pjmedia_sdp_media); - med->desc.media = audio ? pj_str((char*)"audio") : pj_str((char*)"video"); + med->desc.media = audio ? pj_str((char*) "audio") : pj_str((char*) "video"); med->desc.port_count = 1; med->desc.port = audio ? localAudioPort_ : localVideoPort_; // in case of sdes, media are tagged as "RTP/SAVP", RTP/AVP elsewhere - med->desc.transport = pj_str(srtpCrypto_.empty() ? (char*)"RTP/AVP" : (char*)"RTP/SAVP"); + med->desc.transport = pj_str(srtpCrypto_.empty() ? (char*) "RTP/AVP" : (char*) "RTP/SAVP"); int dynamic_payload = 96; med->desc.fmt_count = audio ? audio_codec_list_.size() : video_codec_list_.size(); - for (unsigned i=0; i<med->desc.fmt_count; i++) { + for (unsigned i = 0; i < med->desc.fmt_count; ++i) { unsigned clock_rate; std::string enc_name; int payload; @@ -204,6 +222,62 @@ pjmedia_sdp_media *Sdp::setMediaDescriptorLine(bool audio) return med; } +#else +pjmedia_sdp_media *Sdp::setMediaDescriptorLine(bool /*audio*/) +{ + pjmedia_sdp_media *med = PJ_POOL_ZALLOC_T(memPool_, pjmedia_sdp_media); + + med->desc.media = pj_str((char*) "audio"); + med->desc.port_count = 1; + med->desc.port = localAudioPort_; + // in case of sdes, media are tagged as "RTP/SAVP", RTP/AVP elsewhere + med->desc.transport = pj_str(srtpCrypto_.empty() ? (char*) "RTP/AVP" : (char*) "RTP/SAVP"); + + med->desc.fmt_count = audio_codec_list_.size(); + for (unsigned i = 0; i < med->desc.fmt_count; ++i) { + unsigned clock_rate; + std::string enc_name; + int payload; + + sfl::Codec *codec = audio_codec_list_[i]; + payload = codec->getPayloadType(); + enc_name = codec->getMimeSubtype(); + clock_rate = codec->getClockRate(); + // G722 require G722/8000 media description even if it is 16000 codec + if (codec->getPayloadType () == 9) + clock_rate = 8000; + + std::ostringstream s; + s << payload; + pj_strdup2 (memPool_, &med->desc.fmt[i], s.str().c_str()); + + // Add a rtpmap field for each codec + // We could add one only for dynamic payloads because the codecs with static RTP payloads + // are entirely defined in the RFC 3351, but if we want to add other attributes like an asymmetric + // connection, the rtpmap attribute will be useful to specify for which codec it is applicable + pjmedia_sdp_rtpmap rtpmap; + + rtpmap.pt = med->desc.fmt[i]; + rtpmap.enc_name = pj_str ((char*) enc_name.c_str()); + rtpmap.clock_rate = clock_rate; + rtpmap.param.ptr = ((char* const) ""); + rtpmap.param.slen = 0; + + pjmedia_sdp_attr *attr; + pjmedia_sdp_rtpmap_to_attr(memPool_, &rtpmap, &attr); + + med->attr[med->attr_count++] = attr; + } + + med->attr[ med->attr_count++] = pjmedia_sdp_attr_create(memPool_, "sendrecv", NULL); + if (!zrtpHelloHash_.empty()) + addZrtpAttribute(med, zrtpHelloHash_); + + setTelephoneEventRtpmap(med); + + return med; +} +#endif void Sdp::setTelephoneEventRtpmap(pjmedia_sdp_media *med) { @@ -220,6 +294,7 @@ void Sdp::setTelephoneEventRtpmap(pjmedia_sdp_media *med) med->attr[med->attr_count++] = attr_fmtp; } +#ifdef SFL_VIDEO void Sdp::setLocalMediaVideoCapabilities(const std::vector<std::string> &videoCodecs) { if (videoCodecs.empty()) @@ -227,25 +302,26 @@ void Sdp::setLocalMediaVideoCapabilities(const std::vector<std::string> &videoCo video_codec_list_.clear(); const std::vector<std::string> &codecs_list = sfl_video::getVideoCodecList(); - for (unsigned i=0; i<videoCodecs.size(); i++) { + for (unsigned i = 0; i < videoCodecs.size(); ++i) { const std::string &codec = videoCodecs[i]; - for (unsigned j=0; j<codecs_list.size(); j++) { - if (codecs_list[j] == codec) { - video_codec_list_.push_back(codec); - break; + for (unsigned j = 0; j < codecs_list.size(); ++j) { + if (codecs_list[j] == codec) { + video_codec_list_.push_back(codec); + break; } } } } +#endif -void Sdp::setLocalMediaCapabilities(const CodecOrder &selectedCodecs) +void Sdp::setLocalMediaCapabilities(const std::vector<int> &selectedCodecs) { - if (selectedCodecs.size() == 0) + if (selectedCodecs.empty()) WARN("No selected codec while building local SDP offer"); audio_codec_list_.clear(); - for (CodecOrder::const_iterator iter = selectedCodecs.begin(); iter != selectedCodecs.end(); ++iter) { - sfl::Codec *codec = Manager::instance().audioCodecFactory.getCodec(*iter); + for (std::vector<int>::const_iterator i = selectedCodecs.begin(); i != selectedCodecs.end(); ++i) { + sfl::Codec *codec = Manager::instance().audioCodecFactory.getCodec(*i); if (codec) audio_codec_list_.push_back(codec); else @@ -263,7 +339,8 @@ namespace { } } -int Sdp::createLocalSession(const CodecOrder &selectedCodecs, const std::vector<std::string> &videoCodecs) +#ifdef SFL_VIDEO +int Sdp::createLocalSession(const std::vector<int> &selectedCodecs, const std::vector<std::string> &videoCodecs) { setLocalMediaCapabilities(selectedCodecs); setLocalMediaVideoCapabilities(videoCodecs); @@ -279,11 +356,11 @@ int Sdp::createLocalSession(const CodecOrder &selectedCodecs, const std::vector< localSession_->origin.user = pj_str(pj_gethostname()->ptr); // Use Network Time Protocol format timestamp to ensure uniqueness. localSession_->origin.id = tv.sec + 2208988800UL; - localSession_->origin.net_type = pj_str((char*)"IN"); - localSession_->origin.addr_type = pj_str((char*)"IP4"); - localSession_->origin.addr = pj_str((char*)localIpAddr_.c_str()); + localSession_->origin.net_type = pj_str((char*) "IN"); + localSession_->origin.addr_type = pj_str((char*) "IP4"); + localSession_->origin.addr = pj_str((char*) localIpAddr_.c_str()); - localSession_->name = pj_str((char*)"sflphone"); + localSession_->name = pj_str((char*) PACKAGE); localSession_->conn->net_type = localSession_->origin.net_type; localSession_->conn->addr_type = localSession_->origin.addr_type; @@ -297,8 +374,9 @@ int Sdp::createLocalSession(const CodecOrder &selectedCodecs, const std::vector< // For DTMF RTP events localSession_->media_count = 2; - localSession_->media[0] = setMediaDescriptorLine(true); - localSession_->media[1] = setMediaDescriptorLine(false); + const bool audio = true; + localSession_->media[0] = setMediaDescriptorLine(audio); + localSession_->media[1] = setMediaDescriptorLine(!audio); if (!srtpCrypto_.empty()) addSdesAttribute(srtpCrypto_); @@ -308,17 +386,74 @@ int Sdp::createLocalSession(const CodecOrder &selectedCodecs, const std::vector< return pjmedia_sdp_validate(localSession_); } +#else +int Sdp::createLocalSession(const std::vector<int> &selectedCodecs) +{ + setLocalMediaCapabilities(selectedCodecs); + + localSession_ = PJ_POOL_ZALLOC_T(memPool_, pjmedia_sdp_session); + localSession_->conn = PJ_POOL_ZALLOC_T(memPool_, pjmedia_sdp_conn); -void Sdp::createOffer (const CodecOrder &selectedCodecs, const std::vector<std::string> &videoCodecs) + /* Initialize the fields of the struct */ + localSession_->origin.version = 0; + pj_time_val tv; + pj_gettimeofday(&tv); + + localSession_->origin.user = pj_str(pj_gethostname()->ptr); + // Use Network Time Protocol format timestamp to ensure uniqueness. + localSession_->origin.id = tv.sec + 2208988800UL; + localSession_->origin.net_type = pj_str((char*) "IN"); + localSession_->origin.addr_type = pj_str((char*) "IP4"); + localSession_->origin.addr = pj_str((char*) localIpAddr_.c_str()); + + localSession_->name = pj_str((char*) PACKAGE); + + localSession_->conn->net_type = localSession_->origin.net_type; + localSession_->conn->addr_type = localSession_->origin.addr_type; + localSession_->conn->addr = localSession_->origin.addr; + + // RFC 3264: An offer/answer model session description protocol + // As the session is created and destroyed through an external signaling mean (SIP), the line + // should have a value of "0 0". + localSession_->time.start = 0; + localSession_->time.stop = 0; + + // For DTMF RTP events + localSession_->media_count = 1; + const bool audio = true; + localSession_->media[0] = setMediaDescriptorLine(audio); + + if (!srtpCrypto_.empty()) + addSdesAttribute(srtpCrypto_); + + DEBUG("SDP: Local SDP Session:"); + printSession(localSession_); + + return pjmedia_sdp_validate(localSession_); +} +#endif + +#ifdef SFL_VIDEO +void Sdp::createOffer(const std::vector<int> &selectedCodecs, const std::vector<std::string> &videoCodecs) { - if (createLocalSession (selectedCodecs, videoCodecs) != PJ_SUCCESS) + if (createLocalSession(selectedCodecs, videoCodecs) != PJ_SUCCESS) ERROR("SDP: Error: Failed to create initial offer"); else if (pjmedia_sdp_neg_create_w_local_offer (memPool_, localSession_, &negotiator_) != PJ_SUCCESS) ERROR("SDP: Error: Failed to create an initial SDP negotiator"); } +#else +void Sdp::createOffer(const std::vector<int> &selectedCodecs) +{ + if (createLocalSession(selectedCodecs) != PJ_SUCCESS) + ERROR("SDP: Error: Failed to create initial offer"); + else if (pjmedia_sdp_neg_create_w_local_offer (memPool_, localSession_, &negotiator_) != PJ_SUCCESS) + ERROR("SDP: Error: Failed to create an initial SDP negotiator"); +} +#endif -void Sdp::receiveOffer (const pjmedia_sdp_session* remote, - const CodecOrder &selectedCodecs, +#ifdef SFL_VIDEO +void Sdp::receiveOffer(const pjmedia_sdp_session* remote, + const std::vector<int> &selectedCodecs, const std::vector<std::string> &videoCodecs) { assert(remote); @@ -326,7 +461,28 @@ void Sdp::receiveOffer (const pjmedia_sdp_session* remote, DEBUG("SDP: Remote SDP Session:"); printSession(remote); - if(!localSession_ and createLocalSession (selectedCodecs, videoCodecs) != PJ_SUCCESS) { + if (!localSession_ and createLocalSession (selectedCodecs, videoCodecs) != PJ_SUCCESS) { + ERROR("SDP: Failed to create initial offer"); + return; + } + + remoteSession_ = pjmedia_sdp_session_clone(memPool_, remote); + + pj_status_t status = pjmedia_sdp_neg_create_w_remote_offer(memPool_, localSession_, + remoteSession_, &negotiator_); + + assert(status == PJ_SUCCESS); +} +#else +void Sdp::receiveOffer(const pjmedia_sdp_session* remote, + const std::vector<int> &selectedCodecs) +{ + assert(remote); + + DEBUG("SDP: Remote SDP Session:"); + printSession(remote); + + if (!localSession_ and createLocalSession(selectedCodecs) != PJ_SUCCESS) { ERROR("SDP: Failed to create initial offer"); return; } @@ -338,6 +494,7 @@ void Sdp::receiveOffer (const pjmedia_sdp_session* remote, assert(status == PJ_SUCCESS); } +#endif void Sdp::receivingAnswerAfterInitialOffer(const pjmedia_sdp_session* remote) { @@ -404,6 +561,7 @@ std::string Sdp::getLineFromLocalSDP(const std::string &keyword) const return ""; } +#ifdef SFL_VIDEO std::vector<std::string> Sdp::getActiveVideoDescription() const { std::stringstream ss; @@ -464,16 +622,17 @@ std::vector<std::string> Sdp::getActiveVideoDescription() const v.push_back(ss.str()); return v; } +#endif void Sdp::addSdesAttribute(const std::vector<std::string>& crypto) { - for (std::vector<std::string>::const_iterator iter = crypto.begin(); - iter != crypto.end(); ++iter) { - pj_str_t val = { (char*)(*iter).c_str(), (*iter).size() }; + for (std::vector<std::string>::const_iterator i = crypto.begin(); + i != crypto.end(); ++i) { + pj_str_t val = { (char*) i->c_str(), i->size() }; pjmedia_sdp_attr *attr = pjmedia_sdp_attr_create(memPool_, "crypto", &val); - for (unsigned i = 0; i < localSession_->media_count; i++) - if (pjmedia_sdp_media_add_attr(localSession_->media[i], attr) != PJ_SUCCESS) + for (unsigned j = 0; j < localSession_->media_count; ++j) + if (pjmedia_sdp_media_add_attr(localSession_->media[j], attr) != PJ_SUCCESS) throw SdpException("Could not add sdes attribute to media"); } } @@ -508,12 +667,13 @@ void Sdp::removeAttributeFromLocalAudioMedia(const char *attr) pjmedia_sdp_media_remove_all_attr (localSession_->media[i], attr); } +#ifdef SFL_VIDEO void Sdp::removeAttributeFromLocalVideoMedia(const char *attr) { int i = 0; while (pj_stricmp2(&localSession_->media[i]->desc.media, "video") != 0) ++i; - pjmedia_sdp_media_remove_all_attr (localSession_->media[i], attr); + pjmedia_sdp_media_remove_all_attr(localSession_->media[i], attr); } void Sdp::addAttributeToLocalVideoMedia(const char *attr) @@ -522,9 +682,10 @@ void Sdp::addAttributeToLocalVideoMedia(const char *attr) while (pj_stricmp2(&localSession_->media[i]->desc.media, "video") != 0) ++i; - pjmedia_sdp_attr *attribute = pjmedia_sdp_attr_create (memPool_, attr, NULL); + pjmedia_sdp_attr *attribute = pjmedia_sdp_attr_create(memPool_, attr, NULL); pjmedia_sdp_media_add_attr(localSession_->media[i], attribute); } +#endif void Sdp::setMediaTransportInfoFromRemoteSdp() { @@ -533,13 +694,15 @@ void Sdp::setMediaTransportInfoFromRemoteSdp() return; } - remoteIpAddr_ = std::string (activeRemoteSession_->conn->addr.ptr, activeRemoteSession_->conn->addr.slen); + remoteIpAddr_ = std::string(activeRemoteSession_->conn->addr.ptr, activeRemoteSession_->conn->addr.slen); for (unsigned i = 0; i < activeRemoteSession_->media_count; ++i) if (pj_stricmp2 (&activeRemoteSession_->media[i]->desc.media, "audio") == 0) remoteAudioPort_ = activeRemoteSession_->media[i]->desc.port; +#ifdef SFL_VIDEO else if (pj_stricmp2 (&activeRemoteSession_->media[i]->desc.media, "video") == 0) remoteVideoPort_ = activeRemoteSession_->media[i]->desc.port; +#endif } void Sdp::getRemoteSdpCryptoFromOffer(const pjmedia_sdp_session* remote_sdp, CryptoOffer& crypto_offer) diff --git a/daemon/src/sip/sdp.h b/daemon/src/sip/sdp.h index cdc59f14abd2676a5900fcc806bc9a9ac4781887..cd46eacdb046f9a7ec9e5cc4ad0c6505995bc609 100644 --- a/daemon/src/sip/sdp.h +++ b/daemon/src/sip/sdp.h @@ -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_; +#ifdef SFL_VIDEO unsigned int remoteVideoPort_; +#endif std::string zrtpHelloHash_; @@ -325,13 +352,19 @@ class Sdp { * Build the local media capabilities for this session * @param List of codec in preference order */ - void setLocalMediaCapabilities(const CodecOrder &selectedCodecs); + void setLocalMediaCapabilities(const std::vector<int> &selectedCodecs); +#ifdef SFL_VIDEO void setLocalMediaVideoCapabilities(const std::vector<std::string> &videoCodecs); +#endif /* * Build the local SDP offer */ - int createLocalSession(const CodecOrder &selectedCodecs, const std::vector<std::string> &videoCodecs); +#ifdef SFL_VIDEO + int createLocalSession(const std::vector<int> &selectedCodecs, const std::vector<std::string> &videoCodecs); +#else + int createLocalSession(const std::vector<int> &selectedCodecs); +#endif /* * Adds a sdes attribute to the given media section. * diff --git a/daemon/src/sip/sipaccount.cpp b/daemon/src/sip/sipaccount.cpp index dcd66bb94d9c1572846aec9259b4261f71237f45..64847a010192c562e9173a24bd38ce902d689265 100644 --- a/daemon/src/sip/sipaccount.cpp +++ b/daemon/src/sip/sipaccount.cpp @@ -130,12 +130,14 @@ void SIPAccount::serialize(Conf::YamlEmitter *emitter) ScalarNode sameasLocal(publishedSameasLocal_); ScalarNode codecs(codecStr_); - for (vector<string>::const_iterator i = videoCodecOrder_.begin(); - i != videoCodecOrder_.end(); ++i) +#ifdef SFL_VIDEO + for (vector<string>::const_iterator i = videoCodecList_.begin(); + i != videoCodecList_.end(); ++i) DEBUG("%s", i->c_str()); - DEBUG("%s", Manager::instance().serialize(videoCodecOrder_).c_str()); + DEBUG("%s", Manager::instance().serialize(videoCodecList_).c_str()); - ScalarNode vcodecs(Manager::instance().serialize(videoCodecOrder_)); + ScalarNode vcodecs(Manager::instance().serialize(videoCodecList_)); +#endif ScalarNode ringtonePath(ringtonePath_); ScalarNode ringtoneEnabled(ringtoneEnabled_); @@ -193,7 +195,9 @@ void SIPAccount::serialize(Conf::YamlEmitter *emitter) accountmap.setKeyValue(dtmfTypeKey, &dtmfType); accountmap.setKeyValue(displayNameKey, &displayName); accountmap.setKeyValue(codecsKey, &codecs); +#ifdef SFL_VIDEO accountmap.setKeyValue(videocodecsKey, &vcodecs); +#endif accountmap.setKeyValue(ringtonePathKey, &ringtonePath); accountmap.setKeyValue(ringtoneEnabledKey, &ringtoneEnabled); @@ -271,13 +275,17 @@ void SIPAccount::unserialize(Conf::MappingNode *map) map->getValue(accountEnableKey, &enabled_); map->getValue(mailboxKey, &mailBox_); map->getValue(codecsKey, &codecStr_); +#ifdef SFL_VIDEO std::string vcodecs; map->getValue(videocodecsKey, &vcodecs); +#endif // Update codec list which one is used for SDP offer setActiveCodecs(ManagerImpl::unserialize(codecStr_)); - setActiveVideoCodecs (Manager::instance().unserialize (vcodecs)); +#ifdef SFL_VIDEO + setActiveVideoCodecs(Manager::instance().unserialize(vcodecs)); +#endif map->getValue(ringtonePathKey, &ringtonePath_); map->getValue(ringtoneEnabledKey, &ringtoneEnabled_); diff --git a/daemon/src/sip/sipcall.cpp b/daemon/src/sip/sipcall.cpp index a86c52cfd22c4bfddb72a702146a2b88d8daf371..1dc5ef01eabef48dc1c26b7b5a4880e1ebe76054 100644 --- a/daemon/src/sip/sipcall.cpp +++ b/daemon/src/sip/sipcall.cpp @@ -33,10 +33,13 @@ #include "sipcall.h" #include "logger.h" // for _debug -#include "video/video_rtp_session.h" #include "audio/audiortp/audio_rtp_factory.h" #include "sdp.h" +#ifdef SFL_VIDEO +#include "video/video_rtp_session.h" +#endif + namespace { static const int INITIAL_SIZE = 16384; static const int INCREMENT_SIZE = INITIAL_SIZE; @@ -45,7 +48,9 @@ namespace { SIPCall::SIPCall(const std::string& id, Call::CallType type, pj_caching_pool *caching_pool) : Call(id, type) , inv(NULL) , audiortp_(this) +#ifdef SFL_VIDEO , videortp_(new sfl_video::VideoRtpSession) +#endif , pool_(pj_pool_create(&caching_pool->factory, id.c_str(), INITIAL_SIZE, INCREMENT_SIZE, NULL)) , local_sdp_(new Sdp(pool_)) {} diff --git a/daemon/src/sip/sipcall.h b/daemon/src/sip/sipcall.h index 5ae7a55d60a4c3d7649babcc55a5c06394b1c6fc..1d529c9f61d4a691e83889b715269c14f4b86503 100644 --- a/daemon/src/sip/sipcall.h +++ b/daemon/src/sip/sipcall.h @@ -43,10 +43,12 @@ class pj_pool_t; class pjsip_inv_session; class Sdp; +#ifdef SFL_VIDEO namespace sfl_video { class VideoRtpSession; } +#endif /** * @file sipcall.h @@ -82,12 +84,14 @@ class SIPCall : public Call { return audiortp_; } +#ifdef SFL_VIDEO /** * Returns a pointer to the VideoRtp object */ sfl_video::VideoRtpSession * getVideoRtp () { return videortp_.get(); } +#endif /** * Return the local memory pool for this call @@ -110,10 +114,12 @@ class SIPCall : public Call { */ sfl::AudioRtpFactory audiortp_; +#ifdef SFL_VIDEO /** * Video Rtp Session factory */ std::tr1::shared_ptr<sfl_video::VideoRtpSession> videortp_; +#endif /** * The pool to allocate memory, released once call hang up diff --git a/daemon/src/sip/sipvoiplink.cpp b/daemon/src/sip/sipvoiplink.cpp index 4273b3eb7a080c151ea2562a0e6b1ac509523498..4f1fd25cc7583673dfbb6c08733997d077f43d2e 100644 --- a/daemon/src/sip/sipvoiplink.cpp +++ b/daemon/src/sip/sipvoiplink.cpp @@ -55,7 +55,9 @@ #include "audio/audiolayer.h" +#ifdef SFL_VIDEO #include "video/video_rtp_session.h" +#endif #include "pjsip/sip_endpoint.h" #include "pjsip/sip_transport_tls.h" @@ -460,7 +462,11 @@ Call *SIPVoIPLink::newOutgoingCall(const std::string& id, const std::string& toU call->initRecFilename(toUrl); call->getLocalSDP()->setLocalIP(addrSdp); +#ifdef SFL_VIDEO call->getLocalSDP()->createOffer(account->getActiveCodecs(), account->getActiveVideoCodecs()); +#else + call->getLocalSDP()->createOffer(account->getActiveCodecs()); +#endif if (!SIPStartCall(call)) { delete call; @@ -526,7 +532,9 @@ SIPVoIPLink::hangup(const std::string& id) if (Manager::instance().isCurrentCall (id)) { call->getAudioRtp().stop(); +#ifdef SFL_VIDEO call->getVideoRtp()->stop(); +#endif } removeCall(id); @@ -551,7 +559,9 @@ SIPVoIPLink::peerHungup(const std::string& id) if (Manager::instance().isCurrentCall(id)) { call->getAudioRtp().stop(); +#ifdef SFL_VIDEO call->getVideoRtp()->stop(); +#endif } removeCall(id); @@ -563,7 +573,9 @@ SIPVoIPLink::onhold(const std::string& id) SIPCall *call = getSIPCall(id); call->setState(Call::HOLD); call->getAudioRtp().stop(); +#ifdef SFL_VIDEO call->getVideoRtp()->stop(); +#endif Sdp *sdpSession = call->getLocalSDP(); @@ -572,10 +584,14 @@ SIPVoIPLink::onhold(const std::string& id) sdpSession->removeAttributeFromLocalAudioMedia("sendrecv"); sdpSession->removeAttributeFromLocalAudioMedia("sendonly"); +#ifdef SFL_VIDEO sdpSession->removeAttributeFromLocalVideoMedia("sendrecv"); sdpSession->removeAttributeFromLocalVideoMedia("inactive"); +#endif sdpSession->addAttributeToLocalAudioMedia("sendonly"); +#ifdef SFL_VIDEO sdpSession->addAttributeToLocalVideoMedia("inactive"); +#endif SIPSessionReinvite(call); } @@ -613,10 +629,14 @@ SIPVoIPLink::offhold(const std::string& id) sdpSession->removeAttributeFromLocalAudioMedia("sendrecv"); sdpSession->removeAttributeFromLocalAudioMedia("sendonly"); +#ifdef SFL_VIDEO sdpSession->removeAttributeFromLocalVideoMedia("sendrecv"); sdpSession->removeAttributeFromLocalVideoMedia("inactive"); +#endif sdpSession->addAttributeToLocalAudioMedia("sendrecv"); +#ifdef SFL_VIDEO sdpSession->addAttributeToLocalVideoMedia("sendrecv"); +#endif if (SIPSessionReinvite(call) == PJ_SUCCESS) call->setState(Call::ACTIVE); @@ -754,6 +774,7 @@ SIPVoIPLink::refuse(const std::string& id) removeCall(id); } +#ifdef SFL_VIDEO std::string SIPVoIPLink::getCurrentVideoCodecName(const std::string& id) { @@ -763,6 +784,7 @@ SIPVoIPLink::getCurrentVideoCodecName(const std::string& id) return call->getLocalSDP()->getSessionVideoCodec(); } +#endif std::string SIPVoIPLink::getCurrentCodecName(Call *call) const @@ -898,7 +920,9 @@ SIPVoIPLink::SIPCallClosed(SIPCall *call) if (Manager::instance().isCurrentCall(id)) { call->getAudioRtp().stop(); +#ifdef SFL_VIDEO call->getVideoRtp()->stop(); +#endif } Manager::instance().peerHungupCall(id); @@ -980,7 +1004,11 @@ bool SIPVoIPLink::SIPNewIpToIpCall(const std::string& id, const std::string& to) // Building the local SDP offer call->getLocalSDP()->setLocalIP(localAddress); +#ifdef SFL_VIDEO call->getLocalSDP()->createOffer(account->getActiveCodecs(), account->getActiveVideoCodecs()); +#else + call->getLocalSDP()->createOffer(account->getActiveCodecs()); +#endif // Init TLS transport if enabled if (account->isTlsEnabled()) { @@ -1428,7 +1456,11 @@ void sdp_request_offer_cb(pjsip_inv_session *inv, const pjmedia_sdp_session *off std::string accId(Manager::instance().getAccountFromCall(call->getCallId())); SIPAccount *account = dynamic_cast<SIPAccount *>(Manager::instance().getAccount(accId)); +#ifdef SFL_VIDEO call->getLocalSDP()->receiveOffer(offer, account->getActiveCodecs(), account->getActiveVideoCodecs()); +#else + call->getLocalSDP()->receiveOffer(offer, account->getActiveCodecs()); +#endif call->getLocalSDP()->startNegotiation(); pjsip_inv_set_sdp_answer(call->inv, call->getLocalSDP()->getLocalSdpSession()); @@ -1453,7 +1485,11 @@ static void sdp_create_offer_cb(pjsip_inv_session *inv, pjmedia_sdp_session **p_ setCallMediaLocal(call, localAddress); call->getLocalSDP()->setLocalIP(addrSdp); +#ifdef SFL_VIDEO call->getLocalSDP()->createOffer(account->getActiveCodecs(), account->getActiveVideoCodecs()); +#else + call->getLocalSDP()->createOffer(account->getActiveCodecs()); +#endif *p_offer = call->getLocalSDP()->getLocalSdpSession(); } @@ -1509,9 +1545,11 @@ void sdp_media_update_cb(pjsip_inv_session *inv, pj_status_t status) call->getAudioRtp().updateDestinationIpAddress(); call->getAudioRtp().setDtmfPayloadType(sdpSession->getTelephoneEventType()); +#ifdef SFL_VIDEO call->getVideoRtp()->updateSDP(*call->getLocalSDP()); call->getVideoRtp()->updateDestination(call->getLocalSDP()->getRemoteIP(), call->getLocalSDP()->getRemoteVideoPort()); call->getVideoRtp()->start(); +#endif // Get the crypto attribute containing srtp's cryptographic context (keys, cipher) CryptoOffer crypto_offer; @@ -1952,7 +1990,11 @@ static pj_bool_t transaction_request_cb(pjsip_rx_data *rdata) } } +#ifdef SFL_VIDEO call->getLocalSDP()->receiveOffer(r_sdp, account->getActiveCodecs(), account->getActiveVideoCodecs()); +#else + call->getLocalSDP()->receiveOffer(r_sdp, account->getActiveCodecs()); +#endif sfl::Codec* audiocodec = Manager::instance().audioCodecFactory.instantiateCodec (PAYLOAD_CODEC_ULAW); call->getAudioRtp().start(static_cast<sfl::AudioCodec *>(audiocodec)); @@ -2128,14 +2170,16 @@ void setCallMediaLocal(SIPCall* call, const std::string &localIP) unsigned int callLocalExternAudioPort = account->isStunEnabled() ? account->getStunPort() : callLocalAudioPort; - unsigned int callLocalVideoPort = ((rand() % 27250) + 5250) * 2; - assert(callLocalAudioPort != callLocalVideoPort); call->setLocalIp(localIP); call->setLocalAudioPort(callLocalAudioPort); - call->setLocalVideoPort(callLocalVideoPort); call->getLocalSDP()->setLocalPublishedAudioPort(callLocalExternAudioPort); +#if SFL_VIDEO + unsigned int callLocalVideoPort = ((rand() % 27250) + 5250) * 2; + assert(callLocalAudioPort != callLocalVideoPort); + call->setLocalVideoPort(callLocalVideoPort); call->getLocalSDP()->setLocalPublishedVideoPort(callLocalVideoPort); +#endif } std::string fetchHeaderValue(pjsip_msg *msg, std::string field) diff --git a/daemon/src/sip/sipvoiplink.h b/daemon/src/sip/sipvoiplink.h index 089ae6423ecf8efddd564e81f2fd458281bec446..a18571fc4444ba7a36b658bd6899f5d88f197310 100644 --- a/daemon/src/sip/sipvoiplink.h +++ b/daemon/src/sip/sipvoiplink.h @@ -217,7 +217,9 @@ class SIPVoIPLink : public VoIPLink { * Return the codec protocol used for this call * @param c The call identifier */ +#ifdef SFL_VIDEO std::string getCurrentVideoCodecName(const std::string& id); +#endif std::string getCurrentCodecName(Call *c) const; /** diff --git a/daemon/src/video/Makefile.am b/daemon/src/video/Makefile.am index df98408bb1cc75e4e8d054d227ef1276741c6a71..0bd9fd437c887b775a025ce0876662c1bc16f99f 100644 --- a/daemon/src/video/Makefile.am +++ b/daemon/src/video/Makefile.am @@ -11,7 +11,8 @@ libvideo_la_SOURCES = video_endpoint.cpp video_endpoint.h \ video_receive_thread.h video_receive_thread.cpp \ video_preview.h video_preview.cpp \ video_v4l2.cpp video_v4l2_list.cpp \ - video_v4l2.h video_v4l2_list.h + video_v4l2.h video_v4l2_list.h \ + video_preferences.h video_preferences.cpp libvideo_la_LIBADD = @LIBAVCODEC_LIBS@ @LIBAVFORMAT_LIBS@ @LIBAVDEVICE_LIBS@ @LIBSWSCALE_LIBS@ @LIBAVUTIL_LIBS@ @CCRTP_LIBS@ @UDEV_LIBS@ diff --git a/daemon/src/video/video_preferences.cpp b/daemon/src/video/video_preferences.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1d735260127bf8d60860a0f218663bbfc5d35341 --- /dev/null +++ b/daemon/src/video/video_preferences.cpp @@ -0,0 +1,96 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. + * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Additional permission under GNU GPL version 3 section 7: + * + * If you modify this program, or any covered work, by linking or + * combining it with the OpenSSL project's OpenSSL library (or a + * modified version of that library), containing parts covered by the + * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. + * grants you additional permission to convey the resulting work. + * Corresponding Source for a non-source form of such a combination + * shall include the source code for the parts of OpenSSL used as well + * as that of the covered work. + */ + +#include "video_preferences.h" +#include <sstream> + +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_); +} + diff --git a/daemon/src/video/video_preferences.h b/daemon/src/video/video_preferences.h new file mode 100644 index 0000000000000000000000000000000000000000..21f867c7e8c86e431be2537da816cf0288fb9717 --- /dev/null +++ b/daemon/src/video/video_preferences.h @@ -0,0 +1,119 @@ +/* + * Copyright (C) 2004, 2005, 2006, 2008, 2009, 2010, 2011 Savoir-Faire Linux Inc. + * Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com> + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + * + * Additional permission under GNU GPL version 3 section 7: + * + * If you modify this program, or any covered work, by linking or + * combining it with the OpenSSL project's OpenSSL library (or a + * modified version of that library), containing parts covered by the + * terms of the OpenSSL or SSLeay licenses, Savoir-Faire Linux Inc. + * grants you additional permission to convey the resulting work. + * Corresponding Source for a non-source form of such a combination + * shall include the source code for the parts of OpenSSL used as well + * as that of the covered work. + */ + +#ifndef VIDEO_PREFERENCE_H__ +#define VIDEO_PREFERENCE_H__ + +#include "video/video_v4l2_list.h" +#include "video/video_v4l2.h" + +namespace sflvideo { + class VideoV4l2ListThread; +} +// video preferences +static const char * const videoDeviceKey = "v4l2Dev"; +static const char * const videoChannelKey = "v4l2Channel"; +static const char * const videoSizeKey = "v4l2Size"; +static const char * const videoRateKey = "v4l2Rate"; + +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_; +}; + +#endif diff --git a/daemon/src/voiplink.h b/daemon/src/voiplink.h index 52a0b42977815b7b6b5894a5654379b1aa93836b..f653f8f8e1980586bb75da12e5de52207d188464 100644 --- a/daemon/src/voiplink.h +++ b/daemon/src/voiplink.h @@ -159,7 +159,9 @@ class VoIPLink { * Return the codec protocol used for this call * @param call The call */ +#ifdef SFL_VIDEO virtual std::string getCurrentVideoCodecName(const std::string& id) = 0; +#endif virtual std::string getCurrentCodecName(Call *call) const = 0; /** diff --git a/daemon/test/sdptest.cpp b/daemon/test/sdptest.cpp index 3af82b5efa891769d572af7208331eb6855f9104..8feabcf139109cee1dc5d58f13813765d717c896 100644 --- a/daemon/test/sdptest.cpp +++ b/daemon/test/sdptest.cpp @@ -47,9 +47,12 @@ static const char *sdp_answer1 = "v=0\r\n" "t=0 0\r\n" "m=audio 49920 RTP/AVP 0\r\n" "a=rtpmap:0 PCMU/8000\r\n" +#ifdef SFL_VIDEO "m=video 0 RTP/AVP 31\r\n" "m=video 53002 RTP/AVP 32\r\n" - "a=rtpmap:32 MPV/90000\r\n"; + "a=rtpmap:32 MPV/90000\r\n" +#endif + ; static const char *sdp_offer1 = "v=0\r\n" "o=bob 2890844730 2890844730 IN IP4 host.example.com\r\n" @@ -58,9 +61,12 @@ static const char *sdp_offer1 = "v=0\r\n" "t=0 0\r\n" "m=audio 49920 RTP/AVP 0\r\n" "a=rtpmap:0 PCMU/8000\r\n" +#ifdef SFL_VIDEO "m=video 0 RTP/AVP 31\r\n" "m=video 53002 RTP/AVP 32\r\n" - "a=rtpmap:32 MPV/90000\r\n"; + "a=rtpmap:32 MPV/90000\r\n" +#endif + ; static const char *sdp_answer2 = "v=0\r\n" "o=bob 2890844730 2890844730 IN IP4 host.example.com\r\n" @@ -71,9 +77,12 @@ static const char *sdp_answer2 = "v=0\r\n" "a=rtpmap:3 GSM/8000\r\n" "a=rtpmap:97 iLBC/8000\r\n" "a=rtpmap:9 G722/8000\r\n" +#ifdef SFL_VIDEO "m=video 0 RTP/AVP 31\r\n" "m=video 53002 RTP/AVP 32\r\n" - "a=rtpmap:32 MPV/90000\r\n"; + "a=rtpmap:32 MPV/90000\r\n" +#endif + ; static const char *sdp_offer2 = "v=0\r\n" "o=bob 2890844730 2890844730 IN IP4 host.example.com\r\n" @@ -84,9 +93,12 @@ static const char *sdp_offer2 = "v=0\r\n" "a=rtpmap:3 GSM/8000\r\n" "a=rtpmap:97 iLBC/8000\r\n" "a=rtpmap:9 G722/8000\r\n" +#ifdef SFL_VIDEO "m=video 0 RTP/AVP 31\r\n" "m=video 53002 RTP/AVP 32\r\n" - "a=rtpmap:32 MPV/90000\r\n"; + "a=rtpmap:32 MPV/90000\r\n" +#endif + ; static const char *sdp_reinvite = "v=0\r\n" "o=bob 2890844730 2890844730 IN IP4 host.example.com\r\n" @@ -95,9 +107,12 @@ static const char *sdp_reinvite = "v=0\r\n" "t=0 0\r\n" "m=audio 42445 RTP/AVP 0\r\n" "a=rtpmap:0 PCMU/8000\r\n" +#ifdef SFL_VIDEO "m=video 0 RTP/AVP 31\r\n" "m=video 53002 RTP/AVP 32\r\n" - "a=rtpmap:32 MPV/90000\r\n"; + "a=rtpmap:32 MPV/90000\r\n" +#endif + ; void SDPTest::setUp() @@ -124,20 +139,26 @@ void SDPTest::testInitialOfferFirstCodec() CPPUNIT_ASSERT(session_->getLocalIP().empty()); CPPUNIT_ASSERT(session_->getRemoteIP().empty()); - CodecOrder codecSelection; + std::vector<int> codecSelection; pjmedia_sdp_session *remoteAnswer; codecSelection.push_back(PAYLOAD_CODEC_ULAW); codecSelection.push_back(PAYLOAD_CODEC_ALAW); codecSelection.push_back(PAYLOAD_CODEC_G722); +#ifdef SFL_VIDEO std::vector<std::string> videoCodecs; videoCodecs.push_back("H264"); videoCodecs.push_back("H263"); +#endif session_->setLocalIP("127.0.0.1"); +#ifdef SFL_VIDEO session_->createOffer(codecSelection, videoCodecs); +#else + session_->createOffer(codecSelection); +#endif // pjmedia_sdp_parse(testPool_, test[0].offer_answer[0].sdp2, strlen(test[0].offer_answer[0].sdp2), &remoteAnswer); pjmedia_sdp_parse(testPool_, (char*)sdp_answer1, strlen(sdp_answer1), &remoteAnswer); @@ -158,22 +179,28 @@ void SDPTest::testInitialAnswerFirstCodec() CPPUNIT_ASSERT(session_->getLocalIP().empty()); CPPUNIT_ASSERT(session_->getRemoteIP().empty()); - CodecOrder codecSelection; + std::vector<int> codecSelection; pjmedia_sdp_session *remoteOffer; codecSelection.push_back(PAYLOAD_CODEC_ULAW); codecSelection.push_back(PAYLOAD_CODEC_ALAW); codecSelection.push_back(PAYLOAD_CODEC_G722); +#ifdef SFL_VIDEO std::vector<std::string> videoCodecs; videoCodecs.push_back("H264"); videoCodecs.push_back("H263"); +#endif pjmedia_sdp_parse(testPool_, (char*)sdp_offer1, strlen(sdp_offer1), &remoteOffer); session_->setLocalIP("127.0.0.1"); +#ifdef SFL_VIDEO session_->receiveOffer(remoteOffer, codecSelection, videoCodecs); +#else + session_->receiveOffer(remoteOffer, codecSelection); +#endif session_->startNegotiation(); @@ -190,20 +217,26 @@ void SDPTest::testInitialOfferLastCodec() CPPUNIT_ASSERT(session_->getLocalIP().empty()); CPPUNIT_ASSERT(session_->getRemoteIP().empty()); - CodecOrder codecSelection; + std::vector<int> codecSelection; pjmedia_sdp_session *remoteAnswer; codecSelection.push_back(PAYLOAD_CODEC_ULAW); codecSelection.push_back(PAYLOAD_CODEC_ALAW); codecSelection.push_back(PAYLOAD_CODEC_G722); +#ifdef SFL_VIDEO std::vector<std::string> videoCodecs; videoCodecs.push_back("H264"); videoCodecs.push_back("H263"); +#endif session_->setLocalIP("127.0.0.1"); +#ifdef SFL_VIDEO session_->createOffer(codecSelection, videoCodecs); +#else + session_->createOffer(codecSelection); +#endif // pjmedia_sdp_parse(testPool_, test[0].offer_answer[0].sdp2, strlen(test[0].offer_answer[0].sdp2), &remoteAnswer); pjmedia_sdp_parse(testPool_, (char*)sdp_answer2, strlen(sdp_answer2), &remoteAnswer); @@ -224,22 +257,28 @@ void SDPTest::testInitialAnswerLastCodec() CPPUNIT_ASSERT(session_->getLocalIP().empty()); CPPUNIT_ASSERT(session_->getRemoteIP().empty()); - CodecOrder codecSelection; + std::vector<int> codecSelection; pjmedia_sdp_session *remoteOffer; codecSelection.push_back(PAYLOAD_CODEC_ULAW); codecSelection.push_back(PAYLOAD_CODEC_ALAW); codecSelection.push_back(PAYLOAD_CODEC_G722); +#ifdef SFL_VIDEO std::vector<std::string> videoCodecs; videoCodecs.push_back("H264"); videoCodecs.push_back("H263"); +#endif pjmedia_sdp_parse(testPool_, (char*)sdp_offer2, strlen(sdp_offer2), &remoteOffer); session_->setLocalIP("127.0.0.1"); +#ifdef SFL_VIDEO session_->receiveOffer(remoteOffer, codecSelection, videoCodecs); +#else + session_->receiveOffer(remoteOffer, codecSelection); +#endif session_->startNegotiation(); @@ -257,7 +296,7 @@ void SDPTest::testReinvite() CPPUNIT_ASSERT(session_->getLocalIP().empty()); CPPUNIT_ASSERT(session_->getRemoteIP().empty()); - CodecOrder codecSelection; + std::vector<int> codecSelection; pjmedia_sdp_session *remoteAnswer; pjmedia_sdp_session *reinviteOffer; @@ -265,13 +304,19 @@ void SDPTest::testReinvite() codecSelection.push_back(PAYLOAD_CODEC_ALAW); codecSelection.push_back(PAYLOAD_CODEC_G722); +#ifdef SFL_VIDEO std::vector<std::string> videoCodecs; videoCodecs.push_back("H264"); videoCodecs.push_back("H263"); +#endif session_->setLocalIP("127.0.0.1"); +#ifdef SFL_VIDEO session_->createOffer(codecSelection, videoCodecs); +#else + session_->createOffer(codecSelection); +#endif // pjmedia_sdp_parse(testPool_, test[0].offer_answer[0].sdp2, strlen(test[0].offer_answer[0].sdp2), &remoteAnswer); pjmedia_sdp_parse(testPool_, (char*)sdp_answer1, strlen(sdp_answer1), &remoteAnswer); @@ -284,8 +329,12 @@ void SDPTest::testReinvite() CPPUNIT_ASSERT(session_->getLocalIP() == "127.0.0.1"); CPPUNIT_ASSERT(session_->getRemoteIP() == "host.example.com"); - pjmedia_sdp_parse(testPool_, (char*)sdp_reinvite, strlen(sdp_reinvite), &reinviteOffer); + pjmedia_sdp_parse(testPool_, (char*) sdp_reinvite, strlen(sdp_reinvite), &reinviteOffer); +#ifdef SFL_VIDEO session_->receiveOffer(reinviteOffer, codecSelection, videoCodecs); +#else + session_->receiveOffer(reinviteOffer, codecSelection); +#endif session_->startNegotiation(); session_->setMediaTransportInfoFromRemoteSdp();