[vlc-devel] [PATCH 14/33] chromecast: factorize the code to push a message to send
Steve Lhomme
robux4 at videolabs.io
Wed Dec 23 12:58:33 CET 2015
---
modules/stream_out/chromecast/chromecast.h | 8 ++---
modules/stream_out/chromecast/chromecast_ctrl.cpp | 42 +++++++----------------
2 files changed, 17 insertions(+), 33 deletions(-)
diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h
index 7f186da..b7d63be 100644
--- a/modules/stream_out/chromecast/chromecast.h
+++ b/modules/stream_out/chromecast/chromecast.h
@@ -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;
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index 9f747df..f4e5915 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -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)
@@ -263,49 +263,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()
@@ -313,10 +303,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()
@@ -326,10 +314,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);
}
@@ -350,10 +336,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);
}
/**
--
2.6.3
More information about the vlc-devel
mailing list