edorse03 / sipdroid

Automatically exported from code.google.com/p/sipdroid
GNU General Public License v3.0
0 stars 0 forks source link

Incoming call with incompilable codec error! #895

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
SdpParser has a big issue that is not able to handle some packets without 
correct order list in SessionDescriptor().
For example: The packet is 
v=0\r\no=Sippy 268090472 0 IN IP4 208.65.240.142\r\ns=-\r\nt=0 0\r\nm=audio 
38040 RTP/AVP 0\r\nc=IN IP4 208.65.240.142\r\n

It will not get the media information and it will cause incoming call failed 
with "In-compilable codec error"

Fix:
Add a function to reset index in parser
    public Parser reset() {
        index = 0;
        return this;
    }
And reset the index every time when parser SDR in SessionDescriptor()

    public SessionDescriptor(String sdp) {
        SdpParser par = new SdpParser(sdp);
        // parse mandatory fields
        v = par.parseSdpField('v');
        if (v == null)
            v = new SdpField('v', "0");
        par.reset();
        o = par.parseOriginField();
        if (o == null)
            o = new OriginField("unknown");
        par.reset();
        s = par.parseSessionNameField();
        if (s == null)
            s = new SessionNameField();
        par.reset();
        c = par.parseConnectionField();
        if (c == null)
            c = new ConnectionField("IP4", "0.0.0.0");
        par.reset();
        t = par.parseTimeField();
        if (t == null)
            t = new TimeField();
        par.reset();
        while (par.hasMore()
                && (!par.startsWith("a=") && !par.startsWith("m="))) { // skip
            // unknown
            // lines..
            par.goToNextLine();
        }
        // parse session attributes
        av = new Vector<AttributeField>();
        par.reset();
        while (par.hasMore() && par.startsWith("a=")) {
......

Original issue reported on code.google.com by xiaopeng...@gmail.com on 11 Apr 2011 at 9:06

GoogleCodeExporter commented 9 years ago
From RFC:

Some lines in each description are REQUIRED and some are OPTIONAL,
   but all MUST appear in exactly the order given here (the fixed order
   greatly enhances error detection and allows for a simple parser).
   OPTIONAL items are marked with a "*".

Original comment by pmerl...@googlemail.com on 12 Apr 2011 at 9:17