[MPlayer-cvslog] r19324 - in trunk/stream: Makefile rtp.c rtp.h stream_rtp.c stream_udp.c udp.c udp.h
Michael Niedermayer
michaelni at gmx.at
Sat Aug 5 15:56:35 CEST 2006
Hi
On Fri, Aug 04, 2006 at 09:31:54PM +0200, ben wrote:
> Author: ben
> Date: Fri Aug 4 21:31:53 2006
> New Revision: 19324
>
> Added:
> trunk/stream/udp.c
> trunk/stream/udp.h
> Modified:
> trunk/stream/Makefile
> trunk/stream/rtp.c
> trunk/stream/rtp.h
> trunk/stream/stream_rtp.c
> trunk/stream/stream_udp.c
>
> Log:
> removed udp socket creation code from rtp stack to a new dedicated udp helper file
[...]
> -// Start listening on a UDP port. If multicast, join the group.
> -int rtp_open_socket( URL_t *url ) {
> - int socket_server_fd, rxsockbufsz;
> - int err, err_len;
> - fd_set set;
> - struct sockaddr_in server_address;
> - struct ip_mreq mcast;
> - struct timeval tv;
> - struct hostent *hp;
> -
> - mp_msg(MSGT_NETWORK,MSGL_V,"Listening for traffic on %s:%d ...\n", url->hostname, url->port );
> -
> - socket_server_fd = socket(AF_INET, SOCK_DGRAM, 0);
> -// fcntl( socket_server_fd, F_SETFL, fcntl(socket_server_fd, F_GETFL) | O_NONBLOCK );
> - if( socket_server_fd==-1 ) {
> - mp_msg(MSGT_NETWORK,MSGL_ERR,"Failed to create socket\n");
> - return -1;
> - }
> -
> - if( isalpha(url->hostname[0]) ) {
[...]
> +/* Start listening on a UDP port. If multicast, join the group. */
> +int
> +udp_open_socket (URL_t *url)
> +{
> + int socket_server_fd, rxsockbufsz;
> + int err, err_len;
> + fd_set set;
> + struct sockaddr_in server_address;
> + struct ip_mreq mcast;
> + struct timeval tv;
> + struct hostent *hp;
> +
> + mp_msg (MSGT_NETWORK, MSGL_V,
> + "Listening for traffic on %s:%d ...\n", url->hostname, url->port);
> +
> + socket_server_fd = socket (AF_INET, SOCK_DGRAM, 0);
> + if (socket_server_fd == -1)
> + {
> + mp_msg (MSGT_NETWORK, MSGL_ERR, "Failed to create socket\n");
> + return -1;
> + }
> +
> + if (isalpha (url->hostname[0]))
> + {
reformatting, and IMHO the original was much more readable though thats just
my oppinion nothing more or less
[...]
[...]
> + unsigned int addr = inet_addr (url->hostname);
> + memcpy ((void *) &server_address.sin_addr, (void *) &addr, sizeof (addr));
why not
server_address.sin_addr.s_addr= addr;
and what are the casts good for?
furthermore sin_addr is a struct containing a uint32_t here while
you copy a sizeof(int) into it this doenst look too good IMO
and no i did not review the whole just scrolled through it ...
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
In the past you could go to a library and read, borrow or copy any book
Today you'd get arrested for mere telling someone where the library is
More information about the MPlayer-cvslog
mailing list