[FFmpeg-cvslog] r26246 - in trunk: doc/protocols.texi libavformat/rtsp.c libavformat/rtsp.h
mstorsjo
subversion
Thu Jan 6 16:22:58 CET 2011
Author: mstorsjo
Date: Thu Jan 6 16:22:58 2011
New Revision: 26246
Log:
rtsp: Allow requesting of filtering of source packets
If filtered, only packets from the right source address and port
are received.
To test, play back e.g. some mpeg4 video RTSP stream (where the
video stream is the first stream in the presentation) over UDP.
While receiving this stream, send another stream to the same port:
ffmpeg -re -i <whatever> -vcodec mpeg4 -an -f rtp
rtp://127.0.0.1:5000?localport=1234
Normally, the RTSP playback reports lots of errors at this point.
If the RTSP stream has the ?filter_src option enabled, these
interferring packets are ignored.
Modified:
trunk/doc/protocols.texi
trunk/libavformat/rtsp.c
trunk/libavformat/rtsp.h
Modified: trunk/doc/protocols.texi
==============================================================================
--- trunk/doc/protocols.texi Thu Jan 6 16:16:50 2011 (r26245)
+++ trunk/doc/protocols.texi Thu Jan 6 16:22:58 2011 (r26246)
@@ -251,6 +251,9 @@ Use UDP multicast as lower transport pro
@item http
Use HTTP tunneling as lower transport protocol, which is useful for
passing proxies.
+
+ at item filter_src
+Accept packets only from negotiated peer address and port.
@end table
Multiple lower transport protocols may be specified, in that case they are
Modified: trunk/libavformat/rtsp.c
==============================================================================
--- trunk/libavformat/rtsp.c Thu Jan 6 16:16:50 2011 (r26245)
+++ trunk/libavformat/rtsp.c Thu Jan 6 16:22:58 2011 (r26246)
@@ -1186,16 +1186,18 @@ static int make_setup_request(AVFormatCo
break;
case RTSP_LOWER_TRANSPORT_UDP: {
- char url[1024];
+ char url[1024], options[30] = "";
+ if (rt->filter_source)
+ av_strlcpy(options, "?connect=1", sizeof(options));
/* Use source address if specified */
if (reply->transports[0].source[0]) {
ff_url_join(url, sizeof(url), "rtp", NULL,
reply->transports[0].source,
- reply->transports[0].server_port_min, NULL);
+ reply->transports[0].server_port_min, options);
} else {
ff_url_join(url, sizeof(url), "rtp", NULL, host,
- reply->transports[0].server_port_min, NULL);
+ reply->transports[0].server_port_min, options);
}
if (!(rt->server_type == RTSP_SERVER_WMS && i > 1) &&
rtp_set_remote_url(rtsp_st->rtp_handle, url) < 0) {
@@ -1315,6 +1317,8 @@ redirect:
} else if(!strcmp(option, "http")) {
lower_transport_mask |= (1<< RTSP_LOWER_TRANSPORT_TCP);
rt->control_transport = RTSP_MODE_TUNNEL;
+ } else if (!strcmp(option, "filter_src")) {
+ rt->filter_source = 1;
} else {
/* Write options back into the buffer, using memmove instead
* of strcpy since the strings may overlap. */
Modified: trunk/libavformat/rtsp.h
==============================================================================
--- trunk/libavformat/rtsp.h Thu Jan 6 16:16:50 2011 (r26245)
+++ trunk/libavformat/rtsp.h Thu Jan 6 16:22:58 2011 (r26246)
@@ -309,6 +309,10 @@ typedef struct RTSPState {
/** Reusable buffer for receiving packets */
uint8_t* recvbuf;
+
+ /** Filter incoming UDP packets - receive packets only from the right
+ * source address and port. */
+ int filter_source;
} RTSPState;
/**
More information about the ffmpeg-cvslog
mailing list