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

chromecast: pass the title/artwork to the Chromecast when starting playback

Signed-off-by: Jean-Baptiste Kempf's avatarJean-Baptiste Kempf <jb@videolan.org>
parent f75541f7
......@@ -161,6 +161,22 @@ private:
void setInputState(input_state_e state);
void setTitle( const char *psz_title )
{
if ( psz_title )
title = psz_title;
else
title = "";
}
void setArtwork( const char *psz_artwork )
{
if ( psz_artwork )
artwork = psz_artwork;
else
artwork = "";
}
int sendMessage(const castchannel::CastMessage &msg);
void buildMessage(const std::string & namespace_,
......@@ -187,6 +203,10 @@ private:
bool has_input;
input_state_e input_state;
std::string GetMedia();
std::string artwork;
std::string title;
static void* ChromecastThread(void* p_data);
vlc_interrupt_t *p_ctl_thread_interrupt;
......@@ -247,6 +267,9 @@ private:
static void wait_seek_done(void*);
static void set_input_state(void*, input_state_e state);
static void set_title(void*, const char *psz_title);
static void set_artwork(void*, const char *psz_artwork);
};
#endif /* VLC_CHROMECAST_H */
......@@ -47,6 +47,10 @@ typedef struct
void (*pf_wait_seek_done)(void*);
void (*pf_set_input_state)(void*, input_state_e state);
void (*pf_set_title)(void*, const char *psz_title);
void (*pf_set_artwork)(void*, const char *psz_artwork);
} chromecast_common;
# ifdef __cplusplus
......
......@@ -129,6 +129,8 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device
common.pf_request_seek = request_seek;
common.pf_wait_seek_done = wait_seek_done;
common.pf_set_input_state = set_input_state;
common.pf_set_artwork = set_artwork;
common.pf_set_title = set_title;
assert( var_Type( p_module->p_parent->p_parent, CC_SHARED_VAR_NAME) == 0 );
if (var_Create( p_module->p_parent->p_parent, CC_SHARED_VAR_NAME, VLC_VAR_ADDRESS ) == VLC_SUCCESS )
......@@ -761,16 +763,42 @@ void intf_sys_t::msgPlayerGetStatus()
pushMediaPlayerMessage( ss );
}
std::string intf_sys_t::GetMedia()
{
std::stringstream ss;
if ( title.size() )
{
ss << "\"metadata\":{"
<< " \"metadataType\":0"
<< ",\"title\":\"" << title << "\"";
if ( artwork.size() && !strncmp(artwork.c_str(), "http", 4))
ss << ",\"images\":[\"" << artwork << "\"]";
ss << "},";
}
std::stringstream chromecast_url;
chromecast_url << "http://" << serverIP << ":" << i_port << "/stream";
msg_Dbg( p_module, "s_chromecast_url: %s", chromecast_url.str().c_str());
ss << "\"contentId\":\"" << chromecast_url.str() << "\""
<< ",\"streamType\":\"LIVE\""
<< ",\"contentType\":\"" << mime << "\"";
return ss.str();
}
void intf_sys_t::msgPlayerLoad()
{
std::stringstream ss;
ss << "{\"type\":\"LOAD\","
<< "\"media\":{\"contentId\":\"http://" << serverIP << ":"
<< i_port
<< "/stream\","
<< "\"streamType\":\"LIVE\","
<< "\"contentType\":\"" << mime << "\"},"
<< "\"requestId\":" << i_requestId++ << "}";
<< "\"media\":{" << GetMedia() << "},"
<< "\"autoplay\":\"false\","
<< "\"requestId\":" << i_requestId++
<< "}";
pushMediaPlayerMessage( ss );
}
......@@ -1023,7 +1051,7 @@ void intf_sys_t::requestPlayerSeek(mtime_t pos)
void intf_sys_t::setInputState(input_state_e state)
{
input_state = state;
msg_Dbg( p_module, "new %d state", state );
msg_Dbg( p_module, "new %d state for %s", state, title.c_str() );
switch( input_state )
{
case PLAYING_S:
......@@ -1120,3 +1148,15 @@ void intf_sys_t::set_input_state(void *pt, input_state_e state)
intf_sys_t *p_this = reinterpret_cast<intf_sys_t*>(pt);
p_this->setInputState( state );
}
void intf_sys_t::set_title(void *pt, const char *psz_title)
{
intf_sys_t *p_this = reinterpret_cast<intf_sys_t*>(pt);
p_this->setTitle( psz_title );
}
void intf_sys_t::set_artwork(void *pt, const char *psz_artwork)
{
intf_sys_t *p_this = reinterpret_cast<intf_sys_t*>(pt);
p_this->setArtwork( psz_artwork );
}
......@@ -50,6 +50,18 @@ struct demux_sys_t
while (p_last_demux->p_next)
p_last_demux = p_last_demux->p_next;
input_thread_t *p_input = p_last_demux->p_input;
input_item_t *p_item = input_GetItem( p_input );
if ( p_item )
{
char *psz_title = input_item_GetTitleFbName( p_item );
p_renderer->pf_set_title( p_renderer->p_opaque, psz_title );
free( psz_title );
psz_title = input_item_GetArtworkURL( p_item );
p_renderer->pf_set_artwork( p_renderer->p_opaque, psz_title );
free( psz_title );
}
p_renderer->pf_set_input_state( p_renderer->p_opaque,
(input_state_e) var_GetInteger( p_input, "state" ) );
var_AddCallback( p_input, "intf-event", InputEvent, this );
......@@ -62,6 +74,9 @@ struct demux_sys_t
p_last_demux = p_last_demux->p_next;
input_thread_t *p_input = p_last_demux->p_input;
var_DelCallback( p_input, "intf-event", InputEvent, this );
p_renderer->pf_set_title( p_renderer->p_opaque, NULL );
p_renderer->pf_set_artwork( p_renderer->p_opaque, NULL );
}
/**
......
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