Author: sayer
Date: 2009-01-20 17:20:00 +0100 (Tue, 20 Jan 2009)
New Revision: 1232

Modified:
   trunk/core/AmSdp.cpp
Log:
fixed codec specific parameters parsing (fmtp), fixes SEMS-37


Modified: trunk/core/AmSdp.cpp
===================================================================
--- trunk/core/AmSdp.cpp        2009-01-20 14:54:10 UTC (rev 1231)
+++ trunk/core/AmSdp.cpp        2009-01-20 16:20:00 UTC (rev 1232)
@@ -38,6 +38,7 @@
 static char* is_eql_next(char* s);
 static char* parse_until(char* s, char end);
 static bool contains(char* s, char* next_line, char c);
+static bool is_wsp(char s);
 
 static int media_type(std::string media);
 static int transport_type(std::string transport);
@@ -153,9 +154,8 @@
   }
   
   telephone_event_pt = findPayload("telephone-event");
-  
+    
   return ret;
-  
 }
 
 int AmSdp::genResponse(const string& localip, int localport, string& out_buf, 
bool single_codec)
@@ -681,7 +681,7 @@
     case FMT:
       {
        if(contains(media_line, line_end, ' ')){
-       next = parse_until(media_line, ' ');
+         next = parse_until(media_line, ' ');
        //if(next < line_end){
          string value(media_line, int(next-media_line)-1);
          media_line = next;
@@ -803,13 +803,10 @@
              string value(attr_line, int(next-attr_line)-1);
              str2i(value, encoding_param);
              attr_line = next;
-             params += value;
-             params += ' ';
              rtpmap_st = ENC_PARAM;
            }else{
              string last_value(attr_line, int(line_end-attr_line)-1);
              str2i(last_value, encoding_param);
-             params += last_value;
              parsing = 0;
            }
            break;
@@ -835,7 +832,7 @@
       }
       
 
-    }else if(attr == "fmtp"){
+    } else if(attr == "fmtp"){
       while(parsing){
        switch(fmtp_st){
        case FORMAT:
@@ -849,26 +846,30 @@
          }
        case FORMAT_PARAM:
          { 
-           next = parse_until(attr_line, ' ');
-           if(next < line_end){
-             string value(attr_line, int(next-attr_line)-1);
-             attr_line = next;
-             params += value;
-             params += ' ';
-             fmtp_st = FORMAT_PARAM;
-           }else{
-             string last_value(attr_line, int(line_end-attr_line)-1);
-             params += last_value;
-             parsing = 0;
-           }
-           break;
-             }
+           line_end--;
+           while (is_wsp(*line_end))
+             line_end--;
+
+           params = string(attr_line, line_end-attr_line+1);
+           parsing = 0;
+         }
          break;
        }
       }
 
-      DBG("found media attr 'fmtp' type '%d'\n", payload_type);
+      DBG("found media attr 'fmtp' for payload '%d': '%s'\n", 
+         payload_type, params.c_str());
 
+      vector<SdpPayload>::iterator pl_it;
+      
+      for(pl_it=media.payloads.begin();
+          (pl_it != media.payloads.end())
+            && (pl_it->payload_type != int(payload_type));
+          pl_it++);
+
+      if(pl_it != media.payloads.end())
+       pl_it->sdp_format_parameters = params;
+
     } else if (attr == "direction") {
        next = parse_until(attr_line, '\r');
        if(next < line_end){
@@ -893,7 +894,6 @@
                " followed by cr\n");
        }
 
-
     }else{
       attr_check(attr);
       next = parse_until(attr_line, '\r');
@@ -1053,6 +1053,10 @@
   return false;
 }
 
+static bool is_wsp(char s) {
+  return s==' ' || s == '\r' || s == '\n' || s == '\t';
+}
+
 static char* parse_until(char* s, char end)
 {
   char* line=s;

_______________________________________________
Semsdev mailing list
[email protected]
http://lists.iptel.org/mailman/listinfo/semsdev

Reply via email to