[vlc-commits] chromecast: pass the title/ artwork to the Chromecast when starting playback
Steve Lhomme
git at videolan.org
Wed Jun 15 01:43:05 CEST 2016
vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Wed Jun 15 00:55:55 2016 +0200| [5551921a8faeed0fc8c3c3a74c854910d15e11d4] | committer: Jean-Baptiste Kempf
chromecast: pass the title/artwork to the Chromecast when starting playback
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=5551921a8faeed0fc8c3c3a74c854910d15e11d4
---
modules/stream_out/chromecast/chromecast.h | 23 +++++++++
modules/stream_out/chromecast/chromecast_common.h | 4 ++
modules/stream_out/chromecast/chromecast_ctrl.cpp | 54 +++++++++++++++++---
modules/stream_out/chromecast/chromecast_demux.cpp | 15 ++++++
4 files changed, 89 insertions(+), 7 deletions(-)
diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h
index 18691f5..c99d527 100644
--- a/modules/stream_out/chromecast/chromecast.h
+++ b/modules/stream_out/chromecast/chromecast.h
@@ -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 */
diff --git a/modules/stream_out/chromecast/chromecast_common.h b/modules/stream_out/chromecast/chromecast_common.h
index b036e48..2da91c9 100644
--- a/modules/stream_out/chromecast/chromecast_common.h
+++ b/modules/stream_out/chromecast/chromecast_common.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
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index 225dae4..9e37603 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -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 );
+}
diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp
index 9bcdfc9..48f11bb 100644
--- a/modules/stream_out/chromecast/chromecast_demux.cpp
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -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 );
}
/**
More information about the vlc-commits
mailing list