Mercurial > mplayer.hg
comparison stream/librtsp/rtsp_session.c @ 29263:0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
author | diego |
---|---|
date | Wed, 13 May 2009 02:58:57 +0000 |
parents | c884d17bd005 |
children | d3df5ca12917 |
comparison
equal
deleted
inserted
replaced
29262:7d545a6b8aff | 29263:0f1b5b68af32 |
---|---|
75 struct real_rtsp_session_t* real_session; | 75 struct real_rtsp_session_t* real_session; |
76 struct rtp_rtsp_session_t* rtp_session; | 76 struct rtp_rtsp_session_t* rtp_session; |
77 }; | 77 }; |
78 | 78 |
79 /* | 79 /* |
80 * closes an rtsp connection | 80 * closes an rtsp connection |
81 */ | 81 */ |
82 | 82 |
83 static void rtsp_close(rtsp_t *s) { | 83 static void rtsp_close(rtsp_t *s) { |
84 | 84 |
85 if (s->server_state) | 85 if (s->server_state) |
94 if (s->mrl) free(s->mrl); | 94 if (s->mrl) free(s->mrl); |
95 if (s->session) free(s->session); | 95 if (s->session) free(s->session); |
96 if (s->user_agent) free(s->user_agent); | 96 if (s->user_agent) free(s->user_agent); |
97 rtsp_free_answers(s); | 97 rtsp_free_answers(s); |
98 rtsp_unschedule_all(s); | 98 rtsp_unschedule_all(s); |
99 free(s); | 99 free(s); |
100 } | 100 } |
101 | 101 |
102 //rtsp_session_t *rtsp_session_start(char *mrl) { | 102 //rtsp_session_t *rtsp_session_start(char *mrl) { |
103 rtsp_session_t *rtsp_session_start(int fd, char **mrl, char *path, char *host, | 103 rtsp_session_t *rtsp_session_start(int fd, char **mrl, char *path, char *host, |
104 int port, int *redir, uint32_t bandwidth, char *user, char *pass) { | 104 int port, int *redir, uint32_t bandwidth, char *user, char *pass) { |
110 | 110 |
111 rtsp_session = malloc (sizeof (rtsp_session_t)); | 111 rtsp_session = malloc (sizeof (rtsp_session_t)); |
112 rtsp_session->s = NULL; | 112 rtsp_session->s = NULL; |
113 rtsp_session->real_session = NULL; | 113 rtsp_session->real_session = NULL; |
114 rtsp_session->rtp_session = NULL; | 114 rtsp_session->rtp_session = NULL; |
115 | 115 |
116 //connect: | 116 //connect: |
117 *redir = 0; | 117 *redir = 0; |
118 | 118 |
119 /* connect to server */ | 119 /* connect to server */ |
120 rtsp_session->s=rtsp_connect(fd,*mrl,path,host,port,NULL); | 120 rtsp_session->s=rtsp_connect(fd,*mrl,path,host,port,NULL); |
162 free (server); | 162 free (server); |
163 free(rtsp_session); | 163 free(rtsp_session); |
164 return NULL; | 164 return NULL; |
165 } | 165 } |
166 } | 166 } |
167 | 167 |
168 rtsp_session->real_session = init_real_rtsp_session (); | 168 rtsp_session->real_session = init_real_rtsp_session (); |
169 if(!strncmp(h->streams[0]->mime_type, "application/vnd.rn-rmadriver", h->streams[0]->mime_type_size) || | 169 if(!strncmp(h->streams[0]->mime_type, "application/vnd.rn-rmadriver", h->streams[0]->mime_type_size) || |
170 !strncmp(h->streams[0]->mime_type, "application/smil", h->streams[0]->mime_type_size)) { | 170 !strncmp(h->streams[0]->mime_type, "application/smil", h->streams[0]->mime_type_size)) { |
171 rtsp_session->real_session->header_len = 0; | 171 rtsp_session->real_session->header_len = 0; |
172 rtsp_session->real_session->recv_size = 0; | 172 rtsp_session->real_session->recv_size = 0; |
237 free (rtsp_session); | 237 free (rtsp_session); |
238 return NULL; | 238 return NULL; |
239 } | 239 } |
240 } | 240 } |
241 free(server); | 241 free(server); |
242 | 242 |
243 return rtsp_session; | 243 return rtsp_session; |
244 } | 244 } |
245 | 245 |
246 int rtsp_session_read (rtsp_session_t *this, char *data, int len) { | 246 int rtsp_session_read (rtsp_session_t *this, char *data, int len) { |
247 | 247 |
248 if (this->real_session) { | 248 if (this->real_session) { |
249 int to_copy=len; | 249 int to_copy=len; |
250 char *dest=data; | 250 char *dest=data; |
251 char *source = | 251 char *source = |
252 (char *) (this->real_session->recv + this->real_session->recv_read); | 252 (char *) (this->real_session->recv + this->real_session->recv_read); |
255 if(this->real_session->rdteof) | 255 if(this->real_session->rdteof) |
256 return -1; | 256 return -1; |
257 if (len < 0) return 0; | 257 if (len < 0) return 0; |
258 if (this->real_session->recv_size < 0) return -1; | 258 if (this->real_session->recv_size < 0) return -1; |
259 while (to_copy > fill) { | 259 while (to_copy > fill) { |
260 | 260 |
261 memcpy(dest, source, fill); | 261 memcpy(dest, source, fill); |
262 to_copy -= fill; | 262 to_copy -= fill; |
263 dest += fill; | 263 dest += fill; |
264 this->real_session->recv_read = 0; | 264 this->real_session->recv_read = 0; |
265 this->real_session->recv_size = | 265 this->real_session->recv_size = |
276 mp_msg (MSGT_OPEN, MSGL_INFO, "librtsp: %d of %d bytes provided\n", len-to_copy, len); | 276 mp_msg (MSGT_OPEN, MSGL_INFO, "librtsp: %d of %d bytes provided\n", len-to_copy, len); |
277 #endif | 277 #endif |
278 return len-to_copy; | 278 return len-to_copy; |
279 } | 279 } |
280 } | 280 } |
281 | 281 |
282 memcpy(dest, source, to_copy); | 282 memcpy(dest, source, to_copy); |
283 this->real_session->recv_read += to_copy; | 283 this->real_session->recv_read += to_copy; |
284 | 284 |
285 #ifdef LOG | 285 #ifdef LOG |
286 mp_msg (MSGT_OPEN, MSGL_INFO, "librtsp: %d bytes provided\n", len); | 286 mp_msg (MSGT_OPEN, MSGL_INFO, "librtsp: %d bytes provided\n", len); |
296 /* send RTSP and RTCP keepalive */ | 296 /* send RTSP and RTCP keepalive */ |
297 rtcp_send_rr (this->s, this->rtp_session); | 297 rtcp_send_rr (this->s, this->rtp_session); |
298 | 298 |
299 if (l == 0) | 299 if (l == 0) |
300 rtsp_session_end (this); | 300 rtsp_session_end (this); |
301 | 301 |
302 return l; | 302 return l; |
303 } | 303 } |
304 | 304 |
305 return 0; | 305 return 0; |
306 } | 306 } |