sdp: Don't require the explicit ?multicast option

No such option is used anywhere else. Instead, detect the address type.

Originally committed as revision 25389 to svn://svn.ffmpeg.org/ffmpeg/trunk
oldabi
Martin Storsjö 15 years ago
parent 55b6bd1c01
commit 10105c9b29
  1. 27
      libavformat/sdp.c

@ -79,31 +79,35 @@ static void sdp_write_header(char *buff, int size, struct sdp_session_level *s)
} }
#if CONFIG_NETWORK #if CONFIG_NETWORK
static void resolve_destination(char *dest_addr, int size, char *type, static int resolve_destination(char *dest_addr, int size, char *type,
int type_size) int type_size)
{ {
struct addrinfo hints, *ai; struct addrinfo hints, *ai;
int is_multicast;
av_strlcpy(type, "IP4", type_size); av_strlcpy(type, "IP4", type_size);
if (!dest_addr[0]) if (!dest_addr[0])
return; return 0;
/* Resolve the destination, since it must be written /* Resolve the destination, since it must be written
* as a numeric IP address in the SDP. */ * as a numeric IP address in the SDP. */
memset(&hints, 0, sizeof(hints)); memset(&hints, 0, sizeof(hints));
if (getaddrinfo(dest_addr, NULL, &hints, &ai)) if (getaddrinfo(dest_addr, NULL, &hints, &ai))
return; return 0;
getnameinfo(ai->ai_addr, ai->ai_addrlen, dest_addr, size, getnameinfo(ai->ai_addr, ai->ai_addrlen, dest_addr, size,
NULL, 0, NI_NUMERICHOST); NULL, 0, NI_NUMERICHOST);
if (ai->ai_family == AF_INET6) if (ai->ai_family == AF_INET6)
av_strlcpy(type, "IP6", type_size); av_strlcpy(type, "IP6", type_size);
is_multicast = ff_is_multicast_address(ai->ai_addr);
freeaddrinfo(ai); freeaddrinfo(ai);
return is_multicast;
} }
#else #else
static void resolve_destination(char *dest_addr, int size, char *type, static int resolve_destination(char *dest_addr, int size, char *type,
int type_size) int type_size)
{ {
return 0;
} }
#endif #endif
@ -127,15 +131,12 @@ static int sdp_get_address(char *dest_addr, int size, int *ttl, const char *url)
p = strchr(url, '?'); p = strchr(url, '?');
if (p) { if (p) {
char buff[64]; char buff[64];
int is_multicast = find_info_tag(buff, sizeof(buff), "multicast", p);
if (is_multicast) {
if (find_info_tag(buff, sizeof(buff), "ttl", p)) { if (find_info_tag(buff, sizeof(buff), "ttl", p)) {
*ttl = strtol(buff, NULL, 10); *ttl = strtol(buff, NULL, 10);
} else { } else {
*ttl = 5; *ttl = 5;
} }
}
} }
return port; return port;
@ -465,7 +466,7 @@ int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size)
{ {
AVMetadataTag *title = av_metadata_get(ac[0]->metadata, "title", NULL, 0); AVMetadataTag *title = av_metadata_get(ac[0]->metadata, "title", NULL, 0);
struct sdp_session_level s; struct sdp_session_level s;
int i, j, port, ttl; int i, j, port, ttl, is_multicast;
char dst[32], dst_type[5]; char dst[32], dst_type[5];
memset(buff, 0, size); memset(buff, 0, size);
@ -479,7 +480,10 @@ int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size)
ttl = 0; ttl = 0;
if (n_files == 1) { if (n_files == 1) {
port = sdp_get_address(dst, sizeof(dst), &ttl, ac[0]->filename); port = sdp_get_address(dst, sizeof(dst), &ttl, ac[0]->filename);
resolve_destination(dst, sizeof(dst), dst_type, sizeof(dst_type)); is_multicast = resolve_destination(dst, sizeof(dst), dst_type,
sizeof(dst_type));
if (!is_multicast)
ttl = 0;
if (dst[0]) { if (dst[0]) {
s.dst_addr = dst; s.dst_addr = dst;
s.dst_type = dst_type; s.dst_type = dst_type;
@ -496,7 +500,10 @@ int avf_sdp_create(AVFormatContext *ac[], int n_files, char *buff, int size)
for (i = 0; i < n_files; i++) { for (i = 0; i < n_files; i++) {
if (n_files != 1) { if (n_files != 1) {
port = sdp_get_address(dst, sizeof(dst), &ttl, ac[i]->filename); port = sdp_get_address(dst, sizeof(dst), &ttl, ac[i]->filename);
resolve_destination(dst, sizeof(dst), dst_type, sizeof(dst_type)); is_multicast = resolve_destination(dst, sizeof(dst), dst_type,
sizeof(dst_type));
if (!is_multicast)
ttl = 0;
} }
for (j = 0; j < ac[i]->nb_streams; j++) { for (j = 0; j < ac[i]->nb_streams; j++) {
ff_sdp_write_media(buff, size, ff_sdp_write_media(buff, size,

Loading…
Cancel
Save