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,13 +609,24 @@ static int processMessage(sout_stream_t *p_stream, const castchannel::CastMessag ...@@ -609,13 +609,24 @@ 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_app = &applications[i];
vlc_mutex_lock(&p_sys->lock);
if (p_sys->appTransportId.empty())
p_sys->appTransportId = std::string(applications[i]["transportId"]); p_sys->appTransportId = std::string(applications[i]["transportId"]);
vlc_mutex_unlock(&p_sys->lock);
break;
} }
vlc_mutex_locker locker(&p_sys->lock); }
vlc_mutex_lock(&p_sys->lock);
if ( p_app )
{
if (!p_sys->appTransportId.empty() if (!p_sys->appTransportId.empty()
&& p_sys->i_status == CHROMECAST_AUTHENTICATED) && p_sys->i_status == CHROMECAST_AUTHENTICATED)
{ {
...@@ -627,6 +638,24 @@ static int processMessage(sout_stream_t *p_stream, const castchannel::CastMessag ...@@ -627,6 +638,24 @@ static int processMessage(sout_stream_t *p_stream, const castchannel::CastMessag
} }
} }
else 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
{ {
msg_Err(p_stream, "Receiver command not supported: %s", msg_Err(p_stream, "Receiver command not supported: %s",
msg.payload_utf8().c_str()); msg.payload_utf8().c_str());
......
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