Commit cbe6eace authored by Jean-Paul Saman's avatar Jean-Paul Saman

mux/mpeg/ts.c: support for libdvbpsi >= 1.0.0

Allow compiling against libdvbpsi 1.0.0 or greater.
parent 69cb2f8c
......@@ -25,7 +25,7 @@ libvlc_LTLIBRARIES += libmux_ps_plugin.la
libmux_ts_plugin_la_SOURCES = \
mpeg/pes.c mpeg/pes.h \
mpeg/csa.c mpeg/csa.h \
mpeg/ts.c mpeg/bits.h
mpeg/ts.c mpeg/bits.h mpeg/dvbpsi_compat.h
libmux_ts_plugin_la_CFLAGS = $(AM_CFLAGS) $(DVBPSI_CFLAGS)
libmux_ts_plugin_la_LIBADD = $(AM_LIBADD) $(DVBPSI_LIBS)
if HAVE_DVBPSI
......
/*****************************************************************************
* dvbpsi_compat.h: Compatibility headerfile
*****************************************************************************
* Copyright (C) 2013 VideoLAN Association
*
* Authors: Jean-Paul Saman <jpsaman@videolan.org>
*
* 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 DVBPSI_COMPAT_H
#define DVBPSI_COMPAT_H
/*
* dvbpsi compatibility macros:
* dvbpsi version 1.0.0 and above returns a struct 'dvbpsi_t' as handle
*/
#define DVBPSI_VERSION_WANTED(major,minor,bugfix) (((major)<<16)+((minor)<<8)+(bugfix))
#if (DVBPSI_VERSION_INT >= DVBPSI_VERSION_WANTED(1,0,0))
# define dvbpsi_handle dvbpsi_t*
# define dvbpsi_PushPacket(handle,data) dvbpsi_packet_push((handle),(data))
/* PAT */
# define dvbpsi_InitPAT(pat,id,version,next) dvbpsi_pat_init((pat),(id),(version),(bool)(next))
# define dvbpsi_PATAddProgram(pat,nr,pid) dvbpsi_pat_program_add((pat),(nr),(pid))
# define dvbpsi_EmptyPAT(pat) dvbpsi_pat_empty((pat))
# define dvbpsi_DeletePAT(table) dvbpsi_pat_delete((table))
# define dvbpsi_DetachPAT(pat) dvbpsi_pat_detach((pat))
/* PMT */
# define dvbpsi_InitPMT(pmt,program,version,next,pcr) \
dvbpsi_pmt_init((pmt),(program),(version),(bool)(next),(pcr))
# define dvbpsi_PMTAddDescriptor(pmt,tag,length,data) \
dvbpsi_pmt_descriptor_add((pmt),(tag),(length),(data))
# define dvbpsi_PMTAddES(pmt,type,pid) \
dvbpsi_pmt_es_add((pmt),(type),(pid))
# define dvbpsi_PMTESAddDescriptor(es,tag,length,data) \
dvbpsi_pmt_es_descriptor_add((es),(tag),(length),(data))
# define dvbpsi_EmptyPMT(pmt) dvbpsi_pmt_empty((pmt))
# define dvbpsi_DeletePMT(table) dvbpsi_pmt_delete((table))
# define dvbpsi_DetachPMT(pmt) dvbpsi_pmt_detach((pmt))
/* SDT */
# define dvbpsi_InitSDT(sdt,id,version,curnext,netid) \
dvbpsi_sdt_init((sdt),(id),(0),(version),(bool)(curnext),(netid))
# define dvbpsi_SDTAddService(sdt,id,schedule,present,status,ca) \
dvbpsi_sdt_service_add((sdt),(id),(bool)(schedule),(bool)(present),(status),(bool)(ca))
# define dvbpsi_EmptySDT(sdt) dvbpsi_sdt_empty((sdt))
# define dvbpsi_DeleteSDT(table) dvbpsi_sdt_delete((table))
/* TOT */
# define dvbpsi_DeleteTOT(table) dvbpsi_tot_delete((table))
/* EIT */
# define dvbpsi_DeleteEIT(table) dvbpsi_eit_delete((table))
/* NIT */
# define dvbpsi_DeleteNIT(table) dvbpsi_nit_delete((table))
static void dvbpsi_message(dvbpsi_t *p_dvbpsi, const dvbpsi_msg_level_t level, const char* msg)
{
vlc_object_t *obj = (vlc_object_t *)p_dvbpsi->p_sys;
/* See dvbpsi.h for the definition of these log levels.*/
switch(level)
{
case DVBPSI_MSG_ERROR: msg_Err( obj, "%s", msg ); break;
case DVBPSI_MSG_WARN: msg_Warn( obj, "%s", msg ); break;
case DVBPSI_MSG_DEBUG: msg_Dbg( obj, "%s", msg ); break;
default: msg_Info( obj, "%s", msg ); break;
}
}
#endif
#endif
......@@ -55,6 +55,8 @@
# include <dvbpsi/dr.h>
# include <dvbpsi/psi.h>
#include "dvbpsi_compat.h"
/*
* TODO:
* - check PCR frequency requirement
......@@ -340,6 +342,9 @@ struct sout_mux_sys_t
vlc_mutex_t csa_lock;
#if (DVBPSI_VERSION_INT >= DVBPSI_VERSION_WANTED(1,0,0))
dvbpsi_t *p_dvbpsi;
#endif
bool b_es_id_pid;
bool b_sdt;
int i_pid_video;
......@@ -517,6 +522,16 @@ static int Open( vlc_object_t *p_this )
p_mux->pf_mux = Mux;
p_mux->p_sys = p_sys;
#if (DVBPSI_VERSION_INT >= DVBPSI_VERSION_WANTED(1,0,0))
p_sys->p_dvbpsi = dvbpsi_new( &dvbpsi_message, DVBPSI_MSG_DEBUG );
if( !p_sys->p_dvbpsi )
{
free( p_sys );
return VLC_ENOMEM;
}
p_sys->p_dvbpsi->p_sys = (void *) p_mux;
#endif
p_sys->b_es_id_pid = var_GetBool( p_mux, SOUT_CFG_PREFIX "es-id-pid" );
/*
......@@ -725,6 +740,11 @@ static void Close( vlc_object_t * p_this )
sout_mux_t *p_mux = (sout_mux_t*)p_this;
sout_mux_sys_t *p_sys = p_mux->p_sys;
#if (DVBPSI_VERSION_INT >= DVBPSI_VERSION_WANTED(1,0,0))
if( p_sys->p_dvbpsi )
dvbpsi_delete( p_sys->p_dvbpsi );
#endif
if( p_sys->csa )
{
var_DelCallback( p_mux, SOUT_CFG_PREFIX "csa-ck", ChangeKeyCallback, NULL );
......@@ -1991,6 +2011,8 @@ static block_t *WritePSISection( dvbpsi_psi_section_t* p_section )
(p_section->b_syntax_indicator ? 4 : 0);
p_psi = block_Alloc( i_size + 1 );
if( !p_psi )
goto error;
p_psi->i_pts = 0;
p_psi->i_dts = 0;
p_psi->i_length = 0;
......@@ -2007,6 +2029,11 @@ static block_t *WritePSISection( dvbpsi_psi_section_t* p_section )
}
return( p_first );
error:
if( p_first )
block_ChainRelease( p_first );
return NULL;
}
static void GetPAT( sout_mux_t *p_mux,
......@@ -2024,8 +2051,11 @@ static void GetPAT( sout_mux_t *p_mux,
dvbpsi_PATAddProgram( &pat, p_sys->i_pmt_program_number[i],
p_sys->pmt[i].i_pid );
#if (DVBPSI_VERSION_INT >= DVBPSI_VERSION_WANTED(1,0,0))
p_section = dvbpsi_pat_sections_generate( p_sys->p_dvbpsi, &pat, 0 );
#else
p_section = dvbpsi_GenPATSections( &pat, 0 /* max program per section */ );
#endif
p_pat = WritePSISection( p_section );
PEStoTS( c, p_pat, &p_sys->pat );
......@@ -2232,8 +2262,14 @@ static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c )
psz_sdt_desc[ 2 + provlen ] = (char)servlen;
memcpy( &psz_sdt_desc[3+provlen], psz_sdtserv, servlen );
#if (DVBPSI_VERSION_INT >= DVBPSI_VERSION_WANTED(1,0,0))
dvbpsi_sdt_service_descriptor_add( p_service, 0x48,
(3 + provlen + servlen),
psz_sdt_desc );
#else
dvbpsi_SDTServiceAddDescriptor( p_service, 0x48,
3 + provlen + servlen, psz_sdt_desc );
#endif
}
if( p_sys->i_mpeg4_streams > 0 )
......@@ -2362,7 +2398,12 @@ static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c )
for (unsigned i = 0; i < p_sys->i_num_pmt; i++ )
{
dvbpsi_psi_section_t *sect = dvbpsi_GenPMTSections( &p_sys->dvbpmt[i] );
dvbpsi_psi_section_t *sect;
#if (DVBPSI_VERSION_INT >= DVBPSI_VERSION_WANTED(1,0,0))
sect = dvbpsi_pmt_sections_generate( p_sys->p_dvbpsi, &p_sys->dvbpmt[i] );
#else
sect = dvbpsi_GenPMTSections( &p_sys->dvbpmt[i] );
#endif
block_t *pmt = WritePSISection( sect );
PEStoTS( c, pmt, &p_sys->pmt[i] );
dvbpsi_DeletePSISections(sect);
......@@ -2371,7 +2412,12 @@ static void GetPMT( sout_mux_t *p_mux, sout_buffer_chain_t *c )
if( p_sys->b_sdt )
{
dvbpsi_psi_section_t *sect = dvbpsi_GenSDTSections( &sdt );
dvbpsi_psi_section_t *sect;
#if (DVBPSI_VERSION_INT >= DVBPSI_VERSION_WANTED(1,0,0))
sect = dvbpsi_sdt_sections_generate( p_sys->p_dvbpsi, &sdt );
#else
sect = dvbpsi_GenSDTSections( &sdt );
#endif
block_t *p_sdt = WritePSISection( sect );
PEStoTS( c, p_sdt, &p_sys->sdt );
dvbpsi_DeletePSISections( sect );
......
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