[vlc-commits] chromecast: add a demux-filter to display better time
Steve Lhomme
git at videolan.org
Wed Jun 15 01:43:04 CEST 2016
vlc | branch: master | Steve Lhomme <robux4 at videolabs.io> | Mon Jun 6 16:28:12 2016 +0200| [e56df9fdb55d7efdcac0674feec02ed7141391df] | committer: Jean-Baptiste Kempf
chromecast: add a demux-filter to display better time
Will also wait for the Chromecast to be ready to receive data before sending them
Signed-off-by: Jean-Baptiste Kempf <jb at videolan.org>
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=e56df9fdb55d7efdcac0674feec02ed7141391df
---
modules/MODULES_LIST | 1 +
modules/stream_out/Makefile.am | 7 +-
modules/stream_out/chromecast/chromecast.h | 4 +
modules/stream_out/chromecast/chromecast_common.h | 45 ++++++++
modules/stream_out/chromecast/chromecast_ctrl.cpp | 8 ++
modules/stream_out/chromecast/chromecast_demux.cpp | 111 ++++++++++++++++++++
6 files changed, 175 insertions(+), 1 deletion(-)
diff --git a/modules/MODULES_LIST b/modules/MODULES_LIST
index 468ef62..0330552 100644
--- a/modules/MODULES_LIST
+++ b/modules/MODULES_LIST
@@ -101,6 +101,7 @@ $Id$
* decomp: Decompression module
* deinterlace: naive deinterlacing filter
* demux_cdg: Demuxer for CD-G files (Karaoke)
+ * demux_chromecast: Internal demux filter to report the playback time on the Chromecast
* demux_stl: EBU STL subtitles demuxer
* demuxdump: Pseudo-demuxer that dumps the stream
* diracsys: BBC Dirac demuxer
diff --git a/modules/stream_out/Makefile.am b/modules/stream_out/Makefile.am
index 9b2f12f..a598bcc 100644
--- a/modules/stream_out/Makefile.am
+++ b/modules/stream_out/Makefile.am
@@ -80,9 +80,13 @@ SUFFIXES += .proto .pb.cc
%.pb.h %.pb.cc: %.proto
$(PROTOC) --cpp_out=. -I$(srcdir) $<
+libdemux_chromecast_plugin_la_SOURCES = stream_out/chromecast/chromecast_demux.cpp stream_out/chromecast/chromecast.h \
+ stream_out/chromecast/chromecast_common.h
+libdemux_chromecast_plugin_la_CPPFLAGS = $(AM_CPPFLAGS) -Istream_out/chromecast
+
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 \
+ 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)
@@ -93,5 +97,6 @@ if ENABLE_SOUT
if BUILD_CHROMECAST
BUILT_SOURCES += stream_out/chromecast/cast_channel.pb.h
sout_LTLIBRARIES += libstream_out_chromecast_plugin.la
+demux_LTLIBRARIES += libdemux_chromecast_plugin.la
endif
endif
diff --git a/modules/stream_out/chromecast/chromecast.h b/modules/stream_out/chromecast/chromecast.h
index bab8318..c764e69 100644
--- a/modules/stream_out/chromecast/chromecast.h
+++ b/modules/stream_out/chromecast/chromecast.h
@@ -38,6 +38,7 @@
#include <sstream>
#include "cast_channel.pb.h"
+#include "chromecast_common.h"
#define PACKET_HEADER_LEN 4
@@ -184,6 +185,9 @@ private:
int recvPacket(bool &b_msgReceived, uint32_t &i_payloadSize,
unsigned *pi_received, uint8_t *p_data, bool *pb_pingTimeout,
int *pi_wait_delay, int *pi_wait_retries);
+
+ /* shared structure with the demux-filter */
+ chromecast_common common;
};
#endif /* VLC_CHROMECAST_H */
diff --git a/modules/stream_out/chromecast/chromecast_common.h b/modules/stream_out/chromecast/chromecast_common.h
new file mode 100644
index 0000000..2787c13
--- /dev/null
+++ b/modules/stream_out/chromecast/chromecast_common.h
@@ -0,0 +1,45 @@
+/*****************************************************************************
+ * chromecast_common.h: Chromecast common code between modules for vlc
+ *****************************************************************************
+ * Copyright © 2016 VideoLAN
+ *
+ * Authors: Adrien Maglo <magsoft at videolan.org>
+ * Jean-Baptiste Kempf <jb at videolan.org>
+ * Steve Lhomme <robux4 at videolabs.io>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+#ifndef VLC_CHROMECAST_COMMON_H
+#define VLC_CHROMECAST_COMMON_H
+
+# ifdef __cplusplus
+extern "C" {
+# endif
+
+static const char *CC_SHARED_VAR_NAME = "cc_sout";
+
+typedef struct
+{
+ void *p_opaque;
+
+} chromecast_common;
+
+# ifdef __cplusplus
+}
+# endif
+
+#endif // VLC_CHROMECAST_COMMON_H
+
diff --git a/modules/stream_out/chromecast/chromecast_ctrl.cpp b/modules/stream_out/chromecast/chromecast_ctrl.cpp
index 6285085..63096e9 100644
--- a/modules/stream_out/chromecast/chromecast_ctrl.cpp
+++ b/modules/stream_out/chromecast/chromecast_ctrl.cpp
@@ -114,6 +114,12 @@ intf_sys_t::intf_sys_t(vlc_object_t * const p_this, int port, std::string device
vlc_mutex_init(&lock);
vlc_cond_init(&loadCommandCond);
+ common.p_opaque = this;
+
+ 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 )
+ var_SetAddress( p_module->p_parent->p_parent, CC_SHARED_VAR_NAME, &common );
+
// Start the Chromecast event thread.
if (vlc_clone(&chromecastThread, ChromecastThread, this,
VLC_THREAD_PRIORITY_LOW))
@@ -126,6 +132,8 @@ intf_sys_t::~intf_sys_t()
{
setHasInput( false );
+ var_Destroy( p_module->p_parent->p_parent, CC_SHARED_VAR_NAME );
+
switch ( conn_status )
{
case CHROMECAST_APP_STARTED:
diff --git a/modules/stream_out/chromecast/chromecast_demux.cpp b/modules/stream_out/chromecast/chromecast_demux.cpp
new file mode 100644
index 0000000..870a541
--- /dev/null
+++ b/modules/stream_out/chromecast/chromecast_demux.cpp
@@ -0,0 +1,111 @@
+/*****************************************************************************
+ * chromecast_demux.cpp: Chromecast demux filter module for vlc
+ *****************************************************************************
+ * Copyright © 2015 VideoLAN
+ *
+ * Authors: Steve Lhomme <robux4 at videolabs.io>
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation; either version 2.1 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
+ *****************************************************************************/
+
+/*****************************************************************************
+ * Preamble
+ *****************************************************************************/
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <vlc_common.h>
+#include <vlc_plugin.h>
+#include <vlc_demux.h>
+
+#include "chromecast_common.h"
+
+#include <new>
+
+struct demux_sys_t
+{
+ demux_sys_t(demux_t * const demux, chromecast_common * const renderer)
+ :p_demux(demux)
+ ,p_renderer(renderer)
+ {
+ }
+
+ ~demux_sys_t()
+ {
+ }
+
+ int Demux()
+ {
+ return demux_Demux( p_demux->p_next );
+ }
+
+protected:
+ demux_t * const p_demux;
+ chromecast_common * const p_renderer;
+};
+
+static int Demux( demux_t *p_demux_filter )
+{
+ demux_sys_t *p_sys = p_demux_filter->p_sys;
+
+ return p_sys->Demux();
+}
+
+static int Control( demux_t *p_demux_filter, int i_query, va_list args)
+{
+ return demux_vaControl( p_demux_filter->p_next, i_query, args );
+}
+
+int Open(vlc_object_t *p_this)
+{
+ demux_t *p_demux = reinterpret_cast<demux_t*>(p_this);
+ chromecast_common *p_renderer = reinterpret_cast<chromecast_common *>(
+ var_InheritAddress( p_demux, CC_SHARED_VAR_NAME ) );
+ if ( p_renderer == NULL )
+ {
+ msg_Warn( p_this, "using Chromecast demuxer with no sout" );
+ return VLC_ENOOBJ;
+ }
+
+ demux_sys_t *p_sys = new(std::nothrow) demux_sys_t( p_demux, p_renderer );
+ if (unlikely(p_sys == NULL))
+ return VLC_ENOMEM;
+
+ p_demux->p_sys = p_sys;
+ p_demux->pf_demux = Demux;
+ p_demux->pf_control = Control;
+
+ return VLC_SUCCESS;
+}
+
+void Close(vlc_object_t *p_this)
+{
+ demux_t *p_demux = reinterpret_cast<demux_t*>(p_this);
+ demux_sys_t *p_sys = p_demux->p_sys;
+
+ delete p_sys;
+}
+
+vlc_module_begin ()
+ set_shortname( "cc_demux" )
+ set_category( CAT_INPUT )
+ set_subcategory( SUBCAT_INPUT_DEMUX )
+ set_description( N_( "chromecast demux wrapper" ) )
+ set_capability( "demux_filter", 0 )
+ add_shortcut( "cc_demux" )
+ set_callbacks( Open, Close )
+vlc_module_end ()
More information about the vlc-commits
mailing list