Commit a79172d7 authored by Andrea Gianarda's avatar Andrea Gianarda
Browse files

Fix Conditional jump or move depends on uninitialised value and improve media capabilities enum

parent 1ed9efa5
......@@ -32,7 +32,6 @@ std::ostream& operator<<(std::ostream& lhs, ConferenceMediaCapabilities e) {
case ConferenceMediaCapabilities::Audio: lhs << "Audio"; break;
case ConferenceMediaCapabilities::Video: lhs << "Video"; break;
case ConferenceMediaCapabilities::Text: lhs << "Text"; break;
case ConferenceMediaCapabilities::Count: lhs << "Count"; break;
}
return lhs;
}
......
......@@ -31,8 +31,7 @@ LINPHONE_BEGIN_NAMESPACE
enum class ConferenceMediaCapabilities {
Audio, // Audio text capabilities
Video, // Video capabilities
Text, // Text capabilities
Count // Count of media capabilities
Text // Text capabilities
};
std::ostream& operator<<(std::ostream& lhs, ConferenceMediaCapabilities e);
......
......@@ -129,7 +129,11 @@ void ParticipantDevice::setSession (std::shared_ptr<CallSession> session) {
}
LinphoneMediaDirection ParticipantDevice::getMediaDirection(const ConferenceMediaCapabilities capIdx) const {
return static_cast<LinphoneMediaDirection>(mediaCapabilities[static_cast<int>(capIdx)]);
try {
return mediaCapabilities.at(capIdx);
} catch (std::out_of_range&) {
return LinphoneMediaDirectionInactive;
}
}
LinphoneMediaDirection ParticipantDevice::getAudioDirection() const {
......@@ -145,8 +149,9 @@ LinphoneMediaDirection ParticipantDevice::getTextDirection() const {
}
bool ParticipantDevice::setMediaDirection(const LinphoneMediaDirection & direction, const ConferenceMediaCapabilities capIdx) {
if (mediaCapabilities[static_cast<int>(capIdx)] != static_cast<int>(direction)) {
mediaCapabilities[static_cast<int>(capIdx)] = static_cast<int>(direction);
const bool idxFound = (mediaCapabilities.find(capIdx) != mediaCapabilities.cend());
if (!idxFound || (mediaCapabilities[capIdx] != direction)) {
mediaCapabilities[capIdx] = direction;
return true;
}
return false;
......
......@@ -108,7 +108,7 @@ private:
State mState = State::Joining;
time_t mTimeOfJoining;
int mediaCapabilities[static_cast<int>(ConferenceMediaCapabilities::Count)];
std::map<ConferenceMediaCapabilities, LinphoneMediaDirection> mediaCapabilities;
void *mUserData = nullptr;
......
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