+/*****************************************************************************
+ * ChangeKeyCallback: called when changing the odd encryption key on the fly.
+ *****************************************************************************/
+static int ChangeKeyCallback( vlc_object_t *p_this, char const *psz_cmd,
+ vlc_value_t oldval, vlc_value_t newval,
+ void *p_data )
+{
+ VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval);
+ sout_mux_t *p_mux = (sout_mux_t*)p_this;
+ sout_mux_sys_t *p_sys = p_mux->p_sys;
+ int ret;
+
+ vlc_mutex_lock( &p_sys->csa_lock );
+ ret = csa_SetCW( p_this, p_sys->csa, newval.psz_string,
+ !!(intptr_t)p_data );
+ vlc_mutex_unlock( &p_sys->csa_lock );
+
+ return ret;
+}
+
+/*****************************************************************************
+ * ActiveKeyCallback: called when changing the active (in use) encryption key on the fly.
+ *****************************************************************************/
+static int ActiveKeyCallback( vlc_object_t *p_this, char const *psz_cmd,
+ vlc_value_t oldval, vlc_value_t newval,
+ void *p_data )
+{
+ VLC_UNUSED(psz_cmd); VLC_UNUSED(oldval); VLC_UNUSED(p_data);
+ sout_mux_t *p_mux = (sout_mux_t*)p_this;
+ sout_mux_sys_t *p_sys = p_mux->p_sys;
+ int i_res = VLC_EBADVAR;
+
+ vlc_mutex_lock( &p_sys->csa_lock );
+ if( !strcmp(newval.psz_string, "odd" ) || !strcmp(newval.psz_string, "first" ) || !strcmp(newval.psz_string, "1" ) )
+ {
+ i_res = csa_UseKey( (vlc_object_t*)p_mux, p_sys->csa, 1 );
+ }
+ else if( !strcmp(newval.psz_string, "even" ) || !strcmp(newval.psz_string, "second" ) || !strcmp(newval.psz_string, "2" ) )
+ {
+ i_res = csa_UseKey( (vlc_object_t*)p_mux, p_sys->csa, 0 );
+ }
+ vlc_mutex_unlock( &p_sys->csa_lock );
+
+ return i_res;
+}
+