[vlc-commits] chromecast: pause the input when the CC is paused
Thomas Guillem
git at videolan.org
Wed Feb 7 23:45:43 CET 2018
vlc/vlc-3.0 | branch: master | Thomas Guillem <thomas at gllm.fr> | Wed Feb 7 10:24:01 2018 +0100| [f26e7cc764aab537c1ae599b12c46cefb8ebe52f] | committer: Jean-Baptiste Kempf
chromecast: pause the input when the CC is paused
(cherry picked from commit 496d1a5ada727b1da3ad541b5334d6a123781137)
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc/vlc-3.0.git/?a=commit;h=f26e7cc764aab537c1ae599b12c46cefb8ebe52f
---
modules/stream_out/chromecast/chromecast.h | 6 +++++
modules/stream_out/chromecast/chromecast_common.h | 4 +++
modules/stream_out/chromecast/chromecast_ctrl.cpp | 30 ++++++++++++++++++++++
modules/stream_out/chromecast/chromecast_demux.cpp | 18 +++++++++++++
4 files changed, 58 insertions(+)
diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h
index 201086bc2b..d220171bcc 100644
--- a/modules/stream_out/chromecast/chromecast.h
+++ b/modules/stream_out/chromecast/chromecast.h
@@ -170,6 +170,8 @@ struct intf_sys_t
void requestPlayerSeek(mtime_t pos);
void setOnSeekDoneCb(on_seek_done_itf on_seek_done, void *on_seek_done_data);
+ void setOnPausedChangedCb(on_paused_changed_itf on_paused_changed,
+ void *on_paused_changed_data);
void requestPlayerStop();
States state() const;
@@ -219,6 +221,7 @@ private:
static void set_initial_time( void*, mtime_t time );
static void pace(void*);
+ static void set_on_paused_changed_cb(void *, on_paused_changed_itf, void *);
static void set_pause_state(void*, bool paused);
@@ -242,6 +245,9 @@ private:
on_seek_done_itf m_on_seek_done;
void *m_on_seek_done_data;
+ on_paused_changed_itf m_on_paused_changed;
+ void *m_on_paused_changed_data;
+
ChromecastCommunication m_communication;
std::queue<QueueableMessages> m_msgQueue;
States m_state;
diff --git a/modules/stream_out/chromecast/chromecast_common.h b/modules/stream_out/chromecast/chromecast_common.h
index c8e1726946..4e47c86f7b 100644
--- a/modules/stream_out/chromecast/chromecast_common.h
+++ b/modules/stream_out/chromecast/chromecast_common.h
@@ -33,10 +33,14 @@ extern "C" {
#define CC_SHARED_VAR_NAME "cc_sout"
+typedef void (*on_paused_changed_itf)( void *data, bool );
+
typedef struct
{
void *p_opaque;
+ void (*pf_set_on_paused_changed_cb)(void *, on_paused_changed_itf, void *);
+
void (*pf_set_length)(void*, mtime_t length);
mtime_t (*pf_get_time)(void*);
double (*pf_get_position)(void*);
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index e5c6147992..bc2ac2026e 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -91,6 +91,10 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device
: m_module(p_this)
, m_streaming_port(port)
, m_mediaSessionId( 0 )
+ , m_on_seek_done( NULL )
+ , m_on_seek_done_data( NULL )
+ , m_on_paused_changed( NULL )
+ , m_on_paused_changed_data( NULL )
, m_communication( p_this, device_addr.c_str(), device_port )
, m_state( Authenticating )
, m_request_stop( false )
@@ -120,6 +124,7 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device
m_art_http_ip = ss.str();
m_common.p_opaque = this;
+ m_common.pf_set_on_paused_changed_cb = set_on_paused_changed_cb;
m_common.pf_get_position = get_position;
m_common.pf_get_time = get_time;
m_common.pf_set_length = set_length;
@@ -919,6 +924,14 @@ void intf_sys_t::setOnSeekDoneCb(on_seek_done_itf on_seek_done, void *on_seek_do
m_on_seek_done_data = on_seek_done_data;
}
+void intf_sys_t::setOnPausedChangedCb(on_paused_changed_itf on_paused_changed,
+ void *on_paused_changed_data)
+{
+ vlc_mutex_locker locker(&m_lock);
+ m_on_paused_changed = on_paused_changed;
+ m_on_paused_changed_data = on_paused_changed_data;
+}
+
void intf_sys_t::setPauseState(bool paused)
{
vlc_mutex_locker locker( &m_lock );
@@ -992,6 +1005,8 @@ void intf_sys_t::setState( States state )
if (m_state == Seeking)
if (m_on_seek_done != NULL)
m_on_seek_done(m_on_seek_done_data);
+
+ States old_state = m_state;
m_state = state;
switch( m_state )
@@ -1000,6 +1015,14 @@ void intf_sys_t::setState( States state )
case Ready:
tryLoad();
break;
+ case Paused:
+ if (m_on_paused_changed != NULL)
+ m_on_paused_changed(m_on_paused_changed_data, true);
+ break;
+ case Playing:
+ if (m_on_paused_changed != NULL && old_state == Paused)
+ m_on_paused_changed(m_on_paused_changed_data, false);
+ break;
default:
break;
}
@@ -1028,6 +1051,13 @@ void intf_sys_t::set_initial_time(void *pt, mtime_t time )
return p_this->setInitialTime( time );
}
+void intf_sys_t::set_on_paused_changed_cb(void *pt,
+ on_paused_changed_itf itf, void *data)
+{
+ intf_sys_t *p_this = static_cast<intf_sys_t*>(pt);
+ p_this->setOnPausedChangedCb(itf, data);
+}
+
void intf_sys_t::set_length(void *pt, mtime_t length)
{
intf_sys_t *p_this = static_cast<intf_sys_t*>(pt);
diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp
index 3337f0cb65..bad4edd8ae 100644
--- a/modules/stream_out/chromecast/chromecast_demux.cpp
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -36,6 +36,8 @@
#include <new>
+static void on_paused_changed_cb(void *data, bool paused);
+
struct demux_sys_t
{
demux_sys_t(demux_t * const demux, chromecast_common * const renderer)
@@ -119,12 +121,19 @@ struct demux_sys_t
}
}
}
+
+ p_renderer->pf_set_on_paused_changed_cb(p_renderer->p_opaque,
+ on_paused_changed_cb, demux);
}
~demux_sys_t()
{
if( p_renderer )
+ {
p_renderer->pf_set_meta( p_renderer->p_opaque, NULL );
+ p_renderer->pf_set_on_paused_changed_cb( p_renderer->p_opaque,
+ NULL, NULL );
+ }
}
void setPauseState(bool paused)
@@ -288,6 +297,15 @@ protected:
mtime_t m_startTime;
};
+static void on_paused_changed_cb( void *data, bool paused )
+{
+ demux_t *p_demux = reinterpret_cast<demux_t*>(data);
+
+ input_thread_t *p_input = p_demux->p_next->p_input;
+ if( p_input )
+ input_Control( p_input, INPUT_SET_STATE, paused ? PAUSE_S : PLAYING_S );
+}
+
static int Demux( demux_t *p_demux_filter )
{
demux_sys_t *p_sys = p_demux_filter->p_sys;
More information about the vlc-commits
mailing list