[Live-devel] Patch : Modification of Client MediaSession & Subsession to extend SDP attributes in derived class.

Eric HEURTEL eric at sound4.biz
Fri May 17 04:19:11 PDT 2013


>> I think MediaSession::initializeWithSDP() is not parsing first SDP line (which is usually v=0, though unused).
> No, that is incorrect.  The existing code works correctly, parsing all SDP lines.  You're on a 'wild goose chase'.

Perhaps I miss something, but the following spy shows that first SDP 
line is not analyzed.

      //##### We should really check for:
      // - "a=control:" attributes (to set the URL for aggregate control)
      // - the correct SDP version (v=0)
      if (sdpLine[0] == 'm') break;
+fprintf( stderr, "Parsing %.3s\n", sdpLine );

      // Check for various special SDP lines that we understand:

Anyway, I had to modify Client MediaSession & MediaSubsession classes in 
order to be able to extend SDP attributes in derived class (as I exposed 
you some weeks ago).
Here is the patch, including previous correction (is there a preferred 
way to publish code changes to fulfill the LGPL ?).

diff -r 586a4d995691 -r 9b2ceb7000ee liveMedia/MediaSession.cpp
--- a/liveMedia/MediaSession.cpp    mer. sept. 12 13:13:54 2012 +0200
+++ b/liveMedia/MediaSession.cpp    ven. mai 17 12:27:20 2013 +0200
@@ -102,25 +102,23 @@
    if (sdpDescription == NULL) return False;

    // Begin by processing all SDP lines until we see the first "m="
-  char const* sdpLine = sdpDescription;
-  char const* nextSDPLine;
+  char const* sdpLine;
+  char const* nextSDPLine = sdpDescription;
    while (1) {
+    sdpLine = nextSDPLine;
+    if (sdpLine == NULL) break; // there are no m= lines at all
      if (!parseSDPLine(sdpLine, nextSDPLine)) return False;
+
      //##### We should really check for:
      // - "a=control:" attributes (to set the URL for aggregate control)
      // - the correct SDP version (v=0)
      if (sdpLine[0] == 'm') break;
-    sdpLine = nextSDPLine;
-    if (sdpLine == NULL) break; // there are no m= lines at all

      // Check for various special SDP lines that we understand:
      if (parseSDPLine_s(sdpLine)) continue;
      if (parseSDPLine_i(sdpLine)) continue;
      if (parseSDPLine_c(sdpLine)) continue;
-    if (parseSDPAttribute_control(sdpLine)) continue;
-    if (parseSDPAttribute_range(sdpLine)) continue;
-    if (parseSDPAttribute_type(sdpLine)) continue;
-    if (parseSDPAttribute_source_filter(sdpLine)) continue;
+    if (parseSDPAttributes(sdpLine)) continue;
    }

    while (sdpLine != NULL) {
@@ -207,13 +205,7 @@
        // Check for various special SDP lines that we understand:
        if (subsession->parseSDPLine_c(sdpLine)) continue;
        if (subsession->parseSDPLine_b(sdpLine)) continue;
-      if (subsession->parseSDPAttribute_rtpmap(sdpLine)) continue;
-      if (subsession->parseSDPAttribute_control(sdpLine)) continue;
-      if (subsession->parseSDPAttribute_range(sdpLine)) continue;
-      if (subsession->parseSDPAttribute_fmtp(sdpLine)) continue;
-      if (subsession->parseSDPAttribute_source_filter(sdpLine)) continue;
-      if (subsession->parseSDPAttribute_x_dimensions(sdpLine)) continue;
-      if (subsession->parseSDPAttribute_framerate(sdpLine)) continue;
+      if (subsession->parseSDPAttributes(sdpLine)) continue;

        // (Later, check for malformed lines, and other valid SDP 
lines#####)
      }
@@ -330,6 +322,16 @@
    return False;
  }

+// new virtual method. Must be called by derived method.
+Boolean MediaSession::parseSDPAttributes(char const* sdpLine) {
+    // Check for various special SDP lines that we understand:
+    if (parseSDPAttribute_control(sdpLine)) return True;
+    if (parseSDPAttribute_range(sdpLine)) return True;
+    if (parseSDPAttribute_type(sdpLine)) return True;
+    if (parseSDPAttribute_source_filter(sdpLine)) return True;
+    return False;
+}
+
  Boolean MediaSession::parseSDPAttribute_type(char const* sdpLine) {
    // Check for a 
"a=type:broadcast|meeting|moderated|test|H.332|recvonly" line:
    Boolean parseSuccess = False;
@@ -919,6 +921,18 @@
    return sscanf(sdpLine, "b=AS:%u", &fBandwidth) == 1;
  }

+// new virtual method. Must be called by derived method.
+Boolean MediaSubsession::parseSDPAttributes(char const* sdpLine) {
+    if (parseSDPAttribute_rtpmap(sdpLine)) return True;
+    if (parseSDPAttribute_control(sdpLine)) return True;
+    if (parseSDPAttribute_range(sdpLine)) return True;
+    if (parseSDPAttribute_fmtp(sdpLine)) return True;
+    if (parseSDPAttribute_source_filter(sdpLine)) return True;
+    if (parseSDPAttribute_x_dimensions(sdpLine)) return True;
+    if (parseSDPAttribute_framerate(sdpLine)) return True;
+    return False;
+}
+
  Boolean MediaSubsession::parseSDPAttribute_rtpmap(char const* sdpLine) {
    // Check for a "a=rtpmap:<fmt> <codec>/<freq>" line:
    // (Also check without the "/<freq>"; RealNetworks omits this)
diff -r 586a4d995691 -r 9b2ceb7000ee liveMedia/include/MediaSession.hh
--- a/liveMedia/include/MediaSession.hh    mer. sept. 12 13:13:54 2012 +0200
+++ b/liveMedia/include/MediaSession.hh    ven. mai 17 12:27:20 2013 +0200
@@ -103,6 +103,7 @@
    Boolean parseSDPLine_s(char const* sdpLine);
    Boolean parseSDPLine_i(char const* sdpLine);
    Boolean parseSDPLine_c(char const* sdpLine);
+  virtual Boolean parseSDPAttributes(char const* sdpLine);
    Boolean parseSDPAttribute_type(char const* sdpLine);
    Boolean parseSDPAttribute_control(char const* sdpLine);
    Boolean parseSDPAttribute_range(char const* sdpLine);
@@ -284,6 +285,7 @@

    Boolean parseSDPLine_c(char const* sdpLine);
    Boolean parseSDPLine_b(char const* sdpLine);
+  virtual Boolean parseSDPAttributes(char const* sdpLine);
    Boolean parseSDPAttribute_rtpmap(char const* sdpLine);
    Boolean parseSDPAttribute_control(char const* sdpLine);
    Boolean parseSDPAttribute_range(char const* sdpLine);



Regards

E. HEURTEL


More information about the live-devel mailing list