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 )
245 int r = 0, g = 0, b = 0;
248 skip_space( &psz_command );
249 if( isdigit( *psz_command ) )
251 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
254 skip_space( &psz_command );
255 if( isdigit( *psz_command ) )
257 if( parse_digit( &psz_command, &r ) == VLC_EGENERIC )
260 skip_space( &psz_command );
261 if( isdigit( *psz_command ) )
263 if( parse_digit( &psz_command, &g ) == VLC_EGENERIC )
266 skip_space( &psz_command );
267 if( isdigit( *psz_command ) )
269 if( parse_digit( &psz_command, &b ) == VLC_EGENERIC )
272 p_params->fontstyle.i_font_color = (r<<16) | (g<<8) | (b<<0);
276 static int parser_SetTextSize( char *psz_command, char *psz_end,
277 commandparams_t *p_params )
280 skip_space( &psz_command );
281 if( isdigit( *psz_command ) )
283 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
286 skip_space( &psz_command );
287 if( isdigit( *psz_command ) )
289 if( parse_digit( &psz_command, &p_params->fontstyle.i_font_size ) == VLC_EGENERIC )
295 static int parser_SetVisibility( char *psz_command, char *psz_end,
296 commandparams_t *p_params )
299 skip_space( &psz_command );
300 if( isdigit( *psz_command ) )
302 if( parse_digit( &psz_command, &p_params->i_id ) == VLC_EGENERIC )
305 skip_space( &psz_command );
306 if( isdigit( *psz_command ) )
309 if( parse_digit( &psz_command, &i_vis ) == VLC_EGENERIC )
311 p_params->b_visible = (i_vis == 1) ? true : false;
316 /*****************************************************************************
317 * Command unparser functions
318 *****************************************************************************/
320 static int unparse_default( const commandparams_t *p_results,
323 VLC_UNUSED(p_results);
324 VLC_UNUSED(p_output);
328 static int unparse_GenImage( const commandparams_t *p_results,
331 int ret = BufferPrintf( p_output, " %d", p_results->i_id );
332 if( ret != VLC_SUCCESS )
338 static int unparse_GetAlpha( const commandparams_t *p_results,
341 int ret = BufferPrintf( p_output, " %d", p_results->i_alpha );
342 if( ret != VLC_SUCCESS )
348 static int unparse_GetPosition( const commandparams_t *p_results,
351 int ret = BufferPrintf( p_output, " %d", p_results->i_x );
352 if( ret != VLC_SUCCESS )
355 ret = BufferPrintf( p_output, " %d", p_results->i_y );
356 if( ret != VLC_SUCCESS )
362 static int unparse_GetTextAlpha( const commandparams_t *p_results,
365 int ret = BufferPrintf( p_output, " %d", p_results->fontstyle.i_font_alpha );
366 if( ret != VLC_SUCCESS )
372 static int unparse_GetTextColor( const commandparams_t *p_results,
375 int ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0xff0000)>>16 );
376 if( ret != VLC_SUCCESS )
379 ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0x00ff00)>>8 );
380 if( ret != VLC_SUCCESS )
383 ret = BufferPrintf( p_output, " %d", (p_results->fontstyle.i_font_color & 0x0000ff) );
384 if( ret != VLC_SUCCESS )
390 static int unparse_GetTextSize( const commandparams_t *p_results,
393 int ret = BufferPrintf( p_output, " %d", p_results->fontstyle.i_font_size );
394 if( ret != VLC_SUCCESS )
400 static int unparse_GetVisibility( const commandparams_t *p_results,
403 int ret = BufferPrintf( p_output, " %d", (p_results->b_visible ? 1 : 0) );
404 if( ret != VLC_SUCCESS ) {
410 /*****************************************************************************
412 *****************************************************************************/
413 static int exec_DataSharedMem( filter_t *p_filter,
414 const commandparams_t *p_params,
415 commandparams_t *p_results )
417 #if defined(HAVE_SYS_SHM_H)
418 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
419 struct shmid_ds shminfo;
423 VLC_UNUSED(p_results);
425 p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
428 msg_Err( p_filter, "Invalid overlay: %d", p_params->i_id );
432 if( shmctl( p_params->i_shmid, IPC_STAT, &shminfo ) == -1 )
434 msg_Err( p_filter, "Unable to access shared memory" );
437 i_size = shminfo.shm_segsz;
439 if( p_params->fourcc == VLC_FOURCC('T','E','X','T') )
443 if( (p_params->i_height != 1) || (p_params->i_width < 1) )
446 "Invalid width and/or height. when specifing text height "
447 "must be 1 and width the number of bytes in the string, "
448 "including the null terminator" );
452 if( (size_t)p_params->i_width > i_size )
455 "Insufficient data in shared memory. need %d, got %zu",
456 p_params->i_width, i_size );
460 p_ovl->data.p_text = malloc( p_params->i_width );
461 if( p_ovl->data.p_text == NULL )
463 msg_Err( p_filter, "Unable to allocate string storage" );
467 vout_InitFormat( &p_ovl->format, VLC_FOURCC('T','E','X','T'),
470 p_data = shmat( p_params->i_shmid, NULL, SHM_RDONLY );
473 msg_Err( p_filter, "Unable to attach to shared memory" );
474 free( p_ovl->data.p_text );
475 p_ovl->data.p_text = NULL;
478 memcpy( p_ovl->data.p_text, p_data, p_params->i_width );
484 uint8_t *p_data, *p_in;
485 size_t i_neededsize = 0;
487 p_ovl->data.p_pic = malloc( sizeof( picture_t ) );
488 if( p_ovl->data.p_pic == NULL )
491 vout_InitFormat( &p_ovl->format, p_params->fourcc,
492 p_params->i_width, p_params->i_height,
493 VOUT_ASPECT_FACTOR );
494 if( vout_AllocatePicture( p_filter, p_ovl->data.p_pic,
495 p_ovl->format.i_chroma, p_params->i_width,
496 p_params->i_height, p_ovl->format.i_aspect ) )
498 msg_Err( p_filter, "Unable to allocate picture" );
499 free( p_ovl->data.p_pic );
500 p_ovl->data.p_pic = NULL;
504 for( size_t i_plane = 0; i_plane < (size_t)p_ovl->data.p_pic->i_planes;
507 i_neededsize += p_ovl->data.p_pic->p[i_plane].i_visible_lines *
508 p_ovl->data.p_pic->p[i_plane].i_visible_pitch;
511 if( i_neededsize > i_size )
514 "Insufficient data in shared memory. need %zu, got %zu",
515 i_neededsize, i_size );
516 picture_Release( p_ovl->data.p_pic );
517 free( p_ovl->data.p_pic );
518 p_ovl->data.p_pic = NULL;
522 p_data = shmat( p_params->i_shmid, NULL, SHM_RDONLY );
525 msg_Err( p_filter, "Unable to attach to shared memory" );
526 picture_Release( p_ovl->data.p_pic );
527 free( p_ovl->data.p_pic );
528 p_ovl->data.p_pic = NULL;
533 for( size_t i_plane = 0; i_plane < (size_t)p_ovl->data.p_pic->i_planes;
536 uint8_t *p_out = p_ovl->data.p_pic->p[i_plane].p_pixels;
537 for( size_t i_line = 0;
538 i_line < (size_t)p_ovl->data.p_pic->p[i_plane].i_visible_lines;
541 vlc_memcpy( p_out, p_in,
542 p_ovl->data.p_pic->p[i_plane].i_visible_pitch );
543 p_out += p_ovl->data.p_pic->p[i_plane].i_pitch;
544 p_in += p_ovl->data.p_pic->p[i_plane].i_visible_pitch;
549 p_sys->b_updated = p_ovl->b_active;
553 VLC_UNUSED(p_params);
554 VLC_UNUSED(p_results);
556 msg_Err( p_filter, "system doesn't support shared memory" );
561 static int exec_DeleteImage( filter_t *p_filter,
562 const commandparams_t *p_params,
563 commandparams_t *p_results )
565 VLC_UNUSED(p_results);
566 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
567 p_sys->b_updated = true;
569 return ListRemove( &p_sys->overlays, p_params->i_id );
572 static int exec_EndAtomic( filter_t *p_filter,
573 const commandparams_t *p_params,
574 commandparams_t *p_results )
576 VLC_UNUSED(p_params);
577 VLC_UNUSED(p_results);
578 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
579 QueueTransfer( &p_sys->pending, &p_sys->atomic );
580 p_sys->b_atomic = false;
584 static int exec_GenImage( filter_t *p_filter,
585 const commandparams_t *p_params,
586 commandparams_t *p_results )
588 VLC_UNUSED(p_params);
589 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
591 overlay_t *p_ovl = OverlayCreate();
595 ssize_t i_idx = ListAdd( &p_sys->overlays, p_ovl );
599 p_results->i_id = i_idx;
603 static int exec_GetAlpha( filter_t *p_filter,
604 const commandparams_t *p_params,
605 commandparams_t *p_results )
607 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
608 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
612 p_results->i_alpha = p_ovl->i_alpha;
616 static int exec_GetPosition( filter_t *p_filter,
617 const commandparams_t *p_params,
618 commandparams_t *p_results )
620 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
621 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
625 p_results->i_x = p_ovl->i_x;
626 p_results->i_y = p_ovl->i_y;
630 static int exec_GetTextAlpha( filter_t *p_filter,
631 const commandparams_t *p_params,
632 commandparams_t *p_results )
634 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
635 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
639 p_results->fontstyle.i_font_alpha = p_ovl->fontstyle.i_font_alpha;
643 static int exec_GetTextColor( filter_t *p_filter,
644 const commandparams_t *p_params,
645 commandparams_t *p_results )
647 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
648 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
652 p_results->fontstyle.i_font_color = p_ovl->fontstyle.i_font_color;
656 static int exec_GetTextSize( filter_t *p_filter,
657 const commandparams_t *p_params,
658 commandparams_t *p_results )
660 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
661 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
665 p_results->fontstyle.i_font_size = p_ovl->fontstyle.i_font_size;
669 static int exec_GetVisibility( filter_t *p_filter,
670 const commandparams_t *p_params,
671 commandparams_t *p_results )
673 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
675 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
679 p_results->b_visible = ( p_ovl->b_active == true ) ? 1 : 0;
683 static int exec_SetAlpha( filter_t *p_filter,
684 const commandparams_t *p_params,
685 commandparams_t *p_results )
687 VLC_UNUSED(p_results);
688 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
690 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
694 p_ovl->i_alpha = p_params->i_alpha;
695 p_sys->b_updated = p_ovl->b_active;
699 static int exec_SetPosition( filter_t *p_filter,
700 const commandparams_t *p_params,
701 commandparams_t *p_results )
703 VLC_UNUSED(p_results);
704 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
706 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
710 p_ovl->i_x = p_params->i_x;
711 p_ovl->i_y = p_params->i_y;
713 p_sys->b_updated = p_ovl->b_active;
717 static int exec_SetTextAlpha( filter_t *p_filter,
718 const commandparams_t *p_params,
719 commandparams_t *p_results )
721 VLC_UNUSED(p_results);
722 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
724 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
728 p_ovl->fontstyle.i_font_alpha = p_params->fontstyle.i_font_alpha;
729 p_sys->b_updated = p_ovl->b_active;
733 static int exec_SetTextColor( filter_t *p_filter,
734 const commandparams_t *p_params,
735 commandparams_t *p_results )
737 VLC_UNUSED(p_results);
738 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
740 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
744 p_ovl->fontstyle.i_font_color = p_params->fontstyle.i_font_color;
745 p_sys->b_updated = p_ovl->b_active;
749 static int exec_SetTextSize( filter_t *p_filter,
750 const commandparams_t *p_params,
751 commandparams_t *p_results )
753 VLC_UNUSED(p_results);
754 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
756 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
760 p_ovl->fontstyle.i_font_size = p_params->fontstyle.i_font_size;
761 p_sys->b_updated = p_ovl->b_active;
765 static int exec_SetVisibility( filter_t *p_filter,
766 const commandparams_t *p_params,
767 commandparams_t *p_results )
769 VLC_UNUSED(p_results);
770 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
772 overlay_t *p_ovl = ListGet( &p_sys->overlays, p_params->i_id );
776 p_ovl->b_active = p_params->b_visible;// ? false : true;
777 p_sys->b_updated = true;
781 static int exec_StartAtomic( filter_t *p_filter,
782 const commandparams_t *p_params,
783 commandparams_t *p_results )
785 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
786 VLC_UNUSED(p_params);
787 VLC_UNUSED(p_results);
789 p_sys->b_atomic = true;
793 /*****************************************************************************
795 *****************************************************************************/
796 static const commanddesc_t p_commands[] =
798 { .psz_command = "DataSharedMem",
800 .pf_parser = parser_DataSharedMem,
801 .pf_execute = exec_DataSharedMem,
802 .pf_unparse = unparse_default,
804 { .psz_command = "DeleteImage",
806 .pf_parser = parser_Id,
807 .pf_execute = exec_DeleteImage,
808 .pf_unparse = unparse_default,
810 { .psz_command = "EndAtomic",
812 .pf_parser = parser_None,
813 .pf_execute = exec_EndAtomic,
814 .pf_unparse = unparse_default,
816 { .psz_command = "GenImage",
818 .pf_parser = parser_None,
819 .pf_execute = exec_GenImage,
820 .pf_unparse = unparse_GenImage,
822 { .psz_command = "GetAlpha",
824 .pf_parser = parser_Id,
825 .pf_execute = exec_GetAlpha,
826 .pf_unparse = unparse_GetAlpha,
828 { .psz_command = "GetPosition",
830 .pf_parser = parser_Id,
831 .pf_execute = exec_GetPosition,
832 .pf_unparse = unparse_GetPosition,
834 { .psz_command = "GetTextAlpha",
836 .pf_parser = parser_Id,
837 .pf_execute = exec_GetTextAlpha,
838 .pf_unparse = unparse_GetTextAlpha,
840 { .psz_command = "GetTextColor",
842 .pf_parser = parser_Id,
843 .pf_execute = exec_GetTextColor,
844 .pf_unparse = unparse_GetTextColor,
846 { .psz_command = "GetTextSize",
848 .pf_parser = parser_Id,
849 .pf_execute = exec_GetTextSize,
850 .pf_unparse = unparse_GetTextSize,
852 { .psz_command = "GetVisibility",
854 .pf_parser = parser_Id,
855 .pf_execute = exec_GetVisibility,
856 .pf_unparse = unparse_GetVisibility,
858 { .psz_command = "SetAlpha",
860 .pf_parser = parser_SetAlpha,
861 .pf_execute = exec_SetAlpha,
862 .pf_unparse = unparse_default,
864 { .psz_command = "SetPosition",
866 .pf_parser = parser_SetPosition,
867 .pf_execute = exec_SetPosition,
868 .pf_unparse = unparse_default,
870 { .psz_command = "SetTextAlpha",
872 .pf_parser = parser_SetTextAlpha,
873 .pf_execute = exec_SetTextAlpha,
874 .pf_unparse = unparse_default,
876 { .psz_command = "SetTextColor",
878 .pf_parser = parser_SetTextColor,
879 .pf_execute = exec_SetTextColor,
880 .pf_unparse = unparse_default,
882 { .psz_command = "SetTextSize",
884 .pf_parser = parser_SetTextSize,
885 .pf_execute = exec_SetTextSize,
886 .pf_unparse = unparse_default,
888 { .psz_command = "SetVisibility",
890 .pf_parser = parser_SetVisibility,
891 .pf_execute = exec_SetVisibility,
892 .pf_unparse = unparse_default,
894 { .psz_command = "StartAtomic",
896 .pf_parser = parser_None,
897 .pf_execute = exec_StartAtomic,
898 .pf_unparse = unparse_default,
902 void RegisterCommand( filter_t *p_filter )
904 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
907 p_sys->i_commands = ARRAY_SIZE(p_commands);
908 p_sys->pp_commands = (commanddesc_t **) calloc( p_sys->i_commands, sizeof(commanddesc_t*) );
909 if( !p_sys->pp_commands ) return;
910 for( i_index = 0; i_index < p_sys->i_commands; i_index ++ )
912 p_sys->pp_commands[i_index] = (commanddesc_t *) malloc( sizeof(commanddesc_t) );
913 if( !p_sys->pp_commands[i_index] ) return;
914 p_sys->pp_commands[i_index]->psz_command = strdup( p_commands[i_index].psz_command );
915 p_sys->pp_commands[i_index]->b_atomic = p_commands[i_index].b_atomic;
916 p_sys->pp_commands[i_index]->pf_parser = p_commands[i_index].pf_parser;
917 p_sys->pp_commands[i_index]->pf_execute = p_commands[i_index].pf_execute;
918 p_sys->pp_commands[i_index]->pf_unparse = p_commands[i_index].pf_unparse;
921 msg_Dbg( p_filter, "%zu commands are available", p_sys->i_commands );
922 for( size_t i_index = 0; i_index < p_sys->i_commands; i_index++ )
923 msg_Dbg( p_filter, " %s", p_sys->pp_commands[i_index]->psz_command );
926 void UnregisterCommand( filter_t *p_filter )
928 filter_sys_t *p_sys = (filter_sys_t*) p_filter->p_sys;
931 for( i_index = 0; i_index < p_sys->i_commands; i_index++ )
933 free( p_sys->pp_commands[i_index]->psz_command );
934 free( p_sys->pp_commands[i_index] );
936 free( p_sys->pp_commands );
937 p_sys->pp_commands = NULL;
938 p_sys->i_commands = 0;