annotate stream/librtsp/rtsp_rtp.c @ 23185:3d2aedade36f

dvdnav:// depends on our fork of libdvdnav
author nicodvb
date Tue, 01 May 2007 20:02:05 +0000
parents 64d82a45a05d
children 3744685df066
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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
21 #include <unistd.h>
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
22 #include <stdio.h>
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
23 #include <string.h>
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
24 #include <errno.h>
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
25 #include <stdlib.h>
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
26 #include <sys/types.h>
18849
2f4cf2d615cb fix compilation under mingw (thanks to tempn AT twmi DOT rr DOT com for report and pacman for fix)
ben
parents: 18837
diff changeset
27 #include <inttypes.h>
18829
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
28
18837
70bcf587a49a includes before checking for defines (thanks Reimar for watching me)
ben
parents: 18836
diff changeset
29 #include "config.h"
70bcf587a49a includes before checking for defines (thanks Reimar for watching me)
ben
parents: 18836
diff changeset
30
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
31 #ifndef HAVE_WINSOCK2
18835
65e867664a43 avoid messing up with includes
ben
parents: 18829
diff changeset
32 #include <netdb.h>
18829
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
33 #include <netinet/in.h>
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
34 #include <sys/socket.h>
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
35 #include <arpa/inet.h>
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
36 #else
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
37 #include <winsock2.h>
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
38 #include <ws2tcpip.h>
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
39 #endif
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
40
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
41 #include "mp_msg.h"
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
42 #include "rtsp.h"
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
43 #include "rtsp_rtp.h"
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
44 #include "rtsp_session.h"
317e0fd394c5 added 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 "../freesdp/common.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 "../freesdp/parser.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
47
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
48 #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
49 #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
50
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
51 #define 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
52 #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
53 #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
54 #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
55 #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
56 #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
57 #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
58 #define RTSP_TRANSPORT_REQUEST "Transport: RTP/AVP;%s;%s%i-%i;mode=\"PLAY\""
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
59
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
60 #define RTSP_TRANSPORT_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
61 #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
62
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
63 #define RTSP_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
64 #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
65 #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
66 #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
67
317e0fd394c5 added 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_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
69 #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
70
317e0fd394c5 added 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 /* 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
72 #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
73 #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
74 #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
75
317e0fd394c5 added 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 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
77 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
78
317e0fd394c5 added 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 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
80 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
81 {
317e0fd394c5 added 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 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
83 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
84
317e0fd394c5 added 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 /* 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
86 * 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
87 * 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
88 * 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
89 */
317e0fd394c5 added 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
317e0fd394c5 added 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 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
92 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
93 char rtcp_content[RTCP_RR_SIZE];
317e0fd394c5 added 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 strcpy (rtcp_content, RTCP_RR);
317e0fd394c5 added 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 send (st->rtcp_socket, rtcp_content, RTCP_RR_SIZE, 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
96
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
97 /* ping RTSP server to keep connection alive.
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
98 we use OPTIONS instead of PING as not all servers support it */
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
99 rtsp_request_options (s, "*");
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
100 st->count = 0;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
101 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
102 else
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
103 st->count++;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
104 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
105
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
106 static struct rtp_rtsp_session_t *
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
107 rtp_session_new (void)
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
108 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
109 struct rtp_rtsp_session_t *st = NULL;
317e0fd394c5 added 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 st = malloc (sizeof (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
112
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
113 st->rtp_socket = -1;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
114 st->rtcp_socket = -1;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
115 st->control_url = NULL;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
116 st->count = 0;
317e0fd394c5 added 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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
118 return st;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
119 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
120
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
121 void
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
122 rtp_session_free (struct rtp_rtsp_session_t *st)
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
123 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
124 if (!st)
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
125 return;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
126
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
127 if (st->rtp_socket != -1)
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
128 close (st->rtp_socket);
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
129 if (st->rtcp_socket != -1)
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
130 close (st->rtcp_socket);
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
131
317e0fd394c5 added 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 if (st->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
133 free (st->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
134 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
135 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
136
317e0fd394c5 added 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 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
138 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
139 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
140 {
317e0fd394c5 added 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 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
142 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
143
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
144 st->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
145 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
146 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
147
317e0fd394c5 added 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 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
149 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
150 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
151 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
152 char *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
153 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
154 char *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
155
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
156 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
157
317e0fd394c5 added 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 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
159
317e0fd394c5 added 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 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
161 {
317e0fd394c5 added 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 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
163
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
164 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
165 {
317e0fd394c5 added 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 parse3 = strstr (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
167
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
168 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
169 parse3[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
170
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
171 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
172 }
317e0fd394c5 added 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 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
174 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
175 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
176 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
177 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
178 }
317e0fd394c5 added 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 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
180 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
181 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
182 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
183 }
317e0fd394c5 added 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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
185 *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
186 *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
187
317e0fd394c5 added 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 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
189
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
190 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
191 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
192
317e0fd394c5 added 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 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
194 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
195 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
196 char *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
197 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
198
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
199 char *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
200 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
201 int 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
202
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
203 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
204 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
205 {
317e0fd394c5 added 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 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
207 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
208 }
317e0fd394c5 added 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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
210 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
211 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
212 {
317e0fd394c5 added 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 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
214 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
215 }
317e0fd394c5 added 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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
217 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
218 - 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
219 dest = (char *) malloc (len + 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 snprintf (dest, len, parse1 + strlen (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
221 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
222
317e0fd394c5 added 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 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
224 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
225
317e0fd394c5 added 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 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
227 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
228 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
229 struct 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
230 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
231 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
232
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
233 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
234 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
235
317e0fd394c5 added 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 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
237 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
238 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
239
317e0fd394c5 added 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 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
241 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
242 {
317e0fd394c5 added 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 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
244 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
245 }
317e0fd394c5 added 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 sin.sin_family = AF_INET;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
248 sin.sin_addr.s_addr = INADDR_ANY;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
249 sin.sin_port = htons (client_port);
317e0fd394c5 added 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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
251 if (bind (s, (struct sockaddr *) &sin, sizeof (sin)))
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
252 {
317e0fd394c5 added 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 #ifndef HAVE_WINSOCK2
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
254 if (errno != EINPROGRESS)
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
255 #else
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
256 if (WSAGetLastError() != WSAEINPROGRESS)
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
257 #endif
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
258 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
259 close (s);
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
260 return -1;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
261 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
262 }
317e0fd394c5 added 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 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
265 memcpy (&(sin.sin_addr.s_addr), hp->h_addr, sizeof (hp->h_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
266 sin.sin_port = htons (server_port);
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
267
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
268 /* datagram socket */
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
269 if (connect (s, (struct sockaddr *) &sin, sizeof (sin)) < 0)
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
270 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
271 close (s);
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
272 return -1;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
273 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
274
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
275 return s;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
276 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
277
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
278 static int
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
279 rtp_connect (char *hostname, int port)
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
280 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
281 struct sockaddr_in sin;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
282 struct timeval tv;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
283 int err, err_len;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
284 int rxsockbufsz;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
285 int s;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
286 fd_set set;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
287
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
288 if (port <= 1023)
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
289 return -1;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
290
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
291 s = socket (PF_INET, SOCK_DGRAM, 0);
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
292 if (s == -1)
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
293 return -1;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
294
317e0fd394c5 added 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 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
296 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
297 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
298 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
299 #ifndef HAVE_WINSOCK2
317e0fd394c5 added 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 #ifdef USE_ATON
317e0fd394c5 added 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 inet_aton (hostname, &sin.sin_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
302 #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
303 inet_pton (AF_INET, hostname, &sin.sin_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
304 #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
305 #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
306 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
307 #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
308 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
309
317e0fd394c5 added 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 /* 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
311 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
312 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
313 &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
314 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
315
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
316 /* if 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
317 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
318 {
317e0fd394c5 added 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 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
320 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
321 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
322
317e0fd394c5 added 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 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
324 {
317e0fd394c5 added 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 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
326 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
327 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
328 }
317e0fd394c5 added 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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
331 /* 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
332 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
333 {
317e0fd394c5 added 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 #ifndef HAVE_WINSOCK2
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
335 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
336 #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
337 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
338 #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
339 {
317e0fd394c5 added 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 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
341 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
342 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
343 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
344 }
317e0fd394c5 added 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 tv.tv_sec = 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
347 tv.tv_usec = (1 * 1000000); /* 1 second timeout */
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
348
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
349 FD_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
350 FD_SET (s, &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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
352 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
353 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
354 {
317e0fd394c5 added 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 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
356 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
357 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
358 }
317e0fd394c5 added 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 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
360 {
317e0fd394c5 added 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 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
362 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
363 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
364 }
317e0fd394c5 added 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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
366 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
367 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
368 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
369 {
317e0fd394c5 added 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 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
371 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
372 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
373 }
317e0fd394c5 added 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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
375 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
376 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
377
317e0fd394c5 added 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 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
379 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
380 {
317e0fd394c5 added 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 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
382
317e0fd394c5 added 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 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
384 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
385
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
386 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
387
18836
10d3a190d935 network code portability for win32
ben
parents: 18835
diff changeset
388 #ifndef HAVE_WINSOCK2
10d3a190d935 network code portability for win32
ben
parents: 18835
diff changeset
389 #ifdef USE_ATON
10d3a190d935 network code portability for win32
ben
parents: 18835
diff changeset
390 inet_aton (addr, &sin.sin_addr);
10d3a190d935 network code portability for win32
ben
parents: 18835
diff changeset
391 #else
10d3a190d935 network code portability for win32
ben
parents: 18835
diff changeset
392 inet_pton (AF_INET, addr, &sin.sin_addr);
10d3a190d935 network code portability for win32
ben
parents: 18835
diff changeset
393 #endif
10d3a190d935 network code portability for win32
ben
parents: 18835
diff changeset
394 #else
10d3a190d935 network code portability for win32
ben
parents: 18835
diff changeset
395 sin.sin_addr.s_addr = htonl (INADDR_ANY);
10d3a190d935 network code portability for win32
ben
parents: 18835
diff changeset
396 #endif
10d3a190d935 network code portability for win32
ben
parents: 18835
diff changeset
397
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
398 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
399 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
400
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
401 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
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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
404 struct rtp_rtsp_session_t *
317e0fd394c5 added 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 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
406 {
317e0fd394c5 added 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 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
408 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
409 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
410 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
411
317e0fd394c5 added 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* 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
413 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
414 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
415 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
416
317e0fd394c5 added 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 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
418 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
419 int 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
420
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
421 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
422 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
423
317e0fd394c5 added 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_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
425 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
426 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
427 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
428 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
429 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
430
317e0fd394c5 added 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 /* 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
432 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
433 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
434 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
435 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
436
317e0fd394c5 added 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 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
438 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
439 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
440 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
441 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
442
317e0fd394c5 added 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 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
444 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
445 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
446
317e0fd394c5 added 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 /* 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
448 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
449 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
450 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
451 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
452 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
453 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
454 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
455
317e0fd394c5 added 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 /* 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
457 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
458 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
459 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
460 {
317e0fd394c5 added 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 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
462 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
463 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
464 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
465 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
466 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
467
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
468 /* 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
469 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
470 {
317e0fd394c5 added 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 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
472 "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
473 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
474 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
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
317e0fd394c5 added 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 /* 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
478 * 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
479 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
480 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
481 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
482 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
483 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
484
317e0fd394c5 added 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 /* 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
486 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
487 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
488 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
489 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
490 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
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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
493 /* 6. parse the `m=<media> <port> <transport> <fmt list>' 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
494
317e0fd394c5 added 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 /* 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
496 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
497 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
498 {
317e0fd394c5 added 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 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
500 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
501 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
502
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
503 /* 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
504 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
505 {
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
506 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
507 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
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
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
510 /* only MPEG-TS is supported at the moment */
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
511 if (!strstr (fsdp_get_media_format (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
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;
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
538
317e0fd394c5 added 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 }
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
576
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
577 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);
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
614
317e0fd394c5 added 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);
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
625
317e0fd394c5 added new native rtsp demuxer code for mpeg-ts over rtp (now both real and non-real servers should be handled)
ben
parents:
diff changeset
626 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 }