X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fstream_output%2Fsdp.c;h=d2c0610655df1ac88588dc4120ba48bdf1fcebca;hb=0f2036ebeb3150b063a0001935d7d60440cea368;hp=02ba40ba180e24943c29b6dddd393608e75fa67e;hpb=bc650c59ca6d2edbf555dc0cec11091f274b42f5;p=vlc diff --git a/src/stream_output/sdp.c b/src/stream_output/sdp.c index 02ba40ba18..d2c0610655 100644 --- a/src/stream_output/sdp.c +++ b/src/stream_output/sdp.c @@ -19,8 +19,13 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA. *****************************************************************************/ -#include +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include #include #include #include @@ -74,18 +79,19 @@ char *AddressToSDP (const struct sockaddr *addr, socklen_t addrlen, char *buf) } -static vlc_bool_t IsSDPString (const char *str) +static bool IsSDPString (const char *str) { if (strchr (str, '\r') != NULL) - return VLC_FALSE; + return false; if (strchr (str, '\n') != NULL) - return VLC_FALSE; + return false; if (!IsUTF8 (str)) - return VLC_FALSE; - return VLC_TRUE; + return false; + return true; } +static char *sdp_Start (const char *name, const char *description, const char *url, const char *email, const char *phone, const struct sockaddr *src, size_t srclen, @@ -126,7 +132,7 @@ char *sdp_Start (const char *name, const char *description, const char *url, } if (asprintf (&sdp, "v=0" - "\r\no=- "I64Fu" "I64Fu" IN IP%c %s" + "\r\no=- %"PRIu64" %"PRIu64" IN IP%c %s" "\r\ns=%s" "\r\ni=%s" "%s%s" // optional URL @@ -203,8 +209,9 @@ char *sdp_AddAttribute (char **sdp, const char *name, const char *fmt, ...) char *sdp_AddMedia (char **sdp, const char *type, const char *protocol, int dport, - unsigned pt, vlc_bool_t bw_indep, unsigned bw, - const char *rtpmap, const char *fmtp) + unsigned pt, bool bw_indep, unsigned bw, + const char *ptname, unsigned clock, unsigned chans, + const char *fmtp) { char *newsdp, *ptr; size_t inlen = strlen (*sdp), outlen = inlen; @@ -236,8 +243,14 @@ char *sdp_AddMedia (char **sdp, ptr += sprintf (ptr, "b=RR:0\r\n"); /* RTP payload type map */ - if (rtpmap != NULL) - sdp_AddAttribute (sdp, "rtpmap", "%u %s", pt, rtpmap); + if (ptname != NULL) + { + if ((strcmp (type, "audio") == 0) && (chans != 1)) + sdp_AddAttribute (sdp, "rtpmap", "%u %s/%u/%u", pt, ptname, clock, + chans); + else + sdp_AddAttribute (sdp, "rtpmap", "%u %s/%u", pt, ptname, clock); + } /* Format parameters */ if (fmtp != NULL) sdp_AddAttribute (sdp, "fmtp", "%u %s", pt, fmtp); @@ -257,10 +270,6 @@ char *vlc_sdp_Start (vlc_object_t *obj, const char *cfgpref, char varname[cfglen + sizeof ("description")], *subvar = varname + cfglen; strcpy (varname, cfgpref); - session_descriptor_t *p_session = calloc (1, sizeof (*p_session)); - if (p_session == NULL) - return NULL; - strcpy (subvar, "name"); char *name = var_GetNonEmptyString (obj, varname); strcpy (subvar, "description"); @@ -271,10 +280,6 @@ char *vlc_sdp_Start (vlc_object_t *obj, const char *cfgpref, char *email = var_GetNonEmptyString (obj, varname); strcpy (subvar, "phone"); char *phone = var_GetNonEmptyString (obj, varname); -#if 0 - strcpy (subvar, "group"); - char *group = var_GetNonEmptyString (obj, varname); -#endif char *sdp = sdp_Start (name, description, url, email, phone, src, srclen, addr, addrlen); @@ -284,5 +289,17 @@ char *vlc_sdp_Start (vlc_object_t *obj, const char *cfgpref, free (email); free (phone); + if (sdp == NULL) + return NULL; + + /* Totally non-standard */ + strcpy (subvar, "group"); + char *group = var_GetNonEmptyString (obj, varname); + if (group != NULL) + { + sdp_AddAttribute (&sdp, "x-plgroup", "%s", group); + free (group); + } + return sdp; }