[vlc-commits] chromecast: factorize the code to push a message to send

Steve Lhomme git at videolan.org
Wed Dec 23 20:28:24 CET 2015


vlc | branch: master | Steve Lhomme <robUx4 at videolabs.io> | Wed Dec 23 12:58:33 2015 +0100| [0485d346a119ad3efca305dd57febcd7c32f423a] | committer: Jean-Baptiste Kempf

chromecast: factorize the code to push a message to send

Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=0485d346a119ad3efca305dd57febcd7c32f423a
---

 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 8734f9e..ee42319 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)
@@ -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);
 }
 
 /**



More information about the vlc-commits mailing list