Commit 8b38a343 authored by Francois Cartegnie's avatar Francois Cartegnie

sout: chromecast: check app presence on status

Stop sending and disconnect when app has changed.
parent 2d319620
...@@ -609,22 +609,51 @@ static int processMessage(sout_stream_t *p_stream, const castchannel::CastMessag ...@@ -609,22 +609,51 @@ static int processMessage(sout_stream_t *p_stream, const castchannel::CastMessag
if (type == "RECEIVER_STATUS") if (type == "RECEIVER_STATUS")
{ {
json_value applications = (*p_data)["status"]["applications"]; json_value applications = (*p_data)["status"]["applications"];
const json_value *p_app = NULL;
for (unsigned i = 0; i < applications.u.array.length; ++i) for (unsigned i = 0; i < applications.u.array.length; ++i)
{ {
std::string appId(applications[i]["appId"]); std::string appId(applications[i]["appId"]);
if (appId == APP_ID) if (appId == APP_ID)
p_sys->appTransportId = std::string(applications[i]["transportId"]); {
p_app = &applications[i];
vlc_mutex_lock(&p_sys->lock);
if (p_sys->appTransportId.empty())
p_sys->appTransportId = std::string(applications[i]["transportId"]);
vlc_mutex_unlock(&p_sys->lock);
break;
}
} }
vlc_mutex_locker locker(&p_sys->lock);
if (!p_sys->appTransportId.empty() vlc_mutex_lock(&p_sys->lock);
&& p_sys->i_status == CHROMECAST_AUTHENTICATED) if ( p_app )
{ {
p_sys->i_status = CHROMECAST_APP_STARTED; if (!p_sys->appTransportId.empty()
msgConnect(p_stream, p_sys->appTransportId); && p_sys->i_status == CHROMECAST_AUTHENTICATED)
msgLoad(p_stream); {
p_sys->i_status = CHROMECAST_MEDIA_LOAD_SENT; p_sys->i_status = CHROMECAST_APP_STARTED;
vlc_cond_signal(&p_sys->loadCommandCond); msgConnect(p_stream, p_sys->appTransportId);
msgLoad(p_stream);
p_sys->i_status = CHROMECAST_MEDIA_LOAD_SENT;
vlc_cond_signal(&p_sys->loadCommandCond);
}
} }
else
{
switch(p_sys->i_status)
{
/* If the app is no longer present */
case CHROMECAST_APP_STARTED:
case CHROMECAST_MEDIA_LOAD_SENT:
msg_Warn(p_stream, "app is no longer present. closing");
msgClose(p_stream, p_sys->appTransportId);
i_ret = -1;
// ft
default:
break;
}
}
vlc_mutex_unlock(&p_sys->lock);
} }
else else
{ {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment