Revision 4ec153bb

View differences:

doc/protocols.texi
433 433

  
434 434
@item connect=@var{1|0}
435 435
Initialize the UDP socket with @code{connect()}. In this case, the
436
destination address can't be changed with udp_set_remote_url later.
436
destination address can't be changed with ff_udp_set_remote_url later.
437 437
If the destination address isn't known at the start, this option can
438
be specified in udp_set_remote_url, too.
438
be specified in ff_udp_set_remote_url, too.
439 439
This allows finding out the source address for the packets with getsockname,
440 440
and makes writes return with AVERROR(ECONNREFUSED) if "destination
441 441
unreachable" is received.
libavformat/avio.h
448 448
 */
449 449
attribute_deprecated int url_feof(AVIOContext *s);
450 450
attribute_deprecated int url_ferror(AVIOContext *s);
451

  
452
attribute_deprecated int udp_set_remote_url(URLContext *h, const char *uri);
453
attribute_deprecated int udp_get_local_port(URLContext *h);
451 454
#endif
452 455

  
453 456
AVIOContext *avio_alloc_context(
......
675 678
                   unsigned long (*update_checksum)(unsigned long c, const uint8_t *p, unsigned int len),
676 679
                   unsigned long checksum);
677 680

  
678
/* udp.c */
679
int udp_set_remote_url(URLContext *h, const char *uri);
680
int udp_get_local_port(URLContext *h);
681 681
#if FF_API_UDP_GET_FILE
682 682
int udp_get_file_handle(URLContext *h);
683 683
#endif
libavformat/avio_internal.h
70 70
int64_t ffio_read_seek (AVIOContext *h,    int stream_index,
71 71
                        int64_t timestamp, int flags);
72 72

  
73
/* udp.c */
74
int ff_udp_set_remote_url(URLContext *h, const char *uri);
75
int ff_udp_get_local_port(URLContext *h);
76

  
73 77

  
74 78
#endif // AVFORMAT_AVIO_INTERNAL_H
libavformat/rtpproto.c
27 27
#include "libavutil/parseutils.h"
28 28
#include "libavutil/avstring.h"
29 29
#include "avformat.h"
30
#include "avio_internal.h"
30 31
#include "rtpdec.h"
31 32

  
32 33
#include <unistd.h>
......
71 72
                 path, sizeof(path), uri);
72 73

  
73 74
    ff_url_join(buf, sizeof(buf), "udp", NULL, hostname, port, "%s", path);
74
    udp_set_remote_url(s->rtp_hd, buf);
75
    ff_udp_set_remote_url(s->rtp_hd, buf);
75 76

  
76 77
    ff_url_join(buf, sizeof(buf), "udp", NULL, hostname, port + 1, "%s", path);
77
    udp_set_remote_url(s->rtcp_hd, buf);
78
    ff_udp_set_remote_url(s->rtcp_hd, buf);
78 79
    return 0;
79 80
}
80 81

  
......
191 192
    if (url_open(&s->rtp_hd, buf, flags) < 0)
192 193
        goto fail;
193 194
    if (local_rtp_port>=0 && local_rtcp_port<0)
194
        local_rtcp_port = udp_get_local_port(s->rtp_hd) + 1;
195
        local_rtcp_port = ff_udp_get_local_port(s->rtp_hd) + 1;
195 196

  
196 197
    build_udp_url(buf, sizeof(buf),
197 198
                  hostname, rtcp_port, local_rtcp_port, ttl, max_packet_size,
......
326 327
int rtp_get_local_rtp_port(URLContext *h)
327 328
{
328 329
    RTPContext *s = h->priv_data;
329
    return udp_get_local_port(s->rtp_hd);
330
    return ff_udp_get_local_port(s->rtp_hd);
330 331
}
331 332

  
332 333
/**
......
338 339
int rtp_get_local_rtcp_port(URLContext *h)
339 340
{
340 341
    RTPContext *s = h->priv_data;
341
    return udp_get_local_port(s->rtcp_hd);
342
    return ff_udp_get_local_port(s->rtcp_hd);
342 343
}
343 344

  
344 345
static int rtp_get_file_handle(URLContext *h)
libavformat/udp.c
27 27
#define _BSD_SOURCE     /* Needed for using struct ip_mreq with recent glibc */
28 28
#define _DARWIN_C_SOURCE /* Needed for using IP_MULTICAST_TTL on OS X */
29 29
#include "avformat.h"
30
#include "avio_internal.h"
30 31
#include "libavutil/parseutils.h"
31 32
#include <unistd.h>
32 33
#include "internal.h"
......
243 244
 * @param uri of the remote server
244 245
 * @return zero if no error.
245 246
 */
246
int udp_set_remote_url(URLContext *h, const char *uri)
247
int ff_udp_set_remote_url(URLContext *h, const char *uri)
247 248
{
248 249
    UDPContext *s = h->priv_data;
249 250
    char hostname[256], buf[10];
......
282 283
 * @param h media file context
283 284
 * @return the local port number
284 285
 */
285
int udp_get_local_port(URLContext *h)
286
int ff_udp_get_local_port(URLContext *h)
286 287
{
287 288
    UDPContext *s = h->priv_data;
288 289
    return s->local_port;
......
365 366
        if (flags & URL_WRONLY)
366 367
            goto fail;
367 368
    } else {
368
        if (udp_set_remote_url(h, uri) < 0)
369
        if (ff_udp_set_remote_url(h, uri) < 0)
369 370
            goto fail;
370 371
    }
371 372

  

Also available in: Unified diff