[FFmpeg-cvslog] r25387 - in trunk/libavformat: network.h udp.c
mstorsjo
subversion
Thu Oct 7 09:54:52 CEST 2010
Author: mstorsjo
Date: Thu Oct 7 09:54:52 2010
New Revision: 25387
Log:
Share the is_multicast_address function
The header probably isn't the right permanent place for this function, but
it is quite small, and consensus seems to be that it can stay in the
header for now, instead of creating a new file network.c just for this one.
Modified:
trunk/libavformat/network.h
trunk/libavformat/udp.c
Modified: trunk/libavformat/network.h
==============================================================================
--- trunk/libavformat/network.h Thu Oct 7 09:53:31 2010 (r25386)
+++ trunk/libavformat/network.h Thu Oct 7 09:54:52 2010 (r25387)
@@ -162,4 +162,18 @@ const char *ff_gai_strerror(int ecode);
#define IN6_IS_ADDR_MULTICAST(a) (((uint8_t *) (a))[0] == 0xff)
#endif
+static inline int ff_is_multicast_address(struct sockaddr_storage *addr)
+{
+ if (addr->ss_family == AF_INET) {
+ return IN_MULTICAST(ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr));
+ }
+#if HAVE_STRUCT_SOCKADDR_IN6
+ if (addr->ss_family == AF_INET6) {
+ return IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6 *)addr)->sin6_addr);
+ }
+#endif
+
+ return 0;
+}
+
#endif /* AVFORMAT_NETWORK_H */
Modified: trunk/libavformat/udp.c
==============================================================================
--- trunk/libavformat/udp.c Thu Oct 7 09:53:31 2010 (r25386)
+++ trunk/libavformat/udp.c Thu Oct 7 09:54:52 2010 (r25387)
@@ -177,20 +177,6 @@ static int udp_set_url(struct sockaddr_s
return addr_len;
}
-static int is_multicast_address(struct sockaddr_storage *addr)
-{
- if (addr->ss_family == AF_INET) {
- return IN_MULTICAST(ntohl(((struct sockaddr_in *)addr)->sin_addr.s_addr));
- }
-#if HAVE_STRUCT_SOCKADDR_IN6
- if (addr->ss_family == AF_INET6) {
- return IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6 *)addr)->sin6_addr);
- }
-#endif
-
- return 0;
-}
-
static int udp_socket_create(UDPContext *s,
struct sockaddr_storage *addr, int *addr_len)
{
@@ -268,7 +254,7 @@ int udp_set_remote_url(URLContext *h, co
if (s->dest_addr_len < 0) {
return AVERROR(EIO);
}
- s->is_multicast = is_multicast_address(&s->dest_addr);
+ s->is_multicast = ff_is_multicast_address(&s->dest_addr);
return 0;
}
More information about the ffmpeg-cvslog
mailing list