Commit c07b52af authored by Éloi Bail's avatar Éloi Bail Committed by Guillaume Roguez

daemon: simplify codecs DBus API

Refs #66623

**WARNING**

This commit modify DBUS API.
API are modified only for libringclient.
Gnome client - not based on libringclient - will be unstable.

Change-Id: Ib7ddd32327f3ccb9fccc6c65a0fc93d7defd76f5
parent 7097a513
......@@ -368,34 +368,34 @@
<!-- Codecs-related methods -->
<method name="getAudioCodecList" tp:name-for-bindings="getAudioCodecList">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="VectorInt"/>
<method name="getCodecList" tp:name-for-bindings="getCodecList">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="VectorUInt"/>
<arg type="au" name="list" direction="out">
</arg>
</method>
<method name="getAudioCodecDetails" tp:name-for-bindings="getAudioCodecDetails">
<arg type="u" name="codecId" direction="in">
</arg>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="VectorString"/>
<arg type="as" name="details" direction="out">
<method name="getCodecDetails" tp:name-for-bindings="getCodecDetails">
<arg type="s" name="accountID" direction="in"></arg>
<arg type="u" name="codecId" direction="in"></arg>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="MapStringString"/>
<arg type="a{ss}" name="details" direction="out" tp:type="String_String_Map">
</arg>
</method>
<method name="getActiveAudioCodecList" tp:name-for-bindings="getActiveAudioCodecList">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="VectorInt"/>
<method name="getActiveCodecList" tp:name-for-bindings="getActiveCodecList">
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="VectorUInt"/>
<arg type="s" name="accountID" direction="in">
</arg>
<arg type="au" name="list" direction="out">
</arg>
</method>
<method name="setActiveAudioCodecList" tp:name-for-bindings="setActiveAudioCodecList">
<annotation name="org.qtproject.QtDBus.QtTypeName.In0" value="VectorString"/>
<arg type="as" name="list" direction="in">
</arg>
<method name="setActiveCodecList" tp:name-for-bindings="setActiveCodecList">
<annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="VectorUInt"/>
<arg type="s" name="accountID" direction="in">
</arg>
<arg type="au" name="list" direction="in">
</arg>
</method>
<!-- Audio devices methods -->
......@@ -567,7 +567,7 @@
The account ID
</tp:docstring>
</arg>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out1" value="MapStringString"/>
<annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="MapStringString"/>
<arg type="a{ss}" name="details" tp:type="String_String_Map">
<tp:docstring>
Account.registrationCoarseStatus ( Coarse status like, UNREGISTERED or TRYING )
......
......@@ -98,9 +98,9 @@ DBusConfigurationManager::getTlsDefaultSettings() -> decltype(DRing::getTlsDefau
}
auto
DBusConfigurationManager::getAudioCodecList() -> decltype(DRing::getAudioCodecList())
DBusConfigurationManager::getCodecList() -> decltype(DRing::getCodecList())
{
return DRing::getAudioCodecList();
return DRing::getCodecList();
}
auto
......@@ -116,21 +116,21 @@ DBusConfigurationManager::getSupportedCiphers(const std::string& accountID) -> d
}
auto
DBusConfigurationManager::getAudioCodecDetails(const unsigned& codecId) -> decltype(DRing::getAudioCodecDetails(codecId))
DBusConfigurationManager::getCodecDetails(const std::string& accountID, const unsigned& codecId) -> decltype(DRing::getCodecDetails(accountID, codecId))
{
return DRing::getAudioCodecDetails(codecId);
return DRing::getCodecDetails(accountID, codecId);
}
auto
DBusConfigurationManager::getActiveAudioCodecList(const std::string& accountID) -> decltype(DRing::getActiveAudioCodecList(accountID))
DBusConfigurationManager::getActiveCodecList(const std::string& accountID) -> decltype(DRing::getActiveCodecList(accountID))
{
return DRing::getActiveAudioCodecList(accountID);
return DRing::getActiveCodecList(accountID);
}
void
DBusConfigurationManager::setActiveAudioCodecList(const std::vector<std::string>& list, const std::string& accountID)
DBusConfigurationManager::setActiveCodecList(const std::string& accountID, const std::vector<unsigned>& list)
{
DRing::setActiveAudioCodecList(list, accountID);
DRing::setActiveCodecList(accountID, list);
}
auto
......
......@@ -76,11 +76,11 @@ class DBusConfigurationManager :
void registerAllAccounts(void);
std::map<std::string, std::string> getTlsDefaultSettings();
std::vector<std::string> getSupportedCiphers(const std::string& accountID);
std::vector<unsigned> getAudioCodecList();
std::vector<unsigned> getCodecList();
std::vector<std::string> getSupportedTlsMethod();
std::vector<std::string> getAudioCodecDetails(const unsigned& codecId);
std::vector<unsigned> getActiveAudioCodecList(const std::string& accountID);
void setActiveAudioCodecList(const std::vector<std::string>& list, const std::string& accountID);
std::map<std::string, std::string> getCodecDetails(const std::string& accountID, const unsigned& codecId);
std::vector<unsigned> getActiveCodecList(const std::string& accountID);
void setActiveCodecList(const std::string& accountID, const std::vector<unsigned>& list);
std::vector<std::string> getAudioPluginList();
void setAudioPlugin(const std::string& audioPlugin);
std::vector<std::string> getAudioOutputDeviceList();
......
......@@ -35,24 +35,6 @@ DBusVideoManager::DBusVideoManager(DBus::Connection& connection)
: DBus::ObjectAdaptor(connection, "/cx/ring/Ring/VideoManager")
{}
auto
DBusVideoManager::getVideoCodecList(const std::string& accountID) -> decltype(DRing::getVideoCodecList(accountID))
{
return DRing::getVideoCodecList(accountID);
}
auto
DBusVideoManager::getVideoCodecDetails(const unsigned& codecId) -> decltype(DRing::getVideoCodecDetails(codecId))
{
return DRing::getVideoCodecDetails(codecId);
}
void
DBusVideoManager::setVideoCodecList(const std::string& accountID, const std::vector<unsigned> &list)
{
DRing::setVideoCodecList(accountID, list);
}
auto
DBusVideoManager::getDeviceList() -> decltype(DRing::getDeviceList())
{
......@@ -89,12 +71,6 @@ DBusVideoManager::getDefaultDevice() -> decltype(DRing::getDefaultDevice())
return DRing::getDefaultDevice();
}
auto
DBusVideoManager::getCurrentCodecName(const std::string& callID) -> decltype(DRing::getCurrentCodecName(callID))
{
return DRing::getCurrentCodecName(callID);
}
void
DBusVideoManager::startCamera()
{
......
......@@ -61,16 +61,12 @@ class DBusVideoManager :
DBusVideoManager(DBus::Connection& connection);
// Methods
std::vector<unsigned > getVideoCodecList(const std::string& accountID);
std::vector<std::string> getVideoCodecDetails(const unsigned& codecId);
void setVideoCodecList(const std::string& accountID, const std::vector<unsigned>& list);
std::vector<std::string> getDeviceList();
std::map<std::string, std::map<std::string, std::vector<std::string>>> getCapabilities(const std::string& name);
std::map<std::string, std::string> getSettings(const std::string& name);
void applySettings(const std::string& name, const std::map<std::string, std::string>& settings);
void setDefaultDevice(const std::string& dev);
std::string getDefaultDevice();
std::string getCurrentCodecName(const std::string& callID);
void startCamera();
void stopCamera();
bool switchInput(const std::string& resource);
......
......@@ -47,33 +47,6 @@
</arg>
</method>
<!-- Video Codec related methods -->
<method name="getVideoCodecList" tp:name-for-bindings="getVideoCodecList">
<arg type="s" name="accountID" direction="in">
</arg>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="VectorInt"/>
<arg type="au" name="list" direction="out">
</arg>
</method>
<method name="getVideoCodecDetails" tp:name-for-bindings="getVideoCodecDetails">
<arg type="u" name="codecid" direction="in">
</arg>
<annotation name="org.qtproject.QtDBus.QtTypeName.Out0" value="VectorString"/>
<arg type="as" name="details" direction="out">
</arg>
</method>
<method name="setVideoCodecList" tp:name-for-bindings="setVideoCodecList">
<tp:docstring>Sets a vector of hashtables describing codecs and their parameters for a given account, one hashtable per codec</tp:docstring>
<arg type="s" name="accountID" direction="in">
</arg>
<annotation name="org.qtproject.QtDBus.QtTypeName.In1" value="VectorInt"/>
<arg type="au" name="list" direction="in">
</arg>
</method>
<method name="startCamera" tp:name-for-bindings="startCamera">
<tp:docstring> Starts the video camera, which renders the active v4l2 device's video to shared memory. Useful for testing/debugging camera settings</tp:docstring>
</method>
......@@ -141,10 +114,5 @@
</arg>
</signal>
<method name="getCurrentCodecName" tp:name-for-bindings="getCurrentCodecName">
<annotation name="org.freedesktop.DBus.Deprecated" value="true"/>
<arg type="s" name="callID" direction="in"/>
<arg type="s" name="codecName" direction="out"/>
</method>
</interface>
</node>
......@@ -62,8 +62,7 @@
namespace ring {
const char * const Account::AUDIO_CODECS_KEY = "audioCodecs"; // 0/9/110/111/112/
const char * const Account::VIDEO_CODECS_KEY = "videoCodecs";
const char * const Account::ALL_CODECS_KEY = "allCodecs";
const char * const Account::VIDEO_CODEC_ENABLED = "enabled";
const char * const Account::VIDEO_CODEC_NAME = "name";
const char * const Account::VIDEO_CODEC_PARAMETERS = "parameters";
......@@ -98,8 +97,7 @@ Account::Account(const std::string &accountID)
, registrationState_(RegistrationState::UNREGISTERED)
, systemCodecContainer_(getSystemCodecContainer())
, accountCodecInfoList_()
, audioCodecStr_()
, videoCodecStr_()
, allCodecStr_()
, ringtonePath_("")
, ringtoneEnabled_(true)
, displayName_("")
......@@ -198,7 +196,7 @@ Account::serialize(YAML::Emitter &out)
out << YAML::Key << ALIAS_KEY << YAML::Value << alias_;
out << YAML::Key << ACCOUNT_ENABLE_KEY << YAML::Value << enabled_;
out << YAML::Key << TYPE_KEY << YAML::Value << getAccountType();
out << YAML::Key << AUDIO_CODECS_KEY << YAML::Value << audioCodecStr_;
out << YAML::Key << ALL_CODECS_KEY << YAML::Value << allCodecStr_;
out << YAML::Key << MAILBOX_KEY << YAML::Value << mailBox_;
out << YAML::Key << ACCOUNT_AUTOANSWER_KEY << YAML::Value << autoAnswerEnabled_;
out << YAML::Key << RINGTONE_ENABLED_KEY << YAML::Value << ringtoneEnabled_;
......@@ -223,10 +221,10 @@ Account::unserialize(const YAML::Node &node)
//parseValue(node, PASSWORD_KEY, password_);
parseValue(node, MAILBOX_KEY, mailBox_);
parseValue(node, AUDIO_CODECS_KEY, audioCodecStr_);
parseValue(node, ALL_CODECS_KEY, allCodecStr_);
// Update codec list which one is used for SDP offer
setActiveAudioCodecs(split_string(audioCodecStr_, '/'));
setActiveCodecs(split_string_to_unsigned(allCodecStr_, '/'));
parseValue(node, DISPLAY_NAME_KEY, displayName_);
parseValue(node, HOSTNAME_KEY, hostname_);
......@@ -380,16 +378,6 @@ isCodecListValid(const std::vector<unsigned>& list UNUSED)
}
#endif // RING_VIDEO
void
Account::setVideoCodecs(const std::vector<unsigned> &list)
{
#ifdef RING_VIDEO
if (isCodecListValid(list))
videoCodecList_ = list;
#else
(void) list;
#endif
}
// Convert a list of payloads in a special format, readable by the server.
// Required format: payloads separated by slashes.
......@@ -403,24 +391,23 @@ join_string(const std::vector<unsigned> &v)
}
std::vector<unsigned>
Account::getActiveAudioCodecs() const
Account::getActiveCodecs() const
{
return getActiveAccountCodecInfoIdList(MEDIA_AUDIO);
return getActiveAccountCodecInfoIdList(MEDIA_ALL);
}
void
Account::setActiveAudioCodecs(const std::vector<std::string>& list)
Account::setActiveCodecs(const std::vector<unsigned>& list)
{
// first clear the previously stored codecs
// TODO: mutex to protect isActive
desactivateAllMedia(MEDIA_AUDIO);
desactivateAllMedia(MEDIA_ALL);
// list contains the ordered payload of active codecs picked by the user for this account
// we used the codec vector to save the order.
uint16_t order = 1;
for (const auto& item : list) {
auto codecId = std::atoi(item.c_str());
if (auto accCodec = searchCodecById(codecId, MEDIA_AUDIO)) {
if (auto accCodec = searchCodecById(item, MEDIA_ALL)) {
accCodec->isActive = true;
accCodec->order = order;
++order;
......@@ -434,7 +421,7 @@ Account::setActiveAudioCodecs(const std::vector<std::string>& list)
return a->order < b->order;
});
audioCodecStr_ = join_string(getActiveAccountCodecInfoIdList(MEDIA_AUDIO));
allCodecStr_ = join_string(getActiveAccountCodecInfoIdList(MEDIA_ALL));
for (const auto& item : accountCodecInfoList_)
RING_DBG("[%s] order:%d, isActive=%s, codec=%s", accountID_.c_str(),
......@@ -467,23 +454,9 @@ Account::mapStateNumberToString(RegistrationState state)
}
std::vector<unsigned>
Account::getAllVideoCodecsId() const
Account::getDefaultCodecs()
{
return getAccountCodecInfoIdList(MEDIA_VIDEO);
}
std::vector<unsigned>
Account::getDefaultAudioCodecs()
{
return getSystemCodecContainer()->getSystemCodecInfoIdList(MEDIA_AUDIO);
}
std::vector<unsigned>
Account::getActiveVideoCodecs() const
{
if (videoEnabled_)
return getActiveAccountCodecInfoIdList(MEDIA_VIDEO);
return {};
return getSystemCodecContainer()->getSystemCodecInfoIdList(MEDIA_ALL);
}
#define find_iter() \
......
......@@ -197,22 +197,21 @@ class Account : public Serializable, public std::enable_shared_from_this<Account
alias_ = alias;
}
std::vector<unsigned> getAllVideoCodecsId() const;
std::vector<unsigned> getActiveVideoCodecs() const;
static std::vector<unsigned> getDefaultAudioCodecs();
static std::vector<unsigned> getDefaultCodecs();
/* Accessor to data structures
* @return The list that reflects the user's choice
*/
std::vector<unsigned> getActiveAudioCodecs() const;
std::vector<unsigned> getActiveCodecs() const;
/**
* Update both the codec order structure and the codec string used for
* SDP offer and configuration respectively
*/
void setActiveAudioCodecs(const std::vector<std::string>& list);
void setVideoCodecs(const std::vector<unsigned> &codecs);
void setActiveCodecs(const std::vector<unsigned>& list);
std::shared_ptr<AccountCodecInfo> searchCodecById(unsigned codecId, MediaType mediaType);
std::vector<unsigned> getActiveAccountCodecInfoIdList(MediaType mediaType) const;
std::string getRingtonePath() const {
return ringtonePath_;
......@@ -284,8 +283,7 @@ class Account : public Serializable, public std::enable_shared_from_this<Account
friend class ConfigurationTest;
// General configuration keys for accounts
static const char * const AUDIO_CODECS_KEY;
static const char * const VIDEO_CODECS_KEY;
static const char * const ALL_CODECS_KEY;
static const char * const RINGTONE_PATH_KEY;
static const char * const RINGTONE_ENABLED_KEY;
static const char * const VIDEO_ENABLED_KEY;
......@@ -345,23 +343,19 @@ class Account : public Serializable, public std::enable_shared_from_this<Account
RegistrationState registrationState_;
/**
* Vector containing the order of the codecs
* Vector containing all system codecs (with default parameters)
*/
std::shared_ptr<SystemCodecContainer> systemCodecContainer_;
std::vector<unsigned> audioCodecList_;
std::vector<std::shared_ptr<AccountCodecInfo>> accountCodecInfoList_;
/**
* Vector containing the video codecs in order
* Vector containing all account codecs (set of system codecs with custom parameters)
*/
std::vector<unsigned> videoCodecList_;
std::vector<std::shared_ptr<AccountCodecInfo>> accountCodecInfoList_;
/**
* List of audio codecs obtained when parsing configuration and used
* List of audio and video codecs obtained when parsing configuration and used
* to generate codec order list
*/
std::string audioCodecStr_;
std::string videoCodecStr_;
std::string allCodecStr_;
/**
* Ringtone .au file used for this account
......@@ -416,13 +410,12 @@ class Account : public Serializable, public std::enable_shared_from_this<Account
/**
* private account codec searching functions
*/
std::shared_ptr<AccountCodecInfo> searchCodecById(unsigned codecId, MediaType mediaType);
std::shared_ptr<AccountCodecInfo> searchCodecByName(std::string name, MediaType mediaType);
std::shared_ptr<AccountCodecInfo> searchCodecByPayload(unsigned payload, MediaType mediaType);
std::vector<unsigned> getAccountCodecInfoIdList(MediaType mediaType) const;
std::vector<unsigned> getActiveAccountCodecInfoIdList(MediaType mediaType) const;
void desactivateAllMedia(MediaType mediaType);
std::vector<std::shared_ptr<AccountCodecInfo>> getActiveAccountCodecInfoList(MediaType mediaType);
};
} // namespace ring
......
......@@ -231,9 +231,9 @@ getAccountList()
* Can stay global, as only the active codecs will be set per accounts
*/
std::vector<unsigned>
getAudioCodecList()
getCodecList()
{
std::vector<unsigned> list {ring::getSystemCodecContainer()->getSystemCodecInfoIdList(ring::MEDIA_AUDIO)};
std::vector<unsigned> list {ring::getSystemCodecContainer()->getSystemCodecInfoIdList(ring::MEDIA_ALL)};
if (list.empty())
ring::emitSignal<ConfigurationSignal::Error>(CODECS_NOT_LOADED);
return list;
......@@ -256,31 +256,51 @@ getSupportedCiphers(const std::string& accountID)
return {};
}
std::vector<std::string>
getAudioCodecDetails(unsigned codecId)
std::map<std::string, std::string>
getCodecDetails(const std::string& accountID, const unsigned& codecId)
{
auto codec = ring::getSystemCodecContainer()->searchCodecById(codecId, ring::MEDIA_AUDIO);
if (auto foundCodec = std::static_pointer_cast<ring::SystemAudioCodecInfo>(codec))
return foundCodec->getCodecSpecifications();
auto acc = ring::Manager::instance().getAccount(accountID);
if (!acc)
{
RING_ERR("Could not find account %s", accountID.c_str());
return {};
}
auto codec = acc->searchCodecById(codecId, ring::MEDIA_ALL);
if (!codec)
{
ring::emitSignal<ConfigurationSignal::Error>(CODECS_NOT_LOADED);
return {};
}
if (codec->systemCodecInfo.mediaType & ring::MEDIA_AUDIO)
if (auto foundCodec = std::static_pointer_cast<ring::AccountAudioCodecInfo>(codec))
return foundCodec->getCodecSpecifications();
if (codec->systemCodecInfo.mediaType & ring::MEDIA_VIDEO)
if (auto foundCodec = std::static_pointer_cast<ring::AccountVideoCodecInfo>(codec))
return foundCodec->getCodecSpecifications();
ring::emitSignal<ConfigurationSignal::Error>(CODECS_NOT_LOADED);
return {};
}
std::vector<unsigned>
getActiveAudioCodecList(const std::string& accountID)
getActiveCodecList(const std::string& accountID)
{
if (auto acc = ring::Manager::instance().getAccount(accountID))
return acc->getActiveAudioCodecs();
return acc->getActiveCodecs();
RING_ERR("Could not find account %s, returning default", accountID.c_str());
return Account::getDefaultAudioCodecs();
return Account::getDefaultCodecs();
}
void
setActiveAudioCodecList(const std::vector<std::string>& list,
const std::string& accountID)
setActiveCodecList(const std::string& accountID
, const std::vector<unsigned>& list)
{
if (auto acc = ring::Manager::instance().getAccount(accountID)) {
acc->setActiveAudioCodecs(list);
if (auto acc = ring::Manager::instance().getAccount(accountID))
{
acc->setActiveCodecs(list);
ring::Manager::instance().saveConfig();
} else {
RING_ERR("Could not find account %s", accountID.c_str());
......
......@@ -61,32 +61,6 @@ registerVideoHandlers(const std::map<std::string,
}
}
std::vector<unsigned>
getVideoCodecList(const std::string& accountID)
{
if (auto acc = ring::Manager::instance().getAccount(accountID))
return acc->getAllVideoCodecsId();
return {};
}
std::vector<std::string>
getVideoCodecDetails(unsigned codecId)
{
auto codec = ring::getSystemCodecContainer()->searchCodecById(codecId, ring::MEDIA_VIDEO);
if (auto foundCodec = std::static_pointer_cast<ring::SystemVideoCodecInfo>(codec))
return foundCodec->getCodecSpecifications();
return {};
}
void
setVideoCodecList(const std::string& accountID,
const std::vector<unsigned>& list)
{
if (auto acc = ring::Manager::instance().getAccount(accountID)) {
acc->setVideoCodecs(list);
ring::Manager::instance().saveConfig();
}
}
std::vector<std::string>
getDeviceList()
......@@ -163,11 +137,6 @@ hasCameraStarted()
return videoManager.started;
}
std::string
getCurrentCodecName(const std::string& /*callID*/)
{
return "";
}
} // namespace DRing
......
This diff is collapsed.
......@@ -100,13 +100,13 @@ void registerAllAccounts(void);
std::map<std::string, std::string> getTlsDefaultSettings();
std::vector<unsigned> getAudioCodecList();
std::vector<unsigned> getCodecList();
std::vector<std::string> getSupportedTlsMethod();
std::vector<std::string> getSupportedCiphers(const std::string& accountID);
std::vector<std::string> getAudioCodecDetails(unsigned codecId);
std::vector<unsigned> getActiveAudioCodecList(const std::string& accountID);
std::map<std::string, std::string> getCodecDetails(const std::string& accountID, const unsigned& codecId);
std::vector<unsigned> getActiveCodecList(const std::string& accountID);
void setActiveAudioCodecList(const std::vector<std::string>& list, const std::string& accountID);
void setActiveCodecList(const std::string& accountID, const std::vector<unsigned>& list);
std::vector<std::string> getAudioPluginList();
void setAudioPlugin(const std::string& audioPlugin);
......
......@@ -89,7 +89,7 @@ IAXCall::getSupportedFormat(const std::string &accountID) const
int format_mask = 0;
if (account) {
std::vector<unsigned> codecs{account->getActiveAudioCodecs()};
std::vector<unsigned> codecs{account->getActiveAccountCodecInfoIdList(MEDIA_AUDIO)};
for (const auto &i : codecs)
format_mask |= codecToASTFormat(i);
......@@ -105,7 +105,7 @@ IAXCall::getFirstMatchingFormat(int needles, const std::string &accountID) const
const auto account = Manager::instance().getAccount(accountID);
if (account != NULL) {
std::vector<unsigned> codecs{account->getActiveAudioCodecs()};
std::vector<unsigned> codecs{account->getActiveAccountCodecInfoIdList(MEDIA_AUDIO)};
for (const auto &i : codecs) {
int format_mask = codecToASTFormat(i);
......
......@@ -31,6 +31,7 @@
#include "libav_deps.h" // MUST BE INCLUDED FIRST
#include "media_codec.h"
#include "account_const.h"
#include <string.h>
#include <sstream>
......@@ -102,14 +103,16 @@ SystemAudioCodecInfo::isPCMG722() const
}
std::vector<std::string>
std::map<std::string, std::string>
SystemAudioCodecInfo::getCodecSpecifications()
{
return {name, // name of the codec
std::to_string(sampleRate), // sample rate
std::to_string(bitrate), // bit rate
std::to_string(nbChannels) // channel number
};
return {
{DRing::Account::ConfProperties::CodecInfo::NAME, name},
{DRing::Account::ConfProperties::CodecInfo::TYPE, (mediaType & MEDIA_AUDIO ? "AUDIO" : "VIDEO")},
{DRing::Account::ConfProperties::CodecInfo::BITRATE, std::to_string(bitrate)},
{DRing::Account::ConfProperties::CodecInfo::SAMPLE_RATE, std::to_string(sampleRate)},
{DRing::Account::ConfProperties::CodecInfo::CHANNEL_NUMBER, std::to_string(nbChannels)}
};
}
/*
......@@ -119,20 +122,25 @@ SystemVideoCodecInfo::SystemVideoCodecInfo(unsigned m_avcodecId,
const std::string m_name,
std::string m_libName,
CodecType m_type,
unsigned m_payloadType)
unsigned m_payloadType,
unsigned m_frameRate,
unsigned m_profileId)
: SystemCodecInfo(m_avcodecId, m_name, m_libName, MEDIA_VIDEO, m_type, m_payloadType)
, frameRate(m_frameRate), profileId(m_profileId)
{}
SystemVideoCodecInfo::~SystemVideoCodecInfo()
{}
std::vector<std::string>
std::map<std::string, std::string>
SystemVideoCodecInfo::getCodecSpecifications()
{
return {name, // name of the codec
std::to_string(bitrate), // bit rate
parameters // parameters
};
return {
{DRing::Account::ConfProperties::CodecInfo::NAME, name},
{DRing::Account::ConfProperties::CodecInfo::TYPE, (mediaType & MEDIA_AUDIO ? "AUDIO" : "VIDEO")},
{DRing::Account::ConfProperties::CodecInfo::BITRATE, std::to_string(bitrate)},
{DRing::Account::ConfProperties::CodecInfo::FRAME_RATE, std::to_string(frameRate)}
};
}
AccountCodecInfo::AccountCodecInfo(const SystemCodecInfo& sysCodecInfo)
......@@ -152,6 +160,18 @@ AccountAudioCodecInfo::AccountAudioCodecInfo(const SystemAudioCodecInfo& sysCode
, nbChannels(sysCodecInfo.nbChannels)
{}
std::map<std::string, std::string>
AccountAudioCodecInfo::getCodecSpecifications()
{
return {
{DRing::Account::ConfProperties::CodecInfo::NAME, systemCodecInfo.name},
{DRing::Account::ConfProperties::CodecInfo::TYPE, (systemCodecInfo.mediaType & MEDIA_AUDIO ? "AUDIO" : "VIDEO")},
{DRing::Account::ConfProperties::CodecInfo::BITRATE, std::to_string(bitrate)},
{DRing::Account::ConfProperties::CodecInfo::SAMPLE_RATE, std::to_string(sampleRate)},
{DRing::Account::ConfProperties::CodecInfo::CHANNEL_NUMBER, std::to_string(nbChannels)}
};
}
AccountAudioCodecInfo::~AccountAudioCodecInfo()
{}
......@@ -161,6 +181,17 @@ AccountVideoCodecInfo::AccountVideoCodecInfo(const SystemVideoCodecInfo& sysCode
, profileId(sysCodecInfo.profileId)
{}
std::map<std::string, std::string>
AccountVideoCodecInfo::getCodecSpecifications()
{
return {
{DRing::Account::ConfProperties::CodecInfo::NAME, systemCodecInfo.name},
{DRing::Account::ConfProperties::CodecInfo::TYPE, (systemCodecInfo.mediaType & MEDIA_AUDIO ? "AUDIO" : "VIDEO")},
{DRing::Account::ConfProperties::CodecInfo::BITRATE, std::to_string(bitrate)},
{DRing::Account::ConfProperties::CodecInfo::FRAME_RATE, std::to_string(frameRate)}
};
}
AccountVideoCodecInfo::~AccountVideoCodecInfo()
{}
......
......@@ -38,6 +38,7 @@
#include <string>
#include <vector>
#include <map>
#include <iostream>
#include <unistd.h>
......@@ -101,7 +102,7 @@ struct SystemAudioCodecInfo : SystemCodecInfo
~SystemAudioCodecInfo();
std::vector<std::string> getCodecSpecifications();
std::map<std::string, std::string> getCodecSpecifications();
bool isPCMG722() const;
unsigned sampleRate;
......@@ -117,11 +118,12 @@ struct SystemVideoCodecInfo : SystemCodecInfo