/* * Copyright (c) 2012 Yoann Blein * Licensed under the simplified BSD license. * See Documentation/Licenses/BSD-simplified.txt for more information. */ #include "RTPPayloadTypeParser.h" #include #include #include namespace Swift { RTPPayloadTypeParser::RTPPayloadTypeParser() : level(0) { } void RTPPayloadTypeParser::handleStartElement(const std::string& element, const std::string&, const AttributeMap& attributes) { if (level == 0) { // channels try { getPayloadInternal()->setChannels(boost::lexical_cast(attributes.getAttributeValue("channels").get_value_or("1"))); } catch (boost::bad_lexical_cast &) { getPayloadInternal()->setChannels(1); } // clockrate try { getPayloadInternal()->setClockrate(boost::lexical_cast(attributes.getAttributeValue("clockrate").get_value_or("0"))); } catch (boost::bad_lexical_cast &) { getPayloadInternal()->setClockrate(0); } // ID try { getPayloadInternal()->setID(boost::numeric_cast(boost::lexical_cast(attributes.getAttributeValue("id").get_value_or("0")))); } catch (boost::bad_lexical_cast &) { getPayloadInternal()->setID(151); } // maxptime try { getPayloadInternal()->setMaxptime(boost::lexical_cast(attributes.getAttributeValue("maxptime").get_value_or("0"))); } catch (boost::bad_lexical_cast &) { getPayloadInternal()->setMaxptime(0); } // name getPayloadInternal()->setName(attributes.getAttributeValue("name").get_value_or("")); // ptime try { getPayloadInternal()->setPTime(boost::lexical_cast(attributes.getAttributeValue("ptime").get_value_or("0"))); } catch (boost::bad_lexical_cast &) { getPayloadInternal()->setPTime(0); } } else if (level == 1 && element == "parameter") { getPayloadInternal()->addParameter(attributes.getAttributeValue("name").get_value_or(""), attributes.getAttributeValue("value").get_value_or("")); } ++level; } void RTPPayloadTypeParser::handleEndElement(const std::string&, const std::string&) { --level; } }