vlc | branch: master | Steve Lhomme <[email protected]> | Thu Apr 28 14:20:57 2016 +0200| [284769159c3a0606b1813a6ee062b894ddf3b66b] | committer: Thomas Guillem
chromecast: use the control class with fixed device ip/port Signed-off-by: Thomas Guillem <[email protected]> > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=284769159c3a0606b1813a6ee062b894ddf3b66b --- modules/stream_out/Makefile.am | 7 ++++- modules/stream_out/chromecast/cast.cpp | 33 +++++++++++++++++++-- modules/stream_out/chromecast/chromecast.h | 1 + modules/stream_out/chromecast/chromecast_ctrl.cpp | 2 -- 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/modules/stream_out/Makefile.am b/modules/stream_out/Makefile.am index 26c0cf2..9b2f12f 100644 --- a/modules/stream_out/Makefile.am +++ b/modules/stream_out/Makefile.am @@ -80,9 +80,14 @@ SUFFIXES += .proto .pb.cc %.pb.h %.pb.cc: %.proto $(PROTOC) --cpp_out=. -I$(srcdir) $< -libstream_out_chromecast_plugin_la_SOURCES = stream_out/chromecast/cast.cpp stream_out/chromecast/chromecast.h +libstream_out_chromecast_plugin_la_SOURCES = stream_out/chromecast/cast.cpp stream_out/chromecast/chromecast.h \ + stream_out/chromecast/cast_channel.proto \ + stream_out/chromecast/chromecast_ctrl.cpp \ + misc/webservices/json.h misc/webservices/json.c +nodist_libstream_out_chromecast_plugin_la_SOURCES = stream_out/chromecast/cast_channel.pb.cc libstream_out_chromecast_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -Istream_out/chromecast $(CHROMECAST_CFLAGS) libstream_out_chromecast_plugin_la_LIBADD = $(CHROMECAST_LIBS) $(SOCKET_LIBS) +CLEANFILES += $(nodist_libstream_out_chromecast_plugin_la_SOURCES) if ENABLE_SOUT if BUILD_CHROMECAST diff --git a/modules/stream_out/chromecast/cast.cpp b/modules/stream_out/chromecast/cast.cpp index 9a3c610..36b26c3 100644 --- a/modules/stream_out/chromecast/cast.cpp +++ b/modules/stream_out/chromecast/cast.cpp @@ -54,6 +54,7 @@ struct sout_stream_sys_t ~sout_stream_sys_t() { sout_StreamChainDelete(p_out, p_out); + delete p_intf; } bool canDecodeVideo( const es_format_t *p_es ) const; @@ -91,7 +92,7 @@ static int Open(vlc_object_t *); static void Close(vlc_object_t *); static const char *const ppsz_sout_options[] = { - "http-port", "mux", "mime", "video", NULL + "ip", "port", "http-port", "mux", "mime", "video", NULL }; /***************************************************************************** @@ -99,7 +100,7 @@ static const char *const ppsz_sout_options[] = { *****************************************************************************/ #define HTTP_PORT_TEXT N_("HTTP port") -#define HTTP_PORT_LONGTEXT N_("This sets the HTTP port of the server " \ +#define HTTP_PORT_LONGTEXT N_("This sets the HTTP port of the local server " \ "used to stream the media to the Chromecast.") #define HAS_VIDEO_TEXT N_("Video") #define HAS_VIDEO_LONGTEXT N_("The Chromecast receiver can receive video.") @@ -108,6 +109,11 @@ static const char *const ppsz_sout_options[] = { #define MIME_TEXT N_("MIME content type") #define MIME_LONGTEXT N_("This sets the media MIME content type sent to the Chromecast.") +#define IP_ADDR_TEXT N_("IP Address") +#define IP_ADDR_LONGTEXT N_("IP Address of the Chromecast.") +#define PORT_TEXT N_("Chromecast port") +#define PORT_LONGTEXT N_("The port used to talk to the Chromecast.") + vlc_module_begin () set_shortname(N_("Chromecast")) @@ -118,6 +124,8 @@ vlc_module_begin () set_subcategory(SUBCAT_SOUT_STREAM) set_callbacks(Open, Close) + add_string(SOUT_CFG_PREFIX "ip", NULL, IP_ADDR_TEXT, IP_ADDR_LONGTEXT, false) + add_integer(SOUT_CFG_PREFIX "port", CHROMECAST_CONTROL_PORT, PORT_TEXT, PORT_LONGTEXT, false) add_integer(SOUT_CFG_PREFIX "http-port", HTTP_PORT, HTTP_PORT_TEXT, HTTP_PORT_LONGTEXT, false) add_bool(SOUT_CFG_PREFIX "video", true, HAS_VIDEO_TEXT, HAS_VIDEO_LONGTEXT, false) add_string(SOUT_CFG_PREFIX "mux", DEFAULT_MUXER, MUX_TEXT, MUX_LONGTEXT, false) @@ -382,16 +390,34 @@ static int Open(vlc_object_t *p_this) sout_stream_t *p_stream = reinterpret_cast<sout_stream_t*>(p_this); sout_stream_sys_t *p_sys = NULL; intf_sys_t *p_intf = NULL; + char *psz_ip = NULL; char *psz_mux = NULL; char *psz_var_mime = NULL; sout_stream_t *p_sout = NULL; bool b_has_video = true; int i_local_server_port; + int i_device_port; std::stringstream ss; config_ChainParse(p_stream, SOUT_CFG_PREFIX, ppsz_sout_options, p_stream->p_cfg); + + psz_ip = var_GetNonEmptyString( p_stream, SOUT_CFG_PREFIX "ip"); + if ( psz_ip == NULL ) + { + msg_Err( p_this, "missing Chromecast IP address" ); + goto error; + } + + i_device_port = var_InheritInteger(p_stream, SOUT_CFG_PREFIX "port"); i_local_server_port = var_InheritInteger(p_stream, SOUT_CFG_PREFIX "http-port"); + p_intf = new(std::nothrow) intf_sys_t( p_this, i_local_server_port, psz_ip, i_device_port ); + if ( p_intf == NULL) + { + msg_Err( p_this, "cannot load the Chromecast controler" ); + goto error; + } + psz_mux = var_GetNonEmptyString(p_stream, SOUT_CFG_PREFIX "mux"); if (psz_mux == NULL) { @@ -428,11 +454,14 @@ static int Open(vlc_object_t *p_this) p_stream->pf_control = Control; p_stream->p_sys = p_sys; + free(psz_ip); free(psz_mux); free(psz_var_mime); return VLC_SUCCESS; error: + delete p_intf; + free(psz_ip); free(psz_mux); free(psz_var_mime); delete p_sys; diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h index 82ce9fe..0635a4f 100644 --- a/modules/stream_out/chromecast/chromecast.h +++ b/modules/stream_out/chromecast/chromecast.h @@ -46,6 +46,7 @@ static const std::string DEFAULT_CHOMECAST_RECEIVER = "receiver-0"; /* see https://developers.google.com/cast/docs/reference/messages */ static const std::string NAMESPACE_MEDIA = "urn:x-cast:com.google.cast.media"; +#define CHROMECAST_CONTROL_PORT 8009 #define HTTP_PORT 8010 // Status diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp index bb61410..632fa67 100644 --- a/modules/stream_out/chromecast/chromecast_ctrl.cpp +++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp @@ -45,8 +45,6 @@ // Media player Chromecast app id #define APP_ID "CC1AD845" // Default media player aka DEFAULT_MEDIA_RECEIVER_APPLICATION_ID -static const int CHROMECAST_CONTROL_PORT = 8009; - /* deadline regarding pings sent from receiver */ #define PING_WAIT_TIME 6000 #define PING_WAIT_RETRIES 0 _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
