[FFmpeg-cvslog] avformat/udp: Allow to specify DSCP class
Vincent Bernat
git at videolan.org
Thu Nov 27 20:08:49 CET 2014
ffmpeg | branch: master | Vincent Bernat <vincent at bernat.im> | Fri May 23 15:26:32 2014 +0200| [5269cef4087f3e46e734eb5dfc38085e630514d9] | committer: Michael Niedermayer
avformat/udp: Allow to specify DSCP class
By appending `?dscp=26` to the URL, IP packets will be classified as
AF31 (assured forwarding for multimedia flows with low probability of
loss). On congested network, this allows a user to assign priorities to
flows.
Signed-off-by: Vincent Bernat <vincent at bernat.im>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=5269cef4087f3e46e734eb5dfc38085e630514d9
---
libavformat/udp.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 828b741..91c7910 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -556,7 +556,7 @@ static int parse_source_list(char *buf, char **sources, int *num_sources,
static int udp_open(URLContext *h, const char *uri, int flags)
{
char hostname[1024], localaddr[1024] = "";
- int port, udp_fd = -1, tmp, bind_ret = -1;
+ int port, udp_fd = -1, tmp, bind_ret = -1, dscp = -1;
UDPContext *s = h->priv_data;
int is_output;
const char *p;
@@ -612,6 +612,9 @@ static int udp_open(URLContext *h, const char *uri, int flags)
if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
s->is_connected = strtol(buf, NULL, 10);
}
+ if (av_find_info_tag(buf, sizeof(buf), "dscp", p)) {
+ dscp = strtol(buf, NULL, 10);
+ }
if (av_find_info_tag(buf, sizeof(buf), "fifo_size", p)) {
s->circular_buffer_size = strtol(buf, NULL, 10);
if (!HAVE_PTHREAD_CANCEL)
@@ -695,6 +698,12 @@ static int udp_open(URLContext *h, const char *uri, int flags)
av_log(h, AV_LOG_WARNING, "socket option UDPLITE_RECV_CSCOV not available");
}
+ if (dscp >= 0) {
+ dscp <<= 2;
+ if (setsockopt (udp_fd, IPPROTO_IP, IP_TOS, &dscp, sizeof(dscp)) != 0)
+ goto fail;
+ }
+
/* If multicast, try binding the multicast address first, to avoid
* receiving UDP packets from other sources aimed at the same UDP
* port. This fails on windows. This makes sending to the same address
More information about the ffmpeg-cvslog
mailing list