[vlc-devel] [PATCH 09/12] chromecast: use the device ip/port to create the control class

Steve Lhomme robux4 at videolabs.io
Tue Apr 26 11:02:03 CEST 2016


This patch is replaced by https://patches.videolan.org/patch/13093/

On Mon, Apr 25, 2016 at 5:46 PM, Steve Lhomme <robux4 at videolabs.io> wrote:
> ---
>  modules/stream_out/Makefile.am                    |  7 ++++-
>  modules/stream_out/chromecast/cast.cpp            | 34 +++++++++++++++++++++--
>  modules/stream_out/chromecast/chromecast.h        |  1 +
>  modules/stream_out/chromecast/chromecast_ctrl.cpp |  2 --
>  4 files changed, 38 insertions(+), 6 deletions(-)
>
> diff --git a/modules/stream_out/Makefile.am b/modules/stream_out/Makefile.am
> index 26c0cf2..361c2a1 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_common.h 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 6886799..83ce523 100644
> --- a/modules/stream_out/chromecast/cast.cpp
> +++ b/modules/stream_out/chromecast/cast.cpp
> @@ -56,6 +56,7 @@ struct sout_stream_sys_t
>      ~sout_stream_sys_t()
>      {
>          sout_StreamChainDelete(p_out, p_out);
> +        delete p_intf;
>          vlc_cond_destroy( &es_changed_cond );
>          vlc_mutex_destroy( &es_lock );
>      }
> @@ -98,7 +99,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
>  };
>
>  /*****************************************************************************
> @@ -106,7 +107,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.")
> @@ -115,6 +116,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"))
> @@ -125,6 +131,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)
> @@ -399,16 +407,33 @@ 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_local_server_port, 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)
>      {
> @@ -445,11 +470,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 2a7a744..42ef8ec 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 ba8599a..1a16236 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
> --
> 2.7.0
>


More information about the vlc-devel mailing list