annotate stream/librtsp/rtsp_rtp.c @ 36583:322ffa4a22d2

coverity.sh: Avoid submitting broken builds to coverity.
author reimar
date Mon, 20 Jan 2014 22:32:41 +0000
parents 05916e37848e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
35907
05916e37848e Add _BSD_SOURCE #define for struct hostent and struct ip_mreq.
diego
parents: 35250
diff changeset
21 #define _BSD_SOURCE
05916e37848e Add _BSD_SOURCE #define for struct hostent and struct ip_mreq.
diego
parents: 35250
diff changeset
22
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
23 #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
24 #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
25 #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
26 #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
27 #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
28 #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
29 #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
30
18837
70bcf587a49a includes before checking for defines (thanks Reimar for watching me)
ben
parents: 18836
diff changeset
31 #include "config.h"
70bcf587a49a includes before checking for defines (thanks Reimar for watching me)
ben
parents: 18836
diff changeset
32
28402
c884d17bd005 Convert HAVE_WINSOCK2_H into a 0/1 definition.
diego
parents: 28400
diff changeset
33 #if !HAVE_WINSOCK2_H
18835
65e867664a43 avoid messing up with includes
ben
parents: 18829
diff changeset
34 #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
35 #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
36 #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
37 #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
38 #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
39 #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
40 #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
41 #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
42
317e0fd394c5 added 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 "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
44 #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
45 #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
46 #include "rtsp_session.h"
27712
daff903e23e2 Move socklen_t typedef from config.h to stream/network.h.
diego
parents: 27463
diff changeset
47 #include "stream/network.h"
27463
e16088a911c1 consistency cosmetics: Avoid using .. in #include paths.
diego
parents: 27461
diff changeset
48 #include "stream/freesdp/common.h"
e16088a911c1 consistency cosmetics: Avoid using .. in #include paths.
diego
parents: 27461
diff changeset
49 #include "stream/freesdp/parser.h"
32410
666880b36b8b Add missing avstring include for av_strlcpy.
reimar
parents: 32401
diff changeset
50 #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
51
317e0fd394c5 added 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 #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
53 #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
54
317e0fd394c5 added 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_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
56 #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
57 #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
58 #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
59 #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
60 #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
61 #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
62 #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
63
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
64 #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
65 #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
66
317e0fd394c5 added 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_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
68 #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
69 #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
70 #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
71
317e0fd394c5 added 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 #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
73 #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
74
317e0fd394c5 added 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 /* 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
76 #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
77 #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
78 #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
79
317e0fd394c5 added 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 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
81 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
82
317e0fd394c5 added 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 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
84 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
85 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
86 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
87 return;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
88
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
89 /* 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
90 * 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
91 * 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
92 * 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
93 */
317e0fd394c5 added 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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
95 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
96 {
35214
126ce1e7f87b Remove useless indirection that in addition completely broke the code.
reimar
parents: 32537
diff changeset
97 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
98
317e0fd394c5 added 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 /* 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
100 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
101 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
102 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
103 }
317e0fd394c5 added 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 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
105 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
106 }
317e0fd394c5 added 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
317e0fd394c5 added 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 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
109 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
110 {
317e0fd394c5 added 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 struct rtp_rtsp_session_t *st = NULL;
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 = malloc (sizeof (struct rtp_rtsp_session_t));
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
114
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
115 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
116 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
117 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
118 st->count = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
119
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
120 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
121 }
317e0fd394c5 added 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
317e0fd394c5 added 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 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
124 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
125 {
317e0fd394c5 added 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 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
127 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
128
317e0fd394c5 added 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->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
130 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
131 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
132 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
133
32537
8fa2f43cb760 Remove most of the NULL pointer check before free all over the code
cboesch
parents: 32410
diff changeset
134 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
135 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
136 }
317e0fd394c5 added 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
317e0fd394c5 added 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 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
139 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
140 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
141 {
317e0fd394c5 added 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 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
143 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
144
317e0fd394c5 added 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 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
146 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
147 }
317e0fd394c5 added 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
317e0fd394c5 added 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 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
150 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
151 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
152 {
317e0fd394c5 added 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 *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
154 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
155 char *parse3;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
156
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
157 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
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 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
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 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
162 {
317e0fd394c5 added 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 parse2 = strstr (parse1, "-");
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
164
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
165 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
166 {
317e0fd394c5 added 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 parse3 = strstr (parse2, ";");
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
168
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
169 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
170 parse3[0] = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
171
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
172 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
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 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
175 {
317e0fd394c5 added 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 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
177 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
178 }
317e0fd394c5 added 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 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
181 {
317e0fd394c5 added 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 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
183 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
184 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
185
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
186 *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
187 *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
188
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
189 free (line_copy);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
190
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
191 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
192 }
317e0fd394c5 added 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
317e0fd394c5 added 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 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
195 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
196 {
317e0fd394c5 added 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 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
198 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
199
317e0fd394c5 added 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 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
201 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
202 int len;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
203
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
204 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
205 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
206 {
317e0fd394c5 added 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 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
208 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
209 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
210
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
211 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
212 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
213 {
317e0fd394c5 added 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 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
215 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
216 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
217
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
218 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
219 - 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
220 dest = (char *) malloc (len + 1);
32401
69fb7b91bf76 Replace snprintf by av_strlcpy.
reimar
parents: 31500
diff changeset
221 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
222 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
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 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
225 }
317e0fd394c5 added 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
317e0fd394c5 added 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 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
228 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
229 {
317e0fd394c5 added 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 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
231 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
232 int s;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
233
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
234 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
235 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
236
317e0fd394c5 added 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 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
238 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
239 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
240
317e0fd394c5 added 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 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
242 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
243 {
317e0fd394c5 added 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 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
245 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
246 }
317e0fd394c5 added 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
28697
5b749a93fc89 Use memset to make sure all parts of struct sockaddr_in are always initialized.
reimar
parents: 28404
diff changeset
248 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
249 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
250 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
251 sin.sin_port = htons (client_port);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
252
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
253 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
254 {
28402
c884d17bd005 Convert HAVE_WINSOCK2_H into a 0/1 definition.
diego
parents: 28400
diff changeset
255 #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
256 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
257 #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
258 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
259 #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
260 {
317e0fd394c5 added 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 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
262 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
263 }
317e0fd394c5 added 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 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
265
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_family = AF_INET;
35250
7a93fe8c6956 Use more appropriate value for memcpy length.
reimar
parents: 35214
diff changeset
267 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
268 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
269
317e0fd394c5 added 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 /* 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
271 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
272 {
317e0fd394c5 added 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 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
274 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
275 }
317e0fd394c5 added 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 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
278 }
317e0fd394c5 added 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
317e0fd394c5 added 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 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
281 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
282 {
317e0fd394c5 added 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 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
284 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
285 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
286 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
287 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
288 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
289
317e0fd394c5 added 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 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
291 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
292
317e0fd394c5 added 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 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
294 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
295 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
296
28697
5b749a93fc89 Use memset to make sure all parts of struct sockaddr_in are always initialized.
reimar
parents: 28404
diff changeset
297 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
298 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
299 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
300 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
301 else
28404
613f075b4ef0 Restructure network tests: Always check for both inet_aton and inet_pton.
diego
parents: 28402
diff changeset
302 #if HAVE_INET_PTON
613f075b4ef0 Restructure network tests: Always check for both inet_aton and inet_pton.
diego
parents: 28402
diff changeset
303 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
304 #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
305 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
306 #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
307 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
308 #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
309 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
310
317e0fd394c5 added 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 /* 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
312 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
313 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
314 &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
315 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
316
317e0fd394c5 added 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 /* 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
318 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
319 {
317e0fd394c5 added 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 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
321 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
322 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
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 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
325 {
317e0fd394c5 added 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 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
327 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
328 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
329 }
317e0fd394c5 added 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 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
331
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
332 /* 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
333 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
334 {
28402
c884d17bd005 Convert HAVE_WINSOCK2_H into a 0/1 definition.
diego
parents: 28400
diff changeset
335 #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
336 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
337 #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
338 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
339 #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
340 {
317e0fd394c5 added 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 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
342 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
343 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
344 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
345 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
346
25441
3744685df066 Use tv_sec instead of tv_usec to set 1 second timeout, e.g. NetBSD
reimar
parents: 19271
diff changeset
347 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
348 tv.tv_usec = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
349
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
350 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
351 FD_SET (s, &set);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
352
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
353 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
354 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
355 {
317e0fd394c5 added 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 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
357 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
358 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
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 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
361 {
317e0fd394c5 added 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 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
363 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
364 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
365 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
366
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
367 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
368 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
369 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
370 {
317e0fd394c5 added 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 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
372 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
373 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
374 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
375
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
376 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
377 }
317e0fd394c5 added 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
317e0fd394c5 added 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 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
380 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
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 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
383
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
384 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
385 return -1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
386
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
387 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
388
28404
613f075b4ef0 Restructure network tests: Always check for both inet_aton and inet_pton.
diego
parents: 28402
diff changeset
389 #if HAVE_INET_PTON
613f075b4ef0 Restructure network tests: Always check for both inet_aton and inet_pton.
diego
parents: 28402
diff changeset
390 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
391 #elif HAVE_INET_ATON
18836
10d3a190d935 network code portability for win32
ben
parents: 18835
diff changeset
392 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
393 #elif HAVE_WINSOCK2_H
18836
10d3a190d935 network code portability for win32
ben
parents: 18835
diff changeset
394 sin.sin_addr.s_addr = htonl (INADDR_ANY);
10d3a190d935 network code portability for win32
ben
parents: 18835
diff changeset
395 #endif
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
396
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
397 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
398 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
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 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
401 }
317e0fd394c5 added 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
317e0fd394c5 added 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 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
404 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
405 {
317e0fd394c5 added 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 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
407 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
408 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
409 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
410
317e0fd394c5 added 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* 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
412 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
413 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
414 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
415
317e0fd394c5 added 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 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
417 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
418 int is_multicast = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
419
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
420 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
421 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
422
317e0fd394c5 added 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 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
424 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
425 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
426 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
427 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
428 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
429
317e0fd394c5 added 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 /* 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
431 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
432 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
433 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
434 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
435
317e0fd394c5 added 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 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
437 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
438 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
439 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
440 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
441
317e0fd394c5 added 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 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
443 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
444 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
445
317e0fd394c5 added 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 /* 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
447 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
448 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
449 {
317e0fd394c5 added 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 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
451 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
452 }
317e0fd394c5 added 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 sdp[content_length] = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
454
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
455 /* 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
456 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
457 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
458 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
459 {
317e0fd394c5 added 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 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
461 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
462 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
463 }
317e0fd394c5 added 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 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
465 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
466
317e0fd394c5 added 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 /* 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
468 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
469 {
317e0fd394c5 added 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 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
471 "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
472 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
473 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
474 }
317e0fd394c5 added 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
317e0fd394c5 added 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 /* 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
477 * 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
478 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
479 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
480 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
481 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
482 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
483
317e0fd394c5 added 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 /* 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
485 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
486 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
487 {
317e0fd394c5 added 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 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
489 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
490 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
491
317e0fd394c5 added 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 /* 6. parse the `m=<media> <port> <transport> <fmt list>' line */
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
493
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
494 /* 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
495 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
496 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
497 {
317e0fd394c5 added 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 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
499 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
500 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
501
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
502 /* 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
503 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
504 {
317e0fd394c5 added 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 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
506 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
507 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
508
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
509 /* 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
510 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
511 !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
512 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
513 {
317e0fd394c5 added 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 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
515 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
516 }
317e0fd394c5 added 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
317e0fd394c5 added 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 /* 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
519 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
520 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
521 {
317e0fd394c5 added 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 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
523 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
524 }
317e0fd394c5 added 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
317e0fd394c5 added 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 /* 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
527 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
528 {
317e0fd394c5 added 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 /* 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
530 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
531 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
532 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
533 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
534 }
317e0fd394c5 added 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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
536 /* 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
537 client_rtcp_port = client_rtp_port + 1;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
538
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
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 "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
541 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
542 "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
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 /* 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
545
317e0fd394c5 added 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 /* 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
547 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
548 {
317e0fd394c5 added 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 /* 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
550 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
551 {
317e0fd394c5 added 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 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
553 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
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 }
317e0fd394c5 added 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
317e0fd394c5 added 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 /* 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
558 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
559 {
317e0fd394c5 added 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 /* 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
561 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
562 {
317e0fd394c5 added 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 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
564 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
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 }
317e0fd394c5 added 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
317e0fd394c5 added 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 /* 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
569 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
570 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
571 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
572 {
317e0fd394c5 added 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 /* 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
574 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
575 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
576
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
577 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
578 {
317e0fd394c5 added 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 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
580 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
581 }
317e0fd394c5 added 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
317e0fd394c5 added 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 /* 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
584 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
585
317e0fd394c5 added 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 /* 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
587 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
588 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
589 {
317e0fd394c5 added 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 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
591 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
592 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
593 }
317e0fd394c5 added 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
317e0fd394c5 added 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 /* 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
596 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
597 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
598 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
599 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
600 {
317e0fd394c5 added 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 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
602 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
603 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
604 }
317e0fd394c5 added 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
317e0fd394c5 added 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 /* 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
607 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
608 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
609 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
610 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
611 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
612 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
613 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
614
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
615 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
616 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
617
317e0fd394c5 added 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 /* 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
619 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
620 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
621 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
622 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
623 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
624 NULL, rtp_session->control_url);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 28885
diff changeset
625
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
626 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
627 {
317e0fd394c5 added 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 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
629 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
630 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
631 }
317e0fd394c5 added 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
317e0fd394c5 added 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 /* 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
634 * 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
635 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
636 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
637 {
317e0fd394c5 added 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 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
639 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
640 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
641 }
317e0fd394c5 added 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
317e0fd394c5 added 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 /* 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
644 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
645 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
646 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
647
317e0fd394c5 added 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 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
649 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
650 &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
651 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
652 {
317e0fd394c5 added 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_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
654 &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
655 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
656 &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
657 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
658
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
659 /* 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
660 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
661 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
662 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
663 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
664 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
665 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
666 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
667
317e0fd394c5 added 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, "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
669 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
670 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
671 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
672 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
673
317e0fd394c5 added 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 /* 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
675 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
676 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
677 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
678 {
18876
f041273310d8 missing free() if bails out at step 12
ben
parents: 18874
diff changeset
679 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
680 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
681 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
682 }
317e0fd394c5 added 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
317e0fd394c5 added 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 /* 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
685 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
686 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
687 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
688 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
689
317e0fd394c5 added 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 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
691 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
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 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
694 {
317e0fd394c5 added 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 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
696 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
697 }
317e0fd394c5 added 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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
699 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
700 }