[07/13] avio: make udp_set_remote_url/get_local_port internal.

Message ID 1300131546-2880-7-git-send-email-anton@khirnov.net
State Committed
Headers show

Commit Message

Anton Khirnov March 14, 2011, 7:39 p.m.
---
 doc/protocols.texi          |    4 ++--
 libavformat/avio.h          |    6 +++---
 libavformat/avio_internal.h |    4 ++++
 libavformat/rtpproto.c      |   11 ++++++-----
 libavformat/udp.c           |    7 ++++---
 5 files changed, 19 insertions(+), 13 deletions(-)

Comments

Luca Barbato March 17, 2011, 3:11 a.m. | #1
On 3/14/11 8:39 PM, Anton Khirnov wrote:
> ---
>   doc/protocols.texi          |    4 ++--
>   libavformat/avio.h          |    6 +++---
>   libavformat/avio_internal.h |    4 ++++
>   libavformat/rtpproto.c      |   11 ++++++-----
>   libavformat/udp.c           |    7 ++++---
>   5 files changed, 19 insertions(+), 13 deletions(-)
>

I'm not so keen in having those private...

lu
Anton Khirnov March 22, 2011, 3:50 p.m. | #2
On Thu, Mar 17, 2011 at 04:11:25AM +0100, Luca Barbato wrote:
> On 3/14/11 8:39 PM, Anton Khirnov wrote:
> >---
> >  doc/protocols.texi          |    4 ++--
> >  libavformat/avio.h          |    6 +++---
> >  libavformat/avio_internal.h |    4 ++++
> >  libavformat/rtpproto.c      |   11 ++++++-----
> >  libavformat/udp.c           |    7 ++++---
> >  5 files changed, 19 insertions(+), 13 deletions(-)
> >
> 
> I'm not so keen in having those private...

Martin told me on IRC that they're not meant to be public.
Could you elaborate on why do you think they should be?
Luca Barbato March 22, 2011, 5:08 p.m. | #3
On 3/22/11 4:50 PM, Anton Khirnov wrote:
> On Thu, Mar 17, 2011 at 04:11:25AM +0100, Luca Barbato wrote:
>> On 3/14/11 8:39 PM, Anton Khirnov wrote:
>>> ---
>>>   doc/protocols.texi          |    4 ++--
>>>   libavformat/avio.h          |    6 +++---
>>>   libavformat/avio_internal.h |    4 ++++
>>>   libavformat/rtpproto.c      |   11 ++++++-----
>>>   libavformat/udp.c           |    7 ++++---
>>>   5 files changed, 19 insertions(+), 13 deletions(-)
>>>
>>
>> I'm not so keen in having those private...
>
> Martin told me on IRC that they're not meant to be public.
> Could you elaborate on why do you think they should be?
>

I thought about possible usages outside the current normal demuxers. We 
could keep them private and discuss about external demuxers later. =)

(patch ok)

lu
Martin Storsjö March 22, 2011, 5:43 p.m. | #4
On Tue, 22 Mar 2011, Luca Barbato wrote:

> On 3/22/11 4:50 PM, Anton Khirnov wrote:
> > On Thu, Mar 17, 2011 at 04:11:25AM +0100, Luca Barbato wrote:
> > > On 3/14/11 8:39 PM, Anton Khirnov wrote:
> > > > ---
> > > >   doc/protocols.texi          |    4 ++--
> > > >   libavformat/avio.h          |    6 +++---
> > > >   libavformat/avio_internal.h |    4 ++++
> > > >   libavformat/rtpproto.c      |   11 ++++++-----
> > > >   libavformat/udp.c           |    7 ++++---
> > > >   5 files changed, 19 insertions(+), 13 deletions(-)
> > > > 
> > > 
> > > I'm not so keen in having those private...
> > 
> > Martin told me on IRC that they're not meant to be public.
> > Could you elaborate on why do you think they should be?
> > 
> 
> I thought about possible usages outside the current normal demuxers. We could
> keep them private and discuss about external demuxers later. =)

To elaborate on my own opinion also - they're required in order to use udp 
URLContexts in some scenarios, and thus should be public (or at the same 
visibility level as the rest of url_open/url_read etc, regardless of if 
that turns out to be public or internal). But I'm not sure they're in the 
right form to be made public as is, that's why I suggested internal for 
now.

// Martin
Luca Barbato March 22, 2011, 7:18 p.m. | #5
On 3/22/11 6:43 PM, Martin Storsjö wrote:
> To elaborate on my own opinion also - they're required in order to use udp
> URLContexts in some scenarios, and thus should be public (or at the same
> visibility level as the rest of url_open/url_read etc, regardless of if
> that turns out to be public or internal). But I'm not sure they're in the
> right form to be made public as is, that's why I suggested internal for
> now.

I guess the agreement is to set them private and introduce an api to 
access them later/when needed.

lu

Patch

diff --git a/doc/protocols.texi b/doc/protocols.texi
index 5655b10..9ea2860 100644
--- a/doc/protocols.texi
+++ b/doc/protocols.texi
@@ -433,9 +433,9 @@  set the time to live value (for multicast only)
 
 @item connect=@var{1|0}
 Initialize the UDP socket with @code{connect()}. In this case, the
-destination address can't be changed with udp_set_remote_url later.
+destination address can't be changed with ff_udp_set_remote_url later.
 If the destination address isn't known at the start, this option can
-be specified in udp_set_remote_url, too.
+be specified in ff_udp_set_remote_url, too.
 This allows finding out the source address for the packets with getsockname,
 and makes writes return with AVERROR(ECONNREFUSED) if "destination
 unreachable" is received.
