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

Adrien Maglo magsoft at videolan.org
Wed Aug 20 17:31:42 CEST 2014


Hello Ilkka,


Le 20/08/2014 11:52, Ilkka Ollakka a écrit :
>> +    vlc_url_t url;
>> +    url.psz_host = strdup(psz_ipChromecast);
>> +    url.i_port = 8009;
>
> Is that 8009 some default known port for chromecast?

Yes, it is the port of its control interface.

>> +    // 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()

Ok

>> +
>> +    /* 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?

We can drop the priority of this module.

I agree this is ugly to block and sleep in Open() but it is the only way 
I have found so far to not start the HTTP streaming while the Chromecast 
is still being configured. This can be important since if the Chromecast 
does not receive the first packets of the stream, it gives up very 
quickly because, I guess, it cannot find an I frame. It is however not 
an issue if you transcode into a fragmented mp4, which contains very 
regularly I frames.

For the sleep, the problem is also that the Chromecast does not send any 
event message when it begins to open the stream.


-- 
MagSoft





More information about the vlc-devel mailing list