Changeset 08cb8e62e928457d00602f9b96cb8c4755a74305

Show
Ignore:
Timestamp:
10/02/07 09:50:47 (2 years ago)
Author:
Rémi Denis-Courmont <rem@videolan.org>
git-committer:
Rémi Denis-Courmont <rem@videolan.org> 1171097447 +0000
git-parent:

[2f9e4e4c1287a4fd7b92c244332c35c33ad28fc8]

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

Add support for session description

Files:

Legend:

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

    rcaf669c r08cb8e6  
    2222 *****************************************************************************/ 
    2323 
    24 # include <vlc/vlc.h> 
     24#include <vlc/vlc.h> 
    2525 
    26 # include <string.h> 
    27 # include <vlc_network.h> 
    28 # include <vlc_charset.h> 
     26#include <string.h> 
     27#include <vlc_network.h> 
     28#include <vlc_charset.h> 
    2929 
    30 # include "stream_output.h" 
     30#include "stream_output.h" 
    3131 
    32 # define MAXSDPADDRESS 47 
     32#define MAXSDPADDRESS 47 
    3333 
    3434static 
     
    6969 
    7070 
    71 char *StartSDP (const char *name, 
     71static vlc_bool_t IsSDPString (const char *str) 
     72
     73    if (strchr (str, '\r') != NULL) 
     74        return VLC_FALSE; 
     75    if (strchr (str, '\n') != NULL) 
     76        return VLC_FALSE; 
     77    if (!IsUTF8 (str)) 
     78        return VLC_FALSE; 
     79    return VLC_TRUE; 
     80
     81 
     82 
     83char *StartSDP (const char *name, const char *description, const char *url, 
     84                const char *email, const char *phone, 
    7285                const struct sockaddr *orig, socklen_t origlen, 
    7386                const struct sockaddr *addr, socklen_t addrlen) 
     
    7588    uint64_t t = NTPtime64 (); 
    7689    char *sdp, machine[MAXSDPADDRESS], conn[MAXSDPADDRESS]; 
     90    const char *preurl = "\r\nu=", *premail = "\r\ne=", *prephone = "\r\np="; 
    7791 
    78     if (strchr (name, '\r') || strchr (name, '\n') || !IsUTF8 (name) 
     92    if (name == NULL) 
     93        name = "Unnamed"; 
     94    if (description == NULL) 
     95        description = "N/A"; 
     96    if (url == NULL) 
     97        preurl = url = ""; 
     98    if (email == NULL) 
     99        premail = email = ""; 
     100    if (phone == NULL) 
     101        prephone = phone = ""; 
     102 
     103    if (!IsSDPString (name) || !IsSDPString (description) 
     104     || !IsSDPString (url) || !IsSDPString (email) || !IsSDPString (phone) 
    79105     || (AddressToSDP ((struct sockaddr *)&orig, origlen, machine) == NULL) 
    80106     || (AddressToSDP ((struct sockaddr *)&addr, addrlen, conn) == NULL)) 
    81107        return NULL; 
    82108 
    83     if (asprintf (&sdp, "v=0\r\n" 
    84                         "o=- "I64Fu" "I64Fu" %s\r\n" 
    85                         "s=%s\r\n" 
    86                         "i=N/A\r\n" // must be there even if useless 
    87                         // no URL, email and phone here */ 
    88                         "c=%s\r\n" 
     109    if (asprintf (&sdp, "v=0" 
     110                    "\r\no=- "I64Fu" "I64Fu" %s" 
     111                    "\r\ns=%s" 
     112                    "\r\ni=%s" 
     113                    "%s%s" // optional URL 
     114                    "%s%s" // optional email 
     115                    "%s%s" // optional phone number 
     116                    "\r\nc=%s" 
    89117                        // bandwidth not specified 
    90                         "t= 0 0" // one dummy time span 
     118                    "\r\nt= 0 0" // one dummy time span 
    91119                        // no repeating 
    92120                        // no time zone adjustment (silly idea anyway) 
    93121                        // no encryption key (deprecated) 
    94                         "a=tool:"PACKAGE_STRING"\r\n" 
    95                         "a=recvonly\r\n" 
    96                         "a=type:broadcast\r\n" 
    97                         "a=charset:UTF-8\r\n", 
     122                    "\r\na=tool:"PACKAGE_STRING 
     123                    "\r\na=recvonly" 
     124                    "\r\na=type:broadcast" 
     125                    "\r\na=charset:UTF-8" 
     126                    "\r\n", 
    98127               /* o= */ t, t, machine, 
    99128               /* s= */ name, 
     129               /* i= */ description, 
     130               /* u= */ preurl, url, 
     131               /* e= */ premail, email, 
     132               /* p= */ prephone, phone, 
    100133               /* c= */ conn) == -1) 
    101134        return NULL; 
  • src/stream_output/stream_output.h

    r0336f13 r08cb8e6  
    9191void announce_SAPHandlerDestroy( sap_handler_t *p_sap ); 
    9292 
    93 char *StartSDP (const char *name, 
     93char *StartSDP (const char *name, const char *description, const char *url, 
     94                const char *email, const char *phone, 
    9495                const struct sockaddr *orig, socklen_t origlen, 
    9596                const struct sockaddr *addr, socklen_t addrlen);