Changeset f96ceadbc5389594d67706c1688d70100fa4fc8b

Show
Ignore:
Timestamp:
08/21/07 19:31:09 (1 year ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1187717469 +0000
git-parent:

[6d479b506f0a614d42d75f1389dce6d911bcf492]

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

Append media description to the SDP, as the name suggest

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • src/stream_output/sdp.c

    r6d479b5 rf96cead  
    158158 
    159159 
    160 char *vAddSDPMedia (const char *type, int dport, const char *protocol, 
     160char *vAddSDPMedia (char **sdp, 
     161                    const char *type, int dport, const char *protocol, 
    161162                    unsigned pt, const char *rtpmap, 
    162163                    const char *fmtpfmt, va_list ap) 
    163164{ 
    164     char *sdp_media = NULL; 
     165    char *newsdp, *ptr; 
     166    size_t inlen = strlen (*sdp), outlen = inlen; 
    165167 
    166168    /* Some default values */ 
    167169    if (type == NULL) 
    168170        type = "video"; 
    169     if (dport == 0) 
    170         dport = 9; 
    171171    if (protocol == NULL) 
    172172        protocol = "RTP/AVP"; 
    173173    assert (pt < 128u); 
    174174 
     175    outlen += snprintf (NULL, 0, 
     176                        "m=%s %u %s %d\r\n" 
     177                        "b=RR:0\r\n", 
     178                        type, dport, protocol, pt); 
     179 
    175180    /* RTP payload type map */ 
    176     char sdp_rtpmap[rtpmap ? (sizeof ("a=rtpmap:123 *\r\n") + strlen (rtpmap)) : 1]; 
    177181    if (rtpmap != NULL) 
    178         sprintf (sdp_rtpmap, "a=rtpmap:%u %s\r\n", pt, rtpmap); 
    179     else 
    180         *sdp_rtpmap = '\0'; 
     182        outlen += snprintf (NULL, 0, "a=rtpmap:%u %s\r\n", pt, rtpmap); 
    181183 
    182184    /* Format parameters */ 
    183     char *fmtp = NULL; 
    184     if ((fmtpfmt != NULL) 
    185      && (vasprintf (&fmtp, fmtpfmt, ap) == -1)) 
    186         return NULL; 
    187  
    188     char sdp_fmtp[fmtp ? (sizeof ("a=fmtp:123 *\r\n") + strlen (fmtp)) : 1]; 
    189     if (fmtp != NULL) 
    190     { 
    191         sprintf (sdp_fmtp, "a=fmtp:%u %s\r\n", pt, fmtp); 
    192         free (fmtp); 
    193     } 
    194     else 
    195         *sdp_fmtp = '\0'; 
    196  
    197     if (asprintf (&sdp_media, "m=%s %u %s %d\r\n" "b=RR:0\r\n" "%s" "%s", 
    198                   type, dport, protocol, pt, 
    199                   sdp_rtpmap, sdp_fmtp) == -1) 
    200         return NULL; 
    201  
    202     return sdp_media; 
    203 
    204  
    205  
    206 char *AddSDPMedia (const char *type, int dport, const char *protocol, 
    207                     unsigned pt, const char *rtpmap, const char *fmtpfmt, ...) 
     185    if (fmtpfmt != NULL) 
     186    { 
     187        outlen += sizeof ("a=fmtp:123 *\r\n"); 
     188        outlen += vsnprintf (NULL, 0, fmtpfmt, ap); 
     189    } 
     190 
     191    newsdp = realloc (*sdp, outlen + 1); 
     192    if (newsdp == NULL) 
     193        return NULL; 
     194 
     195    *sdp = newsdp; 
     196    ptr = newsdp + inlen; 
     197 
     198    /* RTP payload type map */ 
     199    ptr += sprintf (ptr, "a=rtpmap:%u %s\r\n", pt, rtpmap); 
     200 
     201    /* Format parameters */ 
     202    if (fmtpfmt != NULL) 
     203    { 
     204        ptr += sprintf (ptr, "a=fmtp:%u ", pt); 
     205        ptr += vsprintf (ptr, fmtpfmt, ap); 
     206    } 
     207 
     208    return newsdp; 
     209
     210 
     211 
     212char *AddSDPMedia (char **sdp, const char *type, int dport, const char *proto, 
     213                   unsigned pt, const char *rtpmap, const char *fmtpfmt, ...) 
    208214{ 
    209215    va_list ap; 
    210216    char *ret; 
     217 
    211218    va_start (ap, fmtpfmt); 
    212     ret = vAddSDPMedia (type, dport, protocol, pt, rtpmap, fmtpfmt, ap); 
     219    ret = vAddSDPMedia (sdp, type, dport, proto, pt, rtpmap, fmtpfmt, ap); 
    213220    va_end (ap); 
     221 
    214222    return ret; 
    215223} 
  • src/stream_output/stream_output.h

    r6d479b5 rf96cead  
    123123                const struct sockaddr *addr, socklen_t addrlen); 
    124124 
    125 char *vAddSDPMedia (const char *type, int dport, const char *protocol
     125char *vAddSDPMedia (char **sdp, const char *type, int dport, const char *prot
    126126                    unsigned pt, const char *rtpmap, 
    127127                    const char *fmtpfmt, va_list ap); 
    128 char *AddSDPMedia (const char *type, int dport, 
    129                    const char *protocol, unsigned pt, const char *rtpmap, 
    130                    const char *fmtpfmt, ...); 
     128char *AddSDPMedia (char **sdp, const char *type, int dport, const char *proto, 
     129                   unsigned pt, const char *rtpmap, const char *fmtpfmt, ...); 
    131130 
    132131#endif