aboutsummaryrefslogtreecommitdiffstats
path: root/libavformat/rtsp.c
diff options
context:
space:
mode:
authorRonald S. Bultje <rsbultje@gmail.com>2008-09-07 01:22:18 +0000
committerRonald S. Bultje <rsbultje@gmail.com>2008-09-07 01:22:18 +0000
commit1256d16b6cf937c180bb898a37e1c79a27b79922 (patch)
tree6303fbea6e991249fd3a6a58041b27bab5bbe2f5 /libavformat/rtsp.c
parentff13ba92fd6bfee75db3d1e2f593474946cbfb68 (diff)
downloadffmpeg-1256d16b6cf937c180bb898a37e1c79a27b79922.tar.gz
Implement a RDT-specific SET_PARAMETER command that subscribes to the
first stream in a RTSP/RDT session. See discussion in "Realmedia patch" thread on ML. Originally committed as revision 15235 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavformat/rtsp.c')
-rw-r--r--libavformat/rtsp.c34
1 files changed, 33 insertions, 1 deletions
diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index 98f868e8a7..20e706229b 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -65,6 +65,7 @@ typedef struct RTSPState {
enum RTSPServerType server_type;
char last_reply[2048]; /* XXX: allocate ? */
RTPDemuxContext *cur_rtp;
+ int need_subscription;
} RTSPState;
typedef struct RTSPStream {
@@ -1034,6 +1035,9 @@ make_setup_request (AVFormatContext *s, const char *host, int port,
}
}
+ if (rt->server_type == RTSP_SERVER_RDT)
+ rt->need_subscription = 1;
+
return 0;
fail:
@@ -1295,6 +1299,31 @@ static int rtsp_read_packet(AVFormatContext *s,
int ret, len;
uint8_t buf[RTP_MAX_PACKET_LENGTH];
+ if (rt->server_type == RTSP_SERVER_RDT && rt->need_subscription) {
+ int i;
+ RTSPHeader reply1, *reply = &reply1;
+ char cmd[1024];
+
+ snprintf(cmd, sizeof(cmd),
+ "SET_PARAMETER %s RTSP/1.0\r\n"
+ "Subscribe: ",
+ s->filename);
+ for (i = 0; i < rt->nb_rtsp_streams; i++) {
+ if (i != 0) av_strlcat(cmd, ",", sizeof(cmd));
+ ff_rdt_subscribe_rule(
+ rt->rtsp_streams[i]->rtp_ctx,
+ cmd, sizeof(cmd), i, 0);
+ }
+ av_strlcat(cmd, "\r\n", sizeof(cmd));
+ rtsp_send_cmd(s, cmd, reply, NULL);
+ if (reply->status_code != RTSP_STATUS_OK)
+ return AVERROR_INVALIDDATA;
+ rt->need_subscription = 0;
+
+ if (rt->state == RTSP_STATE_PLAYING)
+ rtsp_read_play (s);
+ }
+
/* get next frames from the same RTP packet */
if (rt->cur_rtp) {
ret = rtp_parse_packet(rt->cur_rtp, pkt, NULL, 0);
@@ -1342,6 +1371,7 @@ static int rtsp_read_play(AVFormatContext *s)
av_log(s, AV_LOG_DEBUG, "hello state=%d\n", rt->state);
+ if (!(rt->server_type == RTSP_SERVER_RDT && rt->need_subscription)) {
if (rt->state == RTSP_STATE_PAUSED) {
snprintf(cmd, sizeof(cmd),
"PLAY %s RTSP/1.0\r\n",
@@ -1357,6 +1387,7 @@ static int rtsp_read_play(AVFormatContext *s)
if (reply->status_code != RTSP_STATUS_OK) {
return -1;
}
+ }
rt->state = RTSP_STATE_PLAYING;
return 0;
}
@@ -1372,7 +1403,7 @@ static int rtsp_read_pause(AVFormatContext *s)
if (rt->state != RTSP_STATE_PLAYING)
return 0;
-
+ else if (!(rt->server_type == RTSP_SERVER_RDT && rt->need_subscription)) {
snprintf(cmd, sizeof(cmd),
"PAUSE %s RTSP/1.0\r\n",
s->filename);
@@ -1380,6 +1411,7 @@ static int rtsp_read_pause(AVFormatContext *s)
if (reply->status_code != RTSP_STATUS_OK) {
return -1;
}
+ }
rt->state = RTSP_STATE_PAUSED;
return 0;
}