diff --git a/core/AmSdp.cpp b/core/AmSdp.cpp index ccfa5a59..2171cec4 100644 --- a/core/AmSdp.cpp +++ b/core/AmSdp.cpp @@ -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::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::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::const_iterator it = attributes.begin(); + it!=attributes.end(); ++it) + if (it->attribute == name) + return it->value; + + return string(); /* Not found */ +} + /** * SDP body parser * diff --git a/core/AmSdp.h b/core/AmSdp.h index 2fca3680..1328ea4c 100644 --- a/core/AmSdp.h +++ b/core/AmSdp.h @@ -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; } };