[vlc-devel] [PATCH 3/3] chromecast: add an experimental sout module that connects to a ChromeCast device and streams using the HTTP access output

Francois Cartegnie fcvlcdev at free.fr
Tue Sep 16 12:09:16 CEST 2014


Le 15/09/2014 11:39, Adrien Maglo a écrit :
> +    if (poll(ufd, 1, 6000) == 0)
> +    {
> +        if (*pb_pingTimeout)
> +        {
> +            msg_Err(p_stream, "No PONG answer received from the Chromecast");
> +            return 0; // Connection died
> +        }
> +        msg_Warn(p_stream, "No PING received from the Chromecast, sending a PING");
> +        *pb_pingTimeout = true;
> +    }
> +    else
> +        *pb_pingTimeout = false;
> +
> +    int i_ret;
> +
> +    /* Packet structure:
> +     * +------------------------------------+------------------------------+
> +     * | Payload size (uint32_t big endian) |         Payload data         |
> +     * +------------------------------------+------------------------------+ */
> +    if (*pi_received < PACKET_HEADER_LEN)
> +    {
> +        // We receive the header.
> +        i_ret = tls_Recv(p_tls, p_data, PACKET_HEADER_LEN - *pi_received);
> +        if (i_ret <= 0)
> +            return i_ret;
> +        *pi_received += i_ret;
> +    }

Looks wrong to me.

If there's no data to receive (i_ret == 0) and there's ping timeout,
that doesn't mean connection is dead.

We also might not want to poll for 6 sec in case of missed ping as the
device ping frequency is not related to current reply delay. ex: wait 3
times send ping/1 sec for a pong reply then give up.

Would have been easier with just the fixup i've sent.

> +        int i_ret = recvPacket(p_stream, b_msgReceived, i_payloadSize, p_sys->i_sock_fd,
> +                               p_sys->p_tls, &i_received, p_packet, &b_pingTimeout);
> +
> +        canc = vlc_savecancel();
> +        // Not cancellation-safe part.
> +
> +        if ((i_ret < 0 && errno != EAGAIN) || i_ret == 0)
> +        {
> +            msg_Err(p_stream, "The connection to the Chromecast died.");
> +            vlc_mutex_locker locker(&p_sys->lock);
> +            p_sys->i_status = CHROMECAST_CONNECTION_DEAD;
> +            atomic_store(&p_sys->ab_error, true);
> +            break;
> +        }
> +

Francois



More information about the vlc-devel mailing list