From 88d2e1238610a9b72b0bbd64716bcb866d6d8d38 Mon Sep 17 00:00:00 2001
From: Tristan Matthews <tristan.matthews@savoirfairelinux.com>
Date: Fri, 28 Sep 2012 11:59:09 -0400
Subject: [PATCH 1/1] rtpproto: add "reuse" option

---
 libavformat/rtpproto.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index 17b0f64..c17ac80 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -102,7 +102,8 @@ static av_printf_format(3, 4) void url_add_option(char *buf, int buf_size, const
 static void build_udp_url(char *buf, int buf_size,
                           const char *hostname, int port,
                           int local_port, int ttl,
-                          int max_packet_size, int connect)
+                          int max_packet_size, int connect,
+                          int reuse)
 {
     ff_url_join(buf, buf_size, "udp", NULL, hostname, port, NULL);
     if (local_port >= 0)
@@ -113,6 +114,8 @@ static void build_udp_url(char *buf, int buf_size,
         url_add_option(buf, buf_size, "pkt_size=%d", max_packet_size);
     if (connect)
         url_add_option(buf, buf_size, "connect=1");
+    if (reuse)
+        url_add_option(buf, buf_size, "reuse=1");
     url_add_option(buf, buf_size, "fifo_size=0");
 }
 
@@ -137,7 +140,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
 {
     RTPContext *s = h->priv_data;
     int rtp_port, rtcp_port,
-        ttl, connect,
+        ttl, connect, reuse,
         local_rtp_port, local_rtcp_port, max_packet_size;
     char hostname[256];
     char buf[1024];
@@ -153,6 +156,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
     local_rtcp_port = -1;
     max_packet_size = -1;
     connect = 0;
+    reuse = 0;
 
     p = strchr(uri, '?');
     if (p) {
@@ -177,11 +181,14 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
         if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
             connect = strtol(buf, NULL, 10);
         }
+        if (av_find_info_tag(buf, sizeof(buf), "reuse", p)) {
+            reuse = strtol(buf, NULL, 10);
+        }
     }
 
     build_udp_url(buf, sizeof(buf),
                   hostname, rtp_port, local_rtp_port, ttl, max_packet_size,
-                  connect);
+                  connect, reuse);
     if (ffurl_open(&s->rtp_hd, buf, flags, &h->interrupt_callback, NULL) < 0)
         goto fail;
     if (local_rtp_port>=0 && local_rtcp_port<0)
@@ -189,7 +196,7 @@ static int rtp_open(URLContext *h, const char *uri, int flags)
 
     build_udp_url(buf, sizeof(buf),
                   hostname, rtcp_port, local_rtcp_port, ttl, max_packet_size,
-                  connect);
+                  connect, 0);
     if (ffurl_open(&s->rtcp_hd, buf, flags, &h->interrupt_callback, NULL) < 0)
         goto fail;
 
-- 
1.7.11.4

