[vlc-devel] commit: Recognize supported media type for SDP from SAP, not only from files ( Rémi Denis-Courmont )

git version control git at videolan.org
Sat Feb 28 19:15:36 CET 2009


vlc | branch: 0.9-bugfix | Rémi Denis-Courmont <remi at remlab.net> | Sat Feb 28 20:11:54 2009 +0200| [012818b0712338786626c8d6b1b3c9ebdba55d26] | committer: Rémi Denis-Courmont 

Recognize supported media type for SDP from SAP, not only from files
(cherry picked from commit 58469fdae05a8fb3ee5ab7fca330f7e0d520ca99)

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=012818b0712338786626c8d6b1b3c9ebdba55d26
---

 modules/services_discovery/sap.c |   36 +++++++++++++++++++-----------------
 1 files changed, 19 insertions(+), 17 deletions(-)

diff --git a/modules/services_discovery/sap.c b/modules/services_discovery/sap.c
index 26a9dc1..f7a8261 100644
--- a/modules/services_discovery/sap.c
+++ b/modules/services_discovery/sap.c
@@ -287,6 +287,22 @@ static inline int min_int( int a, int b )
     return a > b ? b : a;
 }
 
+static bool IsWellKnownPayload (int type)
+{
+    switch (type)
+    {   /* Should be in sync with modules/demux/rtp.c */
+        case  0: /* PCMU/8000 */
+        case  8: /* PCMA/8000 */
+        case 10: /* L16/44100/2 */
+        case 11: /* L16/44100 */
+        case 14: /* MPA/90000 */
+        case 32: /* MPV/90000 */
+        case 33: /* MP2/90000 */
+            return true;
+   }
+   return false;
+}
+
 /*****************************************************************************
  * Open: initialize and create stuff
  *****************************************************************************/
@@ -394,19 +410,8 @@ static int OpenDemux( vlc_object_t *p_this )
     {
         p_sdp->psz_uri = NULL;
     }
-    switch (p_sdp->i_media_type)
-    {   /* Should be in sync with modules/demux/rtp.c */
-        case  0: /* PCMU/8000 */
-        case  8: /* PCMA/8000 */
-        case 10: /* L16/44100/2 */
-        case 11: /* L16/44100 */
-        case 14: /* MPA/90000 */
-        case 32: /* MPV/90000 */
-        case 33: /* MP2/90000 */
-            break;
-        default:
-            goto error;
-    }
+    if (!IsWellKnownPayload (p_sdp->i_media_type))
+        goto error;
     if( p_sdp->psz_uri == NULL ) goto error;
 
     p_demux->p_sys = (demux_sys_t *)malloc( sizeof(demux_sys_t) );
@@ -780,10 +785,7 @@ static int ParseSAP( services_discovery_t *p_sd, const uint8_t *buf,
         p_sdp->psz_uri = NULL;
 
     /* Multi-media or no-parse -> pass to LIVE.COM */
-    if( ( p_sdp->i_media_type != 14
-       && p_sdp->i_media_type != 32
-       && p_sdp->i_media_type != 33)
-     || p_sd->p_sys->b_parse == false )
+    if( !IsWellKnownPayload( p_sdp->i_media_type ) || !p_sd->p_sys->b_parse )
     {
         free( p_sdp->psz_uri );
         if (asprintf( &p_sdp->psz_uri, "sdp://%s", p_sdp->psz_sdp ) == -1)




More information about the vlc-devel mailing list