Mercurial > mplayer.hg
annotate stream/librtsp/rtsp_rtp.c @ 35488:9ef9131adfe5
Provide a number of tracks information for files in playlists.
author | ib |
---|---|
date | Mon, 03 Dec 2012 14:44:32 +0000 |
parents | 7a93fe8c6956 |
children | 05916e37848e |
rev | line source |
---|---|
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:
diff
changeset
|
1 /* |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
2 * Copyright (C) 2006 Benjamin Zores |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
3 * based on the Freebox patch for xine by 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:
diff
changeset
|
4 * but with many enhancements for better 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:
diff
changeset
|
5 * |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
6 * This program is free software; you can redistribute it and/or modify |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
7 * it under the terms of the GNU General Public License as published by |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
8 * the Free Software Foundation; either version 2 of the License, or |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
9 * (at your option) any later version. |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
10 * |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
11 * This program is distributed in the hope that it will be useful, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
14 * GNU General Public License for more details. |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
15 * |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
16 * You should have received a copy of the GNU General Public License |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
17 * along with this program; if not, write to the Free Software Foundation, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
18 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
19 */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
20 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
21 #include <unistd.h> |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
22 #include <stdio.h> |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
23 #include <string.h> |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
24 #include <errno.h> |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
25 #include <stdlib.h> |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
26 #include <sys/types.h> |
18849
2f4cf2d615cb
fix compilation under mingw (thanks to tempn AT twmi DOT rr DOT com for report and pacman for fix)
ben
parents:
18837
diff
changeset
|
27 #include <inttypes.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:
diff
changeset
|
28 |
18837
70bcf587a49a
includes before checking for defines (thanks Reimar for watching me)
ben
parents:
18836
diff
changeset
|
29 #include "config.h" |
70bcf587a49a
includes before checking for defines (thanks Reimar for watching me)
ben
parents:
18836
diff
changeset
|
30 |
28402 | 31 #if !HAVE_WINSOCK2_H |
18835 | 32 #include <netdb.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:
diff
changeset
|
33 #include <netinet/in.h> |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
34 #include <sys/socket.h> |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
35 #include <arpa/inet.h> |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
36 #else |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
37 #include <winsock2.h> |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
38 #include <ws2tcpip.h> |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
39 #endif |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
40 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
41 #include "mp_msg.h" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
42 #include "rtsp.h" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
43 #include "rtsp_rtp.h" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
44 #include "rtsp_session.h" |
27712
daff903e23e2
Move socklen_t typedef from config.h to stream/network.h.
diego
parents:
27463
diff
changeset
|
45 #include "stream/network.h" |
27463
e16088a911c1
consistency cosmetics: Avoid using .. in #include paths.
diego
parents:
27461
diff
changeset
|
46 #include "stream/freesdp/common.h" |
e16088a911c1
consistency cosmetics: Avoid using .. in #include paths.
diego
parents:
27461
diff
changeset
|
47 #include "stream/freesdp/parser.h" |
32410 | 48 #include "libavutil/avstring.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:
diff
changeset
|
49 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
50 #define RTSP_DEFAULT_PORT 31336 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
51 #define MAX_LENGTH 256 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
52 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
53 #define RTSP_ACCEPT_SDP "Accept: application/sdp" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
54 #define RTSP_CONTENT_LENGTH "Content-length" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
55 #define RTSP_CONTENT_TYPE "Content-Type" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
56 #define RTSP_APPLICATION_SDP "application/sdp" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
57 #define RTSP_RANGE "Range: " |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
58 #define RTSP_NPT_NOW "npt=now-" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
59 #define RTSP_MEDIA_CONTAINER_MPEG_TS "33" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
60 #define RTSP_TRANSPORT_REQUEST "Transport: RTP/AVP;%s;%s%i-%i;mode=\"PLAY\"" |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
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:
diff
changeset
|
62 #define RTSP_TRANSPORT_MULTICAST "multicast" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
63 #define RTSP_TRANSPORT_UNICAST "unicast" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
64 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
65 #define RTSP_MULTICAST_PORT "port=" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
66 #define RTSP_UNICAST_CLIENT_PORT "client_port=" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
67 #define RTSP_UNICAST_SERVER_PORT "server_port=" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
68 #define RTSP_SETUP_DESTINATION "destination=" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
69 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
70 #define RTSP_SESSION "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:
diff
changeset
|
71 #define RTSP_TRANSPORT "Transport" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
72 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
73 /* hardcoded RTCP RR - this is _NOT_ RFC compliant */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
74 #define RTCP_RR_SIZE 32 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
75 #define RTCP_RR "\201\311\0\7(.JD\31+\306\343\0\0\0\0\0\0/E\0\0\2&\0\0\0\0\0\0\0\0\201" |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
76 #define RTCP_SEND_FREQUENCY 1024 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
77 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
78 int rtsp_port = 0; |
18874
57bb217e71a4
new rtsp-destination option which allows forcing destination ip address (fixes some issues with some reluctant rtsp servers)
ben
parents:
18849
diff
changeset
|
79 char *rtsp_destination = 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:
diff
changeset
|
80 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
81 void |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
82 rtcp_send_rr (rtsp_t *s, struct rtp_rtsp_session_t *st) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
83 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
84 if (st->rtcp_socket == -1) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
85 return; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
86 |
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:
diff
changeset
|
87 /* send RTCP RR every RTCP_SEND_FREQUENCY packets |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
88 * FIXME : NOT CORRECT, HARDCODED, BUT MAKES SOME SERVERS HAPPY |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
89 * not rfc compliant |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
90 * http://www.faqs.org/rfcs/rfc1889.html chapter 6 for RTCP |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
91 */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
92 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
93 if (st->count == RTCP_SEND_FREQUENCY) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
94 { |
35214
126ce1e7f87b
Remove useless indirection that in addition completely broke the code.
reimar
parents:
32537
diff
changeset
|
95 send (st->rtcp_socket, RTCP_RR, RTCP_RR_SIZE, DEFAULT_SEND_FLAGS); |
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:
diff
changeset
|
96 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
97 /* ping RTSP server to keep connection alive. |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
98 we use OPTIONS instead of PING as not all servers support it */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
99 rtsp_request_options (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:
diff
changeset
|
100 st->count = 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:
diff
changeset
|
101 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
102 else |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
103 st->count++; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
104 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
105 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
106 static struct rtp_rtsp_session_t * |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
107 rtp_session_new (void) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
108 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
109 struct rtp_rtsp_session_t *st = NULL; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
110 |
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:
diff
changeset
|
111 st = malloc (sizeof (struct rtp_rtsp_session_t)); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
112 |
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:
diff
changeset
|
113 st->rtp_socket = -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
114 st->rtcp_socket = -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
115 st->control_url = 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:
diff
changeset
|
116 st->count = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
117 |
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:
diff
changeset
|
118 return st; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
119 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
120 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
121 void |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
122 rtp_session_free (struct rtp_rtsp_session_t *st) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
123 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
124 if (!st) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
125 return; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
126 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
127 if (st->rtp_socket != -1) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
128 close (st->rtp_socket); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
129 if (st->rtcp_socket != -1) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
130 close (st->rtcp_socket); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
131 |
32537
8fa2f43cb760
Remove most of the NULL pointer check before free all over the code
cboesch
parents:
32410
diff
changeset
|
132 free (st->control_url); |
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:
diff
changeset
|
133 free (st); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
134 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
135 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
136 static void |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
137 rtp_session_set_fd (struct rtp_rtsp_session_t *st, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
138 int rtp_sock, int rtcp_sock) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
139 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
140 if (!st) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
141 return; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
142 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
143 st->rtp_socket = rtp_sock; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
144 st->rtcp_socket = rtcp_sock; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
145 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
146 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
147 static int |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
148 parse_port (const char *line, const char *param, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
149 int *rtp_port, int *rtcp_port) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
150 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
151 char *parse1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
152 char *parse2; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
153 char *parse3; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
154 |
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:
diff
changeset
|
155 char *line_copy = strdup (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:
diff
changeset
|
156 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
157 parse1 = strstr (line_copy, param); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
158 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
159 if (parse1) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
160 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
161 parse2 = strstr (parse1, "-"); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
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:
diff
changeset
|
163 if (parse2) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
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:
diff
changeset
|
165 parse3 = strstr (parse2, ";"); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
166 |
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:
diff
changeset
|
167 if (parse3) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
168 parse3[0] = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
169 |
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:
diff
changeset
|
170 parse2[0] = 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:
diff
changeset
|
171 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
172 else |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
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:
diff
changeset
|
174 free (line_copy); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
175 return 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:
diff
changeset
|
176 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
177 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
178 else |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
179 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
180 free (line_copy); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
181 return 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:
diff
changeset
|
182 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
183 |
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:
diff
changeset
|
184 *rtp_port = atoi (parse1 + strlen (param)); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
185 *rtcp_port = atoi (parse2 + 1); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
186 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
187 free (line_copy); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
188 |
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:
diff
changeset
|
189 return 1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
190 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
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:
diff
changeset
|
192 static char * |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
193 parse_destination (const char *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:
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:
diff
changeset
|
195 char *parse1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
196 char *parse2; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
197 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
198 char *dest = 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:
diff
changeset
|
199 char *line_copy = strdup (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:
diff
changeset
|
200 int len; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
201 |
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:
diff
changeset
|
202 parse1 = strstr (line_copy, RTSP_SETUP_DESTINATION); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
203 if (!parse1) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
204 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
205 free (line_copy); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
206 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:
diff
changeset
|
207 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
208 |
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:
diff
changeset
|
209 parse2 = strstr (parse1, ";"); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
210 if (!parse2) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
211 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
212 free (line_copy); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
213 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:
diff
changeset
|
214 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
215 |
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:
diff
changeset
|
216 len = strlen (parse1) - strlen (parse2) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
217 - strlen (RTSP_SETUP_DESTINATION) + 1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
218 dest = (char *) malloc (len + 1); |
32401 | 219 av_strlcpy (dest, parse1 + strlen (RTSP_SETUP_DESTINATION), len); |
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:
diff
changeset
|
220 free (line_copy); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
221 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
222 return dest; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
223 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
224 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
225 static int |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
226 rtcp_connect (int client_port, int server_port, const char* server_hostname) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
227 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
228 struct sockaddr_in sin; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
229 struct hostent *hp; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
230 int s; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
231 |
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:
diff
changeset
|
232 if (client_port <= 1023) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
233 return -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
234 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
235 s = socket (PF_INET, SOCK_DGRAM, IPPROTO_UDP); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
236 if (s == -1) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
237 return -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
238 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
239 hp = gethostbyname (server_hostname); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
240 if (!hp) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
241 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
242 close (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:
diff
changeset
|
243 return -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
244 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
245 |
28697
5b749a93fc89
Use memset to make sure all parts of struct sockaddr_in are always initialized.
reimar
parents:
28404
diff
changeset
|
246 memset(&sin, 0, sizeof(sin)); |
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:
diff
changeset
|
247 sin.sin_family = AF_INET; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
248 sin.sin_addr.s_addr = INADDR_ANY; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
249 sin.sin_port = htons (client_port); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
250 |
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:
diff
changeset
|
251 if (bind (s, (struct sockaddr *) &sin, sizeof (sin))) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
252 { |
28402 | 253 #if !HAVE_WINSOCK2_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:
diff
changeset
|
254 if (errno != EINPROGRESS) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
255 #else |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
256 if (WSAGetLastError() != WSAEINPROGRESS) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
257 #endif |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
258 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
259 close (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:
diff
changeset
|
260 return -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
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:
diff
changeset
|
262 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
263 |
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:
diff
changeset
|
264 sin.sin_family = AF_INET; |
35250 | 265 memcpy (&(sin.sin_addr.s_addr), hp->h_addr, hp->h_length); |
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:
diff
changeset
|
266 sin.sin_port = htons (server_port); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
267 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
268 /* datagram socket */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
269 if (connect (s, (struct sockaddr *) &sin, sizeof (sin)) < 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:
diff
changeset
|
270 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
271 close (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:
diff
changeset
|
272 return -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
273 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
274 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
275 return 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:
diff
changeset
|
276 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
277 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
278 static int |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
279 rtp_connect (char *hostname, int port) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
280 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
281 struct sockaddr_in sin; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
282 struct timeval tv; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
283 int err, err_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:
diff
changeset
|
284 int rxsockbufsz; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
285 int 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:
diff
changeset
|
286 fd_set set; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
287 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
288 if (port <= 1023) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
289 return -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
290 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
291 s = socket (PF_INET, SOCK_DGRAM, 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:
diff
changeset
|
292 if (s == -1) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
293 return -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
294 |
28697
5b749a93fc89
Use memset to make sure all parts of struct sockaddr_in are always initialized.
reimar
parents:
28404
diff
changeset
|
295 memset(&sin, 0, sizeof(sin)); |
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:
diff
changeset
|
296 sin.sin_family = AF_INET; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
297 if (!hostname || !strcmp (hostname, "0.0.0.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:
diff
changeset
|
298 sin.sin_addr.s_addr = htonl (INADDR_ANY); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
299 else |
28404
613f075b4ef0
Restructure network tests: Always check for both inet_aton and inet_pton.
diego
parents:
28402
diff
changeset
|
300 #if HAVE_INET_PTON |
613f075b4ef0
Restructure network tests: Always check for both inet_aton and inet_pton.
diego
parents:
28402
diff
changeset
|
301 inet_pton (AF_INET, hostname, &sin.sin_addr); |
613f075b4ef0
Restructure network tests: Always check for both inet_aton and inet_pton.
diego
parents:
28402
diff
changeset
|
302 #elif HAVE_INET_ATON |
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:
diff
changeset
|
303 inet_aton (hostname, &sin.sin_addr); |
28404
613f075b4ef0
Restructure network tests: Always check for both inet_aton and inet_pton.
diego
parents:
28402
diff
changeset
|
304 #elif HAVE_WINSOCK2_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:
diff
changeset
|
305 sin.sin_addr.s_addr = htonl (INADDR_ANY); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
306 #endif |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
307 sin.sin_port = htons (port); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
308 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
309 /* Increase the socket rx buffer size to maximum -- this is UDP */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
310 rxsockbufsz = 240 * 1024; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
311 if (setsockopt (s, SOL_SOCKET, SO_RCVBUF, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
312 &rxsockbufsz, sizeof (rxsockbufsz))) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
313 mp_msg (MSGT_OPEN, MSGL_ERR, "Couldn't set receive socket buffer size\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:
diff
changeset
|
314 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
315 /* if multicast address, add membership */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
316 if ((ntohl (sin.sin_addr.s_addr) >> 28) == 0xe) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
317 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
318 struct ip_mreq mcast; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
319 mcast.imr_multiaddr.s_addr = sin.sin_addr.s_addr; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
320 mcast.imr_interface.s_addr = 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:
diff
changeset
|
321 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
322 if (setsockopt (s, IPPROTO_IP, IP_ADD_MEMBERSHIP, &mcast, sizeof (mcast))) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
323 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
324 mp_msg (MSGT_OPEN, MSGL_ERR, "IP_ADD_MEMBERSHIP failed\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:
diff
changeset
|
325 close (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:
diff
changeset
|
326 return -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
327 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
328 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
329 |
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:
diff
changeset
|
330 /* datagram socket */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
331 if (bind (s, (struct sockaddr *) &sin, sizeof (sin))) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
332 { |
28402 | 333 #if !HAVE_WINSOCK2_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:
diff
changeset
|
334 if (errno != EINPROGRESS) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
335 #else |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
336 if (WSAGetLastError() != WSAEINPROGRESS) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
337 #endif |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
338 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
339 mp_msg (MSGT_OPEN, MSGL_ERR, "bind: %s\n", strerror (errno)); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
340 close (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:
diff
changeset
|
341 return -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
342 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
343 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
344 |
25441
3744685df066
Use tv_sec instead of tv_usec to set 1 second timeout, e.g. NetBSD
reimar
parents:
19271
diff
changeset
|
345 tv.tv_sec = 1; /* 1 second timeout */ |
3744685df066
Use tv_sec instead of tv_usec to set 1 second timeout, e.g. NetBSD
reimar
parents:
19271
diff
changeset
|
346 tv.tv_usec = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
347 |
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:
diff
changeset
|
348 FD_ZERO (&set); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
349 FD_SET (s, &set); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
350 |
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:
diff
changeset
|
351 err = select (s + 1, &set, NULL, NULL, &tv); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
352 if (err < 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:
diff
changeset
|
353 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
354 mp_msg (MSGT_OPEN, MSGL_ERR, "Select failed: %s\n", strerror (errno)); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
355 close (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:
diff
changeset
|
356 return -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
357 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
358 else if (err == 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:
diff
changeset
|
359 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
360 mp_msg (MSGT_OPEN, MSGL_ERR, "Timeout! No data from host %s\n", hostname); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
361 close (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:
diff
changeset
|
362 return -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
363 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
364 |
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:
diff
changeset
|
365 err_len = sizeof (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:
diff
changeset
|
366 getsockopt (s, SOL_SOCKET, SO_ERROR, &err, (socklen_t *) &err_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:
diff
changeset
|
367 if (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:
diff
changeset
|
368 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
369 mp_msg (MSGT_OPEN, MSGL_ERR, "Socket error: %d\n", 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:
diff
changeset
|
370 close (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:
diff
changeset
|
371 return -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
372 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
373 |
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:
diff
changeset
|
374 return 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:
diff
changeset
|
375 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
376 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
377 static int |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
378 is_multicast_address (char *addr) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
379 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
380 struct sockaddr_in sin; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
381 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
382 if (!addr) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
383 return -1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
384 |
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:
diff
changeset
|
385 sin.sin_family = AF_INET; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
386 |
28404
613f075b4ef0
Restructure network tests: Always check for both inet_aton and inet_pton.
diego
parents:
28402
diff
changeset
|
387 #if HAVE_INET_PTON |
613f075b4ef0
Restructure network tests: Always check for both inet_aton and inet_pton.
diego
parents:
28402
diff
changeset
|
388 inet_pton (AF_INET, addr, &sin.sin_addr); |
613f075b4ef0
Restructure network tests: Always check for both inet_aton and inet_pton.
diego
parents:
28402
diff
changeset
|
389 #elif HAVE_INET_ATON |
18836 | 390 inet_aton (addr, &sin.sin_addr); |
28404
613f075b4ef0
Restructure network tests: Always check for both inet_aton and inet_pton.
diego
parents:
28402
diff
changeset
|
391 #elif HAVE_WINSOCK2_H |
18836 | 392 sin.sin_addr.s_addr = htonl (INADDR_ANY); |
393 #endif | |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
394 |
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:
diff
changeset
|
395 if ((ntohl (sin.sin_addr.s_addr) >> 28) == 0xe) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
396 return 1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
397 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
398 return 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:
diff
changeset
|
399 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
400 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
401 struct rtp_rtsp_session_t * |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
402 rtp_setup_and_play (rtsp_t *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:
diff
changeset
|
403 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
404 struct rtp_rtsp_session_t* rtp_session = 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:
diff
changeset
|
405 const fsdp_media_description_t *med_dsc = 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:
diff
changeset
|
406 char temp_buf[MAX_LENGTH + 1]; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
407 char npt[256]; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
408 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
409 char* answer; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
410 char* sdp; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
411 char *server_addr = 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:
diff
changeset
|
412 char *destination = 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:
diff
changeset
|
413 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
414 int statut; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
415 int content_length = 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:
diff
changeset
|
416 int is_multicast = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
417 |
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:
diff
changeset
|
418 fsdp_description_t *dsc = 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:
diff
changeset
|
419 fsdp_error_t result; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
420 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
421 int client_rtp_port = -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
422 int client_rtcp_port = -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
423 int server_rtp_port = -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
424 int server_rtcp_port = -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
425 int rtp_sock = -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
426 int rtcp_sock = -1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
427 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
428 /* 1. send a RTSP DESCRIBE request to 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:
diff
changeset
|
429 rtsp_schedule_field (rtsp_session, RTSP_ACCEPT_SDP); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
430 statut = rtsp_request_describe (rtsp_session, 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:
diff
changeset
|
431 if (statut < 200 || statut > 299) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
432 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:
diff
changeset
|
433 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
434 answer = rtsp_search_answers (rtsp_session, RTSP_CONTENT_LENGTH); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
435 if (answer) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
436 content_length = atoi (answer); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
437 else |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
438 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:
diff
changeset
|
439 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
440 answer = rtsp_search_answers (rtsp_session, RTSP_CONTENT_TYPE); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
441 if (!answer || !strstr (answer, RTSP_APPLICATION_SDP)) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
442 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:
diff
changeset
|
443 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
444 /* 2. read SDP message from 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:
diff
changeset
|
445 sdp = (char *) malloc (content_length + 1); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
446 if (rtsp_read_data (rtsp_session, sdp, content_length) <= 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:
diff
changeset
|
447 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
448 free (sdp); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
449 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:
diff
changeset
|
450 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
451 sdp[content_length] = 0; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
452 |
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:
diff
changeset
|
453 /* 3. parse SDP message */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
454 dsc = fsdp_description_new (); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
455 result = fsdp_parse (sdp, dsc); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
456 if (result != FSDPE_OK) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
457 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
458 free (sdp); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
459 fsdp_description_delete (dsc); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
460 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:
diff
changeset
|
461 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
462 mp_msg (MSGT_OPEN, MSGL_V, "SDP:\n%s\n", sdp); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
463 free (sdp); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
464 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
465 /* 4. check for number of media streams: only one is supported */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
466 if (fsdp_get_media_count (dsc) != 1) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
467 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
468 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:
diff
changeset
|
469 "A single media stream only is supported atm.\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:
diff
changeset
|
470 fsdp_description_delete (dsc); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
471 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:
diff
changeset
|
472 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
473 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
474 /* 5. set the Normal Play Time parameter |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
475 * use range provided by server in SDP or start now if empty */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
476 sprintf (npt, RTSP_RANGE); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
477 if (fsdp_get_range (dsc)) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
478 strcat (npt, fsdp_get_range (dsc)); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
479 else |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
480 strcat (npt, RTSP_NPT_NOW); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
481 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
482 /* 5. check for a valid media stream */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
483 med_dsc = fsdp_get_media (dsc, 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:
diff
changeset
|
484 if (!med_dsc) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
485 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
486 fsdp_description_delete (dsc); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
487 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:
diff
changeset
|
488 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
489 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
490 /* 6. parse the `m=<media> <port> <transport> <fmt list>' line */ |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
491 |
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:
diff
changeset
|
492 /* check for an A/V media */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
493 if (fsdp_get_media_type (med_dsc) != FSDP_MEDIA_VIDEO && |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
494 fsdp_get_media_type (med_dsc) != FSDP_MEDIA_AUDIO) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
495 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
496 fsdp_description_delete (dsc); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
497 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:
diff
changeset
|
498 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
499 |
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:
diff
changeset
|
500 /* only RTP/AVP transport method is supported right now */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
501 if (fsdp_get_media_transport_protocol (med_dsc) != FSDP_TP_RTP_AVP) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
502 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
503 fsdp_description_delete (dsc); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
504 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:
diff
changeset
|
505 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
506 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
507 /* only MPEG-TS is supported at the moment */ |
28885
e375263bd10b
Ensure the string we're trying to compare is actually not NULL.
ben
parents:
28697
diff
changeset
|
508 if (!fsdp_get_media_format (med_dsc, 0) || |
e375263bd10b
Ensure the string we're trying to compare is actually not NULL.
ben
parents:
28697
diff
changeset
|
509 !strstr (fsdp_get_media_format (med_dsc, 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:
diff
changeset
|
510 RTSP_MEDIA_CONTAINER_MPEG_TS)) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
511 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
512 fsdp_description_delete (dsc); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
513 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:
diff
changeset
|
514 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
515 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
516 /* get client port (if any) advised by 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:
diff
changeset
|
517 client_rtp_port = fsdp_get_media_port (med_dsc); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
518 if (client_rtp_port == -1) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
519 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
520 fsdp_description_delete (dsc); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
521 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:
diff
changeset
|
522 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
523 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
524 /* if client_rtp_port = 0 => let client randomly pick one */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
525 if (client_rtp_port == 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:
diff
changeset
|
526 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
527 /* TODO: we should check if the port is in use first */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
528 if (rtsp_port) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
529 client_rtp_port = rtsp_port; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
530 else |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
531 client_rtp_port = RTSP_DEFAULT_PORT; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
532 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
533 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
534 /* RTCP port generally is RTP port + 1 */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
535 client_rtcp_port = client_rtp_port + 1; |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
536 |
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:
diff
changeset
|
537 mp_msg (MSGT_OPEN, MSGL_V, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
538 "RTP Port from SDP appears to be: %d\n", client_rtp_port); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
539 mp_msg (MSGT_OPEN, MSGL_V, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
540 "RTCP Port from SDP appears to be: %d\n", client_rtcp_port); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
541 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
542 /* 7. parse the `c=<network type> <addr type> <connection address>' 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:
diff
changeset
|
543 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
544 /* check for a valid media network type (inet) */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
545 if (fsdp_get_media_network_type (med_dsc) != FSDP_NETWORK_TYPE_INET) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
546 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
547 /* no control for media: try global one instead */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
548 if (fsdp_get_global_conn_network_type (dsc) != FSDP_NETWORK_TYPE_INET) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
549 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
550 fsdp_description_delete (dsc); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
551 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:
diff
changeset
|
552 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
553 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
554 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
555 /* only IPv4 is supported atm. */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
556 if (fsdp_get_media_address_type (med_dsc) != FSDP_ADDRESS_TYPE_IPV4) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
557 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
558 /* no control for media: try global one instead */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
559 if (fsdp_get_global_conn_address_type (dsc) != FSDP_ADDRESS_TYPE_IPV4) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
560 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
561 fsdp_description_delete (dsc); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
562 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:
diff
changeset
|
563 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
564 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
565 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
566 /* get the media server address to connect to */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
567 if (fsdp_get_media_address (med_dsc)) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
568 server_addr = strdup (fsdp_get_media_address (med_dsc)); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
569 else if (fsdp_get_global_conn_address (dsc)) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
570 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
571 /* no control for media: try global one instead */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
572 server_addr = strdup (fsdp_get_global_conn_address (dsc)); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
573 } |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
574 |
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:
diff
changeset
|
575 if (!server_addr) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
576 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
577 fsdp_description_delete (dsc); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
578 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:
diff
changeset
|
579 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
580 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
581 /* check for a UNICAST or MULTICAST address to connect to */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
582 is_multicast = is_multicast_address (server_addr); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
583 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
584 /* 8. initiate an 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:
diff
changeset
|
585 rtp_session = rtp_session_new (); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
586 if (!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:
diff
changeset
|
587 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
588 free (server_addr); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
589 fsdp_description_delete (dsc); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
590 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:
diff
changeset
|
591 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
592 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
593 /* get the media control URL */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
594 if (fsdp_get_media_control (med_dsc, 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:
diff
changeset
|
595 rtp_session->control_url = strdup (fsdp_get_media_control (med_dsc, 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:
diff
changeset
|
596 fsdp_description_delete (dsc); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
597 if (!rtp_session->control_url) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
598 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
599 free (server_addr); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
600 rtp_session_free (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:
diff
changeset
|
601 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:
diff
changeset
|
602 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
603 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
604 /* 9. create the payload for RTSP SETUP request */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
605 memset (temp_buf, '\0', MAX_LENGTH); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
606 snprintf (temp_buf, MAX_LENGTH, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
607 RTSP_TRANSPORT_REQUEST, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
608 is_multicast ? RTSP_TRANSPORT_MULTICAST : RTSP_TRANSPORT_UNICAST, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
609 is_multicast ? RTSP_MULTICAST_PORT : RTSP_UNICAST_CLIENT_PORT, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
610 client_rtp_port, client_rtcp_port); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
611 mp_msg (MSGT_OPEN, MSGL_V, "RTSP Transport: %s\n", temp_buf); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
612 |
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:
diff
changeset
|
613 rtsp_unschedule_field (rtsp_session, 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:
diff
changeset
|
614 rtsp_schedule_field (rtsp_session, temp_buf); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
615 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
616 /* 10. check for the media control URL type and initiate RTSP 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:
diff
changeset
|
617 if (!strncmp (rtp_session->control_url, "rtsp://", 7)) /* absolute URL */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
618 statut = rtsp_request_setup (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:
diff
changeset
|
619 rtp_session->control_url, 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:
diff
changeset
|
620 else /* relative URL */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
621 statut = rtsp_request_setup (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:
diff
changeset
|
622 NULL, rtp_session->control_url); |
29263
0f1b5b68af32
whitespace cosmetics: Remove all trailing whitespace.
diego
parents:
28885
diff
changeset
|
623 |
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:
diff
changeset
|
624 if (statut < 200 || statut > 299) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
625 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
626 free (server_addr); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
627 rtp_session_free (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:
diff
changeset
|
628 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:
diff
changeset
|
629 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
630 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
631 /* 11. parse RTSP SETUP response: we need it to actually determine |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
632 * the real address and port to connect to */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
633 answer = rtsp_search_answers (rtsp_session, RTSP_TRANSPORT); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
634 if (!answer) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
635 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
636 free (server_addr); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
637 rtp_session_free (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:
diff
changeset
|
638 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:
diff
changeset
|
639 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
640 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
641 /* check for RTP and RTCP ports to bind according to how request was done */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
642 is_multicast = 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:
diff
changeset
|
643 if (strstr (answer, RTSP_TRANSPORT_MULTICAST)) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
644 is_multicast = 1; |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
645 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
646 if (is_multicast) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
647 parse_port (answer, RTSP_MULTICAST_PORT, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
648 &client_rtp_port, &client_rtcp_port); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
649 else |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
650 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
651 parse_port (answer, RTSP_UNICAST_CLIENT_PORT, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
652 &client_rtp_port, &client_rtcp_port); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
653 parse_port (answer, RTSP_UNICAST_SERVER_PORT, |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
654 &server_rtp_port, &server_rtcp_port); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
655 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
656 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
657 /* now check network settings as determined by server */ |
18874
57bb217e71a4
new rtsp-destination option which allows forcing destination ip address (fixes some issues with some reluctant rtsp servers)
ben
parents:
18849
diff
changeset
|
658 if (rtsp_destination) |
57bb217e71a4
new rtsp-destination option which allows forcing destination ip address (fixes some issues with some reluctant rtsp servers)
ben
parents:
18849
diff
changeset
|
659 destination = strdup (rtsp_destination); |
57bb217e71a4
new rtsp-destination option which allows forcing destination ip address (fixes some issues with some reluctant rtsp servers)
ben
parents:
18849
diff
changeset
|
660 else |
57bb217e71a4
new rtsp-destination option which allows forcing destination ip address (fixes some issues with some reluctant rtsp servers)
ben
parents:
18849
diff
changeset
|
661 destination = parse_destination (answer); |
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:
diff
changeset
|
662 if (!destination) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
663 destination = strdup (server_addr); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
664 free (server_addr); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
665 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
666 mp_msg (MSGT_OPEN, MSGL_V, "RTSP Destination: %s\n", destination); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
667 mp_msg (MSGT_OPEN, MSGL_V, "Client RTP port : %d\n", client_rtp_port); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
668 mp_msg (MSGT_OPEN, MSGL_V, "Client RTCP port : %d\n", client_rtcp_port); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
669 mp_msg (MSGT_OPEN, MSGL_V, "Server RTP port : %d\n", server_rtp_port); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
670 mp_msg (MSGT_OPEN, MSGL_V, "Server RTCP port : %d\n", server_rtcp_port); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
671 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
672 /* 12. performs RTSP PLAY request */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
673 rtsp_schedule_field (rtsp_session, npt); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
674 statut = rtsp_request_play (rtsp_session, 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:
diff
changeset
|
675 if (statut < 200 || statut > 299) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
676 { |
18876 | 677 free (destination); |
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:
diff
changeset
|
678 rtp_session_free (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:
diff
changeset
|
679 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:
diff
changeset
|
680 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
681 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
682 /* 13. create RTP and RTCP connections */ |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
683 rtp_sock = rtp_connect (destination, client_rtp_port); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
684 rtcp_sock = rtcp_connect (client_rtcp_port, server_rtcp_port, destination); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
685 rtp_session_set_fd (rtp_session, rtp_sock, rtcp_sock); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
686 free (destination); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
687 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
688 mp_msg (MSGT_OPEN, MSGL_V, "RTP Sock : %d\nRTCP Sock : %d\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:
diff
changeset
|
689 rtp_session->rtp_socket, rtp_session->rtcp_socket); |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
690 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
691 if (rtp_session->rtp_socket == -1) |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
692 { |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
693 rtp_session_free (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:
diff
changeset
|
694 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:
diff
changeset
|
695 } |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
696 |
317e0fd394c5
added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff
changeset
|
697 return 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:
diff
changeset
|
698 } |