Commit 0485d346 authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

chromecast: factorize the code to push a message to send

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent d4898706
......@@ -114,10 +114,10 @@ struct intf_sys_t
private:
int sendMessage(castchannel::CastMessage &msg);
castchannel::CastMessage buildMessage(const std::string & namespace_,
castchannel::CastMessage_PayloadType payloadType,
const std::string & payload,
const std::string & destinationId = DEFAULT_CHOMECAST_RECEIVER);
void buildMessage(const std::string & namespace_,
castchannel::CastMessage_PayloadType payloadType,
const std::string & payload,
const std::string & destinationId = DEFAULT_CHOMECAST_RECEIVER);
enum connection_status conn_status;
......
......@@ -52,10 +52,10 @@
* @param destinationId the destination idenifier
* @return the generated CastMessage
*/
castchannel::CastMessage intf_sys_t::buildMessage(const std::string & namespace_,
castchannel::CastMessage_PayloadType payloadType,
const std::string & payload,
const std::string & destinationId)
void intf_sys_t::buildMessage(const std::string & namespace_,
castchannel::CastMessage_PayloadType payloadType,
const std::string & payload,
const std::string & destinationId)
{
castchannel::CastMessage msg;
......@@ -69,7 +69,7 @@ castchannel::CastMessage intf_sys_t::buildMessage(const std::string & namespace_
else // CastMessage_PayloadType_BINARY
msg.set_payload_binary(payload);
return msg;
messagesToSend.push(msg);
}
intf_sys_t::intf_sys_t(sout_stream_t * const p_this)
......@@ -262,49 +262,39 @@ void intf_sys_t::msgAuth()
std::string authMessageString;
authMessage.SerializeToString(&authMessageString);
castchannel::CastMessage msg = buildMessage(NAMESPACE_DEVICEAUTH,
buildMessage(NAMESPACE_DEVICEAUTH,
castchannel::CastMessage_PayloadType_BINARY, authMessageString);
messagesToSend.push(msg);
}
void intf_sys_t::msgPing()
{
std::string s("{\"type\":\"PING\"}");
castchannel::CastMessage msg = buildMessage(NAMESPACE_HEARTBEAT,
buildMessage(NAMESPACE_HEARTBEAT,
castchannel::CastMessage_PayloadType_STRING, s);
messagesToSend.push(msg);
}
void intf_sys_t::msgPong()
{
std::string s("{\"type\":\"PONG\"}");
castchannel::CastMessage msg = buildMessage(NAMESPACE_HEARTBEAT,
buildMessage(NAMESPACE_HEARTBEAT,
castchannel::CastMessage_PayloadType_STRING, s);
messagesToSend.push(msg);
}
void intf_sys_t::msgConnect(const std::string & destinationId)
{
std::string s("{\"type\":\"CONNECT\"}");
castchannel::CastMessage msg = buildMessage(NAMESPACE_CONNECTION,
buildMessage(NAMESPACE_CONNECTION,
castchannel::CastMessage_PayloadType_STRING, s, destinationId);
messagesToSend.push(msg);
}
void intf_sys_t::msgReceiverClose(std::string destinationId)
{
std::string s("{\"type\":\"CLOSE\"}");
castchannel::CastMessage msg = buildMessage(NAMESPACE_CONNECTION,
buildMessage(NAMESPACE_CONNECTION,
castchannel::CastMessage_PayloadType_STRING, s, destinationId);
messagesToSend.push(msg);
}
void intf_sys_t::msgReceiverGetStatus()
......@@ -312,10 +302,8 @@ void intf_sys_t::msgReceiverGetStatus()
std::stringstream ss;
ss << "{\"type\":\"GET_STATUS\"}";
castchannel::CastMessage msg = buildMessage(NAMESPACE_RECEIVER,
buildMessage(NAMESPACE_RECEIVER,
castchannel::CastMessage_PayloadType_STRING, ss.str());
messagesToSend.push(msg);
}
void intf_sys_t::msgReceiverLaunchApp()
......@@ -325,10 +313,8 @@ void intf_sys_t::msgReceiverLaunchApp()
<< "\"appId\":\"" << APP_ID << "\","
<< "\"requestId\":" << i_requestId++ << "}";
castchannel::CastMessage msg = buildMessage(NAMESPACE_RECEIVER,
buildMessage(NAMESPACE_RECEIVER,
castchannel::CastMessage_PayloadType_STRING, ss.str());
messagesToSend.push(msg);
}
......@@ -349,10 +335,8 @@ void intf_sys_t::msgPlayerLoad()
free(psz_mime);
castchannel::CastMessage msg = buildMessage(NAMESPACE_MEDIA,
buildMessage(NAMESPACE_MEDIA,
castchannel::CastMessage_PayloadType_STRING, ss.str(), appTransportId);
messagesToSend.push(msg);
}
/**
......
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