Commit 119b4668 authored by Ronald S. Bultje's avatar Ronald S. Bultje

Implement a RTSPTransport field, which allows proper separation of server

types and their non-standard extensions, and the data they serve. Practically,
this patch allows Real servers to serve normal non-RDT (standard RTP) data.
See discussion on ML in "Realmedia patch" thread.

Originally committed as revision 15484 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent ab63fb03
...@@ -51,6 +51,12 @@ enum RTSPServerType { ...@@ -51,6 +51,12 @@ enum RTSPServerType {
RTSP_SERVER_LAST RTSP_SERVER_LAST
}; };
enum RTSPTransport {
RTSP_TRANSPORT_RTP,
RTSP_TRANSPORT_RDT,
RTSP_TRANSPORT_LAST
};
typedef struct RTSPState { typedef struct RTSPState {
URLContext *rtsp_hd; /* RTSP TCP connexion handle */ URLContext *rtsp_hd; /* RTSP TCP connexion handle */
int nb_rtsp_streams; int nb_rtsp_streams;
...@@ -63,6 +69,7 @@ typedef struct RTSPState { ...@@ -63,6 +69,7 @@ typedef struct RTSPState {
// ByteIOContext rtsp_gb; // ByteIOContext rtsp_gb;
int seq; /* RTSP command sequence number */ int seq; /* RTSP command sequence number */
char session_id[512]; char session_id[512];
enum RTSPTransport transport;
enum RTSPLowerTransport lower_transport; enum RTSPLowerTransport lower_transport;
enum RTSPServerType server_type; enum RTSPServerType server_type;
char last_reply[2048]; /* XXX: allocate ? */ char last_reply[2048]; /* XXX: allocate ? */
...@@ -538,6 +545,9 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1, ...@@ -538,6 +545,9 @@ static void sdp_parse_line(AVFormatContext *s, SDPParseState *s1,
rtsp_parse_range_npt(p, &start, &end); rtsp_parse_range_npt(p, &start, &end);
s->start_time= start; s->start_time= start;
s->duration= (end==AV_NOPTS_VALUE)?AV_NOPTS_VALUE:end-start; // AV_NOPTS_VALUE means live broadcast (and can't seek) s->duration= (end==AV_NOPTS_VALUE)?AV_NOPTS_VALUE:end-start; // AV_NOPTS_VALUE means live broadcast (and can't seek)
} else if (av_strstart(p, "IsRealDataType:integer;",&p)) {
if (atoi(p) == 1)
rt->transport = RTSP_TRANSPORT_RDT;
} else if (s->nb_streams > 0) { } else if (s->nb_streams > 0) {
rtsp_st = s->streams[s->nb_streams - 1]->priv_data; rtsp_st = s->streams[s->nb_streams - 1]->priv_data;
if (rtsp_st->dynamic_handler && if (rtsp_st->dynamic_handler &&
...@@ -637,10 +647,13 @@ static void rtsp_parse_transport(RTSPHeader *reply, const char *p) ...@@ -637,10 +647,13 @@ static void rtsp_parse_transport(RTSPHeader *reply, const char *p)
get_word_sep(lower_transport, sizeof(lower_transport), get_word_sep(lower_transport, sizeof(lower_transport),
";,", &p); ";,", &p);
} }
} else if (!strcasecmp (transport_protocol, "x-pn-tng")) { th->transport = RTSP_TRANSPORT_RTP;
} else if (!strcasecmp (transport_protocol, "x-pn-tng") ||
!strcasecmp (transport_protocol, "x-real-rdt")) {
/* x-pn-tng/<protocol> */ /* x-pn-tng/<protocol> */
get_word_sep(lower_transport, sizeof(lower_transport), "/;,", &p); get_word_sep(lower_transport, sizeof(lower_transport), "/;,", &p);
profile[0] = '\0'; profile[0] = '\0';
th->transport = RTSP_TRANSPORT_RDT;
} }
if (!strcasecmp(lower_transport, "TCP")) if (!strcasecmp(lower_transport, "TCP"))
th->lower_transport = RTSP_LOWER_TRANSPORT_TCP; th->lower_transport = RTSP_LOWER_TRANSPORT_TCP;
...@@ -908,7 +921,7 @@ make_setup_request (AVFormatContext *s, const char *host, int port, ...@@ -908,7 +921,7 @@ make_setup_request (AVFormatContext *s, const char *host, int port,
char cmd[2048]; char cmd[2048];
const char *trans_pref; const char *trans_pref;
if (rt->server_type == RTSP_SERVER_REAL) if (rt->transport == RTSP_TRANSPORT_RDT)
trans_pref = "x-pn-tng"; trans_pref = "x-pn-tng";
else else
trans_pref = "RTP/AVP"; trans_pref = "RTP/AVP";
...@@ -952,7 +965,7 @@ make_setup_request (AVFormatContext *s, const char *host, int port, ...@@ -952,7 +965,7 @@ make_setup_request (AVFormatContext *s, const char *host, int port,
av_strlcat(transport, "unicast;", sizeof(transport)); av_strlcat(transport, "unicast;", sizeof(transport));
av_strlcatf(transport, sizeof(transport), av_strlcatf(transport, sizeof(transport),
"client_port=%d", port); "client_port=%d", port);
if (rt->server_type == RTSP_SERVER_RTP) if (rt->transport == RTSP_TRANSPORT_RTP)
av_strlcatf(transport, sizeof(transport), "-%d", port + 1); av_strlcatf(transport, sizeof(transport), "-%d", port + 1);
} }
...@@ -993,12 +1006,14 @@ make_setup_request (AVFormatContext *s, const char *host, int port, ...@@ -993,12 +1006,14 @@ make_setup_request (AVFormatContext *s, const char *host, int port,
/* XXX: same protocol for all streams is required */ /* XXX: same protocol for all streams is required */
if (i > 0) { if (i > 0) {
if (reply->transports[0].lower_transport != rt->lower_transport) { if (reply->transports[0].lower_transport != rt->lower_transport ||
reply->transports[0].transport != rt->transport) {
err = AVERROR_INVALIDDATA; err = AVERROR_INVALIDDATA;
goto fail; goto fail;
} }
} else { } else {
rt->lower_transport = reply->transports[0].lower_transport; rt->lower_transport = reply->transports[0].lower_transport;
rt->transport = reply->transports[0].transport;
} }
/* close RTP connection if not choosen */ /* close RTP connection if not choosen */
...@@ -1325,6 +1340,7 @@ static int rtsp_read_packet(AVFormatContext *s, ...@@ -1325,6 +1340,7 @@ static int rtsp_read_packet(AVFormatContext *s,
for (i = 0; i < rt->nb_rtsp_streams; i++) { for (i = 0; i < rt->nb_rtsp_streams; i++) {
if (i != 0) av_strlcat(cmd, ",", sizeof(cmd)); if (i != 0) av_strlcat(cmd, ",", sizeof(cmd));
ff_rdt_subscribe_rule(cmd, sizeof(cmd), i, 0); ff_rdt_subscribe_rule(cmd, sizeof(cmd), i, 0);
if (rt->transport == RTSP_TRANSPORT_RDT)
ff_rdt_subscribe_rule2( ff_rdt_subscribe_rule2(
rt->rtsp_streams[i]->rtp_ctx, rt->rtsp_streams[i]->rtp_ctx,
cmd, sizeof(cmd), i, 0); cmd, sizeof(cmd), i, 0);
...@@ -1341,7 +1357,7 @@ static int rtsp_read_packet(AVFormatContext *s, ...@@ -1341,7 +1357,7 @@ static int rtsp_read_packet(AVFormatContext *s,
/* get next frames from the same RTP packet */ /* get next frames from the same RTP packet */
if (rt->cur_rtp) { if (rt->cur_rtp) {
if (rt->server_type == RTSP_SERVER_REAL) if (rt->transport == RTSP_TRANSPORT_RDT)
ret = ff_rdt_parse_packet(rt->cur_rtp, pkt, NULL, 0); ret = ff_rdt_parse_packet(rt->cur_rtp, pkt, NULL, 0);
else else
ret = rtp_parse_packet(rt->cur_rtp, pkt, NULL, 0); ret = rtp_parse_packet(rt->cur_rtp, pkt, NULL, 0);
...@@ -1371,7 +1387,7 @@ static int rtsp_read_packet(AVFormatContext *s, ...@@ -1371,7 +1387,7 @@ static int rtsp_read_packet(AVFormatContext *s,
} }
if (len < 0) if (len < 0)
return len; return len;
if (rt->server_type == RTSP_SERVER_REAL) if (rt->transport == RTSP_TRANSPORT_RDT)
ret = ff_rdt_parse_packet(rtsp_st->rtp_ctx, pkt, buf, len); ret = ff_rdt_parse_packet(rtsp_st->rtp_ctx, pkt, buf, len);
else else
ret = rtp_parse_packet(rtsp_st->rtp_ctx, pkt, buf, len); ret = rtp_parse_packet(rtsp_st->rtp_ctx, pkt, buf, len);
......
...@@ -50,6 +50,7 @@ typedef struct RTSPTransportField { ...@@ -50,6 +50,7 @@ typedef struct RTSPTransportField {
int server_port_min, server_port_max; /**< RTP ports */ int server_port_min, server_port_max; /**< RTP ports */
int ttl; /**< ttl value */ int ttl; /**< ttl value */
uint32_t destination; /**< destination IP address */ uint32_t destination; /**< destination IP address */
int transport;
enum RTSPLowerTransport lower_transport; enum RTSPLowerTransport lower_transport;
} RTSPTransportField; } RTSPTransportField;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment