Commit 3c92e2d8 authored by Éloi Bail's avatar Éloi Bail Committed by Éloi Bail

media: handle video-disabled account state

Refs #67691

Change-Id: Ide9853e5be3a3686e595b3e153da346f31cf53ac
Signed-off-by: Guillaume Roguez's avatarGuillaume Roguez <guillaume.roguez@savoirfairelinux.com>
parent a1c17a29
......@@ -164,7 +164,7 @@ Account::loadDefaultCodecs()
for (const auto& systemCodec: systemCodecList) {
// only take encoders and or decoders
if (systemCodec->codecType & CODEC_UNDEFINED)
if (systemCodec->codecType == CODEC_NONE)
continue;
if (systemCodec->mediaType & MEDIA_AUDIO) {
......@@ -381,8 +381,7 @@ std::map<std::string, std::string>
Account::getDefaultCodecDetails(const unsigned& codecId)
{
auto codec = ring::getSystemCodecContainer()->searchCodecById(codecId, ring::MEDIA_ALL);
if (codec)
{
if (codec) {
if (codec->mediaType & ring::MEDIA_AUDIO) {
auto audioCodec = std::static_pointer_cast<ring::SystemAudioCodecInfo>(codec);
return audioCodec->getCodecSpecifications();
......@@ -453,10 +452,12 @@ Account::getUPnPActive(std::chrono::seconds timeout) const
std::shared_ptr<AccountCodecInfo>
Account::searchCodecById(unsigned codecId, MediaType mediaType)
{
for (auto& codecIt: accountCodecInfoList_) {
if ((codecIt->systemCodecInfo.id == codecId) &&
(codecIt->systemCodecInfo.mediaType & mediaType ))
if (mediaType != MEDIA_NONE) {
for (auto& codecIt: accountCodecInfoList_) {
if ((codecIt->systemCodecInfo.id == codecId) &&
(codecIt->systemCodecInfo.mediaType & mediaType ))
return codecIt;
}
}
return {};
}
......@@ -464,10 +465,12 @@ Account::searchCodecById(unsigned codecId, MediaType mediaType)
std::shared_ptr<AccountCodecInfo>
Account::searchCodecByName(std::string name, MediaType mediaType)
{
for (auto& codecIt: accountCodecInfoList_) {
if ((codecIt->systemCodecInfo.name.compare(name) == 0) &&
(codecIt->systemCodecInfo.mediaType & mediaType ))
return codecIt;
if (mediaType != MEDIA_NONE) {
for (auto& codecIt: accountCodecInfoList_) {
if ((codecIt->systemCodecInfo.name.compare(name) == 0) &&
(codecIt->systemCodecInfo.mediaType & mediaType ))
return codecIt;
}
}
return {};
}
......@@ -475,10 +478,12 @@ Account::searchCodecByName(std::string name, MediaType mediaType)
std::shared_ptr<AccountCodecInfo>
Account::searchCodecByPayload(unsigned payload, MediaType mediaType)
{
for (auto& codecIt: accountCodecInfoList_) {
if ((codecIt->payloadType == payload ) &&
(codecIt->systemCodecInfo.mediaType & mediaType ))
return codecIt;
if (mediaType != MEDIA_NONE) {
for (auto& codecIt: accountCodecInfoList_) {
if ((codecIt->payloadType == payload ) &&
(codecIt->systemCodecInfo.mediaType & mediaType ))
return codecIt;
}
}
return {};
}
......@@ -486,6 +491,9 @@ Account::searchCodecByPayload(unsigned payload, MediaType mediaType)
std::vector<unsigned>
Account::getActiveAccountCodecInfoIdList(MediaType mediaType) const
{
if (mediaType == MEDIA_NONE)
return {};
std::vector<unsigned> idList;
for (auto& codecIt: accountCodecInfoList_) {
if ((codecIt->systemCodecInfo.mediaType & mediaType) &&
......@@ -498,17 +506,24 @@ Account::getActiveAccountCodecInfoIdList(MediaType mediaType) const
std::vector<unsigned>
Account::getAccountCodecInfoIdList(MediaType mediaType) const
{
if (mediaType == MEDIA_NONE)
return {};
std::vector<unsigned> idList;
for (auto& codecIt: accountCodecInfoList_) {
if (codecIt->systemCodecInfo.mediaType & mediaType)
idList.push_back(codecIt->systemCodecInfo.id);
}
return idList;
}
void
Account::desactivateAllMedia(MediaType mediaType)
{
if (mediaType == MEDIA_NONE)
return;
for (auto& codecIt: accountCodecInfoList_) {
if (codecIt->systemCodecInfo.mediaType & mediaType)
codecIt->isActive = false;
......@@ -518,12 +533,16 @@ Account::desactivateAllMedia(MediaType mediaType)
std::vector<std::shared_ptr<AccountCodecInfo>>
Account::getActiveAccountCodecInfoList(MediaType mediaType) const
{
if (mediaType == MEDIA_NONE)
return {};
std::vector<std::shared_ptr<AccountCodecInfo>> accountCodecList;
for (auto& codecIt: accountCodecInfoList_) {
if ((codecIt->systemCodecInfo.mediaType & mediaType) &&
(codecIt->isActive))
accountCodecList.push_back(codecIt);
}
return accountCodecList;
}
......
......@@ -166,6 +166,10 @@ class Account : public Serializable, public std::enable_shared_from_this<Account
return enabled_;
}
bool isVideoEnabled() const {
return videoEnabled_;
}
void setEnabled(bool enable) {
enabled_ = enable;
}
......
......@@ -45,14 +45,14 @@
namespace ring {
enum CodecType : unsigned {
CODEC_UNDEFINED = 0,
CODEC_NONE = 0, // indicates that no codec is used or defined
CODEC_ENCODER = 1,
CODEC_DECODER = 2,
CODEC_ENCODER_DECODER = CODEC_ENCODER | CODEC_DECODER
};
enum MediaType : unsigned {
MEDIA_UNDEFINED = 0,
MEDIA_NONE = 0, // indicates that no media is used or defined
MEDIA_AUDIO = 1,
MEDIA_VIDEO = 2,
MEDIA_ALL = MEDIA_AUDIO | MEDIA_VIDEO
......@@ -67,7 +67,7 @@ struct SystemCodecInfo
{
SystemCodecInfo(unsigned avcodecId, const std::string name,
std::string libName, MediaType mediaType,
CodecType codecType = CODEC_UNDEFINED, unsigned bitrate = 0,
CodecType codecType = CODEC_NONE, unsigned bitrate = 0,
unsigned payloadType = 0);
virtual ~SystemCodecInfo();
......@@ -115,7 +115,7 @@ struct SystemAudioCodecInfo : SystemCodecInfo
struct SystemVideoCodecInfo : SystemCodecInfo
{
SystemVideoCodecInfo(unsigned avcodecId, const std::string name,
std::string libName, CodecType type = CODEC_UNDEFINED,
std::string libName, CodecType type = CODEC_NONE,
unsigned payloadType = 0, unsigned frameRate = 0,
unsigned profileId = 0);
......
......@@ -292,7 +292,7 @@ RingAccount::createOutgoingCall(const std::shared_ptr<SIPCall>& call, const std:
sdp.setPublishedIP(addrSdp);
const bool created = sdp.createOffer(
getActiveAccountCodecInfoList(MEDIA_AUDIO),
getActiveAccountCodecInfoList(MEDIA_VIDEO),
getActiveAccountCodecInfoList(videoEnabled_ ? MEDIA_VIDEO : MEDIA_NONE),
getSrtpKeyExchange()
);
......
......@@ -4,6 +4,7 @@
* Author: Emmanuel Milou <emmanuel.milou@savoirfairelinux.com>
* Author: Alexandre Savard <alexandre.savard@savoirfairelinux.com>
* Author: Adrien Béraud <adrien.beraud@savoirfairelinux.com>
* Author: Eloi Bail <eloi.bail@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
......
......@@ -263,7 +263,7 @@ SIPAccount::newOutgoingCall(const std::string& toUrl)
const bool created = sdp.createOffer(
getActiveAccountCodecInfoList(MEDIA_AUDIO),
getActiveAccountCodecInfoList(MEDIA_VIDEO),
getActiveAccountCodecInfoList(videoEnabled_ ? MEDIA_VIDEO : MEDIA_NONE),
getSrtpKeyExchange()
);
......
......@@ -925,7 +925,7 @@ sdp_create_offer_cb(pjsip_inv_session *inv, pjmedia_sdp_session **p_offer)
localSDP.setPublishedIP(address);
const bool created = localSDP.createOffer(
account.getActiveAccountCodecInfoList(MEDIA_AUDIO),
account.getActiveAccountCodecInfoList(MEDIA_VIDEO),
account.getActiveAccountCodecInfoList(account.isVideoEnabled() ? MEDIA_VIDEO : MEDIA_NONE),
account.getSrtpKeyExchange()
);
......
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