Commit 57f014d7 authored by Thomas Guillem's avatar Thomas Guillem Committed by Jean-Baptiste Kempf

chromecast: return a VLC status from msg methods

(cherry picked from commit f9c3a40d)
Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent 2a252aa3
......@@ -104,24 +104,24 @@ public:
*/
void disconnect();
void msgPing();
void msgPong();
void msgConnect( const std::string& destinationId );
void msgReceiverLaunchApp();
void msgReceiverGetStatus();
void msgReceiverClose(const std::string& destinationId);
void msgAuth();
void msgPlayerLoad( const std::string& destinationId, unsigned int i_port,
int msgPing();
int msgPong();
int msgConnect( const std::string& destinationId );
int msgReceiverLaunchApp();
int msgReceiverGetStatus();
int msgReceiverClose(const std::string& destinationId);
int msgAuth();
int msgPlayerLoad( const std::string& destinationId, unsigned int i_port,
const std::string& mime, const vlc_meta_t *p_meta );
void msgPlayerPlay( const std::string& destinationId, int64_t mediaSessionId );
void msgPlayerStop( const std::string& destinationId, int64_t mediaSessionId );
void msgPlayerPause( const std::string& destinationId, int64_t mediaSessionId );
void msgPlayerGetStatus( const std::string& destinationId );
void msgPlayerSeek( const std::string& destinationId, int64_t mediaSessionId,
int msgPlayerPlay( const std::string& destinationId, int64_t mediaSessionId );
int msgPlayerStop( const std::string& destinationId, int64_t mediaSessionId );
int msgPlayerPause( const std::string& destinationId, int64_t mediaSessionId );
int msgPlayerGetStatus( const std::string& destinationId );
int msgPlayerSeek( const std::string& destinationId, int64_t mediaSessionId,
const std::string & currentTime );
void msgPlayerSetVolume( const std::string& destinationId, int64_t mediaSessionId,
float volume, bool mute);
int msgPlayerSetVolume( const std::string& destinationId, int64_t mediaSessionId,
float volume, bool mute);
ssize_t receive( uint8_t *p_data, size_t i_size, int i_timeout, bool *pb_timeout );
const std::string getServerIp()
......@@ -131,11 +131,11 @@ public:
private:
int sendMessage(const castchannel::CastMessage &msg);
void buildMessage(const std::string & namespace_,
const std::string & payload,
const std::string & destinationId = DEFAULT_CHOMECAST_RECEIVER,
castchannel::CastMessage_PayloadType payloadType = castchannel::CastMessage_PayloadType_STRING);
void pushMediaPlayerMessage( const std::string& destinationId, const std::stringstream & payload );
int buildMessage(const std::string & namespace_,
const std::string & payload,
const std::string & destinationId = DEFAULT_CHOMECAST_RECEIVER,
castchannel::CastMessage_PayloadType payloadType = castchannel::CastMessage_PayloadType_STRING);
int pushMediaPlayerMessage( const std::string& destinationId, const std::stringstream & payload );
std::string GetMedia( unsigned int i_port, const std::string& mime,
const vlc_meta_t *p_meta );
......
......@@ -90,7 +90,7 @@ void ChromecastCommunication::disconnect()
* @param destinationId the destination idenifier
* @return the generated CastMessage
*/
void ChromecastCommunication::buildMessage(const std::string & namespace_,
int ChromecastCommunication::buildMessage(const std::string & namespace_,
const std::string & payload,
const std::string & destinationId,
castchannel::CastMessage_PayloadType payloadType)
......@@ -107,7 +107,7 @@ void ChromecastCommunication::buildMessage(const std::string & namespace_,
else // CastMessage_PayloadType_BINARY
msg.set_payload_binary(payload);
sendMessage(msg);
return sendMessage(msg);
}
/**
......@@ -172,68 +172,68 @@ ssize_t ChromecastCommunication::receive( uint8_t *p_data, size_t i_size, int i_
/*****************************************************************************
* Message preparation
*****************************************************************************/
void ChromecastCommunication::msgAuth()
int ChromecastCommunication::msgAuth()
{
castchannel::DeviceAuthMessage authMessage;
authMessage.mutable_challenge();
buildMessage(NAMESPACE_DEVICEAUTH, authMessage.SerializeAsString(),
DEFAULT_CHOMECAST_RECEIVER, castchannel::CastMessage_PayloadType_BINARY);
return buildMessage(NAMESPACE_DEVICEAUTH, authMessage.SerializeAsString(),
DEFAULT_CHOMECAST_RECEIVER, castchannel::CastMessage_PayloadType_BINARY);
}
void ChromecastCommunication::msgPing()
int ChromecastCommunication::msgPing()
{
std::string s("{\"type\":\"PING\"}");
buildMessage( NAMESPACE_HEARTBEAT, s, DEFAULT_CHOMECAST_RECEIVER );
return buildMessage( NAMESPACE_HEARTBEAT, s, DEFAULT_CHOMECAST_RECEIVER );
}
void ChromecastCommunication::msgPong()
int ChromecastCommunication::msgPong()
{
std::string s("{\"type\":\"PONG\"}");
buildMessage( NAMESPACE_HEARTBEAT, s, DEFAULT_CHOMECAST_RECEIVER );
return buildMessage( NAMESPACE_HEARTBEAT, s, DEFAULT_CHOMECAST_RECEIVER );
}
void ChromecastCommunication::msgConnect( const std::string& destinationId )
int ChromecastCommunication::msgConnect( const std::string& destinationId )
{
std::string s("{\"type\":\"CONNECT\"}");
buildMessage( NAMESPACE_CONNECTION, s, destinationId );
return buildMessage( NAMESPACE_CONNECTION, s, destinationId );
}
void ChromecastCommunication::msgReceiverClose( const std::string& destinationId )
int ChromecastCommunication::msgReceiverClose( const std::string& destinationId )
{
std::string s("{\"type\":\"CLOSE\"}");
buildMessage( NAMESPACE_CONNECTION, s, destinationId );
return buildMessage( NAMESPACE_CONNECTION, s, destinationId );
}
void ChromecastCommunication::msgReceiverGetStatus()
int ChromecastCommunication::msgReceiverGetStatus()
{
std::stringstream ss;
ss << "{\"type\":\"GET_STATUS\","
<< "\"requestId\":" << m_receiver_requestId++ << "}";
buildMessage( NAMESPACE_RECEIVER, ss.str(), DEFAULT_CHOMECAST_RECEIVER );
return buildMessage( NAMESPACE_RECEIVER, ss.str(), DEFAULT_CHOMECAST_RECEIVER );
}
void ChromecastCommunication::msgReceiverLaunchApp()
int ChromecastCommunication::msgReceiverLaunchApp()
{
std::stringstream ss;
ss << "{\"type\":\"LAUNCH\","
<< "\"appId\":\"" << APP_ID << "\","
<< "\"requestId\":" << m_receiver_requestId++ << "}";
buildMessage( NAMESPACE_RECEIVER, ss.str(), DEFAULT_CHOMECAST_RECEIVER );
return buildMessage( NAMESPACE_RECEIVER, ss.str(), DEFAULT_CHOMECAST_RECEIVER );
}
void ChromecastCommunication::msgPlayerGetStatus( const std::string& destinationId )
int ChromecastCommunication::msgPlayerGetStatus( const std::string& destinationId )
{
std::stringstream ss;
ss << "{\"type\":\"GET_STATUS\","
<< "\"requestId\":" << m_requestId++
<< "}";
pushMediaPlayerMessage( destinationId, ss );
return pushMediaPlayerMessage( destinationId, ss );
}
std::string ChromecastCommunication::GetMedia( unsigned int i_port,
......@@ -310,7 +310,7 @@ std::string ChromecastCommunication::GetMedia( unsigned int i_port,
return ss.str();
}
void ChromecastCommunication::msgPlayerLoad( const std::string& destinationId, unsigned int i_port,
int ChromecastCommunication::msgPlayerLoad( const std::string& destinationId, unsigned int i_port,
const std::string& mime, const vlc_meta_t *p_meta )
{
std::stringstream ss;
......@@ -320,10 +320,10 @@ void ChromecastCommunication::msgPlayerLoad( const std::string& destinationId, u
<< "\"requestId\":" << m_requestId++
<< "}";
pushMediaPlayerMessage( destinationId, ss );
return pushMediaPlayerMessage( destinationId, ss );
}
void ChromecastCommunication::msgPlayerPlay( const std::string& destinationId, int64_t mediaSessionId )
int ChromecastCommunication::msgPlayerPlay( const std::string& destinationId, int64_t mediaSessionId )
{
assert(mediaSessionId != 0);
......@@ -333,10 +333,10 @@ void ChromecastCommunication::msgPlayerPlay( const std::string& destinationId, i
<< "\"requestId\":" << m_requestId++
<< "}";
pushMediaPlayerMessage( destinationId, ss );
return pushMediaPlayerMessage( destinationId, ss );
}
void ChromecastCommunication::msgPlayerStop( const std::string& destinationId, int64_t mediaSessionId )
int ChromecastCommunication::msgPlayerStop( const std::string& destinationId, int64_t mediaSessionId )
{
assert(mediaSessionId != 0);
......@@ -346,10 +346,10 @@ void ChromecastCommunication::msgPlayerStop( const std::string& destinationId, i
<< "\"requestId\":" << m_requestId++
<< "}";
pushMediaPlayerMessage( destinationId, ss );
return pushMediaPlayerMessage( destinationId, ss );
}
void ChromecastCommunication::msgPlayerPause( const std::string& destinationId, int64_t mediaSessionId )
int ChromecastCommunication::msgPlayerPause( const std::string& destinationId, int64_t mediaSessionId )
{
assert(mediaSessionId != 0);
......@@ -359,15 +359,15 @@ void ChromecastCommunication::msgPlayerPause( const std::string& destinationId,
<< "\"requestId\":" << m_requestId++
<< "}";
pushMediaPlayerMessage( destinationId, ss );
return pushMediaPlayerMessage( destinationId, ss );
}
void ChromecastCommunication::msgPlayerSetVolume( const std::string& destinationId, int64_t mediaSessionId, float f_volume, bool b_mute )
int ChromecastCommunication::msgPlayerSetVolume( const std::string& destinationId, int64_t mediaSessionId, float f_volume, bool b_mute )
{
assert(mediaSessionId != 0);
if ( f_volume < 0.0 || f_volume > 1.0)
return;
return VLC_EGENERIC;
std::stringstream ss;
ss << "{\"type\":\"SET_VOLUME\","
......@@ -376,10 +376,10 @@ void ChromecastCommunication::msgPlayerSetVolume( const std::string& destination
<< "\"requestId\":" << m_requestId++
<< "}";
pushMediaPlayerMessage( destinationId, ss );
return pushMediaPlayerMessage( destinationId, ss );
}
void ChromecastCommunication::msgPlayerSeek( const std::string& destinationId, int64_t mediaSessionId, const std::string& currentTime )
int ChromecastCommunication::msgPlayerSeek( const std::string& destinationId, int64_t mediaSessionId, const std::string& currentTime )
{
assert(mediaSessionId != 0);
......@@ -390,7 +390,7 @@ void ChromecastCommunication::msgPlayerSeek( const std::string& destinationId, i
<< "\"requestId\":" << m_requestId++
<< "}";
pushMediaPlayerMessage( destinationId, ss );
return pushMediaPlayerMessage( destinationId, ss );
}
/**
......@@ -422,8 +422,8 @@ int ChromecastCommunication::sendMessage( const castchannel::CastMessage &msg )
return VLC_EGENERIC;
}
void ChromecastCommunication::pushMediaPlayerMessage( const std::string& destinationId, const std::stringstream & payload )
int ChromecastCommunication::pushMediaPlayerMessage( const std::string& destinationId, const std::stringstream & payload )
{
assert(!destinationId.empty());
buildMessage( NAMESPACE_MEDIA, payload.str(), destinationId );
return buildMessage( NAMESPACE_MEDIA, payload.str(), destinationId );
}
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