Changeset f96ceadbc5389594d67706c1688d70100fa4fc8b
- Timestamp:
- 08/21/07 19:31:09 (1 year ago)
- git-parent:
- Files:
-
- src/stream_output/sdp.c (modified) (1 diff)
- src/stream_output/stream_output.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
src/stream_output/sdp.c
r6d479b5 rf96cead 158 158 159 159 160 char *vAddSDPMedia (const char *type, int dport, const char *protocol, 160 char *vAddSDPMedia (char **sdp, 161 const char *type, int dport, const char *protocol, 161 162 unsigned pt, const char *rtpmap, 162 163 const char *fmtpfmt, va_list ap) 163 164 { 164 char *sdp_media = NULL; 165 char *newsdp, *ptr; 166 size_t inlen = strlen (*sdp), outlen = inlen; 165 167 166 168 /* Some default values */ 167 169 if (type == NULL) 168 170 type = "video"; 169 if (dport == 0)170 dport = 9;171 171 if (protocol == NULL) 172 172 protocol = "RTP/AVP"; 173 173 assert (pt < 128u); 174 174 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 175 180 /* RTP payload type map */ 176 char sdp_rtpmap[rtpmap ? (sizeof ("a=rtpmap:123 *\r\n") + strlen (rtpmap)) : 1];177 181 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); 181 183 182 184 /* 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 212 char *AddSDPMedia (char **sdp, const char *type, int dport, const char *proto, 213 unsigned pt, const char *rtpmap, const char *fmtpfmt, ...) 208 214 { 209 215 va_list ap; 210 216 char *ret; 217 211 218 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); 213 220 va_end (ap); 221 214 222 return ret; 215 223 } src/stream_output/stream_output.h
r6d479b5 rf96cead 123 123 const struct sockaddr *addr, socklen_t addrlen); 124 124 125 char *vAddSDPMedia (c onst char *type, int dport, const char *protocol,125 char *vAddSDPMedia (char **sdp, const char *type, int dport, const char *prot, 126 126 unsigned pt, const char *rtpmap, 127 127 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, ...); 128 char *AddSDPMedia (char **sdp, const char *type, int dport, const char *proto, 129 unsigned pt, const char *rtpmap, const char *fmtpfmt, ...); 131 130 132 131 #endif
