1 /*****************************************************************************
2 * dynamicoverlay_commands.c : dynamic overlay plugin commands
3 *****************************************************************************
4 * Copyright (C) 2008 the VideoLAN team
7 * Author: Soren Bog <avacore@videolan.org>
8 * Jean-Paul Saman <jpsaman@videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
29 #include <vlc_common.h>
30 #include <vlc_arrays.h>
32 #include <vlc_filter.h>
38 #if defined(HAVE_SYS_SHM_H)
42 #include "dynamicoverlay.h"
45 /*****************************************************************************
46 * overlay_t: Overlay descriptor
47 *****************************************************************************/
49 overlay_t *OverlayCreate( void )
51 overlay_t *p_ovl = malloc( sizeof( overlay_t ) );
54 memset( p_ovl, 0, sizeof( overlay_t ) );
56 p_ovl->i_x = p_ovl->i_y = 0;
57 p_ovl->i_alpha = 0xFF;
58 p_ovl->b_active = false;
59 vout_InitFormat( &p_ovl->format, VLC_FOURCC( '\0','\0','\0','\0') , 0, 0,
61 memcpy( &p_ovl->fontstyle, &default_text_style, sizeof(struct text_style_t) );
62 p_ovl->data.p_text = NULL;
67 int OverlayDestroy( overlay_t *p_ovl )
69 if( p_ovl->data.p_text != NULL )
70 free( p_ovl->data.p_text );
75 /*****************************************************************************
77 *****************************************************************************/
78 static int skip_space( char **psz_command )
80 char *psz_temp = *psz_command;
82 while( isspace( *psz_temp ) )
86 if( psz_temp == *psz_command )
90 *psz_command = psz_temp;
94 static int parse_digit( char **psz_command, int32_t *value )
97 *value = strtol( *psz_command, &psz_temp, 10 );
98 if( psz_temp == *psz_command )
102 *psz_command = psz_temp;
106 static int parse_char( char **psz_command, char **psz_end,
107 int count, char *psz_value )
109 if( *psz_end - *psz_command < count )
113 memcpy( psz_value, *psz_command, count );
114 *psz_command += count;
118 static int parser_DataSharedMem( char *psz_command,
120 commandparams_t *p_params )
122 /* Parse: 0 128 128 RGBA 9404459 */
123 skip_space( &psz_command );
124 if( isdigit( *psz_command ) )
126 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
129 skip_space( &psz_command );
130 if( isdigit( *psz_command ) )
132 if( parse_digit( &psz_command, &p_params->i_width ) == VLC_EGENERIC )
135 skip_space( &psz_command );
136 if( isdigit( *psz_command ) )
138 if( parse_digit( &psz_command, &p_params->i_height ) == VLC_EGENERIC )
141 skip_space( &psz_command );
142 if( isascii( *psz_command ) )
144 if( parse_char( &psz_command, &psz_end, 4, (char*)&p_params->fourcc )
148 skip_space( &psz_command );
149 if( isdigit( *psz_command ) )
151 if( parse_digit( &psz_command, &p_params->i_shmid ) == VLC_EGENERIC )
157 static int parser_Id( char *psz_command, char *psz_end,
158 commandparams_t *p_params )
161 skip_space( &psz_command );
162 if( isdigit( *psz_command ) )
164 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
170 static int parser_None( char *psz_command, char *psz_end,
171 commandparams_t *p_params )
173 VLC_UNUSED(psz_command);
175 VLC_UNUSED(p_params);
179 static int parser_SetAlpha( char *psz_command, char *psz_end,
180 commandparams_t *p_params )
183 skip_space( &psz_command );
184 if( isdigit( *psz_command ) )
186 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
189 skip_space( &psz_command );
190 if( isdigit( *psz_command ) )
192 if( parse_digit( &psz_command, &p_params->i_alpha ) == VLC_EGENERIC )
198 static int parser_SetPosition( char *psz_command, char *psz_end,
199 commandparams_t *p_params )
202 skip_space( &psz_command );
203 if( isdigit( *psz_command ) )
205 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
208 skip_space( &psz_command );
209 if( isdigit( *psz_command ) )
211 if( parse_digit( &psz_command, &p_params->i_x ) == VLC_EGENERIC )
214 skip_space( &psz_command );
215 if( isdigit( *psz_command ) )
217 if( parse_digit( &psz_command, &p_params->i_y ) == VLC_EGENERIC )
223 static int parser_SetTextAlpha( char *psz_command, char *psz_end,
224 commandparams_t *p_params )
227 skip_space( &psz_command );
228 if( isdigit( *psz_command ) )
230 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
233 skip_space( &psz_command );
234 if( isdigit( *psz_command ) )
236 if( parse_digit( &psz_command, &p_params->fontstyle.i_font_alpha ) == VLC_EGENERIC )
242 static int parser_SetTextColor( char *psz_command, char *psz_end,
243 commandparams_t *p_params )
247 skip_space( &psz_command );
248 if( isdigit( *psz_command ) )
250 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
253 skip_space( &psz_command );
254 if( isdigit( *psz_command ) )
256 if( parse_digit( &psz_command, &r ) == VLC_EGENERIC )
259 skip_space( &psz_command );
260 if( isdigit( *psz_command ) )
262 if( parse_digit( &psz_command, &g ) == VLC_EGENERIC )
265 skip_space( &psz_command );
266 if( isdigit( *psz_command ) )
268 if( parse_digit( &psz_command, &b ) == VLC_EGENERIC )
271 p_params->fontstyle.i_font_color = (r<<24) | (g<<16) | (b<<8);
275 static int parser_SetTextSize( char *psz_command, char *psz_end,
276 commandparams_t *p_params )
279 skip_space( &psz_command );
280 if( isdigit( *psz_command ) )
282 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
285 skip_space( &psz_command );
286 if( isdigit( *psz_command ) )
288 if( parse_digit( &psz_command, &p_params->fontstyle.i_font_size ) == VLC_EGENERIC )
294 static int parser_SetVisibility( char *psz_command, char *psz_end,
295 commandparams_t *p_params )
298 skip_space( &psz_command );
299 if( isdigit( *psz_command ) )
301 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
304 skip_space( &psz_command );
305 if( isdigit( *psz_command ) )
308 if( parse_digit( &psz_command, &i_vis ) == VLC_EGENERIC )
310 p_params->b_visible = (i_vis == 1) ? true : false;
315 /*****************************************************************************
316 * Command unparser functions
317 *****************************************************************************/
319 static int unparse_default( const commandparams_t *p_results,
322 VLC_UNUSED(p_results);
323 VLC_UNUSED(p_output);
327 static int unparse_GenImage( const commandparams_t *p_results,
330 int ret = BufferPrintf( p_output, " %d", p_results->i_id );
331 if( ret != VLC_SUCCESS )
337 static int unparse_GetAlpha( const commandparams_t *p_results,
340 int ret = BufferPrintf( p_output, " %d", p_results->i_alpha );
341 if( ret != VLC_SUCCESS )
347 static int unparse_GetPosition( const commandparams_t *p_results,
350 int ret = BufferPrintf( p_output, " %d", p_results->i_x );
351 if( ret != VLC_SUCCESS )
354 ret = BufferPrintf( p_output, " %d", p_results->i_y );
355 if( ret != VLC_SUCCESS )
361 static int unparse_GetTextAlpha( const commandparams_t *p_results,
364 int ret = BufferPrintf( p_output, " %d", p_results->fontstyle.i_font_alpha );
365 if( ret != VLC_SUCCESS )
371 static int unparse_GetTextColor( const commandparams_t *p_results,
374 int ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0xff0000)>>24 );
375 if( ret != VLC_SUCCESS )
378 ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0x00ff00)>>16 );
379 if( ret != VLC_SUCCESS )
382 ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0x0000ff)>>8 );
383 if( ret != VLC_SUCCESS )
389 static int unparse_GetTextSize( const commandparams_t *p_results,
392 int ret = BufferPrintf( p_output, " %d", p_results->fontstyle.i_font_size );
393 if( ret != VLC_SUCCESS )
399 static int unparse_GetVisibility( const commandparams_t *p_results,
402 int ret = BufferPrintf( p_output, " %d", (p_results->b_visible ? 1 : 0) );
403 if( ret != VLC_SUCCESS ) {
409 /*****************************************************************************
411 *****************************************************************************/
412 static int exec_DataSharedMem( filter_t *p_filter,
413 const commandparams_t *p_params,
414 commandparams_t *p_results )
416 #if defined(HAVE_SYS_SHM_H)
417 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
418 struct shmid_ds shminfo;
422 VLC_UNUSED(p_results);
424 p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
427 msg_Err( p_filter, "Invalid overlay: %d", p_params->i_id );
431 if( shmctl( p_params->i_shmid, IPC_STAT, &shminfo ) == -1 )
433 msg_Err( p_filter, "Unable to access shared memory" );
436 i_size = shminfo.shm_segsz;
438 if( p_params->fourcc == VLC_FOURCC('T','E','X','T') )
442 if( (p_params->i_height != 1) || (p_params->i_width < 1) )
445 "Invalid width and/or height. when specifing text height "
446 "must be 1 and width the number of bytes in the string, "
447 "including the null terminator" );
451 if( (size_t)p_params->i_width > i_size )
454 "Insufficient data in shared memory. need %d, got %zu",
455 p_params->i_width, i_size );
459 p_ovl->data.p_text = malloc( p_params->i_width );
460 if( p_ovl->data.p_text == NULL )
462 msg_Err( p_filter, "Unable to allocate string storage" );
466 vout_InitFormat( &p_ovl->format, VLC_FOURCC('T','E','X','T'),
469 p_data = shmat( p_params->i_shmid, NULL, SHM_RDONLY );
472 msg_Err( p_filter, "Unable to attach to shared memory" );
473 free( p_ovl->data.p_text );
474 p_ovl->data.p_text = NULL;
477 memcpy( p_ovl->data.p_text, p_data, p_params->i_width );
483 uint8_t *p_data, *p_in;
484 size_t i_neededsize = 0;
486 p_ovl->data.p_pic = malloc( sizeof( picture_t ) );
487 if( p_ovl->data.p_pic == NULL )
490 vout_InitFormat( &p_ovl->format, p_params->fourcc,
491 p_params->i_width, p_params->i_height,
492 VOUT_ASPECT_FACTOR );
493 if( vout_AllocatePicture( p_filter, p_ovl->data.p_pic,
494 p_ovl->format.i_chroma, p_params->i_width,
495 p_params->i_height, p_ovl->format.i_aspect ) )
497 msg_Err( p_filter, "Unable to allocate picture" );
498 free( p_ovl->data.p_pic );
499 p_ovl->data.p_pic = NULL;
503 for( size_t i_plane = 0; i_plane < (size_t)p_ovl->data.p_pic->i_planes;
506 i_neededsize += p_ovl->data.p_pic->p[i_plane].i_visible_lines *
507 p_ovl->data.p_pic->p[i_plane].i_visible_pitch;
510 if( i_neededsize > i_size )
513 "Insufficient data in shared memory. need %zu, got %zu",
514 i_neededsize, i_size );
515 picture_Release( p_ovl->data.p_pic );
516 free( p_ovl->data.p_pic );
517 p_ovl->data.p_pic = NULL;
521 p_data = shmat( p_params->i_shmid, NULL, SHM_RDONLY );
524 msg_Err( p_filter, "Unable to attach to shared memory" );
525 picture_Release( p_ovl->data.p_pic );
526 free( p_ovl->data.p_pic );
527 p_ovl->data.p_pic = NULL;
532 for( size_t i_plane = 0; i_plane < (size_t)p_ovl->data.p_pic->i_planes;
535 uint8_t *p_out = p_ovl->data.p_pic->p[i_plane].p_pixels;
536 for( size_t i_line = 0;
537 i_line < (size_t)p_ovl->data.p_pic->p[i_plane].i_visible_lines;
540 vlc_memcpy( p_out, p_in,
541 p_ovl->data.p_pic->p[i_plane].i_visible_pitch );
542 p_out += p_ovl->data.p_pic->p[i_plane].i_pitch;
543 p_in += p_ovl->data.p_pic->p[i_plane].i_visible_pitch;
548 p_sys->b_updated = p_ovl->b_active;
552 VLC_UNUSED(p_params);
553 VLC_UNUSED(p_results);
555 msg_Err( p_filter, "system doesn't support shared memory" );
560 static int exec_DeleteImage( filter_t *p_filter,
561 const commandparams_t *p_params,
562 commandparams_t *p_results )
564 VLC_UNUSED(p_results);
565 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
566 p_sys->b_updated = true;
568 return ListRemove( &p_sys->overlays, p_params->i_id );
571 static int exec_EndAtomic( filter_t *p_filter,
572 const commandparams_t *p_params,
573 commandparams_t *p_results )
575 VLC_UNUSED(p_params);
576 VLC_UNUSED(p_results);
577 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
578 QueueTransfer( &p_sys->pending, &p_sys->atomic );
579 p_sys->b_atomic = false;
583 static int exec_GenImage( filter_t *p_filter,
584 const commandparams_t *p_params,
585 commandparams_t *p_results )
587 VLC_UNUSED(p_params);
588 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
590 overlay_t *p_ovl = OverlayCreate();
594 ssize_t i_idx = ListAdd( &p_sys->overlays, p_ovl );
598 p_results->i_id = i_idx;
602 static int exec_GetAlpha( filter_t *p_filter,
603 const commandparams_t *p_params,
604 commandparams_t *p_results )
606 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
607 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
611 p_results->i_alpha = p_ovl->i_alpha;
615 static int exec_GetPosition( filter_t *p_filter,
616 const commandparams_t *p_params,
617 commandparams_t *p_results )
619 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
620 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
624 p_results->i_x = p_ovl->i_x;
625 p_results->i_y = p_ovl->i_y;
629 static int exec_GetTextAlpha( filter_t *p_filter,
630 const commandparams_t *p_params,
631 commandparams_t *p_results )
633 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
634 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
638 p_results->fontstyle.i_font_alpha = p_ovl->fontstyle.i_font_alpha;
642 static int exec_GetTextColor( filter_t *p_filter,
643 const commandparams_t *p_params,
644 commandparams_t *p_results )
646 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
647 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
651 p_results->fontstyle.i_font_color = p_ovl->fontstyle.i_font_color;
655 static int exec_GetTextSize( filter_t *p_filter,
656 const commandparams_t *p_params,
657 commandparams_t *p_results )
659 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
660 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
664 p_results->fontstyle.i_font_size = p_ovl->fontstyle.i_font_size;
668 static int exec_GetVisibility( filter_t *p_filter,
669 const commandparams_t *p_params,
670 commandparams_t *p_results )
672 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
674 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
678 p_results->b_visible = ( p_ovl->b_active == true ) ? 1 : 0;
682 static int exec_SetAlpha( filter_t *p_filter,
683 const commandparams_t *p_params,
684 commandparams_t *p_results )
686 VLC_UNUSED(p_results);
687 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
689 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
693 p_ovl->i_alpha = p_params->i_alpha;
694 p_sys->b_updated = p_ovl->b_active;
698 static int exec_SetPosition( filter_t *p_filter,
699 const commandparams_t *p_params,
700 commandparams_t *p_results )
702 VLC_UNUSED(p_results);
703 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
705 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
709 p_ovl->i_x = p_params->i_x;
710 p_ovl->i_y = p_params->i_y;
712 p_sys->b_updated = p_ovl->b_active;
716 static int exec_SetTextAlpha( filter_t *p_filter,
717 const commandparams_t *p_params,
718 commandparams_t *p_results )
720 VLC_UNUSED(p_results);
721 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
723 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
727 p_ovl->fontstyle.i_font_alpha = p_params->fontstyle.i_font_alpha;
728 p_sys->b_updated = p_ovl->b_active;
732 static int exec_SetTextColor( filter_t *p_filter,
733 const commandparams_t *p_params,
734 commandparams_t *p_results )
736 VLC_UNUSED(p_results);
737 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
739 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
743 p_ovl->fontstyle.i_font_color = p_params->fontstyle.i_font_color;
744 p_sys->b_updated = p_ovl->b_active;
748 static int exec_SetTextSize( filter_t *p_filter,
749 const commandparams_t *p_params,
750 commandparams_t *p_results )
752 VLC_UNUSED(p_results);
753 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
755 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
759 p_ovl->fontstyle.i_font_size = p_params->fontstyle.i_font_size;
760 p_sys->b_updated = p_ovl->b_active;
764 static int exec_SetVisibility( filter_t *p_filter,
765 const commandparams_t *p_params,
766 commandparams_t *p_results )
768 VLC_UNUSED(p_results);
769 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
771 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
775 p_ovl->b_active = p_params->b_visible;// ? false : true;
776 p_sys->b_updated = true;
780 static int exec_StartAtomic( filter_t *p_filter,
781 const commandparams_t *p_params,
782 commandparams_t *p_results )
784 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
785 VLC_UNUSED(p_params);
786 VLC_UNUSED(p_results);
788 p_sys->b_atomic = true;
792 /*****************************************************************************
794 *****************************************************************************/
795 static const commanddesc_t p_commands[] =
797 { .psz_command = "DataSharedMem",
799 .pf_parser = parser_DataSharedMem,
800 .pf_execute = exec_DataSharedMem,
801 .pf_unparse = unparse_default,
803 { .psz_command = "DeleteImage",
805 .pf_parser = parser_Id,
806 .pf_execute = exec_DeleteImage,
807 .pf_unparse = unparse_default,
809 { .psz_command = "EndAtomic",
811 .pf_parser = parser_None,
812 .pf_execute = exec_EndAtomic,
813 .pf_unparse = unparse_default,
815 { .psz_command = "GenImage",
817 .pf_parser = parser_None,
818 .pf_execute = exec_GenImage,
819 .pf_unparse = unparse_GenImage,
821 { .psz_command = "GetAlpha",
823 .pf_parser = parser_Id,
824 .pf_execute = exec_GetAlpha,
825 .pf_unparse = unparse_GetAlpha,
827 { .psz_command = "GetPosition",
829 .pf_parser = parser_Id,
830 .pf_execute = exec_GetPosition,
831 .pf_unparse = unparse_GetPosition,
833 { .psz_command = "GetTextAlpha",
835 .pf_parser = parser_Id,
836 .pf_execute = exec_GetTextAlpha,
837 .pf_unparse = unparse_GetTextAlpha,
839 { .psz_command = "GetTextColor",
841 .pf_parser = parser_Id,
842 .pf_execute = exec_GetTextColor,
843 .pf_unparse = unparse_GetTextColor,
845 { .psz_command = "GetTextSize",
847 .pf_parser = parser_Id,
848 .pf_execute = exec_GetTextSize,
849 .pf_unparse = unparse_GetTextSize,
851 { .psz_command = "GetVisibility",
853 .pf_parser = parser_Id,
854 .pf_execute = exec_GetVisibility,
855 .pf_unparse = unparse_GetVisibility,
857 { .psz_command = "SetAlpha",
859 .pf_parser = parser_SetAlpha,
860 .pf_execute = exec_SetAlpha,
861 .pf_unparse = unparse_default,
863 { .psz_command = "SetPosition",
865 .pf_parser = parser_SetPosition,
866 .pf_execute = exec_SetPosition,
867 .pf_unparse = unparse_default,
869 { .psz_command = "SetTextAlpha",
871 .pf_parser = parser_SetTextAlpha,
872 .pf_execute = exec_SetTextAlpha,
873 .pf_unparse = unparse_default,
875 { .psz_command = "SetTextColor",
877 .pf_parser = parser_SetTextColor,
878 .pf_execute = exec_SetTextColor,
879 .pf_unparse = unparse_default,
881 { .psz_command = "SetTextSize",
883 .pf_parser = parser_SetTextSize,
884 .pf_execute = exec_SetTextSize,
885 .pf_unparse = unparse_default,
887 { .psz_command = "SetVisibility",
889 .pf_parser = parser_SetVisibility,
890 .pf_execute = exec_SetVisibility,
891 .pf_unparse = unparse_default,
893 { .psz_command = "StartAtomic",
895 .pf_parser = parser_None,
896 .pf_execute = exec_StartAtomic,
897 .pf_unparse = unparse_default,
901 void RegisterCommand( filter_t *p_filter )
903 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
906 p_sys->i_commands = ARRAY_SIZE(p_commands);
907 p_sys->pp_commands = (commanddesc_t **) calloc( p_sys->i_commands, sizeof(commanddesc_t*) );
908 if( !p_sys->pp_commands ) return;
909 for( i_index = 0; i_index < p_sys->i_commands; i_index ++ )
911 p_sys->pp_commands[i_index] = (commanddesc_t *) malloc( sizeof(commanddesc_t) );
912 if( !p_sys->pp_commands[i_index] ) return;
913 p_sys->pp_commands[i_index]->psz_command = strdup( p_commands[i_index].psz_command );
914 p_sys->pp_commands[i_index]->b_atomic = p_commands[i_index].b_atomic;
915 p_sys->pp_commands[i_index]->pf_parser = p_commands[i_index].pf_parser;
916 p_sys->pp_commands[i_index]->pf_execute = p_commands[i_index].pf_execute;
917 p_sys->pp_commands[i_index]->pf_unparse = p_commands[i_index].pf_unparse;
920 msg_Dbg( p_filter, "%zu commands are available", p_sys->i_commands );
921 for( size_t i_index = 0; i_index < p_sys->i_commands; i_index++ )
922 msg_Dbg( p_filter, " %s", p_sys->pp_commands[i_index]->psz_command );
925 void UnregisterCommand( filter_t *p_filter )
927 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
930 for( i_index = 0; i_index < p_sys->i_commands; i_index++ )
932 free( p_sys->pp_commands[i_index]->psz_command );
933 free( p_sys->pp_commands[i_index] );
935 free( p_sys->pp_commands );
936 p_sys->pp_commands = NULL;
937 p_sys->i_commands = 0;