Revision a7ea5e3d libavformat/udp.c

View differences:

libavformat/udp.c
315 315
    h->is_streamed = 1;
316 316
    h->max_packet_size = 1472;
317 317

  
318
    is_output = (flags & AVIO_FLAG_WRITE);
318
    is_output = !(flags & AVIO_FLAG_READ);
319 319

  
320 320
    s = av_mallocz(sizeof(UDPContext));
321 321
    if (!s)
......
358 358
    /* XXX: fix av_url_split */
359 359
    if (hostname[0] == '\0' || hostname[0] == '?') {
360 360
        /* only accepts null hostname if input */
361
        if (flags & AVIO_FLAG_WRITE)
361
        if (!(flags & AVIO_FLAG_READ))
362 362
            goto fail;
363 363
    } else {
364 364
        if (ff_udp_set_remote_url(h, uri) < 0)
365 365
            goto fail;
366 366
    }
367 367

  
368
    if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE))
368
    if (s->is_multicast && (h->flags & AVIO_FLAG_READ))
369 369
        s->local_port = port;
370 370
    udp_fd = udp_socket_create(s, &my_addr, &len);
371 371
    if (udp_fd < 0)
......
382 382

  
383 383
    /* the bind is needed to give a port to the socket now */
384 384
    /* if multicast, try the multicast address bind first */
385
    if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE)) {
385
    if (s->is_multicast && (h->flags & AVIO_FLAG_READ)) {
386 386
        bind_ret = bind(udp_fd,(struct sockaddr *)&s->dest_addr, len);
387 387
    }
388 388
    /* bind to the local address if not multicast or if the multicast
......
395 395
    s->local_port = udp_port(&my_addr, len);
396 396

  
397 397
    if (s->is_multicast) {
398
        if (h->flags & AVIO_FLAG_WRITE) {
398
        if (!(h->flags & AVIO_FLAG_READ)) {
399 399
            /* output */
400 400
            if (udp_set_multicast_ttl(udp_fd, s->ttl, (struct sockaddr *)&s->dest_addr) < 0)
401 401
                goto fail;
......
478 478
{
479 479
    UDPContext *s = h->priv_data;
480 480

  
481
    if (s->is_multicast && !(h->flags & AVIO_FLAG_WRITE))
481
    if (s->is_multicast && (h->flags & AVIO_FLAG_READ))
482 482
        udp_leave_multicast_group(s->udp_fd, (struct sockaddr *)&s->dest_addr);
483 483
    closesocket(s->udp_fd);
484 484
    av_free(s);

Also available in: Unified diff