예제 #1
0
/**
 * @brief Disconnect from the Chromecast
 */
void intf_sys_t::disconnectChromecast()
{
    if (p_tls)
    {
        vlc_tls_SessionDelete(p_tls);
        vlc_tls_Delete(p_creds);
        p_tls = NULL;
        setConnectionStatus(CHROMECAST_DISCONNECTED);
    }
}
예제 #2
0
파일: cast.cpp 프로젝트: Adatan/vlc
/**
 * @brief Disconnect from the Chromecast
 */
static void disconnectChromecast(sout_stream_t *p_stream)
{
    sout_stream_sys_t *p_sys = p_stream->p_sys;

    if (p_sys->p_tls)
    {
        vlc_tls_SessionDelete(p_sys->p_tls);
        vlc_tls_Delete(p_sys->p_creds);
        p_sys->p_tls = NULL;
        p_sys->i_status = CHROMECAST_DISCONNECTED;
    }
}
예제 #3
0
파일: tls.c 프로젝트: mingyueqingquan/vlc
vlc_tls_t *vlc_tls_ClientSessionCreate (vlc_tls_creds_t *crd, int fd,
                                        const char *host, const char *service,
                                        const char *const *alpn, char **alp)
{
    vlc_tls_t *session;
    int canc, val;

    canc = vlc_savecancel();
    session = vlc_tls_SessionCreate (crd, fd, host, alpn);
    if (session == NULL)
    {
        vlc_restorecancel(canc);
        return NULL;
    }

    mtime_t deadline = mdate ();
    deadline += var_InheritInteger (crd, "ipv4-timeout") * 1000;

    struct pollfd ufd[1];
    ufd[0].fd = fd;

    vlc_cleanup_push (cleanup_tls, session);
    while ((val = crd->handshake(crd, session, host, service, alp)) != 0)
    {
        if (val < 0)
        {
            msg_Err(crd, "TLS session handshake error");
error:
            vlc_tls_SessionDelete (session);
            session = NULL;
            break;
        }

        mtime_t now = mdate ();
        if (now > deadline)
           now = deadline;

        assert (val <= 2);
        ufd[0] .events = (val == 1) ? POLLIN : POLLOUT;

        vlc_restorecancel(canc);
        val = poll (ufd, 1, (deadline - now) / 1000);
        canc = vlc_savecancel();
        if (val == 0)
        {
            msg_Err(crd, "TLS session handshake timeout");
            goto error;
        }
    }
    vlc_cleanup_pop();
    vlc_restorecancel(canc);
    return session;
}
예제 #4
0
파일: tls.c 프로젝트: Crazybond/vlc
/**
 * Performs client side of TLS handshake through a connected socket, and
 * establishes a secure channel. This is a blocking network operation.
 *
 * @param fd socket through which to establish the secure channel
 * @param hostname expected server name, used both as Server Name Indication
 *                 and as expected Common Name of the peer certificate
 *
 * @return NULL on error.
 **/
vlc_tls_t *vlc_tls_ClientSessionCreate (vlc_tls_creds_t *crd, int fd,
                                        const char *host, const char *service)
{
    vlc_tls_t *session = vlc_tls_SessionCreate (crd, fd, host);
    if (session == NULL)
        return NULL;

    mtime_t deadline = mdate ();
    deadline += var_InheritInteger (crd, "ipv4-timeout") * 1000;

    struct pollfd ufd[1];
    ufd[0].fd = fd;

    int val;
    while ((val = vlc_tls_SessionHandshake (session, host, service)) > 0)
    {
        mtime_t now = mdate ();
        if (now > deadline)
           now = deadline;

        assert (val <= 2);
        ufd[0] .events = (val == 1) ? POLLIN : POLLOUT;

        if (poll (ufd, 1, (deadline - now) / 1000) == 0)
        {
            msg_Err (session, "TLS client session handshake timeout");
            val = -1;
            break;
        }
    }
    while (val > 0);

    if (val != 0)
    {
        msg_Err (session, "TLS client session handshake error");
        vlc_tls_SessionDelete (session);
        session = NULL;
    }
    return session;
}
예제 #5
0
파일: tls.c 프로젝트: mingyueqingquan/vlc
static void cleanup_tls(void *data)
{
    vlc_tls_t *session = data;

    vlc_tls_SessionDelete (session);
}