[5/5] rtsp: Set a default ttl if the server didn't indicate anything

Message ID 1331214020-82039-5-git-send-email-martin@martin.st
State Superseded
Headers show

Commit Message

Martin Storsjö March 8, 2012, 1:40 p.m.
Earlier, if the server didn't indicate a ttl, we explicitly set 0
as ttl, making the written packets not to be sent at all (after
making the ttl actually be set for read-write url contexts).
---
 libavformat/rtsp.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

Comments

Luca Barbato March 8, 2012, 3:06 p.m. | #1
On 3/8/12 5:40 AM, Martin Storsjö wrote:
> Earlier, if the server didn't indicate a ttl, we explicitly set 0
> as ttl, making the written packets not to be sent at all (after
> making the ttl actually be set for read-write url contexts).
> ---
>   libavformat/rtsp.c |    2 ++
>   1 files changed, 2 insertions(+), 0 deletions(-)

why 16?
Martin Storsjö March 8, 2012, 3:18 p.m. | #2
On Thu, 8 Mar 2012, Luca Barbato wrote:

> On 3/8/12 5:40 AM, Martin Storsjö wrote:
>> Earlier, if the server didn't indicate a ttl, we explicitly set 0
>> as ttl, making the written packets not to be sent at all (after
>> making the ttl actually be set for read-write url contexts).
>> ---
>>   libavformat/rtsp.c |    2 ++
>>   1 files changed, 2 insertions(+), 0 deletions(-)
>
> why 16?

It's the same as the default in udp.c.

Otoh, a better solution would be to omit the ttl=%d part from the rtp/udp 
url if ttl isn't indicated.

// Martin

Patch

diff --git a/libavformat/rtsp.c b/libavformat/rtsp.c
index dd79407..dd94cc8 100644
--- a/libavformat/rtsp.c
+++ b/libavformat/rtsp.c
@@ -1363,6 +1363,8 @@  int ff_rtsp_make_setup_request(AVFormatContext *s, const char *host, int port,
                 port      = rtsp_st->sdp_port;
                 ttl       = rtsp_st->sdp_ttl;
             }
+            if (ttl <= 0)
+                ttl = 16;
             getnameinfo((struct sockaddr*) &addr, sizeof(addr),
                         namebuf, sizeof(namebuf), NULL, 0, NI_NUMERICHOST);
             ff_url_join(url, sizeof(url), "rtp", NULL, namebuf,