Commit b42ce733 authored by Steve Lhomme's avatar Steve Lhomme Committed by Jean-Baptiste Kempf

chromecast: send a dummy SEEK message when flushing is needed

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent eaf14d15
......@@ -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 );
}
......
......@@ -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);
......
......@@ -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)
......@@ -877,6 +880,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';
}
vlc_mutex_locker locker(&lock);
setPlayerStatus(CMD_SEEK_SENT);
/* send a fake time to seek to, to make sure the device flushes its buffers */
msgPlayerSeek( current_time );
}
int i_ret = recvPacket( b_msgReceived, i_payloadSize,
&i_received, p_packet, &b_pingTimeout,
&i_waitdelay, &i_retries);
......@@ -920,3 +938,9 @@ void intf_sys_t::requestPlayerStop()
requested_stop = true;
notifySendRequest();
}
void intf_sys_t::requestPlayerSeek()
{
requested_seek = true;
notifySendRequest();
}
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