vlc | branch: master | Steve Lhomme <[email protected]> | Mon Mar 21 16:17:31 2016 +0100| [a3d86a75c02b5bbb059a628db232162deac15f20] | committer: Jean-Baptiste Kempf
chromecast: keep track of the last command sent to the device > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=a3d86a75c02b5bbb059a628db232162deac15f20 --- modules/stream_out/chromecast/chromecast.h | 22 ++++++++++++++++++++- modules/stream_out/chromecast/chromecast_ctrl.cpp | 14 +++++++++---- 2 files changed, 31 insertions(+), 5 deletions(-) diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h index d817528..2031fee 100644 --- a/modules/stream_out/chromecast/chromecast.h +++ b/modules/stream_out/chromecast/chromecast.h @@ -55,10 +55,16 @@ enum connection_status CHROMECAST_TLS_CONNECTED, CHROMECAST_AUTHENTICATED, CHROMECAST_APP_STARTED, - CHROMECAST_MEDIA_LOAD_SENT, CHROMECAST_CONNECTION_DEAD, }; +enum command_status { + NO_CMD_PENDING, + CMD_LOAD_SENT, + CMD_PLAYBACK_SENT, + CMD_SEEK_SENT, +}; + enum receiver_state { RECEIVER_IDLE, RECEIVER_PLAYING, @@ -131,6 +137,11 @@ struct intf_sys_t void processMessage(const castchannel::CastMessage &msg); + command_status getPlayerStatus() const + { + return cmd_status; + } + private: int sendMessage(const castchannel::CastMessage &msg); @@ -141,7 +152,16 @@ private: void pushMediaPlayerMessage(const std::stringstream & payload); + void setPlayerStatus(enum command_status status) { + if (cmd_status != status) + { + msg_Dbg(p_module, "change Chromecast command status from %d to %d", cmd_status, status); + cmd_status = status; + } + } + enum connection_status conn_status; + enum command_status cmd_status; unsigned i_receiver_requestId; unsigned i_requestId; diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp index c2639c5..d741b48 100644 --- a/modules/stream_out/chromecast/chromecast_ctrl.cpp +++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp @@ -171,7 +171,7 @@ int Open(vlc_object_t *p_module) // Lock the sout thread until we have sent the media loading command to the Chromecast. deadline = mdate() + 6 * CLOCK_FREQ; vlc_mutex_lock(&p_sys->lock); - while (p_sys->getConnectionStatus() != CHROMECAST_MEDIA_LOAD_SENT) + while (p_sys->getPlayerStatus() != CMD_LOAD_SENT) { int i_ret = vlc_cond_timedwait(&p_sys->loadCommandCond, &p_sys->lock, deadline); if (i_ret == ETIMEDOUT) @@ -244,6 +244,7 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this) , receiverState(RECEIVER_IDLE) , p_tls(NULL) , conn_status(CHROMECAST_DISCONNECTED) + , cmd_status(NO_CMD_PENDING) , i_receiver_requestId(0) , i_requestId(0) { @@ -255,7 +256,6 @@ intf_sys_t::~intf_sys_t() { switch (getConnectionStatus()) { - case CHROMECAST_MEDIA_LOAD_SENT: case CHROMECAST_APP_STARTED: // Generate the close messages. msgReceiverClose(appTransportId); @@ -320,6 +320,7 @@ void intf_sys_t::disconnectChromecast() setConnectionStatus(CHROMECAST_DISCONNECTED); appTransportId = ""; mediaSessionId = ""; // this session is not valid anymore + setPlayerStatus(NO_CMD_PENDING); receiverState = RECEIVER_IDLE; } } @@ -521,7 +522,7 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg) msgConnect(appTransportId); setConnectionStatus(CHROMECAST_APP_STARTED); msgPlayerLoad(); - setConnectionStatus(CHROMECAST_MEDIA_LOAD_SENT); + setPlayerStatus(CMD_LOAD_SENT); vlc_cond_signal(&loadCommandCond); } } @@ -531,7 +532,6 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg) { /* If the app is no longer present */ case CHROMECAST_APP_STARTED: - case CHROMECAST_MEDIA_LOAD_SENT: msg_Warn( p_module, "app is no longer present. closing"); msgReceiverClose(appTransportId); setConnectionStatus(CHROMECAST_CONNECTION_DEAD); @@ -616,6 +616,11 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg) #endif switch( receiverState ) { + case RECEIVER_PLAYING: + /* TODO reset demux PCR ? */ + setPlayerStatus(CMD_PLAYBACK_SENT); + break; + case RECEIVER_PAUSED: #ifndef NDEBUG msg_Dbg( p_module, "Playback paused"); @@ -623,6 +628,7 @@ void intf_sys_t::processMessage(const castchannel::CastMessage &msg) break; case RECEIVER_IDLE: + setPlayerStatus(NO_CMD_PENDING); break; } } _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
