Changeset 13a79c4f582e9564dff23c3d74a3264d7a6e06dd

Show
Ignore:
Timestamp:
04/11/06 17:25:26 (2 years ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1162657526 +0000
git-parent:

[f30d703a6f53606e4db0344eb2a639b73a1c0ebe]

git-author:
Rémi Denis-Courmont <rem@videolan.org> 1162657526 +0000
Message:

Ignore missing TTL in c= line.
It was about time I fix VLC to accept SAP announces on my campus.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • modules/services_discovery/sap.c

    rf30d703 r13a79c4  
    666666    assert (buf[len] == '\0'); 
    667667 
    668     msg_Dbg( p_sd, "SDP:\n%s", psz_sdp ); 
    669  
    670668    /* Skip payload type */ 
    671669    /* SAPv1 has implicit "application/sdp" payload type: first line is v=0 */ 
     
    851849    char *psz_eof = NULL; 
    852850    char *psz_parse = NULL; 
    853     char *psz_uri = NULL
     851    char psz_uri[1026]
    854852    char *psz_proto = NULL; 
    855853    int i_port = 0; 
     
    858856    if( p_sdp->psz_connection ) 
    859857    { 
    860         psz_parse = p_sdp->psz_connection; 
    861  
    862         psz_eof = strchr( psz_parse, ' ' ); 
    863  
    864         if( psz_eof ) 
    865         { 
    866             *psz_eof = '\0'; 
    867             psz_parse = psz_eof + 1; 
    868         } 
     858        char hostname[1024]; 
     859        int ipv; 
     860 
     861        /* 
     862         * NOTE: we ignore the TTL parameter on-purpose, as some SAP 
     863         * advertisers don't include it (and it is utterly useless). 
     864         */ 
     865        if (sscanf (p_sdp->psz_connection, "IN IP%d %1023[^/]", &ipv, 
     866                    hostname) != 2) 
     867        { 
     868            msg_Warn (p_obj, "unable to parse c field: \"%s\"", 
     869                      p_sdp->psz_connection); 
     870            return VLC_EGENERIC; 
     871        } 
     872 
     873        switch (ipv) 
     874        { 
     875            case 4: 
     876            case 6: 
     877                break; 
     878 
     879            default: 
     880                msg_Warn (p_obj, "unknown IP version %d", ipv); 
     881                return VLC_EGENERIC; 
     882        } 
     883 
     884        if (strchr (hostname, ':') != NULL) 
     885            sprintf (psz_uri, "[%s]", hostname); 
    869886        else 
    870         { 
    871             msg_Warn( p_obj, "unable to parse c field (1)"); 
    872             return VLC_EGENERIC; 
    873         } 
    874  
    875         psz_eof = strchr( psz_parse, ' ' ); 
    876  
    877         if( psz_eof ) 
    878         { 
    879             *psz_eof = '\0'; 
    880             if( !strncmp( psz_parse, "IP4", 3 ) ) 
    881             { 
    882                 p_sdp->i_in = 4; 
    883             } 
    884             else if( !strncmp( psz_parse, "IP6", 3 ) ) 
    885             { 
    886                 p_sdp->i_in = 6; 
    887             } 
    888             else 
    889             { 
    890                 p_sdp->i_in = 0; 
    891             } 
    892             psz_parse = psz_eof + 1; 
    893         } 
    894         else 
    895         { 
    896             msg_Warn( p_obj, "unable to parse c field (2)"); 
    897             return VLC_EGENERIC; 
    898         } 
    899  
    900         psz_eof = strchr( psz_parse, '/' ); 
    901  
    902         if( psz_eof ) 
    903         { 
    904             *psz_eof = '\0'; 
    905         } 
    906         else 
    907         { 
    908             msg_Dbg( p_obj, "incorrect c field, %s", p_sdp->psz_connection ); 
    909         } 
    910         if( p_sdp->i_in == 6 && ( isxdigit( *psz_parse ) || *psz_parse == ':' ) ) 
    911         { 
    912             asprintf( &psz_uri, "[%s]", psz_parse ); 
    913         } 
    914         else psz_uri = strdup( psz_parse ); 
    915  
     887            strcpy (psz_uri, hostname); 
    916888    } 
    917889 
     
    927899            *psz_eof = '\0'; 
    928900 
    929             if( strncmp( psz_parse, "audio", 5 )  && 
    930                 strncmp( psz_parse, "video", 5 ) ) 
     901            /* 
     902             * That's ugly. We should go through every media, and make sure 
     903             * at least one of them is audio or video. In the mean time, I 
     904             * need to accept data too. 
     905             */ 
     906            if( strncmp( psz_parse, "audio", 5 ) 
     907             && strncmp( psz_parse, "video", 5 ) 
     908             && strncmp( psz_parse, "data", 4 ) ) 
    931909            { 
    932                 msg_Warn( p_obj, "unhandled media type -%s-", psz_parse ); 
    933                 FREENULL( psz_uri ); 
     910                msg_Warn( p_obj, "unhandled media type \"%s\"", psz_parse ); 
    934911                return VLC_EGENERIC; 
    935912            } 
     
    940917        { 
    941918            msg_Warn( p_obj, "unable to parse m field (1)"); 
    942             FREENULL( psz_uri ); 
    943919            return VLC_EGENERIC; 
    944920        } 
     
    963939        { 
    964940            msg_Warn( p_obj, "unable to parse m field (2)"); 
    965             FREENULL( psz_uri ); 
    966941            return VLC_EGENERIC; 
    967942        } 
     
    1023998              psz_uri, i_port ); 
    1024999 
    1025     FREENULL( psz_uri ); 
    10261000    FREENULL( psz_proto ); 
    10271001    return VLC_SUCCESS;