Mercurial > mplayer.hg
annotate stream/librtsp/rtsp_session.c @ 22458:2c1ecca1886c
Fix bad uninit when switching DVB channels.
author | reimar |
---|---|
date | Tue, 06 Mar 2007 11:24:08 +0000 |
parents | 4cabf7499fef |
children | 7526ff6035c1 |
rev | line source |
---|---|
9922 | 1 /* |
2 * This file was ported to MPlayer from xine CVS rtsp_session.c,v 1.9 2003/02/11 16:20:40 | |
3 */ | |
4 | |
5 /* | |
6 * Copyright (C) 2000-2002 the xine project | |
7 * | |
8 * This file is part of xine, a free video player. | |
9 * | |
10 * xine is free software; you can redistribute it and/or modify | |
11 * it under the terms of the GNU General Public License as published by | |
12 * the Free Software Foundation; either version 2 of the License, or | |
13 * (at your option) any later version. | |
14 * | |
15 * xine is distributed in the hope that it will be useful, | |
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
18 * GNU General Public License for more details. | |
19 * | |
20 * You should have received a copy of the GNU General Public License | |
21 * along with this program; if not, write to the Free Software | |
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA | |
23 * | |
24 * | |
25 * high level interface to rtsp servers. | |
18829
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
26 * |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
27 * 2006, Benjamin Zores and Vincent Mussard |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
28 * Support for MPEG-TS streaming through RFC compliant RTSP servers |
9922 | 29 */ |
30 | |
31 #include <sys/types.h> | |
10281 | 32 #include "config.h" |
33 #ifndef HAVE_WINSOCK2 | |
9922 | 34 #include <sys/socket.h> |
35 #include <netinet/in.h> | |
36 #include <netdb.h> | |
10281 | 37 #else |
38 #include <winsock2.h> | |
39 #endif | |
9922 | 40 #include <unistd.h> |
41 #include <stdio.h> | |
42 #include <fcntl.h> | |
43 #include <stdlib.h> | |
44 #include <string.h> | |
17351
2518f4341587
OS X compilation fix: Include inttypes.h so that uint32_t is not undefined.
diego
parents:
17332
diff
changeset
|
45 #include <inttypes.h> |
9922 | 46 |
18793 | 47 #include "mp_msg.h" |
19316 | 48 #include "../url.h" |
18829
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
49 #include "../rtp.h" |
9922 | 50 #include "rtsp.h" |
18829
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
51 #include "rtsp_rtp.h" |
9922 | 52 #include "rtsp_session.h" |
18799
e16345b97dab
moved generic rtsp related files from realrtsp to librtsp
ben
parents:
18798
diff
changeset
|
53 #include "../realrtsp/real.h" |
e16345b97dab
moved generic rtsp related files from realrtsp to librtsp
ben
parents:
18798
diff
changeset
|
54 #include "../realrtsp/rmff.h" |
e16345b97dab
moved generic rtsp related files from realrtsp to librtsp
ben
parents:
18798
diff
changeset
|
55 #include "../realrtsp/asmrp.h" |
e16345b97dab
moved generic rtsp related files from realrtsp to librtsp
ben
parents:
18798
diff
changeset
|
56 #include "../realrtsp/xbuffer.h" |
9922 | 57 |
58 /* | |
59 #define LOG | |
60 */ | |
61 | |
18829
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
62 #define RTSP_OPTIONS_PUBLIC "Public" |
18822 | 63 #define RTSP_OPTIONS_SERVER "Server" |
64 #define RTSP_OPTIONS_LOCATION "Location" | |
65 #define RTSP_OPTIONS_REAL "RealChallenge1" | |
66 #define RTSP_SERVER_TYPE_REAL "Real" | |
67 #define RTSP_SERVER_TYPE_HELIX "Helix" | |
68 #define RTSP_SERVER_TYPE_UNKNOWN "unknown" | |
69 | |
9922 | 70 struct rtsp_session_s { |
71 rtsp_t *s; | |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
72 struct real_rtsp_session_t* real_session; |
18829
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
73 struct rtp_rtsp_session_t* rtp_session; |
9922 | 74 }; |
75 | |
76 //rtsp_session_t *rtsp_session_start(char *mrl) { | |
20527 | 77 rtsp_session_t *rtsp_session_start(int fd, char **mrl, char *path, char *host, |
78 int port, int *redir, uint32_t bandwidth, char *user, char *pass) { | |
9922 | 79 |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
80 rtsp_session_t *rtsp_session = NULL; |
9922 | 81 char *server; |
82 char *mrl_line = NULL; | |
83 rmff_header_t *h; | |
84 | |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
85 rtsp_session = malloc (sizeof (rtsp_session_t)); |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
86 rtsp_session->s = NULL; |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
87 rtsp_session->real_session = NULL; |
18829
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
88 rtsp_session->rtp_session = NULL; |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
89 |
10199 | 90 //connect: |
91 *redir = 0; | |
9922 | 92 |
93 /* connect to server */ | |
10199 | 94 rtsp_session->s=rtsp_connect(fd,*mrl,path,host,port,NULL); |
9922 | 95 if (!rtsp_session->s) |
96 { | |
18793 | 97 mp_msg (MSGT_OPEN, MSGL_ERR,"rtsp_session: failed to connect to server %s\n", path); |
9922 | 98 free(rtsp_session); |
99 return NULL; | |
100 } | |
101 | |
102 /* looking for server type */ | |
18822 | 103 if (rtsp_search_answers(rtsp_session->s,RTSP_OPTIONS_SERVER)) |
104 server=strdup(rtsp_search_answers(rtsp_session->s,RTSP_OPTIONS_SERVER)); | |
9922 | 105 else { |
18822 | 106 if (rtsp_search_answers(rtsp_session->s,RTSP_OPTIONS_REAL)) |
107 server=strdup(RTSP_SERVER_TYPE_REAL); | |
9922 | 108 else |
18822 | 109 server=strdup(RTSP_SERVER_TYPE_UNKNOWN); |
9922 | 110 } |
18822 | 111 if (strstr(server,RTSP_SERVER_TYPE_REAL) || strstr(server,RTSP_SERVER_TYPE_HELIX)) |
9922 | 112 { |
113 /* we are talking to a real server ... */ | |
114 | |
20527 | 115 h=real_setup_and_get_header(rtsp_session->s, bandwidth, user, pass); |
9922 | 116 if (!h) { |
117 /* got an redirect? */ | |
18822 | 118 if (rtsp_search_answers(rtsp_session->s, RTSP_OPTIONS_LOCATION)) |
9922 | 119 { |
120 free(mrl_line); | |
18822 | 121 mrl_line=strdup(rtsp_search_answers(rtsp_session->s, RTSP_OPTIONS_LOCATION)); |
18793 | 122 mp_msg (MSGT_OPEN, MSGL_INFO,"rtsp_session: redirected to %s\n", mrl_line); |
9922 | 123 rtsp_close(rtsp_session->s); |
124 free(server); | |
10199 | 125 free(*mrl); |
126 free(rtsp_session); | |
127 /* tell the caller to redirect, return url to redirect to in mrl */ | |
128 *mrl = mrl_line; | |
129 *redir = 1; | |
130 return NULL; | |
131 // goto connect; /* *shudder* i made a design mistake somewhere */ | |
9922 | 132 } else |
133 { | |
18793 | 134 mp_msg (MSGT_OPEN, MSGL_ERR,"rtsp_session: session can not be established.\n"); |
9922 | 135 rtsp_close(rtsp_session->s); |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
136 free (server); |
9922 | 137 free(rtsp_session); |
138 return NULL; | |
139 } | |
140 } | |
141 | |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
142 rtsp_session->real_session = init_real_rtsp_session (); |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21842
diff
changeset
|
143 if(!strncmp(h->streams[0]->mime_type, "application/vnd.rn-rmadriver", h->streams[0]->mime_type_size)) { |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21842
diff
changeset
|
144 rtsp_session->real_session->header_len = 0; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21842
diff
changeset
|
145 rtsp_session->real_session->recv_size = 0; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21842
diff
changeset
|
146 rtsp_session->real_session->rdt_rawdata = 1; |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21842
diff
changeset
|
147 mp_msg(MSGT_OPEN, MSGL_V, "smil-over-realrtsp playlist, switching to raw rdt mode\n"); |
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21842
diff
changeset
|
148 } else { |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
149 rtsp_session->real_session->header_len = |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
150 rmff_dump_header (h, (char *) rtsp_session->real_session->header, 1024); |
9922 | 151 |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
152 rtsp_session->real_session->recv = |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
153 xbuffer_copyin (rtsp_session->real_session->recv, 0, |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
154 rtsp_session->real_session->header, |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
155 rtsp_session->real_session->header_len); |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
156 |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
157 rtsp_session->real_session->recv_size = |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
158 rtsp_session->real_session->header_len; |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21842
diff
changeset
|
159 } |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
160 rtsp_session->real_session->recv_read = 0; |
18829
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
161 } else /* not a Real server : try RTP instead */ |
9922 | 162 { |
18829
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
163 char *public = NULL; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
164 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
165 /* look for the Public: field in response to RTSP OPTIONS */ |
19595 | 166 if (!(public = rtsp_search_answers (rtsp_session->s, RTSP_OPTIONS_PUBLIC))) |
18829
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
167 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
168 rtsp_close (rtsp_session->s); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
169 free (server); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
170 free (mrl_line); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
171 free (rtsp_session); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
172 return NULL; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
173 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
174 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
175 /* check for minimalistic RTSP RFC compliance */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
176 if (!strstr (public, RTSP_METHOD_DESCRIBE) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
177 || !strstr (public, RTSP_METHOD_SETUP) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
178 || !strstr (public, RTSP_METHOD_PLAY) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
179 || !strstr (public, RTSP_METHOD_TEARDOWN)) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
180 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
181 mp_msg (MSGT_OPEN, MSGL_ERR, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
182 "Remote server does not meet minimal RTSP 1.0 compliance.\n"); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
183 rtsp_close (rtsp_session->s); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
184 free (server); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
185 free (mrl_line); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
186 free (rtsp_session); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
187 return NULL; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
188 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
189 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
190 rtsp_session->rtp_session = rtp_setup_and_play (rtsp_session->s); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
191 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
192 /* neither a Real or an RTP server */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
193 if (!rtsp_session->rtp_session) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
194 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
195 mp_msg (MSGT_OPEN, MSGL_ERR, "rtsp_session: unsupported RTSP server. "); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
196 mp_msg (MSGT_OPEN, MSGL_ERR, "Server type is '%s'.\n", server); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
197 rtsp_close (rtsp_session->s); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
198 free (server); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
199 free (mrl_line); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
200 free (rtsp_session); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
201 return NULL; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
202 } |
9922 | 203 } |
204 free(server); | |
205 | |
206 return rtsp_session; | |
207 } | |
208 | |
209 int rtsp_session_read (rtsp_session_t *this, char *data, int len) { | |
210 | |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
211 if (this->real_session) { |
9922 | 212 int to_copy=len; |
213 char *dest=data; | |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
214 char *source = |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
215 (char *) (this->real_session->recv + this->real_session->recv_read); |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
216 int fill = this->real_session->recv_size - this->real_session->recv_read; |
9922 | 217 |
21842 | 218 if(this->real_session->rdteof) |
219 return -1; | |
9922 | 220 if (len < 0) return 0; |
21836
7c5e893dff54
Make sure we do not crash when eof is reset, e.g. due to an attempt to seek.
reimar
parents:
20527
diff
changeset
|
221 if (this->real_session->recv_size < 0) return -1; |
9922 | 222 while (to_copy > fill) { |
223 | |
224 memcpy(dest, source, fill); | |
225 to_copy -= fill; | |
226 dest += fill; | |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
227 this->real_session->recv_read = 0; |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
228 this->real_session->recv_size = |
22242
4cabf7499fef
Add support for smil playlist served over realrtsp
rtogni
parents:
21842
diff
changeset
|
229 real_get_rdt_chunk (this->s, (char **)&(this->real_session->recv), this->real_session->rdt_rawdata); |
21842 | 230 if (this->real_session->recv_size < 0) { |
231 this->real_session->rdteof = 1; | |
232 this->real_session->recv_size = 0; | |
233 } | |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
234 source = (char *) this->real_session->recv; |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
235 fill = this->real_session->recv_size; |
9922 | 236 |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
237 if (this->real_session->recv_size == 0) { |
9922 | 238 #ifdef LOG |
18793 | 239 mp_msg (MSGT_OPEN, MSGL_INFO, "librtsp: %d of %d bytes provided\n", len-to_copy, len); |
9922 | 240 #endif |
241 return len-to_copy; | |
242 } | |
243 } | |
244 | |
245 memcpy(dest, source, to_copy); | |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
246 this->real_session->recv_read += to_copy; |
9922 | 247 |
248 #ifdef LOG | |
18793 | 249 mp_msg (MSGT_OPEN, MSGL_INFO, "librtsp: %d bytes provided\n", len); |
9922 | 250 #endif |
251 | |
252 return len; | |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
253 } |
18829
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
254 else if (this->rtp_session) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
255 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
256 int l = 0; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
257 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
258 l = read_rtp_from_server (this->rtp_session->rtp_socket, data, len); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
259 /* send RTSP and RTCP keepalive */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
260 rtcp_send_rr (this->s, this->rtp_session); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
261 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
262 if (l == 0) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
263 rtsp_session_end (this); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
264 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
265 return l; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
266 } |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
267 |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
268 return 0; |
9922 | 269 } |
270 | |
271 void rtsp_session_end(rtsp_session_t *session) { | |
272 | |
273 rtsp_close(session->s); | |
18792
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
274 if (session->real_session) |
6a015ba5bf45
move real_rtsp init/uninit code to its dedicated place to simplify a bit rtsp session demuxer
ben
parents:
17351
diff
changeset
|
275 free_real_rtsp_session (session->real_session); |
18829
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
276 if (session->rtp_session) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
18822
diff
changeset
|
277 rtp_session_free (session->rtp_session); |
9922 | 278 free(session); |
279 } |