Mercurial > mplayer.hg
comparison libmpdemux/network.c @ 4553:bab3aac84143
ehh. i forgot to commit this patch: fix RTP streaming. patch by Dave Chapman <dave@dchapman.com>
author | arpi |
---|---|
date | Wed, 06 Feb 2002 20:30:34 +0000 |
parents | 9f12fd5f47d0 |
children | 17cf55182029 |
comparison
equal
deleted
inserted
replaced
4552:46ccfbb41f9c | 4553:bab3aac84143 |
---|---|
95 read_rtp_from_server(int fd, char *buffer, int length) { | 95 read_rtp_from_server(int fd, char *buffer, int length) { |
96 struct rtpheader rh; | 96 struct rtpheader rh; |
97 char *data; | 97 char *data; |
98 int len; | 98 int len; |
99 static int got_first = 0; | 99 static int got_first = 0; |
100 static int sequence; | 100 static unsigned short sequence; |
101 | 101 |
102 if( buffer==NULL || length<0 ) return -1; | 102 if( buffer==NULL || length<0 ) return -1; |
103 | 103 |
104 getrtp2(fd, &rh, &data, &len); | 104 getrtp2(fd, &rh, &data, &len); |
105 if( got_first && rh.b.sequence != sequence+1 ) | 105 if( got_first && rh.b.sequence != (unsigned short)(sequence+1) ) |
106 printf("RTP packet sequence error! Expected: %d, received: %d\n", | 106 printf("RTP packet sequence error! Expected: %d, received: %d\n", |
107 sequence+1, rh.b.sequence); | 107 sequence+1, rh.b.sequence); |
108 got_first = 1; | 108 got_first = 1; |
109 sequence = rh.b.sequence; | 109 sequence = rh.b.sequence; |
110 memcpy(buffer, data, len); | 110 memcpy(buffer, data, len); |
364 if( !strcasecmp(url->protocol, "rtp") ) { | 364 if( !strcasecmp(url->protocol, "rtp") ) { |
365 if( url->port==0 ) { | 365 if( url->port==0 ) { |
366 printf("You must enter a port number for RTP streams!\n"); | 366 printf("You must enter a port number for RTP streams!\n"); |
367 return -1; | 367 return -1; |
368 } | 368 } |
369 return -1; | 369 return 0; |
370 } | 370 } |
371 | 371 |
372 // Checking for ASF | 372 // Checking for ASF |
373 if( !strncasecmp(url->protocol, "mms", 3) ) { | 373 if( !strncasecmp(url->protocol, "mms", 3) ) { |
374 *file_format = DEMUXER_TYPE_ASF; | 374 *file_format = DEMUXER_TYPE_ASF; |
560 int socket_server_fd, rxsockbufsz; | 560 int socket_server_fd, rxsockbufsz; |
561 int err, err_len; | 561 int err, err_len; |
562 fd_set set; | 562 fd_set set; |
563 struct sockaddr_in server_address; | 563 struct sockaddr_in server_address; |
564 struct ip_mreq mcast; | 564 struct ip_mreq mcast; |
565 struct timeval tv; | |
565 | 566 |
566 printf("Listening for traffic on %s:%d ...\n", url->hostname, url->port ); | 567 printf("Listening for traffic on %s:%d ...\n", url->hostname, url->port ); |
567 | 568 |
568 socket_server_fd = socket(AF_INET, SOCK_DGRAM, 0); | 569 socket_server_fd = socket(AF_INET, SOCK_DGRAM, 0); |
569 // fcntl( socket_server_fd, F_SETFL, fcntl(socket_server_fd, F_GETFL) | O_NONBLOCK ); | 570 // fcntl( socket_server_fd, F_SETFL, fcntl(socket_server_fd, F_GETFL) | O_NONBLOCK ); |
607 perror("IP_ADD_MEMBERSHIP failed (do you have multicasting enabled in your kernel?)"); | 608 perror("IP_ADD_MEMBERSHIP failed (do you have multicasting enabled in your kernel?)"); |
608 return -1; | 609 return -1; |
609 } | 610 } |
610 } | 611 } |
611 | 612 |
612 //tv.tv_sec = 0; | 613 tv.tv_sec = 0; |
613 //tv.tv_usec = (10 * 1000000); // 10 seconds timeout | 614 tv.tv_usec = (1 * 1000000); // 1 second timeout |
614 FD_ZERO( &set ); | 615 FD_ZERO( &set ); |
615 FD_SET( socket_server_fd, &set ); | 616 FD_SET( socket_server_fd, &set ); |
616 //if( select(socket_server_fd+1, &set, NULL, NULL, &tv)>0 ) { | 617 if( select(socket_server_fd+1, &set, NULL, NULL, &tv)>0 ) { |
617 if( select(socket_server_fd+1, &set, NULL, NULL, NULL)>0 ) { | 618 //if( select(socket_server_fd+1, &set, NULL, NULL, NULL)>0 ) { |
618 err_len = sizeof( err ); | 619 err_len = sizeof( err ); |
619 getsockopt( socket_server_fd, SOL_SOCKET, SO_ERROR, &err, &err_len ); | 620 getsockopt( socket_server_fd, SOL_SOCKET, SO_ERROR, &err, &err_len ); |
620 if( err ) { | 621 if( err ) { |
621 printf("Timeout! No data from host %s\n", url->hostname ); | 622 printf("Timeout! No data from host %s\n", url->hostname ); |
622 printf("Socket error: %d\n", err ); | 623 printf("Socket error: %d\n", err ); |