+void input_DecoderIsCcPresent( decoder_t *p_dec, vlc_bool_t pb_present[4] )
+{
+ int i;
+
+ vlc_mutex_lock( &p_dec->p_owner->lock_cc );
+ for( i = 0; i < 4; i++ )
+ pb_present[i] = p_dec->p_owner->pb_cc_present[i];
+ vlc_mutex_unlock( &p_dec->p_owner->lock_cc );
+}
+int input_DecoderSetCcState( decoder_t *p_dec, vlc_bool_t b_decode, int i_channel )
+{
+ decoder_owner_sys_t *p_owner = p_dec->p_owner;
+
+ //msg_Warn( p_dec, "input_DecoderSetCcState: %d @%d", b_decode, i_channel );
+
+ if( i_channel < 0 || i_channel >= 4 || !p_owner->pb_cc_present[i_channel] )
+ return VLC_EGENERIC;
+
+ if( b_decode )
+ {
+ static const vlc_fourcc_t fcc[4] = {
+ VLC_FOURCC('c', 'c', '1', ' '),
+ VLC_FOURCC('c', 'c', '2', ' '),
+ VLC_FOURCC('c', 'c', '3', ' '),
+ VLC_FOURCC('c', 'c', '4', ' '),
+ };
+ decoder_t *p_cc;
+ es_format_t fmt;
+
+ es_format_Init( &fmt, SPU_ES, fcc[i_channel] );
+ p_cc = CreateDecoder( p_owner->p_input, &fmt, VLC_OBJECT_DECODER );
+ if( !p_cc )
+ {
+ msg_Err( p_dec, "could not create decoder" );
+ intf_UserFatal( p_dec, VLC_FALSE, _("Streaming / Transcoding failed"),
+ _("VLC could not open the decoder module.") );
+ return VLC_EGENERIC;
+ }
+ else if( !p_cc->p_module )
+ {
+ DecoderUnsupportedCodec( p_dec, fcc[i_channel] );
+ DeleteDecoder( p_cc );
+ vlc_object_destroy( p_cc );
+ return VLC_EGENERIC;
+ }
+
+ vlc_mutex_lock( &p_owner->lock_cc );
+ p_dec->p_owner->pp_cc[i_channel] = p_cc;
+ vlc_mutex_unlock( &p_owner->lock_cc );
+ }
+ else
+ {
+ decoder_t *p_cc;
+
+ vlc_mutex_lock( &p_owner->lock_cc );
+ p_cc = p_dec->p_owner->pp_cc[i_channel];
+ p_dec->p_owner->pp_cc[i_channel] = NULL;
+ vlc_mutex_unlock( &p_dec->p_owner->lock_cc );
+
+ if( p_cc )
+ {
+ vlc_object_kill( p_cc );
+ module_Unneed( p_cc, p_cc->p_module );
+ DeleteDecoder( p_cc );
+ vlc_object_destroy( p_cc );
+ }
+ }
+ return VLC_SUCCESS;
+}
+int input_DecoderGetCcState( decoder_t *p_dec, vlc_bool_t *pb_decode, int i_channel )
+{
+ decoder_owner_sys_t *p_owner = p_dec->p_owner;
+
+ *pb_decode = VLC_FALSE;
+ if( i_channel < 0 || i_channel >= 4 || !p_owner->pb_cc_present[i_channel] )
+ return VLC_EGENERIC;
+
+ vlc_mutex_lock( &p_owner->lock_cc );
+ *pb_decode = p_dec->p_owner->pp_cc[i_channel] != NULL;
+ vlc_mutex_unlock( &p_dec->p_owner->lock_cc );
+ return VLC_EGENERIC;
+}
+