# include "config.h"
#endif
-#include <vlc/vlc.h>
+#include <vlc_common.h>
#include <vlc_access.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <sys/stat.h>
#include <sys/poll.h>
+#include <netinet/in.h>
/* DVB Card Drivers */
#include <linux/dvb/version.h>
# include <dvbpsi/pmt.h>
# include <dvbpsi/dr.h>
# include <dvbpsi/psi.h>
+# include <dvbpsi/demux.h>
+# include <dvbpsi/sdt.h>
#else
# include "dvbpsi.h"
# include "descriptor.h"
# include "tables/pmt.h"
# include "descriptors/dr.h"
# include "psi.h"
+# include "demux.h"
+# include "tables/sdt.h"
#endif
#ifdef ENABLE_HTTPD
static void ConditionalAccessOpen( access_t * p_access, int i_session_id );
static void DateTimeOpen( access_t * p_access, int i_session_id );
static void MMIOpen( access_t * p_access, int i_session_id );
-static char *dvbsi_to_utf8( char *psz_instring, size_t i_length );
/*****************************************************************************
* Utility functions
for ( i = 0; i < i_size && i < MAX_DUMP; i++)
fprintf(stderr, "%02X ", p_data[i]);
fprintf(stderr, "%s\n", i_size >= MAX_DUMP ? "..." : "");
+#else
+ VLC_UNUSED(b_outgoing); VLC_UNUSED(p_data); VLC_UNUSED(i_size);
#endif
}
if ( i_size < 5 )
{
msg_Err( p_access, "cannot read from CAM device (%d:%m)", i_size );
+ if( pi_size == NULL )
+ free( p_data );
return VLC_EGENERIC;
}
{
msg_Err( p_access, "invalid read from CAM device (%d instead of %d)",
p_data[1], i_tcid );
+ if( pi_size == NULL )
+ free( p_data );
return VLC_EGENERIC;
}
if ( !p_sys->p_sessions[i_session_id - 1].i_resource_id )
break;
}
- if ( i_session_id == MAX_SESSIONS )
+ if ( i_session_id > MAX_SESSIONS )
{
msg_Err( p_access, "too many sessions !" );
return;
}
else
{
- char *psz_hex;
ca_msg.length = i_size + p - p_apdu;
if ( i_size == 0 ) ca_msg.length=3;
- psz_hex = (char*)malloc( ca_msg.length*3 + 1);
memcpy( ca_msg.msg, p_apdu, i_size + p - p_apdu );
i_ret = ioctl(p_sys->i_ca_handle, CA_SEND_MSG, &ca_msg );
if ( i_ret < 0 )
0x3 /* only */, 0x1 /* ok_descrambling */,
&i_capmt_size );
- if ( i_capmt_size )
+ if( i_capmt_size )
+ {
APDUSend( p_access, i_session_id, AOT_CA_PMT, p_capmt, i_capmt_size );
+ free( p_capmt );
+ }
}
/*****************************************************************************
0x4 /* add */, 0x1 /* ok_descrambling */,
&i_capmt_size );
- if ( i_capmt_size )
+ if( i_capmt_size )
+ {
APDUSend( p_access, i_session_id, AOT_CA_PMT, p_capmt, i_capmt_size );
+ free( p_capmt );
+ }
}
/*****************************************************************************
0x5 /* update */, 0x1 /* ok_descrambling */,
&i_capmt_size );
- if ( i_capmt_size )
+ if( i_capmt_size )
+ {
APDUSend( p_access, i_session_id, AOT_CA_PMT, p_capmt, i_capmt_size );
+ free( p_capmt );
+ }
}
/*****************************************************************************
0x5 /* update */, 0x4 /* not selected */,
&i_capmt_size );
- if ( i_capmt_size )
+ if( i_capmt_size )
+ {
APDUSend( p_access, i_session_id, AOT_CA_PMT, p_capmt, i_capmt_size );
+ free( p_capmt );
+ }
}
/*****************************************************************************
p_sys->p_sessions[i_session_id - 1].pf_handle = ConditionalAccessHandle;
p_sys->p_sessions[i_session_id - 1].pf_close = ConditionalAccessClose;
- p_sys->p_sessions[i_session_id - 1].p_sys = malloc(sizeof(system_ids_t));
- memset( p_sys->p_sessions[i_session_id - 1].p_sys, 0,
- sizeof(system_ids_t) );
+ p_sys->p_sessions[i_session_id - 1].p_sys = calloc( 1, sizeof(system_ids_t) );
APDUSend( p_access, i_session_id, AOT_CA_INFO_ENQ, NULL, 0 );
}
p_sys->p_sessions[i_session_id - 1].pf_handle = DateTimeHandle;
p_sys->p_sessions[i_session_id - 1].pf_manage = DateTimeManage;
p_sys->p_sessions[i_session_id - 1].pf_close = DateTimeClose;
- p_sys->p_sessions[i_session_id - 1].p_sys = malloc(sizeof(date_time_t));
- memset( p_sys->p_sessions[i_session_id - 1].p_sys, 0, sizeof(date_time_t) );
+ p_sys->p_sessions[i_session_id - 1].p_sys = calloc( 1, sizeof(date_time_t) );
DateTimeSend( p_access, i_session_id );
}
/*****************************************************************************
* en50221_Init : Initialize the CAM for en50221
*****************************************************************************/
-int E_(en50221_Init)( access_t * p_access )
+int en50221_Init( access_t * p_access )
{
access_sys_t *p_sys = p_access->p_sys;
#if HLCI_WAIT_CAM_READY
while( ca_msg.msg[8] == 0xff && ca_msg.msg[9] == 0xff )
{
- if( p_access->b_die ) return VLC_EGENERIC;
+ if( !vlc_object_alive (p_access) ) return VLC_EGENERIC;
msleep(1);
msg_Dbg( p_access, "CAM: please wait" );
APDUSend( p_access, 1, AOT_APPLICATION_INFO_ENQ, NULL, 0 );
/*****************************************************************************
* en50221_Poll : Poll the CAM for TPDUs
*****************************************************************************/
-int E_(en50221_Poll)( access_t * p_access )
+int en50221_Poll( access_t * p_access )
{
access_sys_t *p_sys = p_access->p_sys;
int i_slot;
/*****************************************************************************
* en50221_SetCAPMT :
*****************************************************************************/
-int E_(en50221_SetCAPMT)( access_t * p_access, dvbpsi_pmt_t *p_pmt )
+int en50221_SetCAPMT( access_t * p_access, dvbpsi_pmt_t *p_pmt )
{
access_sys_t *p_sys = p_access->p_sys;
int i, i_session_id;
/*****************************************************************************
* en50221_OpenMMI :
*****************************************************************************/
-int E_(en50221_OpenMMI)( access_t * p_access, int i_slot )
+int en50221_OpenMMI( access_t * p_access, int i_slot )
{
access_sys_t *p_sys = p_access->p_sys;
/*****************************************************************************
* en50221_CloseMMI :
*****************************************************************************/
-int E_(en50221_CloseMMI)( access_t * p_access, int i_slot )
+int en50221_CloseMMI( access_t * p_access, int i_slot )
{
access_sys_t *p_sys = p_access->p_sys;
/*****************************************************************************
* en50221_GetMMIObject :
*****************************************************************************/
-en50221_mmi_object_t *E_(en50221_GetMMIObject)( access_t * p_access,
+en50221_mmi_object_t *en50221_GetMMIObject( access_t * p_access,
int i_slot )
{
access_sys_t *p_sys = p_access->p_sys;
/*****************************************************************************
* en50221_SendMMIObject :
*****************************************************************************/
-void E_(en50221_SendMMIObject)( access_t * p_access, int i_slot,
+void en50221_SendMMIObject( access_t * p_access, int i_slot,
en50221_mmi_object_t *p_object )
{
access_sys_t *p_sys = p_access->p_sys;
/*****************************************************************************
* en50221_End :
*****************************************************************************/
-void E_(en50221_End)( access_t * p_access )
+void en50221_End( access_t * p_access )
{
access_sys_t *p_sys = p_access->p_sys;
int i_session_id, i;
return p;
}
-static char *dvbsi_to_utf8( char *psz_instring, size_t i_length )
+char *dvbsi_to_utf8( char *psz_instring, size_t i_length )
{
- const char *psz_encoding;
- char *psz_stringstart, *psz_outstring, *psz_tmp;
+ const char *psz_encoding, *psz_stringstart;
+ char *psz_outstring, *psz_tmp;
char psz_encbuf[12];
size_t i_in, i_out;
vlc_iconv_t iconv_handle;
iconv_handle = vlc_iconv_open( "UTF-8", psz_encoding );
i_in = i_length - (psz_stringstart - psz_instring );
i_out = i_in * 6;
- psz_outstring = psz_tmp = (char*)malloc( i_out * sizeof(char) + 1 );
+ psz_outstring = psz_tmp = (char*)malloc( i_out + 1 );
vlc_iconv( iconv_handle, &psz_stringstart, &i_in, &psz_tmp, &i_out );
vlc_iconv_close( iconv_handle );
*psz_tmp = '\0';