Revision 236bb1ab libavformat/udp.c

View differences:

libavformat/udp.c
44 44
typedef struct {
45 45
    int udp_fd;
46 46
    int ttl;
47
    int buffer_size;
47 48
    int is_multicast;
48 49
    int local_port;
49 50
    int reuse_socket;
......
358 359

  
359 360
    h->priv_data = s;
360 361
    s->ttl = 16;
362
    s->buffer_size = is_output ? UDP_TX_BUF_SIZE : UDP_MAX_PKT_SIZE;
363

  
361 364
    p = strchr(uri, '?');
362 365
    if (p) {
363 366
        s->reuse_socket = find_info_tag(buf, sizeof(buf), "reuse", p);
......
370 373
        if (find_info_tag(buf, sizeof(buf), "pkt_size", p)) {
371 374
            h->max_packet_size = strtol(buf, NULL, 10);
372 375
        }
376
        if (find_info_tag(buf, sizeof(buf), "buffer_size", p)) {
377
            s->buffer_size = strtol(buf, NULL, 10);
378
        }
373 379
    }
374 380

  
375 381
    /* fill the dest addr */
......
416 422

  
417 423
    if (is_output) {
418 424
        /* limit the tx buf size to limit latency */
419
        tmp = UDP_TX_BUF_SIZE;
425
        tmp = s->buffer_size;
420 426
        if (setsockopt(udp_fd, SOL_SOCKET, SO_SNDBUF, &tmp, sizeof(tmp)) < 0) {
421 427
            av_log(NULL, AV_LOG_ERROR, "setsockopt(SO_SNDBUF): %s\n", strerror(errno));
422 428
            goto fail;
......
424 430
    } else {
425 431
        /* set udp recv buffer size to the largest possible udp packet size to
426 432
         * avoid losing data on OSes that set this too low by default. */
427
        tmp = UDP_MAX_PKT_SIZE;
428
        setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp));
433
        tmp = s->buffer_size;
434
        if (setsockopt(udp_fd, SOL_SOCKET, SO_RCVBUF, &tmp, sizeof(tmp)) < 0) {
435
            av_log(NULL, AV_LOG_WARNING, "setsockopt(SO_RECVBUF): %s\n", strerror(errno));
436
        }
429 437
    }
430 438

  
431 439
    s->udp_fd = udp_fd;

Also available in: Unified diff