O'Reilly logo

Practical VoIP Using VOCAL by Luan Dang, Cullen Jennings, David Kelly

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Parsing

SIP messages arrive from the network as character strings, which the parser transforms into objects. The Vovida SIP stack uses a method called lazy parsing , which, rather than constructing all header objects at the time the parser is invoked, constructs them the first time another structure accesses them. This is explained later. Each header object takes care of parsing the corresponding header line. The SipContentDataContainer class parses the MIME data, which normally consists of an SDP message.

SIP headers are kept in SipMsg objects via the container SipRawHeaderContainer, which is a vector of a smart pointer (Sptr, explained later). SipRawHeader is a container that holds two representations of a SIP header—the raw, textual representation, as well as a pointer to a SipHeader object. The SipRawHeader class can translate between the raw and parsed forms of the headers, compare the headers, and perform other housekeeping tasks.

Figure 8-6 illustrates the method for handling To headers.

This method is known as lazy parsing, because instead of parsing the entire message before processing the data, the data for any given header is parsed from the message only after it is requested by another process. This change has made a big difference in the performance of the stack.

Lazy parsing uses smart pointers , and for those of you not familiar with these clever little fellows, let’s take a brief time-out to discuss them.

Smart pointers

While pointers are simply addresses in memory ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required