2576
2578
#ifdef TS_USE_DVB_SI
2579
/* FIXME same than dvbsi_to_utf8 from dvb access */
2580
static char *EITConvertToUTF8( const unsigned char *psz_instring,
2583
const char *psz_encoding;
2584
char *psz_outstring;
2585
char psz_encbuf[sizeof( "ISO_8859-123" )];
2586
size_t i_in, i_out, offset = 1;
2587
vlc_iconv_t iconv_handle;
2589
if( i_length < 1 ) return NULL;
2590
if( psz_instring[0] >= 0x20 )
2592
/* According to ETSI EN 300 468 Annex A, this should be ISO6937,
2593
* but some broadcasters use different charset... */
2594
if ( i_broken_epg == 1 )
2596
psz_encoding = "ISO_8859-1";
2600
psz_encoding = "ISO_6937";
2605
else switch( psz_instring[0] )
2608
psz_encoding = "ISO_8859-5";
2611
psz_encoding = "ISO_8859-6";
2614
psz_encoding = "ISO_8859-7";
2617
psz_encoding = "ISO_8859-8";
2620
psz_encoding = "ISO_8859-9";
2623
psz_encoding = "ISO_8859-10";
2626
psz_encoding = "ISO_8859-11";
2629
psz_encoding = "ISO_8859-12";
2632
psz_encoding = "ISO_8859-13";
2635
psz_encoding = "ISO_8859-14";
2638
psz_encoding = "ISO_8859-15";
2641
#warning Is Latin-10 (psz_instring[2] == 16) really illegal?
2642
if( i_length < 3 || psz_instring[1] != 0x00 || psz_instring[2] > 15
2643
|| psz_instring[2] == 0 )
2645
psz_encoding = "UTF-8";
2650
sprintf( psz_encbuf, "ISO_8859-%u", psz_instring[2] );
2651
psz_encoding = psz_encbuf;
2656
#warning Is there a BOM or do we use a fixed endianess?
2657
psz_encoding = "UTF-16";
2660
psz_encoding = "KSC5601-1987";
2663
psz_encoding = "GB2312"; /* GB-2312-1980 */
2666
psz_encoding = "BIG-5";
2669
psz_encoding = "UTF-8";
2673
psz_encoding = "UTF-8";
2677
i_in = i_length - offset;
2678
i_out = i_in * 6 + 1;
2680
psz_outstring = malloc( i_out );
2681
if( !psz_outstring )
2686
iconv_handle = vlc_iconv_open( "UTF-8", psz_encoding );
2687
if( iconv_handle == (vlc_iconv_t)(-1) )
2689
/* Invalid character set (e.g. ISO_8859-12) */
2690
memcpy( psz_outstring, &psz_instring[offset], i_in );
2691
psz_outstring[i_in] = '\0';
2692
EnsureUTF8( psz_outstring );
2696
const char *psz_in = (const char *)&psz_instring[offset];
2697
char *psz_out = psz_outstring;
2699
while( vlc_iconv( iconv_handle, &psz_in, &i_in,
2700
&psz_out, &i_out ) == (size_t)(-1) )
2702
/* skip naughty byte. This may fail terribly for multibyte stuff,
2703
* but what can we do anyway? */
2706
vlc_iconv( iconv_handle, NULL, NULL, NULL, NULL ); /* reset */
2708
vlc_iconv_close( iconv_handle );
2712
return psz_outstring;
2577
2715
static void SDTCallBack( demux_t *p_demux, dvbpsi_sdt_t *p_sdt )
2579
2717
demux_sys_t *p_sys = p_demux->p_sys;
2637
2777
"DVB MHP service"
2639
2779
dvbpsi_service_dr_t *pD = dvbpsi_DecodeServiceDr( p_dr );
2643
memcpy( str1, pD->i_service_provider_name,
2644
pD->i_service_provider_name_length );
2645
str1[pD->i_service_provider_name_length] = '\0';
2646
memcpy( str2, pD->i_service_name, pD->i_service_name_length );
2647
str2[pD->i_service_name_length] = '\0';
2783
/* Workarounds for broadcasters with broken EPG */
2785
if ( p_sdt->i_network_id == 133 )
2786
i_broken_epg = 1; /* SKY DE & BetaDigital use ISO8859-1 */
2788
if ( (pD->i_service_provider_name_length == 4) &&
2789
!strncmp(pD->i_service_provider_name, "CSAT", 4) )
2790
i_broken_epg = 1; /* CanalSat FR uses ISO8859-1 */
2792
/* FIXME: Digital+ ES also uses ISO8859-1 */
2794
str1 = EITConvertToUTF8(pD->i_service_provider_name,
2795
pD->i_service_provider_name_length);
2796
str2 = EITConvertToUTF8(pD->i_service_name,
2797
pD->i_service_name_length);
2649
2799
msg_Dbg( p_demux, " - type=%d provider=%s name=%s",
2650
2800
pD->i_service_type, str1, str2 );
2743
2895
#undef CVT_FROM_BCD
2745
/* FIXME same than dvbsi_to_utf8 from dvb access */
2746
static char *EITConvertToUTF8( const unsigned char *psz_instring,
2749
const char *psz_encoding;
2750
char *psz_outstring;
2751
char psz_encbuf[sizeof( "ISO_8859-123" )];
2752
size_t i_in, i_out, offset = 1;
2753
vlc_iconv_t iconv_handle;
2755
if( i_length < 1 ) return NULL;
2756
if( psz_instring[0] >= 0x20 )
2758
psz_encoding = "ISO_8859-1";
2759
/* According to the specification, this should be ISO6937,
2760
* but it seems Latin-1 is used instead. */
2763
else switch( psz_instring[0] )
2766
psz_encoding = "ISO_8859-5";
2769
psz_encoding = "ISO_8859-6";
2772
psz_encoding = "ISO_8859-7";
2775
psz_encoding = "ISO_8859-8";
2778
psz_encoding = "ISO_8859-9";
2781
psz_encoding = "ISO_8859-10";
2784
psz_encoding = "ISO_8859-11";
2787
psz_encoding = "ISO_8859-12";
2790
psz_encoding = "ISO_8859-13";
2793
psz_encoding = "ISO_8859-14";
2796
psz_encoding = "ISO_8859-15";
2799
#warning Is Latin-10 (psz_instring[2] == 16) really illegal?
2800
if( i_length < 3 || psz_instring[1] != 0x00 || psz_instring[2] > 15
2801
|| psz_instring[2] == 0 )
2803
psz_encoding = "UTF-8";
2808
sprintf( psz_encbuf, "ISO_8859-%u", psz_instring[2] );
2809
psz_encoding = psz_encbuf;
2814
#warning Is there a BOM or do we use a fixed endianess?
2815
psz_encoding = "UTF-16";
2818
psz_encoding = "KSC5601-1987";
2821
psz_encoding = "GB2312"; /* GB-2312-1980 */
2824
psz_encoding = "BIG-5";
2827
psz_encoding = "UTF-8";
2831
psz_encoding = "UTF-8";
2835
i_in = i_length - offset;
2836
i_out = i_in * 6 + 1;
2838
psz_outstring = malloc( i_out );
2839
if( !psz_outstring )
2844
iconv_handle = vlc_iconv_open( "UTF-8", psz_encoding );
2845
if( iconv_handle == (vlc_iconv_t)(-1) )
2847
/* Invalid character set (e.g. ISO_8859-12) */
2848
memcpy( psz_outstring, &psz_instring[offset], i_in );
2849
psz_outstring[i_in] = '\0';
2850
EnsureUTF8( psz_outstring );
2854
const char *psz_in = (const char *)&psz_instring[offset];
2855
char *psz_out = psz_outstring;
2857
while( vlc_iconv( iconv_handle, &psz_in, &i_in,
2858
&psz_out, &i_out ) == (size_t)(-1) )
2860
/* skip naughty byte. This may fail terribly for multibyte stuff,
2861
* but what can we do anyway? */
2864
vlc_iconv( iconv_handle, NULL, NULL, NULL, NULL ); /* reset */
2866
vlc_iconv_close( iconv_handle );
2870
return psz_outstring;
2873
static void EITCallBack( demux_t *p_demux, dvbpsi_eit_t *p_eit )
2898
static void EITCallBack( demux_t *p_demux,
2899
dvbpsi_eit_t *p_eit, bool b_current_following )
2875
2901
demux_sys_t *p_sys = p_demux->p_sys;
2876
2902
dvbpsi_eit_event_t *p_evt;
2953
2979
if( psz_dsc && psz_itm )
2955
2981
msg_Dbg( p_demux, " - desc='%s' item='%s'", psz_dsc, psz_itm );
2957
2983
psz_extra = realloc( psz_extra, strlen(psz_extra) + strlen(psz_dsc) + strlen(psz_itm) + 3 + 1 );
2958
2984
strcat( psz_extra, "(" );
2959
2985
strcat( psz_extra, psz_dsc );
2960
2986
strcat( psz_extra, " " );
2961
2987
strcat( psz_extra, psz_itm );
2962
2988
strcat( psz_extra, ")" );
2964
2991
free( psz_dsc );
2965
2992
free( psz_itm );
2976
3003
if( i_start > 0 )
2977
vlc_epg_AddEvent( p_epg, i_start, i_duration, psz_name, psz_text, psz_extra );
3004
vlc_epg_AddEvent( p_epg, i_start, i_duration, psz_name, psz_text,
3005
*psz_extra ? psz_extra : NULL );
2979
3007
/* Update "now playing" field */
2980
3008
if( p_evt->i_running_status == 0x04 && i_start > 0 )
3005
3033
dvbpsi_DeleteEIT( p_eit );
3035
static void EITCallBackCurrentFollowing( demux_t *p_demux, dvbpsi_eit_t *p_eit )
3037
EITCallBack( p_demux, p_eit, true );
3039
static void EITCallBackSchedule( demux_t *p_demux, dvbpsi_eit_t *p_eit )
3041
EITCallBack( p_demux, p_eit, false );
3008
3044
static void PSINewTableCallBack( demux_t *p_demux, dvbpsi_handle h,
3009
3045
uint8_t i_table_id, uint16_t i_extension )
3027
3063
msg_Dbg( p_demux, "PSINewTableCallBack: table 0x%x(%d) ext=0x%x(%d)",
3028
3064
i_table_id, i_table_id, i_extension, i_extension );
3030
dvbpsi_AttachEIT( h, i_table_id, i_extension,
3031
(dvbpsi_eit_callback)EITCallBack, p_demux );
3066
dvbpsi_eit_callback cb = i_table_id == 0x4e ?
3067
(dvbpsi_eit_callback)EITCallBackCurrentFollowing :
3068
(dvbpsi_eit_callback)EITCallBackSchedule;
3069
dvbpsi_AttachEIT( h, i_table_id, i_extension, cb, p_demux );