front-end/build/ffmpeg/libavformat/udp.c
/**
 * If no filename is given to av_open_input_file because you want to
 * get the local port first, then you must call this function to set
 * the remote server address.
 *
 * url syntax: udp://host:port[?option=val...]
 * option: 'ttl=n'       : set the ttl value (for multicast only)
 *         'localport=n' : set the local port
 *         'pkt_size=n'  : set max packet size
 *         'reuse=1'     : enable reusing the socket
 *         'overrun_nonfatal=1': survive in case of circular buffer overrun
 *
 * @param h media file context
 * @param uri of the remote server
 * @return zero if no error.
 */
If no filename is given to av_open_input_file because you want to
get the local port first, then you must call this function to set
the remote server address.



@param h media file context
@param uri of the remote server
@return zero if no error.
If no filename is given to av_open_input_file because you want to get the local port first then you must call this function to set the remote server address . @param h media file context @param uri of the remote server @return zero if no error .
int ff_udp_set_remote_url(URLContext *h, const char *uri)
{
    UDPContext *s = h->priv_data;
    char hostname[256], buf[10];
    int port;
    const char *p;
    av_url_split(NULL, 0, NULL, 0, hostname, sizeof(hostname), &port, NULL, 0, uri);
    s->dest_addr_len = udp_set_url(&s->dest_addr, hostname, port);
    if (s->dest_addr_len < 0) {
        return AVERROR(EIO);
    }
    s->is_multicast = ff_is_multicast_address((struct sockaddr*) &s->dest_addr);
    p = strchr(uri, '?');
    if (p) {
        if (av_find_info_tag(buf, sizeof(buf), "connect", p)) {
            int was_connected = s->is_connected;
            s->is_connected = strtol(buf, NULL, 10);
            if (s->is_connected && !was_connected) {
                if (connect(s->udp_fd, (struct sockaddr *) &s->dest_addr,
                            s->dest_addr_len)) {
                    s->is_connected = 0;
                    log_net_error(h, AV_LOG_ERROR, "connect");
                    return AVERROR(EIO);
                }
            }
        }
    }
    return 0;
}
int ff_udp_set_remote_url ( URLContext * h , const char * uri ) { UDPContext * s = h -> priv_data ; char hostname [ 256 ] , buf [ 10 ] ; int port ; const char * p ; av_url_split ( NULL , 0 , NULL , 0 , hostname , sizeof ( hostname ) , & port , NULL , 0 , uri ) ; s -> dest_addr_len = udp_set_url ( & s -> dest_addr , hostname , port ) ; if ( s -> dest_addr_len < 0 ) { return AVERROR ( EIO ) ; } s -> is_multicast = ff_is_multicast_address ( ( struct sockaddr * ) & s -> dest_addr ) ; p = strchr ( uri , ' ' ) ; if ( p ) { if ( av_find_info_tag ( buf , sizeof ( buf ) , " " , p ) ) { int was_connected = s -> is_connected ; s -> is_connected = strtol ( buf , NULL , 10 ) ; if ( s -> is_connected && ! was_connected ) { if ( connect ( s -> udp_fd , ( struct sockaddr * ) & s -> dest_addr , s -> dest_addr_len ) ) { s -> is_connected = 0 ; log_net_error ( h , AV_LOG_ERROR , " " ) ; return AVERROR ( EIO ) ; } } } } return 0 ; }
If no filename is given to av_open_input_file because you want to
 get the local port first, then you must call this function to set
 the remote server address.
If no filename is given to av_open_input_file because you want to get the local port first then you must call this function to set the remote server address .
/* set the destination address */