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

Ilkka Ollakka ileoo at videolan.org
Wed Aug 20 11:52:06 CEST 2014


On Wed, Aug 20, 2014 at 10:38:21AM +0200, magsoft at videolan.org wrote:
> From: Adrien Maglo <magsoft at videolan.org>

Hi,


> diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
> +vlc_module_begin ()
> +
> +    set_shortname(N_("Chromecast"))
> +    set_description(N_("Chromecast stream output"))
> +    set_capability("sout stream", 50)
> +
> +vlc_module_end ()

> +/*****************************************************************************
> + * Open: connect to the Chromecast and initialize the sout
> + *****************************************************************************/
> +static int Open(vlc_object_t *p_this)
> +{
> +    sout_stream_t *p_stream = (sout_stream_t*)p_this;
> +    sout_stream_sys_t *p_sys;
> +    p_sys = new(nothrow) sout_stream_sys_t();
> +    if (p_sys == NULL)
> +        return VLC_ENOMEM;
> +    p_stream->p_sys = p_sys;
> +
> +    config_ChainParse(p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg);
> +
> +    char *psz_ipChromecast = var_GetNonEmptyString(p_stream, SOUT_CFG_PREFIX "receiver-ip");
> +    if (psz_ipChromecast == NULL)
> +    {
> +        msg_Err(p_stream, "No Chromecast receiver IP provided");
> +        Close(p_this);
> +        return VLC_EGENERIC;
> +    }
> +
> +    vlc_url_t url;
> +    url.psz_host = strdup(psz_ipChromecast);
> +    url.i_port = 8009;

Is that 8009 some default known port for chromecast?

> +    // Set the sout callbacks.
> +    p_stream->pf_add    = Add;
> +    p_stream->pf_del    = Del;
> +    p_stream->pf_send   = Send;

Maybe these should be defined at the end of Open() 

> +
> +    /* Ugly part:
> +     * We want to be sure that the Chromecast receives the first data packet sent by
> +     * the HTTP server. */
> +
> +    // Lock the sout thread until we have sent the media loading command to the Chromecast.
> +    vlc_mutex_lock(&p_sys->loadCommandMutex);
> +    const mtime_t deadline = mdate() + 6000 * 1000;
> +    int i_ret = vlc_cond_timedwait(&p_sys->loadCommandCond, &p_sys->loadCommandMutex, deadline);
> +    if (i_ret == ETIMEDOUT)
> +    {
> +        msg_Err(p_stream, "Timeout reached before sending the media loading command");
> +        vlc_mutex_unlock(&p_sys->loadCommandMutex);
> +        Close(p_this);
> +        return VLC_EGENERIC;
> +    }
> +    vlc_mutex_unlock(&p_sys->loadCommandMutex);
> +
> +    // Sleep more to let to the Chromecast initiate the connection to the http server.
> +    sleep(2);

Not sure it's wise to sleep in Open() when there is priority for this
module, this can't be done in later phase?

-- 
Ilkka Ollakka
The worst part of having success is trying to find someone who is happy for you.
		-- Bette Midler
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20140820/11df2026/attachment.sig>


More information about the vlc-devel mailing list