diff --git a/libavformat/avio.h b/libavformat/avio.h
index 22370d1..2db72be 100644
--- a/libavformat/avio.h
+++ b/libavformat/avio.h
@@ -451,6 +451,9 @@  attribute_deprecated int url_setbufsize(AVIOContext *s, int buf_size);
  */
 attribute_deprecated int url_feof(AVIOContext *s);
 attribute_deprecated int url_ferror(AVIOContext *s);
+
+attribute_deprecated int udp_set_remote_url(URLContext *h, const char *uri);
+attribute_deprecated int udp_get_local_port(URLContext *h);
 #endif
 
 AVIOContext *avio_alloc_context(
@@ -676,9 +679,6 @@  void init_checksum(AVIOContext *s,
                    unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
                    unsigned long checksum);
 
-/* udp.c */
-int udp_set_remote_url(URLContext *h, const char *uri);
-int udp_get_local_port(URLContext *h);
 #if FF_API_UDP_GET_FILE
 int udp_get_file_handle(URLContext *h);
 #endif
diff --git a/libavformat/avio_internal.h b/libavformat/avio_internal.h
index 88da0f6..7568935 100644
--- a/libavformat/avio_internal.h
+++ b/libavformat/avio_internal.h
@@ -70,5 +70,9 @@  int     ffio_read_pause(AVIOContext *h,    int pause);
 int64_t ffio_read_seek( AVIOContext *h,    int stream_index,
                         int64_t timestamp, int flags);
 
+/* udp.c */
+int ff_udp_set_remote_url(URLContext *h, const char *uri);
+int ff_udp_get_local_port(URLContext *h);
+
 
 #endif // AVFORMAT_AVIO_INTERNAL_H
diff --git a/libavformat/rtpproto.c b/libavformat/rtpproto.c
index 269b1b2..b946115 100644
--- a/libavformat/rtpproto.c
+++ b/libavformat/rtpproto.c
@@ -27,6 +27,7 @@ 
 #include "libavutil/parseutils.h"
 #include "libavutil/avstring.h"
 #include "avformat.h"
+#include "avio_internal.h"
 #include "rtpdec.h"
 
 #include <unistd.h>
@@ -71,10 +72,10 @@  int rtp_set_remote_url(URLContext *h, const char *uri)
                  path, sizeof(path), uri);
 
     ff_url_join(buf, sizeof(buf), "udp", NULL, hostname, port, "%s", path);
-    udp_set_remote_url(s->rtp_hd, buf);
+    ff_udp_set_remote_url(s->rtp_hd, buf);
 
     ff_url_join(buf, sizeof(buf), "udp", NULL, hostname, port + 1, "%s", path);
-    udp_set_remote_url(s->rtcp_hd, buf);
+    ff_udp_set_remote_url(s->rtcp_hd, buf);
     return 0;
 }
 
@@ -191,7 +192,7 @@  static int rtp_open(URLContext *h, const char *uri, int flags)
     if (url_open(&s->rtp_hd, buf, flags) < 0)
         goto fail;
     if (local_rtp_port>=0 && local_rtcp_port<0)
-        local_rtcp_port = udp_get_local_port(s->rtp_hd) + 1;
+        local_rtcp_port = ff_udp_get_local_port(s->rtp_hd) + 1;
 
     build_udp_url(buf, sizeof(buf),
                   hostname, rtcp_port, local_rtcp_port, ttl, max_packet_size,
@@ -326,7 +327,7 @@  static int rtp_close(URLContext *h)
 int rtp_get_local_rtp_port(URLContext *h)
 {
     RTPContext *s = h->priv_data;
-    return udp_get_local_port(s->rtp_hd);
+    return ff_udp_get_local_port(s->rtp_hd);
 }
 
 /**
@@ -338,7 +339,7 @@  int rtp_get_local_rtp_port(URLContext *h)
 int rtp_get_local_rtcp_port(URLContext *h)
 {
     RTPContext *s = h->priv_data;
-    return udp_get_local_port(s->rtcp_hd);
+    return ff_udp_get_local_port(s->rtcp_hd);
 }
 
 static int rtp_get_file_handle(URLContext *h)
diff --git a/libavformat/udp.c b/libavformat/udp.c
index 0196573..1e71361 100644
--- a/libavformat/udp.c
+++ b/libavformat/udp.c
@@ -27,6 +27,7 @@ 
 #define _BSD_SOURCE     /* Needed for using struct ip_mreq with recent glibc */
 #define _DARWIN_C_SOURCE /* Needed for using IP_MULTICAST_TTL on OS X */
 #include "avformat.h"
+#include "avio_internal.h"
 #include "libavutil/parseutils.h"
 #include <unistd.h>
 #include "internal.h"
@@ -243,7 +244,7 @@  static int udp_port(struct sockaddr_storage *addr, int addr_len)
  * @param uri of the remote server
  * @return zero if no error.
  */
-int udp_set_remote_url(URLContext *h, const char *uri)
+int ff_udp_set_remote_url(URLContext *h, const char *uri)
 {
     UDPContext *s = h->priv_data;
     char hostname[256], buf[10];
@@ -282,7 +283,7 @@  int udp_set_remote_url(URLContext *h, const char *uri)
  * @param h media file context
  * @return the local port number
  */
-int udp_get_local_port(URLContext *h)
+int ff_udp_get_local_port(URLContext *h)
 {
     UDPContext *s = h->priv_data;
     return s->local_port;
@@ -365,7 +366,7 @@  static int udp_open(URLContext *h, const char *uri, int flags)
         if (flags & URL_WRONLY)
             goto fail;
     } else {
-        if (udp_set_remote_url(h, uri) < 0)
+        if (ff_udp_set_remote_url(h, uri) < 0)
             goto fail;
     }