MT#59962 AmSdp: extend attribute management

Add functions for extended management:
- `addAttribute()`
- `hasAttribute()`
- `getAttribute()`
- `removeAttribute()`
- `isRejected()`

Change-Id: I4e78f9547f9309074cdb75c1493a75d2f97a9a02
mr13.5
Donat Zenichev 1 year ago
parent 37657414b1
commit 54f55d449c

@ -202,6 +202,10 @@ bool SdpMedia::operator == (const SdpMedia& other) const
&& send == other.send && recv == other.recv;
}
bool SdpMedia::isRejected() const {
return port == 0;
}
//
// class RtcpAddress: Methods
//
@ -610,6 +614,49 @@ void SdpMedia::calcAnswer(const AmPayloadProvider* payload_prov,
}
}
void SdpMedia::addAttribute(SdpAttribute attr)
{
attributes.push_back(attr);
}
bool SdpMedia::removeAttribute(const string& name)
{
int match=0;
for (vector<SdpAttribute>::iterator it = attributes.begin();
it != attributes.end(); ++it)
{
if (it->attribute == name) {
match++;
attributes.erase(it++);
if (it == attributes.end())
return match > 0;
}
}
return match > 0;
}
bool SdpMedia::hasAttribute(const string& name) const
{
for (vector<SdpAttribute>::const_iterator it = attributes.begin();
it!=attributes.end(); ++it)
if (it->attribute == name)
return true;
return false; /* Not found */
}
string SdpMedia::getAttribute(const string& name)
{
for (vector<SdpAttribute>::const_iterator it = attributes.begin();
it!=attributes.end(); ++it)
if (it->attribute == name)
return it->value;
return string(); /* Not found */
}
/**
* SDP body parser
*

@ -229,6 +229,17 @@ struct SdpMedia
/**
* Attribute management
*/
void addAttribute(SdpAttribute att);
bool hasAttribute(const string& name) const;
string getAttribute(const string& name);
/**
* Remove attribute
*/
bool removeAttribute(const string& name);
bool isRejected() const;
bool isAudio() const { return type == MT_AUDIO; }
};

Loading…
Cancel
Save