Mercurial > mplayer.hg
comparison libmpdemux/network.c @ 12799:befb79b0232e
Make rtp:// cohexist with LIVE.COM
Patch by Nico Sabbi
author | rtognimp |
---|---|
date | Sun, 11 Jul 2004 22:47:49 +0000 |
parents | 6a23658331f8 |
children | 1591792d4054 |
comparison
equal
deleted
inserted
replaced
12798:33423862b159 | 12799:befb79b0232e |
---|---|
30 #include "network.h" | 30 #include "network.h" |
31 #include "http.h" | 31 #include "http.h" |
32 #include "cookies.h" | 32 #include "cookies.h" |
33 #include "url.h" | 33 #include "url.h" |
34 #include "asf.h" | 34 #include "asf.h" |
35 #ifndef STREAMING_LIVE_DOT_COM | |
36 #include "rtp.h" | 35 #include "rtp.h" |
37 #endif | |
38 #include "pnm.h" | 36 #include "pnm.h" |
39 #include "realrtsp/rtsp_session.h" | 37 #include "realrtsp/rtsp_session.h" |
40 | 38 |
41 #include "../version.h" | 39 #include "../version.h" |
42 | 40 |
147 if( streaming_ctrl->buffer ) free( streaming_ctrl->buffer ); | 145 if( streaming_ctrl->buffer ) free( streaming_ctrl->buffer ); |
148 if( streaming_ctrl->data ) free( streaming_ctrl->data ); | 146 if( streaming_ctrl->data ) free( streaming_ctrl->data ); |
149 free( streaming_ctrl ); | 147 free( streaming_ctrl ); |
150 } | 148 } |
151 | 149 |
152 #ifndef STREAMING_LIVE_DOT_COM | |
153 int | 150 int |
154 read_rtp_from_server(int fd, char *buffer, int length) { | 151 read_rtp_from_server(int fd, char *buffer, int length) { |
155 struct rtpheader rh; | 152 struct rtpheader rh; |
156 char *data; | 153 char *data; |
157 int len; | 154 int len; |
167 got_first = 1; | 164 got_first = 1; |
168 sequence = rh.b.sequence; | 165 sequence = rh.b.sequence; |
169 memcpy(buffer, data, len); | 166 memcpy(buffer, data, len); |
170 return(len); | 167 return(len); |
171 } | 168 } |
172 #endif | |
173 | 169 |
174 | 170 |
175 // Converts an address family constant to a string | 171 // Converts an address family constant to a string |
176 | 172 |
177 char *af2String(int af) { | 173 char *af2String(int af) { |
702 mp_msg(MSGT_NETWORK,MSGL_ERR,"SIP support requires the \"LIVE.COM Streaming Media\" libraries!\n"); | 698 mp_msg(MSGT_NETWORK,MSGL_ERR,"SIP support requires the \"LIVE.COM Streaming Media\" libraries!\n"); |
703 return -1; | 699 return -1; |
704 #endif | 700 #endif |
705 } | 701 } |
706 | 702 |
707 #ifndef STREAMING_LIVE_DOT_COM | 703 // Old, hacked RTP support, which works for MPEG Streams |
708 // Old, hacked RTP support, which works for MPEG Program Streams | |
709 // RTP streams only: | 704 // RTP streams only: |
710 // Checking for RTP | 705 // Checking for RTP |
711 if( !strcasecmp(url->protocol, "rtp") ) { | 706 if( !strcasecmp(url->protocol, "rtp") ) { |
712 if( url->port==0 ) { | 707 if( url->port==0 ) { |
713 mp_msg(MSGT_NETWORK,MSGL_ERR,"You must enter a port number for RTP streams!\n"); | 708 mp_msg(MSGT_NETWORK,MSGL_ERR,"You must enter a port number for RTP streams!\n"); |
714 return -1; | 709 return -1; |
715 } | 710 } |
716 return 0; | 711 return 0; |
717 } | 712 } |
718 #endif | |
719 | 713 |
720 // Checking for ASF | 714 // Checking for ASF |
721 if( !strncasecmp(url->protocol, "mms", 3) ) { | 715 if( !strncasecmp(url->protocol, "mms", 3) ) { |
722 *file_format = DEMUXER_TYPE_ASF; | 716 *file_format = DEMUXER_TYPE_ASF; |
723 return 0; | 717 return 0; |
1073 stream->streaming_ctrl->status = streaming_playing_e; | 1067 stream->streaming_ctrl->status = streaming_playing_e; |
1074 return 0; | 1068 return 0; |
1075 } | 1069 } |
1076 | 1070 |
1077 | 1071 |
1078 #ifndef STREAMING_LIVE_DOT_COM | |
1079 // Start listening on a UDP port. If multicast, join the group. | 1072 // Start listening on a UDP port. If multicast, join the group. |
1080 int | 1073 static int |
1081 rtp_open_socket( URL_t *url ) { | 1074 rtp_open_socket( URL_t *url ) { |
1082 int socket_server_fd, rxsockbufsz; | 1075 int socket_server_fd, rxsockbufsz; |
1083 int err, err_len; | 1076 int err, err_len; |
1084 fd_set set; | 1077 fd_set set; |
1085 struct sockaddr_in server_address; | 1078 struct sockaddr_in server_address; |
1179 } | 1172 } |
1180 } | 1173 } |
1181 return socket_server_fd; | 1174 return socket_server_fd; |
1182 } | 1175 } |
1183 | 1176 |
1184 int | 1177 static int |
1185 rtp_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *streaming_ctrl ) { | 1178 rtp_streaming_read( int fd, char *buffer, int size, streaming_ctrl_t *streaming_ctrl ) { |
1186 return read_rtp_from_server( fd, buffer, size ); | 1179 return read_rtp_from_server( fd, buffer, size ); |
1187 } | 1180 } |
1188 | 1181 |
1189 int | 1182 static int |
1190 rtp_streaming_start( stream_t *stream ) { | 1183 rtp_streaming_start( stream_t *stream ) { |
1191 streaming_ctrl_t *streaming_ctrl; | 1184 streaming_ctrl_t *streaming_ctrl; |
1192 int fd; | 1185 int fd; |
1193 | 1186 |
1194 if( stream==NULL ) return -1; | 1187 if( stream==NULL ) return -1; |
1206 streaming_ctrl->prebuffer_size = 64*1024; // 64 KBytes | 1199 streaming_ctrl->prebuffer_size = 64*1024; // 64 KBytes |
1207 streaming_ctrl->buffering = 0; | 1200 streaming_ctrl->buffering = 0; |
1208 streaming_ctrl->status = streaming_playing_e; | 1201 streaming_ctrl->status = streaming_playing_e; |
1209 return 0; | 1202 return 0; |
1210 } | 1203 } |
1211 #endif | |
1212 | 1204 |
1213 int | 1205 int |
1214 streaming_start(stream_t *stream, int *demuxer_type, URL_t *url) { | 1206 streaming_start(stream_t *stream, int *demuxer_type, URL_t *url) { |
1215 int ret; | 1207 int ret; |
1216 if( stream==NULL ) return -1; | 1208 if( stream==NULL ) return -1; |
1238 ret = -1; | 1230 ret = -1; |
1239 | 1231 |
1240 // Get the bandwidth available | 1232 // Get the bandwidth available |
1241 stream->streaming_ctrl->bandwidth = network_bandwidth; | 1233 stream->streaming_ctrl->bandwidth = network_bandwidth; |
1242 | 1234 |
1243 #ifndef STREAMING_LIVE_DOT_COM | |
1244 // For RTP streams, we usually don't know the stream type until we open it. | 1235 // For RTP streams, we usually don't know the stream type until we open it. |
1245 if( !strcasecmp( stream->streaming_ctrl->url->protocol, "rtp")) { | 1236 if( !strcasecmp( stream->streaming_ctrl->url->protocol, "rtp")) { |
1246 if(stream->fd >= 0) { | 1237 if(stream->fd >= 0) { |
1247 if(closesocket(stream->fd) < 0) | 1238 if(closesocket(stream->fd) < 0) |
1248 mp_msg(MSGT_NETWORK,MSGL_ERR,"streaming_start : Closing socket %d failed %s\n",stream->fd,strerror(errno)); | 1239 mp_msg(MSGT_NETWORK,MSGL_ERR,"streaming_start : Closing socket %d failed %s\n",stream->fd,strerror(errno)); |
1249 } | 1240 } |
1250 stream->fd = -1; | 1241 stream->fd = -1; |
1251 ret = rtp_streaming_start( stream ); | 1242 ret = rtp_streaming_start( stream ); |
1252 } else | 1243 } else |
1253 #endif | |
1254 | 1244 |
1255 if( !strcasecmp( stream->streaming_ctrl->url->protocol, "pnm")) { | 1245 if( !strcasecmp( stream->streaming_ctrl->url->protocol, "pnm")) { |
1256 stream->fd = -1; | 1246 stream->fd = -1; |
1257 ret = pnm_streaming_start( stream ); | 1247 ret = pnm_streaming_start( stream ); |
1258 } else | 1248 } else |