Commit e56df9fd authored by Steve Lhomme's avatar Steve Lhomme Committed by 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's avatarJean-Baptiste Kempf <jb@videolan.org>
parent ef667f29
......@@ -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
......
......@@ -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
......@@ -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 */
/*****************************************************************************
* chromecast_common.h: Chromecast common code between modules for vlc
*****************************************************************************
* Copyright 2016 VideoLAN
*
* Authors: Adrien Maglo <magsoft@videolan.org>
* Jean-Baptiste Kempf <jb@videolan.org>
* Steve Lhomme <robux4@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
......@@ -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:
......
/*****************************************************************************
* chromecast_demux.cpp: Chromecast demux filter module for vlc
*****************************************************************************
* Copyright 2015 VideoLAN
*
* Authors: Steve Lhomme <robux4@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 ()
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