annotate libmpdemux/realrtsp/rtsp_session.c @ 10202:f586be782e69

sync
author nicolas
date Thu, 29 May 2003 13:17:47 +0000
parents 0c72c1d0d6a4
children 54bcbf28698a
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
1 /*
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
2 * This file was ported to MPlayer from xine CVS rtsp_session.c,v 1.9 2003/02/11 16:20:40
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
3 */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
4
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
5 /*
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
6 * Copyright (C) 2000-2002 the xine project
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
7 *
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
8 * This file is part of xine, a free video player.
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
9 *
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
10 * xine is free software; you can redistribute it and/or modify
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
11 * it under the terms of the GNU General Public License as published by
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
12 * the Free Software Foundation; either version 2 of the License, or
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
13 * (at your option) any later version.
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
14 *
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
15 * xine is distributed in the hope that it will be useful,
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
18 * GNU General Public License for more details.
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
19 *
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
20 * You should have received a copy of the GNU General Public License
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
21 * along with this program; if not, write to the Free Software
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
22 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
23 *
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
24 *
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
25 * high level interface to rtsp servers.
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
26 */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
27
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
28 #include <sys/types.h>
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
29 #include <sys/socket.h>
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
30 #include <netinet/in.h>
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
31 #include <netdb.h>
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
32 #include <unistd.h>
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
33 #include <stdio.h>
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
34 #include <fcntl.h>
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
35 #include <stdlib.h>
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
36 #include <string.h>
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
37
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
38 #include "rtsp.h"
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
39 #include "rtsp_session.h"
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
40 #include "real.h"
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
41 #include "rmff.h"
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
42 #include "asmrp.h"
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
43
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
44 /*
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
45 #define LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
46 */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
47
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
48 #define BUF_SIZE 4096
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
49 #define HEADER_SIZE 4096
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
50
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
51 struct rtsp_session_s {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
52
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
53 rtsp_t *s;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
54
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
55 /* receive buffer */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
56 uint8_t recv[BUF_SIZE];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
57 int recv_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
58 int recv_read;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
59
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
60 /* header buffer */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
61 uint8_t header[HEADER_SIZE];
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
62 int header_len;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
63 int header_read;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
64
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
65 };
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
66
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
67 //rtsp_session_t *rtsp_session_start(char *mrl) {
10199
0c72c1d0d6a4 Fix redirection in real rtsp connections.
rtognimp
parents: 10198
diff changeset
68 rtsp_session_t *rtsp_session_start(int fd, char **mrl, char *path, char *host, int port, int *redir) {
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
69
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
70 rtsp_session_t *rtsp_session=malloc(sizeof(rtsp_session_t));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
71 char *server;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
72 char *mrl_line = NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
73 rmff_header_t *h;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
74 uint32_t bandwidth=10485800;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
75
10199
0c72c1d0d6a4 Fix redirection in real rtsp connections.
rtognimp
parents: 10198
diff changeset
76 //connect:
0c72c1d0d6a4 Fix redirection in real rtsp connections.
rtognimp
parents: 10198
diff changeset
77 *redir = 0;
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
78
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
79 /* connect to server */
10199
0c72c1d0d6a4 Fix redirection in real rtsp connections.
rtognimp
parents: 10198
diff changeset
80 rtsp_session->s=rtsp_connect(fd,*mrl,path,host,port,NULL);
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
81 if (!rtsp_session->s)
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
82 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
83 printf("rtsp_session: failed to connect to server %s\n", path);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
84 free(rtsp_session);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
85 return NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
86 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
87
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
88 /* looking for server type */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
89 if (rtsp_search_answers(rtsp_session->s,"Server"))
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
90 server=strdup(rtsp_search_answers(rtsp_session->s,"Server"));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
91 else {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
92 if (rtsp_search_answers(rtsp_session->s,"RealChallenge1"))
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
93 server=strdup("Real");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
94 else
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
95 server=strdup("unknown");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
96 }
10198
5c773d4f3a60 Accept Helix as a valid Real server
rtognimp
parents: 9922
diff changeset
97 if (strstr(server,"Real") || strstr(server,"Helix"))
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
98 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
99 /* we are talking to a real server ... */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
100
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
101 h=real_setup_and_get_header(rtsp_session->s, bandwidth);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
102 if (!h) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
103 /* got an redirect? */
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
104 if (rtsp_search_answers(rtsp_session->s, "Location"))
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
105 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
106 free(mrl_line);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
107 mrl_line=strdup(rtsp_search_answers(rtsp_session->s, "Location"));
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
108 printf("rtsp_session: redirected to %s\n", mrl_line);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
109 rtsp_close(rtsp_session->s);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
110 free(server);
10199
0c72c1d0d6a4 Fix redirection in real rtsp connections.
rtognimp
parents: 10198
diff changeset
111 free(*mrl);
0c72c1d0d6a4 Fix redirection in real rtsp connections.
rtognimp
parents: 10198
diff changeset
112 free(rtsp_session);
0c72c1d0d6a4 Fix redirection in real rtsp connections.
rtognimp
parents: 10198
diff changeset
113 /* tell the caller to redirect, return url to redirect to in mrl */
0c72c1d0d6a4 Fix redirection in real rtsp connections.
rtognimp
parents: 10198
diff changeset
114 *mrl = mrl_line;
0c72c1d0d6a4 Fix redirection in real rtsp connections.
rtognimp
parents: 10198
diff changeset
115 *redir = 1;
0c72c1d0d6a4 Fix redirection in real rtsp connections.
rtognimp
parents: 10198
diff changeset
116 return NULL;
0c72c1d0d6a4 Fix redirection in real rtsp connections.
rtognimp
parents: 10198
diff changeset
117 // goto connect; /* *shudder* i made a design mistake somewhere */
9922
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
118 } else
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
119 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
120 printf("rtsp_session: session can not be established.\n");
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
121 rtsp_close(rtsp_session->s);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
122 free(rtsp_session);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
123 return NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
124 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
125 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
126
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
127 rtsp_session->header_len=rmff_dump_header(h,rtsp_session->header,1024);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
128
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
129 memcpy(rtsp_session->recv, rtsp_session->header, rtsp_session->header_len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
130 rtsp_session->recv_size = rtsp_session->header_len;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
131 rtsp_session->recv_read = 0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
132
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
133 } else
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
134 {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
135 printf("rtsp_session: rtsp server type is '%s' instead of Real. Please report.\n",server);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
136 rtsp_close(rtsp_session->s);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
137 free(server);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
138 free(rtsp_session);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
139 return NULL;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
140 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
141 free(server);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
142
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
143 return rtsp_session;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
144 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
145
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
146 int rtsp_session_read (rtsp_session_t *this, char *data, int len) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
147
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
148 int to_copy=len;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
149 char *dest=data;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
150 char *source=this->recv + this->recv_read;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
151 int fill=this->recv_size - this->recv_read;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
152
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
153 if (len < 0) return 0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
154 while (to_copy > fill) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
155
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
156 memcpy(dest, source, fill);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
157 to_copy -= fill;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
158 dest += fill;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
159 this->recv_read = 0;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
160 source = this->recv;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
161 this->recv_size = real_get_rdt_chunk (this->s, source);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
162 fill = this->recv_size;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
163
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
164 if (this->recv_size == 0) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
165 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
166 printf ("librtsp: %d of %d bytes provided\n", len-to_copy, len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
167 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
168 return len-to_copy;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
169 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
170 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
171
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
172 memcpy(dest, source, to_copy);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
173 this->recv_read += to_copy;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
174
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
175 #ifdef LOG
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
176 printf ("librtsp: %d bytes provided\n", len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
177 #endif
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
178
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
179 return len;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
180 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
181
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
182 int rtsp_session_peek_header(rtsp_session_t *this, char *buf, int maxsize) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
183
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
184 int len;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
185
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
186 len = (this->header_len < maxsize) ? this->header_len : maxsize;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
187
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
188 memcpy(buf, this->header, len);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
189 return len;
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
190 }
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
191
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
192 void rtsp_session_end(rtsp_session_t *session) {
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
193
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
194 rtsp_close(session->s);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
195 free(session);
6cb7a295ab0e Real rstp:// streaming support, ported from xine
rtognimp
parents:
diff changeset
196 }