[vlc-devel] [PATCH 3/3] chromecast: send a dummy SEEK message when flushing is needed
Steve Lhomme
robux4 at videolabs.io
Mon May 9 18:56:38 CEST 2016
---
modules/stream_out/chromecast/cast.cpp | 3 +++
modules/stream_out/chromecast/chromecast.h | 2 ++
modules/stream_out/chromecast/chromecast_ctrl.cpp | 24 +++++++++++++++++++++++
3 files changed, 29 insertions(+)
diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp
index bc4c462..69747f4 100644
--- a/modules/stream_out/chromecast/cast.cpp
+++ b/modules/stream_out/chromecast/cast.cpp
@@ -374,6 +374,9 @@ static void Flush( sout_stream_t *p_stream, sout_stream_id_sys_t *id )
if ( id == NULL )
return;
+ /* a seek on the Chromecast flushes its buffers */
+ p_sys->p_intf->requestPlayerSeek();
+
sout_StreamFlush( p_sys->p_out, id );
}
diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h
index 1cd55db..c26eef7 100644
--- a/modules/stream_out/chromecast/chromecast.h
+++ b/modules/stream_out/chromecast/chromecast.h
@@ -89,6 +89,7 @@ struct intf_sys_t
void setHasInput( bool has_input, const std::string mime_type = "");
+ void requestPlayerSeek();
void requestPlayerStop();
private:
@@ -151,6 +152,7 @@ private:
void notifySendRequest();
std::atomic_bool requested_stop;
+ std::atomic_bool requested_seek;
int sendMessage(const castchannel::CastMessage &msg);
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index 1dbba93..48f5cf8 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -52,6 +52,8 @@
#define PONG_WAIT_TIME 500
#define PONG_WAIT_RETRIES 2
+static const mtime_t SEEK_FORWARD_OFFSET = 1000000;
+
#define CONTROL_CFG_PREFIX "chromecast-"
static const std::string NAMESPACE_DEVICEAUTH = "urn:x-cast:com.google.cast.tp.deviceauth";
@@ -101,6 +103,7 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device
, p_creds(NULL)
, p_tls(NULL)
, requested_stop(false)
+ , requested_seek(false)
, conn_status(CHROMECAST_DISCONNECTED)
, cmd_status(NO_CMD_PENDING)
, i_receiver_requestId(0)
@@ -891,6 +894,21 @@ bool intf_sys_t::handleMessages()
msgPlayerStop();
}
+ if ( requested_seek.exchange(false) && !mediaSessionId.empty() )
+ {
+ char current_time[32];
+ mtime_t m_seek_request_time = mdate() + SEEK_FORWARD_OFFSET;
+ if( snprintf( current_time, sizeof(current_time), "%.3f", double( m_seek_request_time ) / 1000000.0 ) >= (int)sizeof(current_time) )
+ {
+ msg_Err( p_module, "snprintf() truncated string for mediaSessionId" );
+ current_time[sizeof(current_time) - 1] = '\0';
+ }
+ setPlayerStatus(CMD_SEEK_SENT);
+ /* send a fake time to seek to, to make sure the device flushes its buffers */
+ msgPlayerSeek( current_time );
+ }
+
+ vlc_mutex_unlock(&lock);
vlc_restorecancel(canc);
int i_ret = recvPacket( p_module, b_msgReceived, i_payloadSize, i_sock_fd,
@@ -939,3 +957,9 @@ void intf_sys_t::requestPlayerStop()
requested_stop = true;
notifySendRequest();
}
+
+void intf_sys_t::requestPlayerSeek()
+{
+ requested_seek = true;
+ notifySendRequest();
+}
--
2.7.0
More information about the vlc-devel
mailing list