Commit 496d1a5a authored by Thomas Guillem's avatar Thomas Guillem

chromecast: pause the input when the CC is paused

parent 30c7c878
...@@ -170,6 +170,8 @@ struct intf_sys_t ...@@ -170,6 +170,8 @@ struct intf_sys_t
void requestPlayerSeek(mtime_t pos); void requestPlayerSeek(mtime_t pos);
void setOnSeekDoneCb(on_seek_done_itf on_seek_done, void *on_seek_done_data); 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(); void requestPlayerStop();
States state() const; States state() const;
...@@ -219,6 +221,7 @@ private: ...@@ -219,6 +221,7 @@ private:
static void set_initial_time( void*, mtime_t time ); static void set_initial_time( void*, mtime_t time );
static void pace(void*); 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); static void set_pause_state(void*, bool paused);
...@@ -242,6 +245,9 @@ private: ...@@ -242,6 +245,9 @@ private:
on_seek_done_itf m_on_seek_done; on_seek_done_itf m_on_seek_done;
void *m_on_seek_done_data; void *m_on_seek_done_data;
on_paused_changed_itf m_on_paused_changed;
void *m_on_paused_changed_data;
ChromecastCommunication m_communication; ChromecastCommunication m_communication;
std::queue<QueueableMessages> m_msgQueue; std::queue<QueueableMessages> m_msgQueue;
States m_state; States m_state;
......
...@@ -33,10 +33,14 @@ extern "C" { ...@@ -33,10 +33,14 @@ extern "C" {
#define CC_SHARED_VAR_NAME "cc_sout" #define CC_SHARED_VAR_NAME "cc_sout"
typedef void (*on_paused_changed_itf)( void *data, bool );
typedef struct typedef struct
{ {
void *p_opaque; void *p_opaque;
void (*pf_set_on_paused_changed_cb)(void *, on_paused_changed_itf, void *);
void (*pf_set_length)(void*, mtime_t length); void (*pf_set_length)(void*, mtime_t length);
mtime_t (*pf_get_time)(void*); mtime_t (*pf_get_time)(void*);
double (*pf_get_position)(void*); double (*pf_get_position)(void*);
......
...@@ -91,6 +91,10 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device ...@@ -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_module(p_this)
, m_streaming_port(port) , m_streaming_port(port)
, m_mediaSessionId( 0 ) , 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_communication( p_this, device_addr.c_str(), device_port )
, m_state( Authenticating ) , m_state( Authenticating )
, m_request_stop( false ) , 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 ...@@ -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_art_http_ip = ss.str();
m_common.p_opaque = this; 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_position = get_position;
m_common.pf_get_time = get_time; m_common.pf_get_time = get_time;
m_common.pf_set_length = set_length; 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 ...@@ -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; 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) void intf_sys_t::setPauseState(bool paused)
{ {
vlc_mutex_locker locker( &m_lock ); vlc_mutex_locker locker( &m_lock );
...@@ -992,6 +1005,8 @@ void intf_sys_t::setState( States state ) ...@@ -992,6 +1005,8 @@ void intf_sys_t::setState( States state )
if (m_state == Seeking) if (m_state == Seeking)
if (m_on_seek_done != NULL) if (m_on_seek_done != NULL)
m_on_seek_done(m_on_seek_done_data); m_on_seek_done(m_on_seek_done_data);
States old_state = m_state;
m_state = state; m_state = state;
switch( m_state ) switch( m_state )
...@@ -1000,6 +1015,14 @@ void intf_sys_t::setState( States state ) ...@@ -1000,6 +1015,14 @@ void intf_sys_t::setState( States state )
case Ready: case Ready:
tryLoad(); tryLoad();
break; 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: default:
break; break;
} }
...@@ -1028,6 +1051,13 @@ void intf_sys_t::set_initial_time(void *pt, mtime_t time ) ...@@ -1028,6 +1051,13 @@ void intf_sys_t::set_initial_time(void *pt, mtime_t time )
return p_this->setInitialTime( 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) void intf_sys_t::set_length(void *pt, mtime_t length)
{ {
intf_sys_t *p_this = static_cast<intf_sys_t*>(pt); intf_sys_t *p_this = static_cast<intf_sys_t*>(pt);
......
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
#include <new> #include <new>
static void on_paused_changed_cb(void *data, bool paused);
struct demux_sys_t struct demux_sys_t
{ {
demux_sys_t(demux_t * const demux, chromecast_common * const renderer) demux_sys_t(demux_t * const demux, chromecast_common * const renderer)
...@@ -118,12 +120,19 @@ struct demux_sys_t ...@@ -118,12 +120,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() ~demux_sys_t()
{ {
if( p_renderer ) if( p_renderer )
{
p_renderer->pf_set_meta( p_renderer->p_opaque, NULL ); 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) void setPauseState(bool paused)
...@@ -262,6 +271,15 @@ protected: ...@@ -262,6 +271,15 @@ protected:
mtime_t m_startTime; 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 ) static int Demux( demux_t *p_demux_filter )
{ {
demux_sys_t *p_sys = (demux_sys_t *)p_demux_filter->p_sys; demux_sys_t *p_sys = (demux_sys_t *)p_demux_filter->p_sys;
......
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