annotate stream/librtsp/rtsp.c @ 36428:7766530caa76

Add new stream control command STREAM_CTRL_GET_CURRENT_CHANNEL. This provides the name of the currently selected DVB channel. (Unsupported for analog TV though.)
author ib
date Fri, 29 Nov 2013 12:34:21 +0000
parents 389d43c448b3
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
1 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
2 * This file was ported to MPlayer from xine CVS rtsp.c,v 1.9 2003/04/10 02:30:48
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
3 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
4
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
5 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
6 * Copyright (C) 2000-2002 the xine project
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
7 *
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
8 * This file is part of xine, a free video player.
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
9 *
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
10 * xine is free software; you can redistribute it and/or modify
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
13 * (at your option) any later version.
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
14 *
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
15 * xine is distributed in the hope that it will be useful,
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
18 * GNU General Public License for more details.
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
19 *
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
23 *
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
24 *
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
25 * a minimalistic implementation of rtsp protocol,
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
26 * *not* RFC 2326 compilant yet.
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
27 *
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
28 * 2006, Benjamin Zores and Vincent Mussard
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
29 * fixed a lot of RFC compliance issues.
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
30 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
31
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
32 #include <unistd.h>
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
33 #include <stdio.h>
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
34 #include <assert.h>
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
35 #include "config.h"
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
36 #include <string.h>
35903
389d43c448b3 Add missing strings.h #includes for strcasecmp().
diego
parents: 32537
diff changeset
37 #include <strings.h>
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
38 #include <sys/stat.h>
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
39 #include <fcntl.h>
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
40 #include <errno.h>
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
41 #include <stdlib.h>
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
42 #include <time.h>
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
43 #include <sys/time.h>
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
44 #include <sys/types.h>
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
45 #include <inttypes.h>
28402
c884d17bd005 Convert HAVE_WINSOCK2_H into a 0/1 definition.
diego
parents: 27461
diff changeset
46 #if HAVE_WINSOCK2_H
27109
9440e551f9e3 mingw uses Windows sockets.
vayne
parents: 27104
diff changeset
47 #include <winsock2.h>
27320
44341e4d5621 Do not include sys/socket.h when using winsock2, it is pointless
reimar
parents: 27202
diff changeset
48 #else
44341e4d5621 Do not include sys/socket.h when using winsock2, it is pointless
reimar
parents: 27202
diff changeset
49 #include <sys/socket.h>
27109
9440e551f9e3 mingw uses Windows sockets.
vayne
parents: 27104
diff changeset
50 #endif
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
51 #include "mp_msg.h"
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
52 #include "rtsp.h"
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
53 #include "rtsp_session.h"
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
54 #include "osdep/timer.h"
31500
b01f807eb183 Use MSG_NOSIGNAL flag if available for send().
reimar
parents: 29263
diff changeset
55 #include "stream/network.h"
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
56
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
57 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
58 #define LOG
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
59 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
60
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
61 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
62 * network utilities
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
63 */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
64
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
65 static int write_stream(int s, const char *buf, int len) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
66 int total, timeout;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
67
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
68 total = 0; timeout = 30;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
69 while (total < len){
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
70 int n;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
71
31500
b01f807eb183 Use MSG_NOSIGNAL flag if available for send().
reimar
parents: 29263
diff changeset
72 n = send (s, &buf[total], len - total, DEFAULT_SEND_FLAGS);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
73
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
74 if (n > 0)
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
75 total += n;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
76 else if (n < 0) {
28402
c884d17bd005 Convert HAVE_WINSOCK2_H into a 0/1 definition.
diego
parents: 27461
diff changeset
77 #if !HAVE_WINSOCK2_H
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
78 if ((timeout>0) && ((errno == EAGAIN) || (errno == EINPROGRESS))) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
79 #else
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
80 if ((timeout>0) && ((errno == EAGAIN) || (WSAGetLastError() == WSAEINPROGRESS))) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
81 #endif
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
82 usec_sleep (1000000); timeout--;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
83 } else
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
84 return -1;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
85 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
86 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
87
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
88 return total;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
89 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
90
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
91 static ssize_t read_stream(int fd, void *buf, size_t count) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
92
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
93 ssize_t ret, total;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
94
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
95 total = 0;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
96
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
97 while (total < count) {
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
98
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
99 ret=recv (fd, ((uint8_t*)buf)+total, count-total, 0);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
100
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
101 if (ret<0) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
102 if(errno == EAGAIN) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
103 fd_set rset;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
104 struct timeval timeout;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
105
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
106 FD_ZERO (&rset);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
107 FD_SET (fd, &rset);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
108
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
109 timeout.tv_sec = 30;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
110 timeout.tv_usec = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
111
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
112 if (select (fd+1, &rset, NULL, NULL, &timeout) <= 0) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
113 return -1;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
114 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
115 continue;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
116 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
117
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
118 mp_msg(MSGT_OPEN, MSGL_ERR, "rtsp: read error.\n");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
119 return ret;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
120 } else
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
121 total += ret;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
122
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
123 /* end of stream */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
124 if (!ret) break;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
125 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
126
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
127 return total;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
128 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
129
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
130 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
131 * rtsp_get gets a line from stream
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
132 * and returns a null terminated string.
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
133 */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
134
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
135 static char *rtsp_get(rtsp_t *s) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
136
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
137 int n=1;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
138 char *buffer = malloc(BUF_SIZE);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
139 char *string = NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
140
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
141 read_stream(s->s, buffer, 1);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
142 while (n<BUF_SIZE) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
143 read_stream(s->s, &(buffer[n]), 1);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
144 if ((buffer[n-1]==0x0d)&&(buffer[n]==0x0a)) break;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
145 n++;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
146 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
147
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
148 if (n>=BUF_SIZE) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
149 mp_msg(MSGT_OPEN, MSGL_FATAL, "librtsp: buffer overflow in rtsp_get\n");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
150 exit(1);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
151 }
18854
a973acb2e572 cosmetic patch to remove useless sizeof(char) statements
ben
parents: 18853
diff changeset
152 string=malloc(n);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
153 memcpy(string,buffer,n-1);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
154 string[n-1]=0;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
155
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
156 #ifdef LOG
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
157 mp_msg(MSGT_OPEN, MSGL_INFO, "librtsp: << '%s'\n", string);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
158 #endif
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
159
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
160
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
161 free(buffer);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
162 return string;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
163 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
164
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
165 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
166 * rtsp_put puts a line on stream
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
167 */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
168
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
169 static void rtsp_put(rtsp_t *s, const char *string) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
170
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
171 int len=strlen(string);
18854
a973acb2e572 cosmetic patch to remove useless sizeof(char) statements
ben
parents: 18853
diff changeset
172 char *buf=malloc(len+2);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
173
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
174 #ifdef LOG
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
175 mp_msg(MSGT_OPEN, MSGL_INFO, "librtsp: >> '%s'", string);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
176 #endif
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
177
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
178 memcpy(buf,string,len);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
179 buf[len]=0x0d;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
180 buf[len+1]=0x0a;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
181
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
182 write_stream(s->s, buf, len+2);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
183
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
184 #ifdef LOG
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
185 mp_msg(MSGT_OPEN, MSGL_INFO, " done.\n");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
186 #endif
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
187
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
188 free(buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
189 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
190
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
191 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
192 * extract server status code
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
193 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
194
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
195 static int rtsp_get_code(const char *string) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
196
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
197 char buf[4];
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
198 int code=0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
199
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
200 if (!strncmp(string, RTSP_PROTOCOL_VERSION, strlen(RTSP_PROTOCOL_VERSION)))
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
201 {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
202 memcpy(buf, string+strlen(RTSP_PROTOCOL_VERSION)+1, 3);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
203 buf[3]=0;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
204 code=atoi(buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
205 } else if (!strncmp(string, RTSP_METHOD_SET_PARAMETER,8))
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
206 {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
207 return RTSP_STATUS_SET_PARAMETER;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
208 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
209
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
210 if(code != RTSP_STATUS_OK) mp_msg(MSGT_OPEN, MSGL_INFO, "librtsp: server responds: '%s'\n",string);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
211
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
212 return code;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
213 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
214
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
215 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
216 * send a request
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
217 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
218
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
219 static void rtsp_send_request(rtsp_t *s, const char *type, const char *what) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
220
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
221 char **payload=s->scheduled;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
222 char *buf;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
223
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
224 buf = malloc(strlen(type)+strlen(what)+strlen(RTSP_PROTOCOL_VERSION)+3);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
225
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
226 sprintf(buf,"%s %s %s",type, what, RTSP_PROTOCOL_VERSION);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
227 rtsp_put(s,buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
228 free(buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
229 if (payload)
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
230 while (*payload) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
231 rtsp_put(s,*payload);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
232 payload++;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
233 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
234 rtsp_put(s,"");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
235 rtsp_unschedule_all(s);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
236 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
237
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
238 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
239 * schedule standard fields
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
240 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
241
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
242 static void rtsp_schedule_standard(rtsp_t *s) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
243
18853
1ec19da0c642 increase buffer size, "CSeq: %u" has a worst case of 17 (fix 1.18 from xine, see http://xine.cvs.sourceforge.net/xine/xine-lib/src/input/librtsp/rtsp.c?r1=1.17&r2=1.18)
ben
parents: 18852
diff changeset
244 char tmp[17];
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
245
18853
1ec19da0c642 increase buffer size, "CSeq: %u" has a worst case of 17 (fix 1.18 from xine, see http://xine.cvs.sourceforge.net/xine/xine-lib/src/input/librtsp/rtsp.c?r1=1.17&r2=1.18)
ben
parents: 18852
diff changeset
246 snprintf(tmp, 17, "CSeq: %u", s->cseq);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
247 rtsp_schedule_field(s, tmp);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
248
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
249 if (s->session) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
250 char *buf;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
251 buf = malloc(strlen(s->session)+15);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
252 sprintf(buf, "Session: %s", s->session);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
253 rtsp_schedule_field(s, buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
254 free(buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
255 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
256 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
257 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
258 * get the answers, if server responses with something != 200, return NULL
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
259 */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
260
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
261 static int rtsp_get_answers(rtsp_t *s) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
262
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
263 char *answer=NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
264 unsigned int answer_seq;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
265 char **answer_ptr=s->answers;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
266 int code;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
267 int ans_count = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
268
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
269 answer=rtsp_get(s);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
270 if (!answer)
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
271 return 0;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
272 code=rtsp_get_code(answer);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
273 free(answer);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
274
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
275 rtsp_free_answers(s);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
276
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
277 do { /* while we get answer lines */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
278
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
279 answer=rtsp_get(s);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
280 if (!answer)
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
281 return 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
282
18852
b17648e2762e be more tolerant on server responses parameters case (fix 1.17 from xine, see http://xine.cvs.sourceforge.net/xine/xine-lib/src/input/librtsp/rtsp.c?r1=1.16&r2=1.17)
ben
parents: 18851
diff changeset
283 if (!strncasecmp(answer,"CSeq:",5)) {
b17648e2762e be more tolerant on server responses parameters case (fix 1.17 from xine, see http://xine.cvs.sourceforge.net/xine/xine-lib/src/input/librtsp/rtsp.c?r1=1.16&r2=1.17)
ben
parents: 18851
diff changeset
284 sscanf(answer,"%*s %u",&answer_seq);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
285 if (s->cseq != answer_seq) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
286 #ifdef LOG
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
287 mp_msg(MSGT_OPEN, MSGL_WARN, "librtsp: warning: CSeq mismatch. got %u, assumed %u", answer_seq, s->cseq);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
288 #endif
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
289 s->cseq=answer_seq;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
290 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
291 }
18852
b17648e2762e be more tolerant on server responses parameters case (fix 1.17 from xine, see http://xine.cvs.sourceforge.net/xine/xine-lib/src/input/librtsp/rtsp.c?r1=1.16&r2=1.17)
ben
parents: 18851
diff changeset
292 if (!strncasecmp(answer,"Server:",7)) {
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
293 char *buf = malloc(strlen(answer));
18852
b17648e2762e be more tolerant on server responses parameters case (fix 1.17 from xine, see http://xine.cvs.sourceforge.net/xine/xine-lib/src/input/librtsp/rtsp.c?r1=1.16&r2=1.17)
ben
parents: 18851
diff changeset
294 sscanf(answer,"%*s %s",buf);
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31500
diff changeset
295 free(s->server);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
296 s->server=strdup(buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
297 free(buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
298 }
18852
b17648e2762e be more tolerant on server responses parameters case (fix 1.17 from xine, see http://xine.cvs.sourceforge.net/xine/xine-lib/src/input/librtsp/rtsp.c?r1=1.16&r2=1.17)
ben
parents: 18851
diff changeset
299 if (!strncasecmp(answer,"Session:",8)) {
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
300 char *buf = calloc(1, strlen(answer));
18852
b17648e2762e be more tolerant on server responses parameters case (fix 1.17 from xine, see http://xine.cvs.sourceforge.net/xine/xine-lib/src/input/librtsp/rtsp.c?r1=1.16&r2=1.17)
ben
parents: 18851
diff changeset
301 sscanf(answer,"%*s %s",buf);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
302 if (s->session) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
303 if (strcmp(buf, s->session)) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
304 mp_msg(MSGT_OPEN, MSGL_WARN, "rtsp: warning: setting NEW session: %s\n", buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
305 free(s->session);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
306 s->session=strdup(buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
307 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
308 } else
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
309 {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
310 #ifdef LOG
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
311 mp_msg(MSGT_OPEN, MSGL_INFO, "rtsp: setting session id to: %s\n", buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
312 #endif
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
313 s->session=strdup(buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
314 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
315 free(buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
316 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
317 *answer_ptr=answer;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
318 answer_ptr++;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
319 } while ((strlen(answer)!=0) && (++ans_count < MAX_FIELDS));
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
320
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
321 s->cseq++;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
322
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
323 *answer_ptr=NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
324 rtsp_schedule_standard(s);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
325
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
326 return code;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
327 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
328
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
329 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
330 * send an ok message
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
331 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
332
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
333 int rtsp_send_ok(rtsp_t *s) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
334 char cseq[16];
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
335
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
336 rtsp_put(s, "RTSP/1.0 200 OK");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
337 sprintf(cseq,"CSeq: %u", s->cseq);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
338 rtsp_put(s, cseq);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
339 rtsp_put(s, "");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
340 return 0;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
341 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
342
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
343 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
344 * implementation of must-have rtsp requests; functions return
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
345 * server status code.
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
346 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
347
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
348 int rtsp_request_options(rtsp_t *s, const char *what) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
349
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
350 char *buf;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
351
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
352 if (what) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
353 buf=strdup(what);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
354 } else
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
355 {
18854
a973acb2e572 cosmetic patch to remove useless sizeof(char) statements
ben
parents: 18853
diff changeset
356 buf=malloc(strlen(s->host)+16);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
357 sprintf(buf,"rtsp://%s:%i", s->host, s->port);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
358 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
359 rtsp_send_request(s,RTSP_METHOD_OPTIONS,buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
360 free(buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
361
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
362 return rtsp_get_answers(s);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
363 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
364
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
365 int rtsp_request_describe(rtsp_t *s, const char *what) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
366
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
367 char *buf;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
368
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
369 if (what) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
370 buf=strdup(what);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
371 } else
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
372 {
18854
a973acb2e572 cosmetic patch to remove useless sizeof(char) statements
ben
parents: 18853
diff changeset
373 buf=malloc(strlen(s->host)+strlen(s->path)+16);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
374 sprintf(buf,"rtsp://%s:%i/%s", s->host, s->port, s->path);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
375 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
376 rtsp_send_request(s,RTSP_METHOD_DESCRIBE,buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
377 free(buf);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
378
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
379 return rtsp_get_answers(s);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
380 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
381
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
382 int rtsp_request_setup(rtsp_t *s, const char *what, char *control) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
383
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
384 char *buf = NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
385
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
386 if (what)
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
387 buf = strdup (what);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
388 else
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
389 {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
390 int len = strlen (s->host) + strlen (s->path) + 16;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
391 if (control)
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
392 len += strlen (control) + 1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
393
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
394 buf = malloc (len);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
395 sprintf (buf, "rtsp://%s:%i/%s%s%s", s->host, s->port, s->path,
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
396 control ? "/" : "", control ? control : "");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
397 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
398
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
399 rtsp_send_request (s, RTSP_METHOD_SETUP, buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
400 free (buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
401 return rtsp_get_answers (s);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
402 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
403
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
404 int rtsp_request_setparameter(rtsp_t *s, const char *what) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
405
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
406 char *buf;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
407
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
408 if (what) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
409 buf=strdup(what);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
410 } else
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
411 {
18854
a973acb2e572 cosmetic patch to remove useless sizeof(char) statements
ben
parents: 18853
diff changeset
412 buf=malloc(strlen(s->host)+strlen(s->path)+16);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
413 sprintf(buf,"rtsp://%s:%i/%s", s->host, s->port, s->path);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
414 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
415 rtsp_send_request(s,RTSP_METHOD_SET_PARAMETER,buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
416 free(buf);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
417
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
418 return rtsp_get_answers(s);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
419 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
420
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
421 int rtsp_request_play(rtsp_t *s, const char *what) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
422
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
423 char *buf;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
424 int ret;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
425
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
426 if (what) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
427 buf=strdup(what);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
428 } else
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
429 {
18854
a973acb2e572 cosmetic patch to remove useless sizeof(char) statements
ben
parents: 18853
diff changeset
430 buf=malloc(strlen(s->host)+strlen(s->path)+16);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
431 sprintf(buf,"rtsp://%s:%i/%s", s->host, s->port, s->path);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
432 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
433 rtsp_send_request(s,RTSP_METHOD_PLAY,buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
434 free(buf);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
435
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
436 ret = rtsp_get_answers (s);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
437 if (ret == RTSP_STATUS_OK)
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
438 s->server_state = RTSP_PLAYING;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
439
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
440 return ret;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
441 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
442
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
443 int rtsp_request_teardown(rtsp_t *s, const char *what) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
444
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
445 char *buf;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
446
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
447 if (what)
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
448 buf = strdup (what);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
449 else
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
450 {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
451 buf =
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
452 malloc (strlen (s->host) + strlen (s->path) + 16);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
453 sprintf (buf, "rtsp://%s:%i/%s", s->host, s->port, s->path);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
454 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
455 rtsp_send_request (s, RTSP_METHOD_TEARDOWN, buf);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
456 free (buf);
18801
f17474882196 prevent a buffer overflow to occur at teardown
ben
parents: 18799
diff changeset
457
f17474882196 prevent a buffer overflow to occur at teardown
ben
parents: 18799
diff changeset
458 /* after teardown we're done with RTSP streaming, no need to get answer as
f17474882196 prevent a buffer overflow to occur at teardown
ben
parents: 18799
diff changeset
459 reading more will only result to garbage and buffer overflow */
f17474882196 prevent a buffer overflow to occur at teardown
ben
parents: 18799
diff changeset
460 return RTSP_STATUS_OK;
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
461 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
462
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
463 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
464 * read opaque data from stream
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
465 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
466
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
467 int rtsp_read_data(rtsp_t *s, char *buffer, unsigned int size) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
468
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
469 int i,seq;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
470
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
471 if (size>=4) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
472 i=read_stream(s->s, buffer, 4);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
473 if (i<4) return i;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
474 if (((buffer[0]=='S')&&(buffer[1]=='E')&&(buffer[2]=='T')&&(buffer[3]=='_')) ||
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
475 ((buffer[0]=='O')&&(buffer[1]=='P')&&(buffer[2]=='T')&&(buffer[3]=='I'))) // OPTIONS
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
476 {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
477 char *rest=rtsp_get(s);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
478 if (!rest)
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
479 return -1;
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
480
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
481 seq=-1;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
482 do {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
483 free(rest);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
484 rest=rtsp_get(s);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
485 if (!rest)
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
486 return -1;
18852
b17648e2762e be more tolerant on server responses parameters case (fix 1.17 from xine, see http://xine.cvs.sourceforge.net/xine/xine-lib/src/input/librtsp/rtsp.c?r1=1.16&r2=1.17)
ben
parents: 18851
diff changeset
487 if (!strncasecmp(rest,"CSeq:",5))
b17648e2762e be more tolerant on server responses parameters case (fix 1.17 from xine, see http://xine.cvs.sourceforge.net/xine/xine-lib/src/input/librtsp/rtsp.c?r1=1.16&r2=1.17)
ben
parents: 18851
diff changeset
488 sscanf(rest,"%*s %u",&seq);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
489 } while (strlen(rest)!=0);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
490 free(rest);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
491 if (seq<0) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
492 #ifdef LOG
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
493 mp_msg(MSGT_OPEN, MSGL_WARN, "rtsp: warning: CSeq not recognized!\n");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
494 #endif
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
495 seq=1;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
496 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
497 /* let's make the server happy */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
498 rtsp_put(s, "RTSP/1.0 451 Parameter Not Understood");
18854
a973acb2e572 cosmetic patch to remove useless sizeof(char) statements
ben
parents: 18853
diff changeset
499 rest=malloc(17);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
500 sprintf(rest,"CSeq: %u", seq);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
501 rtsp_put(s, rest);
18855
a60bcf4969c3 coverity report #179 from xine: variable "rest" not freed or pointed-to in function "rtsp_put" (see http://xine.cvs.sourceforge.net/xine/xine-lib/src/input/librtsp/rtsp.c?r1=1.19&r2=1.20)
ben
parents: 18854
diff changeset
502 free(rest);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
503 rtsp_put(s, "");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
504 i=read_stream(s->s, buffer, size);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
505 } else
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
506 {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
507 i=read_stream(s->s, buffer+4, size-4);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
508 i+=4;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
509 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
510 } else
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
511 i=read_stream(s->s, buffer, size);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
512 #ifdef LOG
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
513 mp_msg(MSGT_OPEN, MSGL_INFO, "librtsp: << %d of %d bytes\n", i, size);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
514 #endif
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
515
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
516 return i;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
517 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
518
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
519 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
520 * connect to a rtsp server
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
521 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
522
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
523 //rtsp_t *rtsp_connect(const char *mrl, const char *user_agent) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
524 rtsp_t *rtsp_connect(int fd, char* mrl, char *path, char *host, int port, char *user_agent) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
525
27103
a3f6dc43b585 Move rtsp_close away by simplification - avoids symbol clash with libnemesi
lu_zero
parents: 19271
diff changeset
526 rtsp_t *s;
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
527 int i;
27103
a3f6dc43b585 Move rtsp_close away by simplification - avoids symbol clash with libnemesi
lu_zero
parents: 19271
diff changeset
528
a3f6dc43b585 Move rtsp_close away by simplification - avoids symbol clash with libnemesi
lu_zero
parents: 19271
diff changeset
529 if (fd < 0) {
a3f6dc43b585 Move rtsp_close away by simplification - avoids symbol clash with libnemesi
lu_zero
parents: 19271
diff changeset
530 mp_msg(MSGT_OPEN, MSGL_ERR, "rtsp: failed to connect to '%s'\n", host);
a3f6dc43b585 Move rtsp_close away by simplification - avoids symbol clash with libnemesi
lu_zero
parents: 19271
diff changeset
531 return NULL;
a3f6dc43b585 Move rtsp_close away by simplification - avoids symbol clash with libnemesi
lu_zero
parents: 19271
diff changeset
532 }
a3f6dc43b585 Move rtsp_close away by simplification - avoids symbol clash with libnemesi
lu_zero
parents: 19271
diff changeset
533
a3f6dc43b585 Move rtsp_close away by simplification - avoids symbol clash with libnemesi
lu_zero
parents: 19271
diff changeset
534 s = malloc(sizeof(rtsp_t));
a3f6dc43b585 Move rtsp_close away by simplification - avoids symbol clash with libnemesi
lu_zero
parents: 19271
diff changeset
535
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
536 for (i=0; i<MAX_FIELDS; i++) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
537 s->answers[i]=NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
538 s->scheduled[i]=NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
539 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
540
27103
a3f6dc43b585 Move rtsp_close away by simplification - avoids symbol clash with libnemesi
lu_zero
parents: 19271
diff changeset
541 s->s = fd;
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
542 s->server=NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
543 s->server_state=0;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
544 s->server_caps=0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
545
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
546 s->cseq=0;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
547 s->session=NULL;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
548
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
549 if (user_agent)
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
550 s->user_agent=strdup(user_agent);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
551 else
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
552 s->user_agent=strdup("User-Agent: RealMedia Player Version 6.0.9.1235 (linux-2.0-libc6-i386-gcc2.95)");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
553
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
554 s->mrl = strdup(mrl);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
555 s->host = strdup(host);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
556 s->port = port;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
557 s->path = strdup(path);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
558 while (*path == '/')
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
559 path++;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
560 if ((s->param = strchr(s->path, '?')) != NULL)
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
561 s->param++;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
562 //mp_msg(MSGT_OPEN, MSGL_INFO, "path=%s\n", s->path);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
563 //mp_msg(MSGT_OPEN, MSGL_INFO, "param=%s\n", s->param ? s->param : "NULL");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
564
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
565 s->server_state=RTSP_CONNECTED;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
566
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
567 /* now let's send an options request. */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
568 rtsp_schedule_field(s, "CSeq: 1");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
569 rtsp_schedule_field(s, s->user_agent);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
570 rtsp_schedule_field(s, "ClientChallenge: 9e26d33f2984236010ef6253fb1887f7");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
571 rtsp_schedule_field(s, "PlayerStarttime: [28/03/2003:22:50:23 00:00]");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
572 rtsp_schedule_field(s, "CompanyID: KnKV4M4I/B2FjJ1TToLycw==");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
573 rtsp_schedule_field(s, "GUID: 00000000-0000-0000-0000-000000000000");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
574 rtsp_schedule_field(s, "RegionData: 0");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
575 rtsp_schedule_field(s, "ClientID: Linux_2.4_6.0.9.1235_play32_RN01_EN_586");
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
576 /*rtsp_schedule_field(s, "Pragma: initiate-session");*/
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
577 rtsp_request_options(s, NULL);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
578
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
579 return s;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
580 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
581
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
582
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
583 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
584 * search in answers for tags. returns a pointer to the content
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
585 * after the first matched tag. returns NULL if no match found.
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
586 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
587
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
588 char *rtsp_search_answers(rtsp_t *s, const char *tag) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
589
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
590 char **answer;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
591 char *ptr;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
592
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
593 if (!s->answers) return NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
594 answer=s->answers;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
595
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
596 while (*answer) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
597 if (!strncasecmp(*answer,tag,strlen(tag))) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
598 ptr=strchr(*answer,':');
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
599 if (!ptr) return NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
600 ptr++;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
601 while(*ptr==' ') ptr++;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
602 return ptr;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
603 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
604 answer++;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
605 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
606
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
607 return NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
608 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
609
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
610 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
611 * session id management
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
612 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
613
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
614 void rtsp_set_session(rtsp_t *s, const char *id) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
615
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31500
diff changeset
616 free(s->session);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
617
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
618 s->session=strdup(id);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
619
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
620 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
621
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
622 char *rtsp_get_session(rtsp_t *s) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
623
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
624 return s->session;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
625
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
626 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
627
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
628 char *rtsp_get_mrl(rtsp_t *s) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
629
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
630 return s->mrl;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
631
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
632 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
633
19108
5e767cabf4cd marks several read-only string parameters and function return-values which can only be used read-only as const. Patch by Stefan Huehner, stefan _AT huener-org
reynaldo
parents: 18855
diff changeset
634 char *rtsp_get_param(rtsp_t *s, const char *p) {
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
635 int len;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
636 char *param;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
637 if (!s->param)
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
638 return NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
639 if (!p)
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
640 return strdup(s->param);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
641 len = strlen(p);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
642 param = s->param;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
643 while (param && *param) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
644 char *nparam = strchr(param, '&');
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
645 if (strncmp(param, p, len) == 0 && param[len] == '=') {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
646 param += len + 1;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
647 len = nparam ? nparam - param : strlen(param);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
648 nparam = malloc(len + 1);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
649 memcpy(nparam, param, len);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
650 nparam[len] = 0;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
651 return nparam;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
652 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
653 param = nparam ? nparam + 1 : NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
654 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
655 return NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
656 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
657
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
658 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
659 * schedules a field for transmission
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
660 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
661
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
662 void rtsp_schedule_field(rtsp_t *s, const char *string) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
663
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
664 int i=0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
665
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
666 if (!string) return;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
667
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
668 while(s->scheduled[i]) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
669 i++;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
670 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
671 s->scheduled[i]=strdup(string);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
672 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
673
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
674 /*
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
675 * removes the first scheduled field which prefix matches string.
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
676 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
677
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
678 void rtsp_unschedule_field(rtsp_t *s, const char *string) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
679
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
680 char **ptr=s->scheduled;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
681
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
682 if (!string) return;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
683
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
684 while(*ptr) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
685 if (!strncmp(*ptr, string, strlen(string)))
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
686 break;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
687 else
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
688 ptr++;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
689 }
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 31500
diff changeset
690 free(*ptr);
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
691 ptr++;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
692 do {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
693 *(ptr-1)=*ptr;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
694 } while(*ptr);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
695 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
696
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
697 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
698 * unschedule all fields
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
699 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
700
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
701 void rtsp_unschedule_all(rtsp_t *s) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
702
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
703 char **ptr;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
704
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
705 if (!s->scheduled) return;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
706 ptr=s->scheduled;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
707
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
708 while (*ptr) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
709 free(*ptr);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
710 *ptr=NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
711 ptr++;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
712 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
713 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
714 /*
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
715 * free answers
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
716 */
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
717
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
718 void rtsp_free_answers(rtsp_t *s) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
719
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
720 char **answer;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28402
diff changeset
721
18799
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
722 if (!s->answers) return;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
723 answer=s->answers;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
724
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
725 while (*answer) {
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
726 free(*answer);
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
727 *answer=NULL;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
728 answer++;
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
729 }
e16345b97dab moved generic rtsp related files from realrtsp to librtsp
ben
parents:
diff changeset
730 }