Commit ff04efc7 authored by Tristan Matthews's avatar Tristan Matthews

* #11269: make clearer distinction between codecs and audiocodecs

parent 9963c8ff
......@@ -45,11 +45,10 @@ Account::Account(const std::string &accountID, const std::string &type) :
, enabled_(true)
, type_(type)
, registrationState_(Unregistered)
, codecList_()
#ifdef SFL_VIDEO
, audioCodecList_()
, videoCodecList_()
#endif
, codecStr_()
, audioCodecStr_()
, videoCodecStr_()
, ringtonePath_("/usr/share/sflphone/ringtones/konga.ul")
, ringtoneEnabled_(true)
, displayName_("")
......@@ -92,28 +91,28 @@ void Account::loadDefaultCodecs()
#endif
}
#ifdef SFL_VIDEO
void Account::setActiveVideoCodecs(const std::vector<std::string> &list)
{
#ifdef SFL_VIDEO
videoCodecList_ = !list.empty() ? list : sfl_video::getCodecList();
}
#endif
}
void Account::setActiveCodecs(const std::vector <std::string> &list)
void Account::setActiveCodecs(const std::vector<std::string> &list)
{
// first clear the previously stored codecs
codecList_.clear();
audioCodecList_.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.
for (std::vector<std::string>::const_iterator iter = list.begin(); iter != list.end();
++iter) {
int payload = std::atoi(iter->c_str());
codecList_.push_back(static_cast<int>(payload));
audioCodecList_.push_back(static_cast<int>(payload));
}
// update the codec string according to new codec selection
codecStr_ = ManagerImpl::join_string(list);
audioCodecStr_ = ManagerImpl::join_string(list);
}
std::string Account::mapStateNumberToString(RegistrationState state)
......
......@@ -143,10 +143,8 @@ static const char * const HOSTNAME_KEY = "hostname";
static const char * const ACCOUNT_ENABLE_KEY = "enable";
static const char * const MAILBOX_KEY = "mailbox";
static const char * const CODECS_KEY = "codecs"; // 0/9/110/111/112/
#ifdef SFL_VIDEO
static const char * const AUDIO_CODECS_KEY = "audioCodecs"; // 0/9/110/111/112/
static const char * const VIDEO_CODECS_KEY = "videoCodecs";
#endif
static const char * const RINGTONE_PATH_KEY = "ringtonePath";
static const char * const RINGTONE_ENABLED_KEY = "ringtoneEnabled";
static const char * const DISPLAY_NAME_KEY = "displayName";
......@@ -235,7 +233,6 @@ class Account : public Serializable {
alias_ = alias;
}
#ifdef SFL_VIDEO
/**
* Accessor to data structures
* @return std::vector<std::string>& The list that reflects the user's choice
......@@ -243,13 +240,12 @@ class Account : public Serializable {
std::vector<std::string> getActiveVideoCodecs() const {
return videoCodecList_;
}
#endif
/* Accessor to data structures
* @return CodecOrder& The list that reflects the user's choice
*/
std::vector<int> getActiveCodecs() const {
return codecList_;
return audioCodecList_;
}
/**
......@@ -257,9 +253,7 @@ 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_;
......@@ -344,20 +338,24 @@ class Account : public Serializable {
/**
* Vector containing the order of the codecs
*/
std::vector<int> codecList_;
#ifdef SFL_VIDEO
std::vector<int> audioCodecList_;
/**
* Vector containing the order of the video codecs
*/
std::vector<std::string> videoCodecList_;
#endif
/**
* List of codec obtained when parsing configuration and used
* List of audio codecs obtained when parsing configuration and used
* to generate codec order list
*/
std::string audioCodecStr_;
/**
* List of video codecs obtained when parsing configuration and used
* to generate codec order list
*/
std::string codecStr_;
std::string videoCodecStr_;
/**
* Ringtone .au file used for this account
......
......@@ -49,6 +49,12 @@ VideoControls::VideoControls(DBus::Connection& connection) :
libav_utils::sfl_avcodec_init();
}
VideoPreference &
VideoControls::getVideoPreferences()
{
return videoPreference_;
}
/**
* Send the list of all codecs loaded to the client through DBus.
* Can stay global, as only the active codecs will be set per accounts
......
......@@ -65,6 +65,7 @@ class VideoControls : public org::sflphone::SFLphone::VideoControls_adaptor,
public:
VideoControls(DBus::Connection& connection);
VideoPreference &getVideoPreferences();
std::vector<std::string> getCodecList();
std::vector<std::string> getCodecDetails(const std::string& payload);
......
......@@ -59,7 +59,7 @@ void IAXAccount::serialize(Conf::YamlEmitter &emitter)
Conf::ScalarNode type(type_);
Conf::ScalarNode mailbox(mailBox_);
Conf::ScalarNode codecs(codecStr_);
Conf::ScalarNode codecs(audioCodecStr_);
Conf::ScalarNode displayName(displayName_);
accountmap.setKeyValue(ALIAS_KEY, &alias);
......@@ -72,7 +72,7 @@ void IAXAccount::serialize(Conf::YamlEmitter &emitter)
accountmap.setKeyValue(MAILBOX_KEY, &mailbox);
accountmap.setKeyValue(DISPLAY_NAME_KEY, &displayName);
accountmap.setKeyValue(CODECS_KEY, &codecs);
accountmap.setKeyValue(AUDIO_CODECS_KEY, &codecs);
try {
emitter.serializeAccount(&accountmap);
......@@ -90,10 +90,10 @@ void IAXAccount::unserialize(const Conf::MappingNode &map)
map.getValue(HOSTNAME_KEY, &hostname_);
map.getValue(ACCOUNT_ENABLE_KEY, &enabled_);
map.getValue(MAILBOX_KEY, &mailBox_);
map.getValue(CODECS_KEY, &codecStr_);
map.getValue(AUDIO_CODECS_KEY, &audioCodecStr_);
// Update codec list which one is used for SDP offer
setActiveCodecs(ManagerImpl::split_string(codecStr_));
setActiveCodecs(ManagerImpl::split_string(audioCodecStr_));
map.getValue(DISPLAY_NAME_KEY, &displayName_);
}
......
......@@ -58,6 +58,9 @@
#include "manager.h"
#include "dbus/configurationmanager.h"
#ifdef SFL_VIDEO
#include "dbus/video_controls.h"
#endif
#include "conference.h"
......@@ -2640,6 +2643,12 @@ void ManagerImpl::loadAccountMap(Conf::YamlParser &parser)
hookPreference.unserialize(*parser.getHookNode());
audioPreference.unserialize(*parser.getAudioNode());
shortcutPreferences.unserialize(*parser.getShortcutNode());
#ifdef SFL_VIDEO
VideoControls *controls(Manager::instance().getDbusManager()->getVideoControls());
MappingNode *videoNode = parser.getVideoNode();
if (videoNode)
controls->getVideoPreferences().unserialize(*videoNode);
#endif
using namespace std::tr1; // for std::tr1::bind and std::tr1::ref
using namespace std::tr1::placeholders;
......
......@@ -141,14 +141,14 @@ void SIPAccount::serialize(Conf::YamlEmitter &emitter)
ScalarNode publishPort(publicportstr.str());
ScalarNode sameasLocal(publishedSameasLocal_);
ScalarNode codecs(codecStr_);
ScalarNode audioCodecs(audioCodecStr_);
#ifdef SFL_VIDEO
for (vector<string>::const_iterator i = videoCodecList_.begin();
i != videoCodecList_.end(); ++i)
DEBUG("%s", i->c_str());
DEBUG("%s", Manager::instance().join_string(videoCodecList_).c_str());
ScalarNode vcodecs(Manager::instance().join_string(videoCodecList_));
ScalarNode videoCodecs(Manager::instance().join_string(videoCodecList_));
#endif
ScalarNode ringtonePath(ringtonePath_);
......@@ -206,9 +206,9 @@ void SIPAccount::serialize(Conf::YamlEmitter &emitter)
accountmap.setKeyValue(UPDATE_CONTACT_HEADER_KEY, &contactUpdateEnabled);
accountmap.setKeyValue(DTMF_TYPE_KEY, &dtmfType);
accountmap.setKeyValue(DISPLAY_NAME_KEY, &displayName);
accountmap.setKeyValue(CODECS_KEY, &codecs);
accountmap.setKeyValue(AUDIO_CODECS_KEY, &audioCodecs);
#ifdef SFL_VIDEO
accountmap.setKeyValue(VIDEO_CODECS_KEY, &vcodecs);
accountmap.setKeyValue(VIDEO_CODECS_KEY, &videoCodecs);
#endif
accountmap.setKeyValue(RINGTONE_PATH_KEY, &ringtonePath);
accountmap.setKeyValue(RINGTONE_ENABLED_KEY, &ringtoneEnabled);
......@@ -282,13 +282,13 @@ void SIPAccount::unserialize(const Conf::MappingNode &map)
map.getValue(HOSTNAME_KEY, &hostname_);
map.getValue(ACCOUNT_ENABLE_KEY, &enabled_);
map.getValue(MAILBOX_KEY, &mailBox_);
map.getValue(CODECS_KEY, &codecStr_);
map.getValue(AUDIO_CODECS_KEY, &audioCodecStr_);
#ifdef SFL_VIDEO
std::string vcodecs;
map.getValue(VIDEO_CODECS_KEY, &vcodecs);
map.getValue(VIDEO_CODECS_KEY, &videoCodecStr_);
setActiveVideoCodecs(ManagerImpl::split_string(videoCodecStr_));
#endif
// Update codec list which one is used for SDP offer
setActiveCodecs(ManagerImpl::split_string(codecStr_));
setActiveCodecs(ManagerImpl::split_string(audioCodecStr_));
map.getValue(RINGTONE_PATH_KEY, &ringtonePath_);
map.getValue(RINGTONE_ENABLED_KEY, &ringtoneEnabled_);
......
......@@ -43,11 +43,6 @@ VideoPreference::VideoPreference() :
v4l2_list_->start();
}
VideoPreference::~VideoPreference()
{
delete v4l2_list_;
}
std::map<std::string, std::string> VideoPreference::getSettings() const
{
std::map<std::string, std::string> args;
......
......@@ -37,6 +37,7 @@
#include <map>
#include <string>
#include <tr1/memory>
namespace sflvideo {
class VideoV4l2ListThread;
......@@ -52,7 +53,6 @@ class VideoPreference : public Serializable
public:
VideoPreference();
~VideoPreference();
virtual void serialize(Conf::YamlEmitter &emitter);
......@@ -112,7 +112,7 @@ class VideoPreference : public Serializable
NON_COPYABLE(VideoPreference);
// V4L2 devices
sfl_video::VideoV4l2ListThread *v4l2_list_;
std::tr1::shared_ptr<sfl_video::VideoV4l2ListThread> v4l2_list_;
std::string device_;
std::string channel_;
......
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