enum RTSPLowerTransport lower_transport;
enum RTSPServerType server_type;
char last_reply[2048]; /* XXX: allocate ? */
- RTPDemuxContext *cur_rtp;
+ void *cur_tx;
int need_subscription;
} RTSPState;
typedef struct RTSPStream {
URLContext *rtp_handle; /* RTP stream handle */
- RTPDemuxContext *rtp_ctx; /* RTP parse context */
+ void *tx_ctx; /* RTP/RDT parse context */
int stream_index; /* corresponding stream index, if any. -1 if none (MPEG2TS case) */
int interleaved_min, interleaved_max; /* interleave ids, if TCP transport */
return;
}
-typedef struct attrname_map
-{
+typedef struct {
const char *str;
uint16_t type;
uint32_t offset;
-} attrname_map_t;
+} AttrNameMap;
/* All known fmtp parmeters and the corresping RTPAttrTypeEnum */
#define ATTR_NAME_TYPE_INT 0
#define ATTR_NAME_TYPE_STR 1
-static const attrname_map_t attr_names[]=
+static const AttrNameMap attr_names[]=
{
{"SizeLength", ATTR_NAME_TYPE_INT, offsetof(rtp_payload_data_t, sizelength)},
{"IndexLength", ATTR_NAME_TYPE_INT, offsetof(rtp_payload_data_t, indexlength)},
rtsp_st = st->priv_data;
if (rtsp_st->sdp_payload_type == payload_type) {
if(rtsp_st->dynamic_handler && rtsp_st->dynamic_handler->parse_sdp_a_line) {
- if(!rtsp_st->dynamic_handler->parse_sdp_a_line(st, rtsp_st->dynamic_protocol_context, buf)) {
+ if(!rtsp_st->dynamic_handler->parse_sdp_a_line(s, i, rtsp_st->dynamic_protocol_context, buf)) {
sdp_parse_fmtp(st, p);
}
} else {
rtsp_st = st->priv_data;
if (rtsp_st->sdp_payload_type == payload_type) {
if(rtsp_st->dynamic_handler && rtsp_st->dynamic_handler->parse_sdp_a_line) {
- rtsp_st->dynamic_handler->parse_sdp_a_line(st, rtsp_st->dynamic_protocol_context, buf);
+ rtsp_st->dynamic_handler->parse_sdp_a_line(s, i, rtsp_st->dynamic_protocol_context, buf);
}
}
}
rtsp_st = s->streams[s->nb_streams - 1]->priv_data;
if (rtsp_st->dynamic_handler &&
rtsp_st->dynamic_handler->parse_sdp_a_line)
- rtsp_st->dynamic_handler->parse_sdp_a_line(s->streams[s->nb_streams - 1],
+ rtsp_st->dynamic_handler->parse_sdp_a_line(s, s->nb_streams - 1,
rtsp_st->dynamic_protocol_context, buf);
}
break;
for(i=0;i<rt->nb_rtsp_streams;i++) {
rtsp_st = rt->rtsp_streams[i];
if (rtsp_st) {
- if (rtsp_st->rtp_ctx)
- rtp_parse_close(rtsp_st->rtp_ctx);
+ if (rtsp_st->tx_ctx) {
+ if (rt->transport == RTSP_TRANSPORT_RDT)
+ ff_rdt_parse_close(rtsp_st->tx_ctx);
+ else
+ rtp_parse_close(rtsp_st->tx_ctx);
+ }
if (rtsp_st->rtp_handle)
url_close(rtsp_st->rtp_handle);
if (rtsp_st->dynamic_handler && rtsp_st->dynamic_protocol_context)
static int
rtsp_open_transport_ctx(AVFormatContext *s, RTSPStream *rtsp_st)
{
+ RTSPState *rt = s->priv_data;
AVStream *st = NULL;
/* open the RTP context */
st = s->streams[rtsp_st->stream_index];
if (!st)
s->ctx_flags |= AVFMTCTX_NOHEADER;
- rtsp_st->rtp_ctx = rtp_parse_open(s, st, rtsp_st->rtp_handle, rtsp_st->sdp_payload_type, &rtsp_st->rtp_payload_data);
- if (!rtsp_st->rtp_ctx) {
+ if (rt->transport == RTSP_TRANSPORT_RDT)
+ rtsp_st->tx_ctx = ff_rdt_parse_open(s, st->index,
+ rtsp_st->dynamic_protocol_context,
+ rtsp_st->dynamic_handler);
+ else
+ rtsp_st->tx_ctx = rtp_parse_open(s, st, rtsp_st->rtp_handle,
+ rtsp_st->sdp_payload_type,
+ &rtsp_st->rtp_payload_data);
+
+ if (!rtsp_st->tx_ctx) {
return AVERROR(ENOMEM);
- } else {
+ } else if (rt->transport != RTSP_TRANSPORT_RDT) {
if(rtsp_st->dynamic_handler) {
- rtp_parse_set_dynamic_protocol(rtsp_st->rtp_ctx,
+ rtp_parse_set_dynamic_protocol(rtsp_st->tx_ctx,
rtsp_st->dynamic_protocol_context,
rtsp_st->dynamic_handler);
}
if (ret != len)
return -1;
if (rt->transport == RTSP_TRANSPORT_RDT &&
- ff_rdt_parse_header(buf, len, &id, NULL, NULL, NULL) < 0)
+ ff_rdt_parse_header(buf, len, &id, NULL, NULL, NULL, NULL) < 0)
return -1;
/* find the matching stream */
ff_rdt_subscribe_rule(cmd, sizeof(cmd), i, 0);
if (rt->transport == RTSP_TRANSPORT_RDT)
ff_rdt_subscribe_rule2(
- rt->rtsp_streams[i]->rtp_ctx,
+ rt->rtsp_streams[i]->tx_ctx,
cmd, sizeof(cmd), i, 0);
}
av_strlcat(cmd, "\r\n", sizeof(cmd));
}
/* get next frames from the same RTP packet */
- if (rt->cur_rtp) {
+ if (rt->cur_tx) {
if (rt->transport == RTSP_TRANSPORT_RDT)
- ret = ff_rdt_parse_packet(rt->cur_rtp, pkt, NULL, 0);
+ ret = ff_rdt_parse_packet(rt->cur_tx, pkt, NULL, 0);
else
- ret = rtp_parse_packet(rt->cur_rtp, pkt, NULL, 0);
+ ret = rtp_parse_packet(rt->cur_tx, pkt, NULL, 0);
if (ret == 0) {
- rt->cur_rtp = NULL;
+ rt->cur_tx = NULL;
return 0;
} else if (ret == 1) {
return 0;
} else {
- rt->cur_rtp = NULL;
+ rt->cur_tx = NULL;
}
}
case RTSP_LOWER_TRANSPORT_UDP:
case RTSP_LOWER_TRANSPORT_UDP_MULTICAST:
len = udp_read_packet(s, &rtsp_st, buf, sizeof(buf));
- if (len >=0 && rtsp_st->rtp_ctx)
- rtp_check_and_send_back_rr(rtsp_st->rtp_ctx, len);
+ if (len >=0 && rtsp_st->tx_ctx && rt->transport == RTSP_TRANSPORT_RTP)
+ rtp_check_and_send_back_rr(rtsp_st->tx_ctx, len);
break;
}
if (len < 0)
return len;
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->tx_ctx, pkt, buf, len);
else
- ret = rtp_parse_packet(rtsp_st->rtp_ctx, pkt, buf, len);
+ ret = rtp_parse_packet(rtsp_st->tx_ctx, pkt, buf, len);
if (ret < 0)
goto redo;
if (ret == 1) {
/* more packets may follow, so we save the RTP context */
- rt->cur_rtp = rtsp_st->rtp_ctx;
+ rt->cur_tx = rtsp_st->tx_ctx;
}
return 0;
}