]>
code.delx.au - pulseaudio/blob - src/modules/rtp/sdp.c
4 This file is part of polypaudio.
6 polypaudio is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published
8 by the Free Software Foundation; either version 2 of the License,
9 or (at your option) any later version.
11 polypaudio is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 General Public License for more details.
16 You should have received a copy of the GNU Lesser General Public License
17 along with polypaudio; if not, write to the Free Software
18 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
29 #include <sys/types.h>
30 #include <sys/socket.h>
31 #include <arpa/inet.h>
33 #include <polypcore/util.h>
37 static const char* map_format(pa_sample_format_t f
) {
39 case PA_SAMPLE_S16BE
: return "L16";
40 case PA_SAMPLE_U8
: return "L8";
41 case PA_SAMPLE_ALAW
: return "PCMA";
42 case PA_SAMPLE_ULAW
: return "PCMU";
48 char *pa_sdp_build(int af
, const void *src
, const void *dst
, const char *name
, uint16_t port
, uint8_t payload
, const pa_sample_spec
*ss
) {
50 char buf_src
[64], buf_dst
[64];
51 const char *u
, *f
, *a
;
55 assert(af
== AF_INET
|| af
== AF_INET6
);
57 f
= map_format(ss
->format
);
60 if (!(u
= getenv("USER")))
61 if (!(u
= getenv("USERNAME")))
64 ntp
= time(NULL
) + 2208988800;
66 a
= inet_ntop(af
, src
, buf_src
, sizeof(buf_src
));
68 a
= inet_ntop(af
, dst
, buf_dst
, sizeof(buf_dst
));
71 return pa_sprintf_malloc(
73 "o=%s %lu 0 IN %s %s\n"
78 "m=audio %u RTP/AVP %i\n"
79 "a=rtpmap:%i %s/%u/%u\n"
81 u
, (unsigned long) ntp
, af
== AF_INET
? "IP4" : "IP6", buf_src
,
83 af
== AF_INET
? "IP4" : "IP6", buf_dst
,
86 payload
, f
, ss
->rate
, ss
->channels
);